src/haptic/darwin/SDL_syshaptic.c
changeset 13860 d16844f83bfd
parent 13789 a359f4f93439
equal deleted inserted replaced
13859:e9e8b7e01629 13860:d16844f83bfd
   597  * Checks to see if a joystick has haptic features.
   597  * Checks to see if a joystick has haptic features.
   598  */
   598  */
   599 int
   599 int
   600 SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
   600 SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
   601 {
   601 {
       
   602 #ifdef SDL_JOYSTICK_IOKIT
   602     if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
   603     if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
   603         return SDL_FALSE;
   604         return SDL_FALSE;
   604     }
   605     }
   605     if (joystick->hwdata->ffservice != 0) {
   606     if (joystick->hwdata->ffservice != 0) {
   606         return SDL_TRUE;
   607         return SDL_TRUE;
   607     }
   608     }
       
   609 #endif
   608     return SDL_FALSE;
   610     return SDL_FALSE;
   609 }
   611 }
   610 
   612 
   611 
   613 
   612 /*
   614 /*
   613  * Checks to see if the haptic device and joystick are in reality the same.
   615  * Checks to see if the haptic device and joystick are in reality the same.
   614  */
   616  */
   615 int
   617 int
   616 SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
   618 SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
   617 {
   619 {
       
   620 #ifdef SDL_JOYSTICK_IOKIT
   618     if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
   621     if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
   619         return 0;
   622         return 0;
   620     }
   623     }
   621     if (IOObjectIsEqualTo((io_object_t) ((size_t)haptic->hwdata->device),
   624     if (IOObjectIsEqualTo((io_object_t) ((size_t)haptic->hwdata->device),
   622                           joystick->hwdata->ffservice)) {
   625                           joystick->hwdata->ffservice)) {
   623         return 1;
   626         return 1;
   624     }
   627     }
       
   628 #endif
   625     return 0;
   629     return 0;
   626 }
   630 }
   627 
   631 
   628 
   632 
   629 /*
   633 /*
   630  * Opens a SDL_Haptic from a SDL_Joystick.
   634  * Opens a SDL_Haptic from a SDL_Joystick.
   631  */
   635  */
   632 int
   636 int
   633 SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
   637 SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
   634 {
   638 {
       
   639 #ifdef SDL_JOYSTICK_IOKIT
   635     int device_index = 0;
   640     int device_index = 0;
   636     SDL_hapticlist_item *item;
   641     SDL_hapticlist_item *item;
   637     
   642     
   638     if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
   643     if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
   639         return -1;
   644         return -1;
   646         }
   651         }
   647         ++device_index;
   652         ++device_index;
   648     }
   653     }
   649 
   654 
   650     return SDL_SYS_HapticOpenFromService(haptic, joystick->hwdata->ffservice);
   655     return SDL_SYS_HapticOpenFromService(haptic, joystick->hwdata->ffservice);
       
   656 #else
       
   657 	return -1;
       
   658 #endif
   651 }
   659 }
   652 
   660 
   653 
   661 
   654 /*
   662 /*
   655  * Closes the haptic device.
   663  * Closes the haptic device.