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;
205 for (item = SDL_hapticlist; item; item = next) {
210 SDL_hapticlist = SDL_hapticlist_tail =
NULL;
241 float total = (large * 0.6f) + (small * 0.4
f);
305 Android_AddHaptic(
int device_id,
const char *
name)
313 item->device_id = device_id;
320 if (SDL_hapticlist_tail ==
NULL) {
321 SDL_hapticlist = SDL_hapticlist_tail = item;
323 SDL_hapticlist_tail->
next = item;
324 SDL_hapticlist_tail = item;
332 Android_RemoveHaptic(
int device_id)
337 for (item = SDL_hapticlist; item !=
NULL; item = item->
next) {
339 if (device_id == item->device_id) {
346 SDL_hapticlist = item->
next;
348 if (item == SDL_hapticlist_tail) {
349 SDL_hapticlist_tail = prev;