21 #include "../../SDL_internal.h" 23 #ifdef SDL_HAPTIC_ANDROID 27 #include "SDL_syshaptic_c.h" 28 #include "../SDL_syshaptic.h" 30 #include "../../core/android/SDL_android.h" 32 #include "../../joystick/SDL_sysjoystick.h" 33 #include "../../joystick/android/SDL_sysjoystick_c.h" 46 static int numhaptics = 0;
71 HapticByOrder(
int index)
74 if ((index < 0) || (index >= numhaptics)) {
86 HapticByDevId (
int device_id)
89 for (item = SDL_hapticlist; item !=
NULL; item = item->
next) {
90 if (device_id == item->device_id) {
126 haptic->neffects = 1;
127 haptic->nplaying = haptic->neffects;
129 if (haptic->effects ==
NULL) {
138 OpenHapticByOrder(SDL_Haptic *haptic,
int index)
140 return OpenHaptic (haptic, HapticByOrder(index));
144 OpenHapticByDevId(SDL_Haptic *haptic,
int device_id)
146 return OpenHaptic (haptic, HapticByDevId(device_id));
152 return (OpenHapticByOrder(haptic, haptic->index) ==
NULL ? -1 : 0);
167 item = HapticByDevId(((
joystick_hwdata *)joystick->hwdata)->device_id);
168 return (item !=
NULL) ? 1 : 0;
175 return (OpenHapticByDevId(haptic, ((
joystick_hwdata *)joystick->hwdata)->device_id) ==
NULL ? -1 : 0);
190 haptic->hwdata =
NULL;
201 for (item = SDL_hapticlist; item; item =
next) {
206 SDL_hapticlist = SDL_hapticlist_tail =
NULL;
294 Android_AddHaptic(
int device_id,
const char *
name)
302 item->device_id = device_id;
309 if (SDL_hapticlist_tail ==
NULL) {
310 SDL_hapticlist = SDL_hapticlist_tail = item;
312 SDL_hapticlist_tail->
next = item;
313 SDL_hapticlist_tail = item;
321 Android_RemoveHaptic(
int device_id)
326 for (item = SDL_hapticlist; item !=
NULL; item = item->
next) {
328 if (device_id == item->device_id) {
335 SDL_hapticlist = item->
next;
337 if (item == SDL_hapticlist_tail) {
338 SDL_hapticlist_tail = prev;
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
int SDL_SYS_HapticOpen(SDL_Haptic *haptic)
int SDL_SYS_HapticMouse(void)
int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
const char * SDL_SYS_HapticName(int index)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
The SDL haptic subsystem allows you to control haptic (force feedback) devices.
int SDL_SYS_HapticUnpause(SDL_Haptic *haptic)
int SDL_SYS_NumHaptics(void)
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect)
GLuint const GLchar * name
SDL_hapticlist_item * SDL_hapticlist
struct SDL_hapticlist_item * next
The generic template for any haptic effect.
int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data)
int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
void Android_JNI_PollHapticDevices(void)
void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
#define SDL_assert(condition)
#define SDL_OutOfMemory()
int SDL_SYS_HapticInit(void)
void SDL_SYS_HapticQuit(void)
void SDL_SYS_HapticClose(SDL_Haptic *haptic)
int SDL_SYS_HapticPause(SDL_Haptic *haptic)
SDL_HapticLeftRight leftright
GLbitfield GLuint64 timeout
int SDL_SYS_HapticStopAll(SDL_Haptic *haptic)
int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain)
#define SDL_TICKS_PASSED(A, B)
Compare SDL ticks values, and return true if A has passed B.
#define SDL_HAPTIC_LEFTRIGHT
Left/Right effect supported.
int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations)
void Android_JNI_HapticRun(int device_id, int length)
int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base)