[SVN] r3835 - branches/gsoc2008_force_feedback/src/haptic
svn-owner at libsdl.org
svn-owner at libsdl.org
Thu Jul 31 02:02:43 PDT 2008
Author: bobbens
Date: 2008-07-31 02:02:43 -0700 (Thu, 31 Jul 2008)
New Revision: 3835
Modified:
branches/gsoc2008_force_feedback/src/haptic/SDL_haptic.c
Log:
Made ValidHaptic cleaner.
Modified: branches/gsoc2008_force_feedback/src/haptic/SDL_haptic.c
===================================================================
--- branches/gsoc2008_force_feedback/src/haptic/SDL_haptic.c 2008-07-30 18:29:55 UTC (rev 3834)
+++ branches/gsoc2008_force_feedback/src/haptic/SDL_haptic.c 2008-07-31 09:02:43 UTC (rev 3835)
@@ -61,16 +61,19 @@
* Checks to see if the haptic device is valid
*/
static int
-ValidHaptic(SDL_Haptic ** haptic)
+ValidHaptic(SDL_Haptic * haptic)
{
+ int i;
int valid;
+
+ valid = 0;
+ for (i=0; i<SDL_numhaptics; i++) {
+ if (SDL_haptics[i] == haptic) {
+ valid = 1;
+ break;
+ }
+ }
- if (*haptic == NULL) {
- SDL_SetError("Haptic: Device hasn't been opened yet");
- valid = 0;
- } else {
- valid = 1;
- }
return valid;
}
@@ -178,7 +181,7 @@
int
SDL_HapticIndex(SDL_Haptic * haptic)
{
- if (!ValidHaptic(&haptic)) {
+ if (!ValidHaptic(haptic)) {
return -1;
}
@@ -299,7 +302,7 @@
int i;
/* Must be valid */
- if (!ValidHaptic(&haptic)) {
+ if (!ValidHaptic(haptic)) {
return;
}
@@ -349,7 +352,7 @@
int
SDL_HapticNumEffects(SDL_Haptic * haptic)
{
- if (!ValidHaptic(&haptic)) {
+ if (!ValidHaptic(haptic)) {
return -1;
}
@@ -363,7 +366,7 @@
int
SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic)
{
- if (!ValidHaptic(&haptic)) {
+ if (!ValidHaptic(haptic)) {
return -1;
}
@@ -377,7 +380,7 @@
unsigned int
SDL_HapticQuery(SDL_Haptic * haptic)
{
- if (!ValidHaptic(&haptic)) {
+ if (!ValidHaptic(haptic)) {
return -1;
}
@@ -391,7 +394,7 @@
int
SDL_HapticNumAxes(SDL_Haptic * haptic)
{
- if (!ValidHaptic(&haptic)) {
+ if (!ValidHaptic(haptic)) {
return -1;
}
@@ -404,7 +407,7 @@
int
SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect)
{
- if (!ValidHaptic(&haptic)) {
+ if (!ValidHaptic(haptic)) {
return -1;
}
@@ -422,7 +425,7 @@
int i;
/* Check for device validity. */
- if (!ValidHaptic(&haptic)) {
+ if (!ValidHaptic(haptic)) {
return -1;
}
@@ -469,7 +472,7 @@
int
SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, SDL_HapticEffect * data)
{
- if (!ValidHaptic(&haptic) || !ValidEffect(haptic,effect)) {
+ if (!ValidHaptic(haptic) || !ValidEffect(haptic,effect)) {
return -1;
}
@@ -495,7 +498,7 @@
int
SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations)
{
- if (!ValidHaptic(&haptic) || !ValidEffect(haptic,effect)) {
+ if (!ValidHaptic(haptic) || !ValidEffect(haptic,effect)) {
return -1;
}
@@ -513,7 +516,7 @@
int
SDL_HapticStopEffect(SDL_Haptic * haptic, int effect)
{
- if (!ValidHaptic(&haptic) || !ValidEffect(haptic,effect)) {
+ if (!ValidHaptic(haptic) || !ValidEffect(haptic,effect)) {
return -1;
}
@@ -531,7 +534,7 @@
void
SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect)
{
- if (!ValidHaptic(&haptic) || !ValidEffect(haptic,effect)) {
+ if (!ValidHaptic(haptic) || !ValidEffect(haptic,effect)) {
return;
}
@@ -549,7 +552,7 @@
int
SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
{
- if (!ValidHaptic(&haptic) || !ValidEffect(haptic,effect)) {
+ if (!ValidHaptic(haptic) || !ValidEffect(haptic,effect)) {
return -1;
}
@@ -570,7 +573,7 @@
const char *env;
int real_gain, max_gain;
- if (!ValidHaptic(&haptic)) {
+ if (!ValidHaptic(haptic)) {
return -1;
}
@@ -613,7 +616,7 @@
int
SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter )
{
- if (!ValidHaptic(&haptic)) {
+ if (!ValidHaptic(haptic)) {
return -1;
}
More information about the commits
mailing list