| | |
| | | |
| | | #ifdef SDL_HAPTIC_IOKIT |
| | | |
| | | #include "SDL_assert.h" |
| | | #include "SDL_stdinc.h" |
| | | #include "SDL_haptic.h" |
| | | #include "../SDL_syshaptic.h" |
| | | #include "SDL_joystick.h" |
| | | #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ |
| | | #include "../../joystick/darwin/SDL_sysjoystick_c.h" /* For joystick hwdata */ |
| | | #include "../../joystick/darwin/SDL_iokitjoystick_c.h" /* For joystick hwdata */ |
| | | #include "SDL_syshaptic_c.h" |
| | | |
| | | #include <IOKit/IOKitLib.h> |
| | |
| | | int |
| | | SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) |
| | | { |
| | | #ifdef SDL_JOYSTICK_IOKIT |
| | | if (joystick->driver != &SDL_DARWIN_JoystickDriver) { |
| | | return SDL_FALSE; |
| | | } |
| | | if (joystick->hwdata->ffservice != 0) { |
| | | return SDL_TRUE; |
| | | } |
| | | #endif |
| | | return SDL_FALSE; |
| | | } |
| | | |
| | |
| | | int |
| | | SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) |
| | | { |
| | | #ifdef SDL_JOYSTICK_IOKIT |
| | | if (joystick->driver != &SDL_DARWIN_JoystickDriver) { |
| | | return 0; |
| | | } |
| | |
| | | joystick->hwdata->ffservice)) { |
| | | return 1; |
| | | } |
| | | #endif |
| | | return 0; |
| | | } |
| | | |
| | |
| | | int |
| | | SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) |
| | | { |
| | | #ifdef SDL_JOYSTICK_IOKIT |
| | | int device_index = 0; |
| | | SDL_hapticlist_item *item; |
| | | |
| | |
| | | } |
| | | |
| | | return SDL_SYS_HapticOpenFromService(haptic, joystick->hwdata->ffservice); |
| | | #else |
| | | return -1; |
| | | #endif |
| | | } |
| | | |
| | | |
| | |
| | | rglDir[2] = dir->dir[2]; |
| | | } |
| | | return 0; |
| | | case SDL_HAPTIC_STEERING_AXIS: |
| | | effect->dwFlags |= FFEFF_CARTESIAN; |
| | | rglDir[0] = 0; |
| | | return 0; |
| | | |
| | | default: |
| | | return SDL_SetError("Haptic: Unknown direction type."); |
| | |
| | | envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */ |
| | | |
| | | /* Axes. */ |
| | | dest->cAxes = haptic->naxes; |
| | | if (src->constant.direction.type == SDL_HAPTIC_STEERING_AXIS) { |
| | | dest->cAxes = 1; |
| | | } else { |
| | | dest->cAxes = haptic->naxes; |
| | | } |
| | | if (dest->cAxes > 0) { |
| | | axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); |
| | | if (axes == NULL) { |