src/haptic/SDL_haptic.c
branchgsoc2008_force_feedback
changeset 2512 ef147ee4896c
parent 2507 8ef1d0f4d0c1
child 2513 55fd9103a330
     1.1 --- a/src/haptic/SDL_haptic.c	Wed Jul 09 18:29:11 2008 +0000
     1.2 +++ b/src/haptic/SDL_haptic.c	Thu Jul 10 08:38:08 2008 +0000
     1.3 @@ -25,7 +25,7 @@
     1.4  #include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */
     1.5  
     1.6  
     1.7 -static Uint8 SDL_numhaptics = 0;
     1.8 +Uint8 SDL_numhaptics = 0;
     1.9  SDL_Haptic **SDL_haptics = NULL;
    1.10  static SDL_Haptic *default_haptic = NULL;
    1.11  
    1.12 @@ -188,6 +188,37 @@
    1.13  
    1.14  
    1.15  /*
    1.16 + * Returns SDL_TRUE if mouse is haptic, SDL_FALSE if it isn't.
    1.17 + */
    1.18 +int
    1.19 +SDL_MouseIsHaptic(void)
    1.20 +{
    1.21 +   if (SDL_SYS_HapticMouse() < 0)
    1.22 +      return SDL_FALSE;
    1.23 +   return SDL_TRUE;
    1.24 +}
    1.25 +
    1.26 +
    1.27 +/*
    1.28 + * Returns the haptic device if mouse is haptic or NULL elsewise.
    1.29 + */
    1.30 +SDL_Haptic *
    1.31 +SDL_HapticOpenFromMouse(void)
    1.32 +{
    1.33 +   int device_index;
    1.34 +
    1.35 +   device_index = SDL_SYS_HapticMouse();
    1.36 +
    1.37 +   if (device_index < 0) {
    1.38 +      SDL_SetError("Mouse isn't a haptic device.");
    1.39 +      return NULL;
    1.40 +   }
    1.41 +
    1.42 +   return SDL_HapticOpen(device_index);
    1.43 +}
    1.44 +
    1.45 +
    1.46 +/*
    1.47   * Returns SDL_TRUE if joystick has haptic features.
    1.48   */
    1.49  int