SDL  2.0
SDL_sysjoystick.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #include "../../SDL_internal.h"
23 
24 #ifdef SDL_JOYSTICK_ANDROID
25 
26 #include <stdio.h> /* For the definition of NULL */
27 #include "SDL_error.h"
28 #include "SDL_events.h"
29 
30 #include "SDL_joystick.h"
31 #include "SDL_hints.h"
32 #include "SDL_assert.h"
33 #include "SDL_timer.h"
34 #include "SDL_log.h"
35 #include "SDL_sysjoystick_c.h"
36 #include "../SDL_joystick_c.h"
37 #include "../../events/SDL_keyboard_c.h"
38 #include "../../core/android/SDL_android.h"
39 #include "../steam/SDL_steamcontroller.h"
40 
41 #include "android/keycodes.h"
42 
43 /* As of platform android-14, android/keycodes.h is missing these defines */
44 #ifndef AKEYCODE_BUTTON_1
45 #define AKEYCODE_BUTTON_1 188
46 #define AKEYCODE_BUTTON_2 189
47 #define AKEYCODE_BUTTON_3 190
48 #define AKEYCODE_BUTTON_4 191
49 #define AKEYCODE_BUTTON_5 192
50 #define AKEYCODE_BUTTON_6 193
51 #define AKEYCODE_BUTTON_7 194
52 #define AKEYCODE_BUTTON_8 195
53 #define AKEYCODE_BUTTON_9 196
54 #define AKEYCODE_BUTTON_10 197
55 #define AKEYCODE_BUTTON_11 198
56 #define AKEYCODE_BUTTON_12 199
57 #define AKEYCODE_BUTTON_13 200
58 #define AKEYCODE_BUTTON_14 201
59 #define AKEYCODE_BUTTON_15 202
60 #define AKEYCODE_BUTTON_16 203
61 #endif
62 
63 #define ANDROID_ACCELEROMETER_NAME "Android Accelerometer"
64 #define ANDROID_ACCELEROMETER_DEVICE_ID INT_MIN
65 #define ANDROID_MAX_NBUTTONS 36
66 
67 static SDL_joylist_item * JoystickByDeviceId(int device_id);
68 
69 static SDL_joylist_item *SDL_joylist = NULL;
70 static SDL_joylist_item *SDL_joylist_tail = NULL;
71 static int numjoysticks = 0;
72 static int instance_counter = 0;
73 
74 
75 /* Function to convert Android keyCodes into SDL ones.
76  * This code manipulation is done to get a sequential list of codes.
77  * FIXME: This is only suited for the case where we use a fixed number of buttons determined by ANDROID_MAX_NBUTTONS
78  */
79 static int
80 keycode_to_SDL(int keycode)
81 {
82  /* FIXME: If this function gets too unwieldy in the future, replace with a lookup table */
83  int button = 0;
84  switch (keycode) {
85  /* Some gamepad buttons (API 9) */
86  case AKEYCODE_BUTTON_A:
87  button = SDL_CONTROLLER_BUTTON_A;
88  break;
89  case AKEYCODE_BUTTON_B:
90  button = SDL_CONTROLLER_BUTTON_B;
91  break;
92  case AKEYCODE_BUTTON_X:
93  button = SDL_CONTROLLER_BUTTON_X;
94  break;
95  case AKEYCODE_BUTTON_Y:
96  button = SDL_CONTROLLER_BUTTON_Y;
97  break;
98  case AKEYCODE_BUTTON_L1:
100  break;
101  case AKEYCODE_BUTTON_R1:
103  break;
104  case AKEYCODE_BUTTON_THUMBL:
106  break;
107  case AKEYCODE_BUTTON_THUMBR:
109  break;
110  case AKEYCODE_BUTTON_START:
112  break;
113  case AKEYCODE_BACK:
114  case AKEYCODE_BUTTON_SELECT:
116  break;
117  case AKEYCODE_BUTTON_MODE:
119  break;
120  case AKEYCODE_BUTTON_L2:
121  button = SDL_CONTROLLER_BUTTON_MAX; /* Not supported by GameController */
122  break;
123  case AKEYCODE_BUTTON_R2:
124  button = SDL_CONTROLLER_BUTTON_MAX+1; /* Not supported by GameController */
125  break;
126  case AKEYCODE_BUTTON_C:
127  button = SDL_CONTROLLER_BUTTON_MAX+2; /* Not supported by GameController */
128  break;
129  case AKEYCODE_BUTTON_Z:
130  button = SDL_CONTROLLER_BUTTON_MAX+3; /* Not supported by GameController */
131  break;
132 
133  /* D-Pad key codes (API 1) */
134  case AKEYCODE_DPAD_UP:
136  break;
137  case AKEYCODE_DPAD_DOWN:
139  break;
140  case AKEYCODE_DPAD_LEFT:
142  break;
143  case AKEYCODE_DPAD_RIGHT:
145  break;
146  case AKEYCODE_DPAD_CENTER:
147  /* This is handled better by applications as the A button */
148  /*button = SDL_CONTROLLER_BUTTON_MAX+4;*/ /* Not supported by GameController */
149  button = SDL_CONTROLLER_BUTTON_A;
150  break;
151 
152  /* More gamepad buttons (API 12), these get mapped to 20...35*/
153  case AKEYCODE_BUTTON_1:
154  case AKEYCODE_BUTTON_2:
155  case AKEYCODE_BUTTON_3:
156  case AKEYCODE_BUTTON_4:
157  case AKEYCODE_BUTTON_5:
158  case AKEYCODE_BUTTON_6:
159  case AKEYCODE_BUTTON_7:
160  case AKEYCODE_BUTTON_8:
161  case AKEYCODE_BUTTON_9:
162  case AKEYCODE_BUTTON_10:
163  case AKEYCODE_BUTTON_11:
164  case AKEYCODE_BUTTON_12:
165  case AKEYCODE_BUTTON_13:
166  case AKEYCODE_BUTTON_14:
167  case AKEYCODE_BUTTON_15:
168  case AKEYCODE_BUTTON_16:
169  button = keycode - AKEYCODE_BUTTON_1 + SDL_CONTROLLER_BUTTON_MAX + 5;
170  break;
171 
172  default:
173  return -1;
174  /* break; -Wunreachable-code-break */
175  }
176 
177  /* This is here in case future generations, probably with six fingers per hand,
178  * happily add new cases up above and forget to update the max number of buttons.
179  */
180  SDL_assert(button < ANDROID_MAX_NBUTTONS);
181  return button;
182 }
183 
184 static SDL_Scancode
185 button_to_scancode(int button)
186 {
187  switch (button) {
189  return SDL_SCANCODE_RETURN;
191  return SDL_SCANCODE_ESCAPE;
193  return SDL_SCANCODE_ESCAPE;
195  return SDL_SCANCODE_UP;
197  return SDL_SCANCODE_DOWN;
199  return SDL_SCANCODE_LEFT;
201  return SDL_SCANCODE_RIGHT;
202  }
203 
204  /* Unsupported button */
205  return SDL_SCANCODE_UNKNOWN;
206 }
207 
208 int
209 Android_OnPadDown(int device_id, int keycode)
210 {
211  SDL_joylist_item *item;
212  int button = keycode_to_SDL(keycode);
213  if (button >= 0) {
214  item = JoystickByDeviceId(device_id);
215  if (item && item->joystick) {
216  SDL_PrivateJoystickButton(item->joystick, button , SDL_PRESSED);
217  } else {
218  SDL_SendKeyboardKey(SDL_PRESSED, button_to_scancode(button));
219  }
220  return 0;
221  }
222 
223  return -1;
224 }
225 
226 int
227 Android_OnPadUp(int device_id, int keycode)
228 {
229  SDL_joylist_item *item;
230  int button = keycode_to_SDL(keycode);
231  if (button >= 0) {
232  item = JoystickByDeviceId(device_id);
233  if (item && item->joystick) {
234  SDL_PrivateJoystickButton(item->joystick, button, SDL_RELEASED);
235  } else {
236  SDL_SendKeyboardKey(SDL_RELEASED, button_to_scancode(button));
237  }
238  return 0;
239  }
240 
241  return -1;
242 }
243 
244 int
245 Android_OnJoy(int device_id, int axis, float value)
246 {
247  /* Android gives joy info normalized as [-1.0, 1.0] or [0.0, 1.0] */
248  SDL_joylist_item *item = JoystickByDeviceId(device_id);
249  if (item && item->joystick) {
250  SDL_PrivateJoystickAxis(item->joystick, axis, (Sint16) (32767.*value));
251  }
252 
253  return 0;
254 }
255 
256 int
257 Android_OnHat(int device_id, int hat_id, int x, int y)
258 {
259  const Uint8 position_map[3][3] = {
263  };
264 
265  if (x >= -1 && x <=1 && y >= -1 && y <= 1) {
266  SDL_joylist_item *item = JoystickByDeviceId(device_id);
267  if (item && item->joystick) {
268  SDL_PrivateJoystickHat(item->joystick, hat_id, position_map[y+1][x+1]);
269  }
270  return 0;
271  }
272 
273  return -1;
274 }
275 
276 
277 int
278 Android_AddJoystick(int device_id, const char *name, const char *desc, SDL_bool is_accelerometer, int nbuttons, int naxes, int nhats, int nballs)
279 {
280  SDL_JoystickGUID guid;
281  SDL_joylist_item *item;
282 
284  /* Ignore devices that aren't actually controllers (e.g. remotes), they'll be handled as keyboard input */
285  if (naxes < 2 && nhats < 1) {
286  return -1;
287  }
288  }
289 
290  if (JoystickByDeviceId(device_id) != NULL || name == NULL) {
291  return -1;
292  }
293 
294  /* the GUID is just the first 16 chars of the name for now */
295  SDL_zero(guid);
296  SDL_memcpy(&guid, desc, SDL_min(sizeof(guid), SDL_strlen(desc)));
297 
298  item = (SDL_joylist_item *) SDL_malloc(sizeof (SDL_joylist_item));
299  if (item == NULL) {
300  return -1;
301  }
302 
303  SDL_zerop(item);
304  item->guid = guid;
305  item->device_id = device_id;
306  item->name = SDL_strdup(name);
307  if (item->name == NULL) {
308  SDL_free(item);
309  return -1;
310  }
311 
312  item->is_accelerometer = is_accelerometer;
313  if (nbuttons > -1) {
314  item->nbuttons = nbuttons;
315  }
316  else {
317  item->nbuttons = ANDROID_MAX_NBUTTONS;
318  }
319  item->naxes = naxes;
320  item->nhats = nhats;
321  item->nballs = nballs;
322  item->device_instance = instance_counter++;
323  if (SDL_joylist_tail == NULL) {
324  SDL_joylist = SDL_joylist_tail = item;
325  } else {
326  SDL_joylist_tail->next = item;
327  SDL_joylist_tail = item;
328  }
329 
330  /* Need to increment the joystick count before we post the event */
331  ++numjoysticks;
332 
334 
335 #ifdef DEBUG_JOYSTICK
336  SDL_Log("Added joystick %s with device_id %d", name, device_id);
337 #endif
338 
339  return numjoysticks;
340 }
341 
342 int
343 Android_RemoveJoystick(int device_id)
344 {
345  SDL_joylist_item *item = SDL_joylist;
346  SDL_joylist_item *prev = NULL;
347 
348  /* Don't call JoystickByDeviceId here or there'll be an infinite loop! */
349  while (item != NULL) {
350  if (item->device_id == device_id) {
351  break;
352  }
353  prev = item;
354  item = item->next;
355  }
356 
357  if (item == NULL) {
358  return -1;
359  }
360 
361  if (item->joystick) {
362  item->joystick->hwdata = NULL;
363  }
364 
365  if (prev != NULL) {
366  prev->next = item->next;
367  } else {
368  SDL_assert(SDL_joylist == item);
369  SDL_joylist = item->next;
370  }
371  if (item == SDL_joylist_tail) {
372  SDL_joylist_tail = prev;
373  }
374 
375  /* Need to decrement the joystick count before we post the event */
376  --numjoysticks;
377 
378  SDL_PrivateJoystickRemoved(item->device_instance);
379 
380 #ifdef DEBUG_JOYSTICK
381  SDL_Log("Removed joystick with device_id %d", device_id);
382 #endif
383 
384  SDL_free(item->name);
385  SDL_free(item);
386  return numjoysticks;
387 }
388 
389 
390 static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickGUID guid, int *device_instance)
391 {
392  SDL_joylist_item *item;
393 
394  item = (SDL_joylist_item *)SDL_calloc(1, sizeof (SDL_joylist_item));
395  if (item == NULL) {
396  return SDL_FALSE;
397  }
398 
399  *device_instance = item->device_instance = instance_counter++;
400  item->device_id = -1;
401  item->name = SDL_strdup(name);
402  item->guid = guid;
403  SDL_GetSteamControllerInputs(&item->nbuttons,
404  &item->naxes,
405  &item->nhats);
406  item->m_bSteamController = SDL_TRUE;
407 
408  if (SDL_joylist_tail == NULL) {
409  SDL_joylist = SDL_joylist_tail = item;
410  } else {
411  SDL_joylist_tail->next = item;
412  SDL_joylist_tail = item;
413  }
414 
415  /* Need to increment the joystick count before we post the event */
416  ++numjoysticks;
417 
419 
420  return SDL_TRUE;
421 }
422 
423 static void SteamControllerDisconnectedCallback(int device_instance)
424 {
425  SDL_joylist_item *item = SDL_joylist;
426  SDL_joylist_item *prev = NULL;
427 
428  while (item != NULL) {
429  if (item->device_instance == device_instance) {
430  break;
431  }
432  prev = item;
433  item = item->next;
434  }
435 
436  if (item == NULL) {
437  return;
438  }
439 
440  if (item->joystick) {
441  item->joystick->hwdata = NULL;
442  }
443 
444  if (prev != NULL) {
445  prev->next = item->next;
446  } else {
447  SDL_assert(SDL_joylist == item);
448  SDL_joylist = item->next;
449  }
450  if (item == SDL_joylist_tail) {
451  SDL_joylist_tail = prev;
452  }
453 
454  /* Need to decrement the joystick count before we post the event */
455  --numjoysticks;
456 
457  SDL_PrivateJoystickRemoved(item->device_instance);
458 
459  SDL_free(item->name);
460  SDL_free(item);
461 }
462 
463 int
465 {
467 
469  /* Default behavior, accelerometer as joystick */
470  Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, ANDROID_ACCELEROMETER_NAME, SDL_TRUE, 0, 3, 0, 0);
471  }
472 
475 
476  return (numjoysticks);
477 
478 }
479 
480 int
482 {
483  return numjoysticks;
484 }
485 
486 void
488 {
489  /* Support for device connect/disconnect is API >= 16 only,
490  * so we poll every three seconds
491  * Ref: http://developer.android.com/reference/android/hardware/input/InputManager.InputDeviceListener.html
492  */
493  static Uint32 timeout = 0;
494  if (!timeout || SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) {
495  timeout = SDL_GetTicks() + 3000;
497  }
498 
500 }
501 
502 static SDL_joylist_item *
503 JoystickByDevIndex(int device_index)
504 {
505  SDL_joylist_item *item = SDL_joylist;
506 
507  if ((device_index < 0) || (device_index >= numjoysticks)) {
508  return NULL;
509  }
510 
511  while (device_index > 0) {
512  SDL_assert(item != NULL);
513  device_index--;
514  item = item->next;
515  }
516 
517  return item;
518 }
519 
520 static SDL_joylist_item *
521 JoystickByDeviceId(int device_id)
522 {
523  SDL_joylist_item *item = SDL_joylist;
524 
525  while (item != NULL) {
526  if (item->device_id == device_id) {
527  return item;
528  }
529  item = item->next;
530  }
531 
532  /* Joystick not found, try adding it */
534 
535  while (item != NULL) {
536  if (item->device_id == device_id) {
537  return item;
538  }
539  item = item->next;
540  }
541 
542  return NULL;
543 }
544 
545 /* Function to get the device-dependent name of a joystick */
546 const char *
547 SDL_SYS_JoystickNameForDeviceIndex(int device_index)
548 {
549  return JoystickByDevIndex(device_index)->name;
550 }
551 
552 /* Function to perform the mapping from device index to the instance id for this index */
554 {
555  return JoystickByDevIndex(device_index)->device_instance;
556 }
557 
558 /* Function to open a joystick for use.
559  The joystick to open is specified by the device index.
560  This should fill the nbuttons and naxes fields of the joystick structure.
561  It returns 0, or -1 if there is an error.
562  */
563 int
564 SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
565 {
566  SDL_joylist_item *item = JoystickByDevIndex(device_index);
567 
568  if (item == NULL) {
569  return SDL_SetError("No such device");
570  }
571 
572  if (item->joystick != NULL) {
573  return SDL_SetError("Joystick already opened");
574  }
575 
576  joystick->instance_id = item->device_instance;
577  joystick->hwdata = (struct joystick_hwdata *) item;
578  item->joystick = joystick;
579  joystick->nhats = item->nhats;
580  joystick->nballs = item->nballs;
581  joystick->nbuttons = item->nbuttons;
582  joystick->naxes = item->naxes;
583 
584  return (0);
585 }
586 
587 /* Function to determine if this joystick is attached to the system right now */
588 SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
589 {
590  return joystick->hwdata != NULL;
591 }
592 
593 void
594 SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
595 {
596  SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
597 
598  if (item == NULL) {
599  return;
600  }
601 
602  if (item->m_bSteamController) {
603  SDL_UpdateSteamController(joystick);
604  return;
605  }
606 
607  if (item->is_accelerometer) {
608  int i;
609  Sint16 value;
610  float values[3];
611 
613  for (i = 0; i < 3; i++) {
614  if (values[i] > 1.0f) {
615  values[i] = 1.0f;
616  } else if (values[i] < -1.0f) {
617  values[i] = -1.0f;
618  }
619 
620  value = (Sint16)(values[i] * 32767.0f);
621  SDL_PrivateJoystickAxis(item->joystick, i, value);
622  }
623  }
624  }
625 }
626 
627 /* Function to close a joystick after use */
628 void
629 SDL_SYS_JoystickClose(SDL_Joystick * joystick)
630 {
631  SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
632  if (item) {
633  item->joystick = NULL;
634  }
635 }
636 
637 /* Function to perform any system-specific joystick related cleanup */
638 void
640 {
641 /* We don't have any way to scan for joysticks at init, so don't wipe the list
642  * of joysticks here in case this is a reinit.
643  */
644 #if 0
645  SDL_joylist_item *item = NULL;
646  SDL_joylist_item *next = NULL;
647 
648  for (item = SDL_joylist; item; item = next) {
649  next = item->next;
650  SDL_free(item->name);
651  SDL_free(item);
652  }
653 
654  SDL_joylist = SDL_joylist_tail = NULL;
655 
656  numjoysticks = 0;
657  instance_counter = 0;
658 #endif /* 0 */
659 
661 }
662 
664 {
665  return JoystickByDevIndex(device_index)->guid;
666 }
667 
668 SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
669 {
671 
672  if (joystick->hwdata != NULL) {
673  return ((SDL_joylist_item*)joystick->hwdata)->guid;
674  }
675 
676  SDL_zero(guid);
677  return guid;
678 }
679 
680 SDL_bool SDL_SYS_IsDPAD_DeviceIndex(int device_index)
681 {
682  return JoystickByDevIndex(device_index)->naxes == 0;
683 }
684 
685 #endif /* SDL_JOYSTICK_ANDROID */
686 
687 /* vi: set ts=4 sw=4 expandtab: */
#define SDL_HAT_LEFTDOWN
Definition: SDL_joystick.h:324
#define SDL_HINT_TV_REMOTE_AS_JOYSTICK
A variable controlling whether the Android / tvOS remotes should be listed as joystick devices...
Definition: SDL_hints.h:399
void SDL_UpdateSteamControllers(void)
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
SDL_Texture * button
void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance)
Definition: SDL_joystick.c:638
SDL_JoystickGUID guid
int SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value)
Definition: SDL_joystick.c:712
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
void SDL_InitSteamControllers(SteamControllerConnectedCallback_t connectedCallback, SteamControllerDisconnectedCallback_t disconnectedCallback)
static void SteamControllerDisconnectedCallback(int device_instance)
void SDL_QuitSteamControllers(void)
SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
SDL_Joystick * joystick
#define SDL_HAT_RIGHTUP
Definition: SDL_joystick.h:321
int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
Definition: SDL_joystick.c:788
GLfloat f
struct joystick_hwdata * next
SDL_Texture * axis
void SDL_SYS_JoystickQuit(void)
uint32_t Uint32
Definition: SDL_stdinc.h:181
#define SDL_zerop(x)
Definition: SDL_stdinc.h:417
int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
Definition: SDL_joystick.c:655
GLuint const GLchar * name
int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
Definition: SDL_keyboard.c:679
#define SDL_GetHintBoolean
GLenum GLsizei GLsizei GLint * values
#define SDL_HAT_RIGHT
Definition: SDL_joystick.h:318
#define SDL_Log
#define SDL_memcpy
#define SDL_HINT_ACCELEROMETER_AS_JOYSTICK
A variable controlling whether the Android / iOS built-in accelerometer should be listed as a joystic...
Definition: SDL_hints.h:389
#define SDL_HAT_RIGHTDOWN
Definition: SDL_joystick.h:322
Sint32 SDL_JoystickID
Definition: SDL_joystick.h:81
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
#define SDL_HAT_LEFT
Definition: SDL_joystick.h:320
uint8_t Uint8
Definition: SDL_stdinc.h:157
#define SDL_free
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
GLsizei const GLfloat * value
void SDL_PrivateJoystickAdded(int device_index)
Definition: SDL_joystick.c:595
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
const char * SDL_SYS_JoystickNameForDeviceIndex(int device_index)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick *joystick)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickGUID guid, int *device_instance)
#define SDL_assert(condition)
Definition: SDL_assert.h:169
int SDL_SYS_JoystickInit(void)
#define NULL
Definition: begin_code.h:164
void SDL_UpdateSteamController(SDL_Joystick *joystick)
SDL_bool
Definition: SDL_stdinc.h:139
int SDL_SYS_NumJoysticks(void)
#define SDL_SetError
#define SDL_calloc
#define SDL_strlen
#define SDL_strdup
#define SDL_HAT_LEFTUP
Definition: SDL_joystick.h:323
GLbitfield GLuint64 timeout
struct SDL_joylist_item * item
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
static int numjoysticks
void SDL_GetSteamControllerInputs(int *nbuttons, int *naxes, int *nhats)
int SDL_SYS_JoystickOpen(SDL_Joystick *joystick, int device_index)
#define SDL_malloc
void Android_JNI_PollInputDevices(void)
#define SDL_PRESSED
Definition: SDL_events.h:50
#define SDL_HAT_CENTERED
Definition: SDL_joystick.h:316
void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
#define SDL_TICKS_PASSED(A, B)
Compare SDL ticks values, and return true if A has passed B.
Definition: SDL_timer.h:56
#define SDL_RELEASED
Definition: SDL_events.h:49
#define SDL_HAT_UP
Definition: SDL_joystick.h:317
#define SDL_HAT_DOWN
Definition: SDL_joystick.h:319
SDL_Scancode
The SDL keyboard scancode representation.
Definition: SDL_scancode.h:43
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index)
int16_t Sint16
Definition: SDL_stdinc.h:163
void SDL_SYS_JoystickDetect(void)