src/haptic/SDL_haptic.c
branchgsoc2008_force_feedback
changeset 2505 abfcba0f3bd1
parent 2497 0893fbf73b3d
child 2506 ba8e99fe92c1
     1.1 --- a/src/haptic/SDL_haptic.c	Mon Jul 07 18:42:10 2008 +0000
     1.2 +++ b/src/haptic/SDL_haptic.c	Tue Jul 08 19:23:03 2008 +0000
     1.3 @@ -59,6 +59,24 @@
     1.4  
     1.5  
     1.6  /*
     1.7 + * Checks to see if the haptic device is valid
     1.8 + */
     1.9 +static int
    1.10 +ValidHaptic(SDL_Haptic ** haptic)
    1.11 +{
    1.12 +   int valid;
    1.13 +   
    1.14 +   if (*haptic == NULL) {
    1.15 +      SDL_SetError("Haptic device hasn't been opened yet");
    1.16 +      valid = 0;
    1.17 +   } else {
    1.18 +      valid = 1;
    1.19 +   }
    1.20 +   return valid;
    1.21 +}
    1.22 +
    1.23 +
    1.24 +/*
    1.25   * Returns the number of available devices.
    1.26   */
    1.27  int
    1.28 @@ -131,6 +149,20 @@
    1.29  
    1.30  
    1.31  /*
    1.32 + * Returns the index to a haptic device.
    1.33 + */
    1.34 +int
    1.35 +SDL_HapticIndex(SDL_Haptic * haptic)
    1.36 +{
    1.37 +   if (!ValidHaptic(&haptic)) {
    1.38 +      return -1;
    1.39 +   }
    1.40 +
    1.41 +   return haptic->index;
    1.42 +}
    1.43 +
    1.44 +
    1.45 +/*
    1.46   * Returns SDL_TRUE if joystick has haptic features.
    1.47   */
    1.48  int
    1.49 @@ -204,24 +236,6 @@
    1.50  
    1.51  
    1.52  /*
    1.53 - * Checks to see if the haptic device is valid
    1.54 - */
    1.55 -static int
    1.56 -ValidHaptic(SDL_Haptic ** haptic)
    1.57 -{
    1.58 -   int valid;
    1.59 -
    1.60 -   if (*haptic == NULL) {
    1.61 -      SDL_SetError("Haptic device hasn't been opened yet");
    1.62 -      valid = 0;
    1.63 -   } else {
    1.64 -      valid = 1;
    1.65 -   }
    1.66 -   return valid;
    1.67 -}
    1.68 -
    1.69 -
    1.70 -/*
    1.71   * Closes a SDL_Haptic device.
    1.72   */
    1.73  void