src/haptic/SDL_haptic.c
branchgsoc2008_force_feedback
changeset 2512 ef147ee4896c
parent 2507 8ef1d0f4d0c1
child 2513 55fd9103a330
equal deleted inserted replaced
2511:f12ae0bae468 2512:ef147ee4896c
    23 
    23 
    24 #include "SDL_syshaptic.h"
    24 #include "SDL_syshaptic.h"
    25 #include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */
    25 #include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */
    26 
    26 
    27 
    27 
    28 static Uint8 SDL_numhaptics = 0;
    28 Uint8 SDL_numhaptics = 0;
    29 SDL_Haptic **SDL_haptics = NULL;
    29 SDL_Haptic **SDL_haptics = NULL;
    30 static SDL_Haptic *default_haptic = NULL;
    30 static SDL_Haptic *default_haptic = NULL;
    31 
    31 
    32 
    32 
    33 /*
    33 /*
   186    return haptic->index;
   186    return haptic->index;
   187 }
   187 }
   188 
   188 
   189 
   189 
   190 /*
   190 /*
       
   191  * Returns SDL_TRUE if mouse is haptic, SDL_FALSE if it isn't.
       
   192  */
       
   193 int
       
   194 SDL_MouseIsHaptic(void)
       
   195 {
       
   196    if (SDL_SYS_HapticMouse() < 0)
       
   197       return SDL_FALSE;
       
   198    return SDL_TRUE;
       
   199 }
       
   200 
       
   201 
       
   202 /*
       
   203  * Returns the haptic device if mouse is haptic or NULL elsewise.
       
   204  */
       
   205 SDL_Haptic *
       
   206 SDL_HapticOpenFromMouse(void)
       
   207 {
       
   208    int device_index;
       
   209 
       
   210    device_index = SDL_SYS_HapticMouse();
       
   211 
       
   212    if (device_index < 0) {
       
   213       SDL_SetError("Mouse isn't a haptic device.");
       
   214       return NULL;
       
   215    }
       
   216 
       
   217    return SDL_HapticOpen(device_index);
       
   218 }
       
   219 
       
   220 
       
   221 /*
   191  * Returns SDL_TRUE if joystick has haptic features.
   222  * Returns SDL_TRUE if joystick has haptic features.
   192  */
   223  */
   193 int
   224 int
   194 SDL_JoystickIsHaptic(SDL_Joystick * joystick)
   225 SDL_JoystickIsHaptic(SDL_Joystick * joystick)
   195 {
   226 {