SDL  2.0
SDL_joystick.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 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 #include "../SDL_internal.h"
22 
23 /* This is the joystick API for Simple DirectMedia Layer */
24 
25 #include "SDL.h"
26 #include "SDL_atomic.h"
27 #include "SDL_events.h"
28 #include "SDL_sysjoystick.h"
29 #include "SDL_assert.h"
30 #include "SDL_hints.h"
31 
32 #if !SDL_EVENTS_DISABLED
33 #include "../events/SDL_events_c.h"
34 #endif
35 #include "../video/SDL_sysvideo.h"
37 
38 /* This is included in only one place because it has a large static list of controllers */
39 #include "controller_type.h"
40 
41 #ifdef __WIN32__
42 /* Needed for checking for input remapping programs */
43 #include "../core/windows/SDL_windows.h"
44 
45 #undef UNICODE /* We want ASCII functions */
46 #include <tlhelp32.h>
47 #endif
48 
50 #if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
52 #endif
53 #ifdef SDL_JOYSTICK_LINUX
55 #endif
56 #ifdef SDL_JOYSTICK_IOKIT
58 #endif
59 #if defined(__IPHONEOS__) || defined(__TVOS__)
61 #endif
62 #ifdef SDL_JOYSTICK_ANDROID
64 #endif
65 #ifdef SDL_JOYSTICK_EMSCRIPTEN
67 #endif
68 #ifdef SDL_JOYSTICK_HAIKU
70 #endif
71 #ifdef SDL_JOYSTICK_USBHID /* !!! FIXME: "USBHID" is a generic name, and doubly-confusing with HIDAPI next to it. This is the *BSD interface, rename this. */
73 #endif
74 #ifdef SDL_JOYSTICK_HIDAPI
76 #endif
77 #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED)
79 #endif
80 };
82 static SDL_Joystick *SDL_joysticks = NULL;
84 static SDL_mutex *SDL_joystick_lock = NULL; /* This needs to support recursive locks */
88 
89 void
91 {
92  if (SDL_joystick_lock) {
94  }
95 }
96 
97 void
99 {
100  if (SDL_joystick_lock) {
102  }
103 }
104 
105 static int
107 {
108  int player_index;
109 
110  for (player_index = 0; player_index < SDL_joystick_player_count; ++player_index) {
111  if (SDL_joystick_players[player_index] == -1) {
112  return player_index;
113  }
114  }
115  return player_index;
116 }
117 
118 static int
120 {
121  int player_index;
122 
123  for (player_index = 0; player_index < SDL_joystick_player_count; ++player_index) {
124  if (instance_id == SDL_joystick_players[player_index]) {
125  break;
126  }
127  }
128  if (player_index == SDL_joystick_player_count) {
129  player_index = -1;
130  }
131  return player_index;
132 }
133 
134 static SDL_JoystickID
136 {
137  if (player_index < 0 || player_index >= SDL_joystick_player_count) {
138  return -1;
139  }
140  return SDL_joystick_players[player_index];
141 }
142 
143 static SDL_bool
144 SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id)
145 {
146  SDL_JoystickID existing_instance = SDL_GetJoystickIDForPlayerIndex(player_index);
147  SDL_JoystickDriver *driver;
148  int device_index;
149  int existing_player_index;
150 
151  if (player_index < 0) {
152  return SDL_FALSE;
153  }
154  if (player_index >= SDL_joystick_player_count) {
155  SDL_JoystickID *new_players = (SDL_JoystickID *)SDL_realloc(SDL_joystick_players, (player_index + 1)*sizeof(*SDL_joystick_players));
156  if (!new_players) {
157  SDL_OutOfMemory();
158  return SDL_FALSE;
159  }
160 
161  SDL_joystick_players = new_players;
163  SDL_joystick_player_count = player_index + 1;
164  } else if (SDL_joystick_players[player_index] == instance_id) {
165  /* Joystick is already assigned the requested player index */
166  return SDL_TRUE;
167  }
168 
169  /* Clear the old player index */
170  existing_player_index = SDL_GetPlayerIndexForJoystickID(instance_id);
171  if (existing_player_index >= 0) {
172  SDL_joystick_players[existing_player_index] = -1;
173  }
174 
175  SDL_joystick_players[player_index] = instance_id;
176 
177  /* Update the driver with the new index */
178  device_index = SDL_JoystickGetDeviceIndexFromInstanceID(instance_id);
179  if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) {
180  driver->SetDevicePlayerIndex(device_index, player_index);
181  }
182 
183  /* Move any existing joystick to another slot */
184  if (existing_instance >= 0) {
186  }
187  return SDL_TRUE;
188 }
189 
190 static void SDLCALL
191 SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
192 {
193  if (hint && *hint == '1') {
195  } else {
197  }
198 }
199 
200 int
202 {
203  int i, status;
204 
206 
207  /* Create the joystick list lock */
208  if (!SDL_joystick_lock) {
210  }
211 
212  /* See if we should allow joystick events while in the background */
215 
216 #if !SDL_EVENTS_DISABLED
218  return -1;
219  }
220 #endif /* !SDL_EVENTS_DISABLED */
221 
222  status = -1;
223  for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) {
224  if (SDL_joystick_drivers[i]->Init() >= 0) {
225  status = 0;
226  }
227  }
228  return status;
229 }
230 
231 /*
232  * Count the number of joysticks attached to the system
233  */
234 int
236 {
237  int i, total_joysticks = 0;
239  for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) {
240  total_joysticks += SDL_joystick_drivers[i]->GetCount();
241  }
243  return total_joysticks;
244 }
245 
246 /*
247  * Return the next available joystick instance ID
248  * This may be called by drivers from multiple threads, unprotected by any locks
249  */
251 {
253 }
254 
255 /*
256  * Get the driver and device index for an API device index
257  * This should be called while the joystick lock is held, to prevent another thread from updating the list
258  */
259 SDL_bool
260 SDL_GetDriverAndJoystickIndex(int device_index, SDL_JoystickDriver **driver, int *driver_index)
261 {
262  int i, num_joysticks, total_joysticks = 0;
263 
264  if (device_index >= 0) {
265  for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) {
266  num_joysticks = SDL_joystick_drivers[i]->GetCount();
267  if (device_index < num_joysticks) {
268  *driver = SDL_joystick_drivers[i];
269  *driver_index = device_index;
270  return SDL_TRUE;
271  }
272  device_index -= num_joysticks;
273  total_joysticks += num_joysticks;
274  }
275  }
276 
277  SDL_SetError("There are %d joysticks available", total_joysticks);
278  return SDL_FALSE;
279 }
280 
281 /*
282  * Perform any needed fixups for joystick names
283  */
284 static const char *
286 {
287  if (name) {
288  const char *skip_prefix = "NVIDIA Corporation ";
289 
290  if (SDL_strncmp(name, skip_prefix, SDL_strlen(skip_prefix)) == 0) {
291  name += SDL_strlen(skip_prefix);
292  }
293  }
294  return name;
295 }
296 
297 
298 /*
299  * Get the implementation dependent name of a joystick
300  */
301 const char *
302 SDL_JoystickNameForIndex(int device_index)
303 {
304  SDL_JoystickDriver *driver;
305  const char *name = NULL;
306 
308  if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) {
309  name = SDL_FixupJoystickName(driver->GetDeviceName(device_index));
310  }
312 
313  /* FIXME: Really we should reference count this name so it doesn't go away after unlock */
314  return name;
315 }
316 
317 /*
318  * Get the player index of a joystick, or -1 if it's not available
319  */
320 int
322 {
323  int player_index;
324 
328 
329  return player_index;
330 }
331 
332 /*
333  * Return true if this joystick is known to have all axes centered at zero
334  * This isn't generally needed unless the joystick never generates an initial axis value near zero,
335  * e.g. it's emulating axes with digital buttons
336  */
337 static SDL_bool
339 {
340  static Uint32 zero_centered_joysticks[] = {
341  MAKE_VIDPID(0x0e8f, 0x3013), /* HuiJia SNES USB adapter */
342  MAKE_VIDPID(0x05a0, 0x3232), /* 8Bitdo Zero Gamepad */
343  };
344 
345  int i;
348 
349 /*printf("JOYSTICK '%s' VID/PID 0x%.4x/0x%.4x AXES: %d\n", joystick->name, vendor, product, joystick->naxes);*/
350 
351  if (joystick->naxes == 2) {
352  /* Assume D-pad or thumbstick style axes are centered at 0 */
353  return SDL_TRUE;
354  }
355 
356  for (i = 0; i < SDL_arraysize(zero_centered_joysticks); ++i) {
357  if (id == zero_centered_joysticks[i]) {
358  return SDL_TRUE;
359  }
360  }
361  return SDL_FALSE;
362 }
363 
364 /*
365  * Open a joystick for use - the index passed as an argument refers to
366  * the N'th joystick on the system. This index is the value which will
367  * identify this joystick in future joystick events.
368  *
369  * This function returns a joystick identifier, or NULL if an error occurred.
370  */
371 SDL_Joystick *
372 SDL_JoystickOpen(int device_index)
373 {
374  SDL_JoystickDriver *driver;
375  SDL_JoystickID instance_id;
376  SDL_Joystick *joystick;
377  SDL_Joystick *joysticklist;
378  const char *joystickname = NULL;
379 
381 
382  if (!SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) {
384  return NULL;
385  }
386 
387  joysticklist = SDL_joysticks;
388  /* If the joystick is already open, return it
389  * it is important that we have a single joystick * for each instance id
390  */
391  instance_id = driver->GetDeviceInstanceID(device_index);
392  while (joysticklist) {
393  if (instance_id == joysticklist->instance_id) {
394  joystick = joysticklist;
395  ++joystick->ref_count;
397  return joystick;
398  }
399  joysticklist = joysticklist->next;
400  }
401 
402  /* Create and initialize the joystick */
403  joystick = (SDL_Joystick *) SDL_calloc(sizeof(*joystick), 1);
404  if (joystick == NULL) {
405  SDL_OutOfMemory();
407  return NULL;
408  }
409  joystick->driver = driver;
410  joystick->instance_id = instance_id;
411  joystick->attached = SDL_TRUE;
412  joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
413 
414  if (driver->Open(joystick, device_index) < 0) {
417  return NULL;
418  }
419 
420  joystickname = driver->GetDeviceName(device_index);
421  if (joystickname) {
422  joystick->name = SDL_strdup(joystickname);
423  } else {
424  joystick->name = NULL;
425  }
426 
427  joystick->guid = driver->GetDeviceGUID(device_index);
428 
429  if (joystick->naxes > 0) {
431  }
432  if (joystick->nhats > 0) {
433  joystick->hats = (Uint8 *) SDL_calloc(joystick->nhats, sizeof(Uint8));
434  }
435  if (joystick->nballs > 0) {
436  joystick->balls = (struct balldelta *) SDL_calloc(joystick->nballs, sizeof(*joystick->balls));
437  }
438  if (joystick->nbuttons > 0) {
439  joystick->buttons = (Uint8 *) SDL_calloc(joystick->nbuttons, sizeof(Uint8));
440  }
441  if (((joystick->naxes > 0) && !joystick->axes)
442  || ((joystick->nhats > 0) && !joystick->hats)
443  || ((joystick->nballs > 0) && !joystick->balls)
444  || ((joystick->nbuttons > 0) && !joystick->buttons)) {
445  SDL_OutOfMemory();
446  SDL_JoystickClose(joystick);
448  return NULL;
449  }
450 
451  /* If this joystick is known to have all zero centered axes, skip the auto-centering code */
452  if (SDL_JoystickAxesCenteredAtZero(joystick)) {
453  int i;
454 
455  for (i = 0; i < joystick->naxes; ++i) {
456  joystick->axes[i].has_initial_value = SDL_TRUE;
457  }
458  }
459 
460  joystick->is_game_controller = SDL_IsGameController(device_index);
461 
462  /* Add joystick to list */
463  ++joystick->ref_count;
464  /* Link the joystick in the list */
465  joystick->next = SDL_joysticks;
466  SDL_joysticks = joystick;
467 
469 
470  driver->Update(joystick);
471 
472  return joystick;
473 }
474 
475 
476 /*
477  * Checks to make sure the joystick is valid.
478  */
479 SDL_bool
480 SDL_PrivateJoystickValid(SDL_Joystick * joystick)
481 {
482  SDL_bool valid;
483 
484  if (joystick == NULL) {
485  SDL_SetError("Joystick hasn't been opened yet");
486  valid = SDL_FALSE;
487  } else {
488  valid = SDL_TRUE;
489  }
490 
491  return valid;
492 }
493 
494 /*
495  * Get the number of multi-dimensional axis controls on a joystick
496  */
497 int
498 SDL_JoystickNumAxes(SDL_Joystick * joystick)
499 {
500  if (!SDL_PrivateJoystickValid(joystick)) {
501  return -1;
502  }
503  return joystick->naxes;
504 }
505 
506 /*
507  * Get the number of hats on a joystick
508  */
509 int
510 SDL_JoystickNumHats(SDL_Joystick * joystick)
511 {
512  if (!SDL_PrivateJoystickValid(joystick)) {
513  return -1;
514  }
515  return joystick->nhats;
516 }
517 
518 /*
519  * Get the number of trackballs on a joystick
520  */
521 int
522 SDL_JoystickNumBalls(SDL_Joystick * joystick)
523 {
524  if (!SDL_PrivateJoystickValid(joystick)) {
525  return -1;
526  }
527  return joystick->nballs;
528 }
529 
530 /*
531  * Get the number of buttons on a joystick
532  */
533 int
534 SDL_JoystickNumButtons(SDL_Joystick * joystick)
535 {
536  if (!SDL_PrivateJoystickValid(joystick)) {
537  return -1;
538  }
539  return joystick->nbuttons;
540 }
541 
542 /*
543  * Get the current state of an axis control on a joystick
544  */
545 Sint16
546 SDL_JoystickGetAxis(SDL_Joystick * joystick, int axis)
547 {
548  Sint16 state;
549 
550  if (!SDL_PrivateJoystickValid(joystick)) {
551  return 0;
552  }
553  if (axis < joystick->naxes) {
554  state = joystick->axes[axis].value;
555  } else {
556  SDL_SetError("Joystick only has %d axes", joystick->naxes);
557  state = 0;
558  }
559  return state;
560 }
561 
562 /*
563  * Get the initial state of an axis control on a joystick
564  */
565 SDL_bool
566 SDL_JoystickGetAxisInitialState(SDL_Joystick * joystick, int axis, Sint16 *state)
567 {
568  if (!SDL_PrivateJoystickValid(joystick)) {
569  return SDL_FALSE;
570  }
571  if (axis >= joystick->naxes) {
572  SDL_SetError("Joystick only has %d axes", joystick->naxes);
573  return SDL_FALSE;
574  }
575  if (state) {
576  *state = joystick->axes[axis].initial_value;
577  }
578  return joystick->axes[axis].has_initial_value;
579 }
580 
581 /*
582  * Get the current state of a hat on a joystick
583  */
584 Uint8
585 SDL_JoystickGetHat(SDL_Joystick * joystick, int hat)
586 {
587  Uint8 state;
588 
589  if (!SDL_PrivateJoystickValid(joystick)) {
590  return 0;
591  }
592  if (hat < joystick->nhats) {
593  state = joystick->hats[hat];
594  } else {
595  SDL_SetError("Joystick only has %d hats", joystick->nhats);
596  state = 0;
597  }
598  return state;
599 }
600 
601 /*
602  * Get the ball axis change since the last poll
603  */
604 int
605 SDL_JoystickGetBall(SDL_Joystick * joystick, int ball, int *dx, int *dy)
606 {
607  int retval;
608 
609  if (!SDL_PrivateJoystickValid(joystick)) {
610  return -1;
611  }
612 
613  retval = 0;
614  if (ball < joystick->nballs) {
615  if (dx) {
616  *dx = joystick->balls[ball].dx;
617  }
618  if (dy) {
619  *dy = joystick->balls[ball].dy;
620  }
621  joystick->balls[ball].dx = 0;
622  joystick->balls[ball].dy = 0;
623  } else {
624  return SDL_SetError("Joystick only has %d balls", joystick->nballs);
625  }
626  return retval;
627 }
628 
629 /*
630  * Get the current state of a button on a joystick
631  */
632 Uint8
633 SDL_JoystickGetButton(SDL_Joystick * joystick, int button)
634 {
635  Uint8 state;
636 
637  if (!SDL_PrivateJoystickValid(joystick)) {
638  return 0;
639  }
640  if (button < joystick->nbuttons) {
641  state = joystick->buttons[button];
642  } else {
643  SDL_SetError("Joystick only has %d buttons", joystick->nbuttons);
644  state = 0;
645  }
646  return state;
647 }
648 
649 /*
650  * Return if the joystick in question is currently attached to the system,
651  * \return SDL_FALSE if not plugged in, SDL_TRUE if still present.
652  */
653 SDL_bool
654 SDL_JoystickGetAttached(SDL_Joystick * joystick)
655 {
656  if (!SDL_PrivateJoystickValid(joystick)) {
657  return SDL_FALSE;
658  }
659 
660  return joystick->attached;
661 }
662 
663 /*
664  * Get the instance id for this opened joystick
665  */
667 SDL_JoystickInstanceID(SDL_Joystick * joystick)
668 {
669  if (!SDL_PrivateJoystickValid(joystick)) {
670  return -1;
671  }
672 
673  return joystick->instance_id;
674 }
675 
676 /*
677  * Return the SDL_Joystick associated with an instance id.
678  */
679 SDL_Joystick *
681 {
682  SDL_Joystick *joystick;
683 
685  for (joystick = SDL_joysticks; joystick; joystick = joystick->next) {
686  if (joystick->instance_id == instance_id) {
687  break;
688  }
689  }
691  return joystick;
692 }
693 
694 /**
695  * Return the SDL_Joystick associated with a player index.
696  */
697 SDL_Joystick *
699 {
700  SDL_JoystickID instance_id;
701  SDL_Joystick *joystick;
702 
704  instance_id = SDL_GetJoystickIDForPlayerIndex(player_index);
705  for (joystick = SDL_joysticks; joystick; joystick = joystick->next) {
706  if (joystick->instance_id == instance_id) {
707  break;
708  }
709  }
711  return joystick;
712 }
713 
714 /*
715  * Get the friendly name of this joystick
716  */
717 const char *
718 SDL_JoystickName(SDL_Joystick * joystick)
719 {
720  if (!SDL_PrivateJoystickValid(joystick)) {
721  return NULL;
722  }
723 
724  return SDL_FixupJoystickName(joystick->name);
725 }
726 
727 /**
728  * Get the player index of an opened joystick, or -1 if it's not available
729  */
730 int
731 SDL_JoystickGetPlayerIndex(SDL_Joystick * joystick)
732 {
733  int player_index;
734 
735  if (!SDL_PrivateJoystickValid(joystick)) {
736  return -1;
737  }
738 
740  player_index = SDL_GetPlayerIndexForJoystickID(joystick->instance_id);
742 
743  return player_index;
744 }
745 
746 /**
747  * Set the player index of an opened joystick
748  */
749 void
750 SDL_JoystickSetPlayerIndex(SDL_Joystick * joystick, int player_index)
751 {
752  if (!SDL_PrivateJoystickValid(joystick)) {
753  return;
754  }
755 
757  SDL_SetJoystickIDForPlayerIndex(player_index, joystick->instance_id);
759 }
760 
761 int
762 SDL_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
763 {
764  int result;
765 
766  if (!SDL_PrivateJoystickValid(joystick)) {
767  return -1;
768  }
769 
771  if (low_frequency_rumble == joystick->low_frequency_rumble &&
772  high_frequency_rumble == joystick->high_frequency_rumble) {
773  /* Just update the expiration */
774  result = 0;
775  } else {
776  result = joystick->driver->Rumble(joystick, low_frequency_rumble, high_frequency_rumble);
777  }
778 
779  /* Save the rumble value regardless of success, so we don't spam the driver */
780  joystick->low_frequency_rumble = low_frequency_rumble;
781  joystick->high_frequency_rumble = high_frequency_rumble;
782 
783  if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
784  joystick->rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
785  if (!joystick->rumble_expiration) {
786  joystick->rumble_expiration = 1;
787  }
788  } else {
789  joystick->rumble_expiration = 0;
790  }
792 
793  return result;
794 }
795 
796 /*
797  * Close a joystick previously opened with SDL_JoystickOpen()
798  */
799 void
800 SDL_JoystickClose(SDL_Joystick * joystick)
801 {
802  SDL_Joystick *joysticklist;
803  SDL_Joystick *joysticklistprev;
804 
805  if (!SDL_PrivateJoystickValid(joystick)) {
806  return;
807  }
808 
810 
811  /* First decrement ref count */
812  if (--joystick->ref_count > 0) {
814  return;
815  }
816 
817  if (SDL_updating_joystick) {
819  return;
820  }
821 
822  if (joystick->rumble_expiration) {
823  SDL_JoystickRumble(joystick, 0, 0, 0);
824  }
825 
826  joystick->driver->Close(joystick);
827  joystick->hwdata = NULL;
828 
829  joysticklist = SDL_joysticks;
830  joysticklistprev = NULL;
831  while (joysticklist) {
832  if (joystick == joysticklist) {
833  if (joysticklistprev) {
834  /* unlink this entry */
835  joysticklistprev->next = joysticklist->next;
836  } else {
837  SDL_joysticks = joystick->next;
838  }
839  break;
840  }
841  joysticklistprev = joysticklist;
842  joysticklist = joysticklist->next;
843  }
844 
845  SDL_free(joystick->name);
846 
847  /* Free the data associated with this joystick */
848  SDL_free(joystick->axes);
849  SDL_free(joystick->hats);
850  SDL_free(joystick->balls);
851  SDL_free(joystick->buttons);
852  SDL_free(joystick);
853 
855 }
856 
857 void
859 {
860  int i;
861 
862  /* Make sure we're not getting called in the middle of updating joysticks */
864  while (SDL_updating_joystick) {
866  SDL_Delay(1);
868  }
869 
870  /* Stop the event polling */
871  while (SDL_joysticks) {
872  SDL_joysticks->ref_count = 1;
874  }
875 
876  /* Quit the joystick setup */
877  for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) {
879  }
880 
881  if (SDL_joystick_players) {
885  }
887 
888 #if !SDL_EVENTS_DISABLED
890 #endif
891 
894 
895  if (SDL_joystick_lock) {
899  }
900 
902 }
903 
904 
905 static SDL_bool
907 {
909  return SDL_FALSE;
910  }
911 
912  if (SDL_HasWindows() && SDL_GetKeyboardFocus() == NULL) {
913  /* We have windows but we don't have focus, ignore the event. */
914  return SDL_TRUE;
915  }
916  return SDL_FALSE;
917 }
918 
919 /* These are global for SDL_sysjoystick.c and SDL_events.c */
920 
922 {
923  SDL_JoystickDriver *driver;
924  int driver_device_index;
925  int player_index = -1;
926  int device_index = SDL_JoystickGetDeviceIndexFromInstanceID(device_instance);
927  if (device_index < 0) {
928  return;
929  }
930 
932  if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &driver_device_index)) {
933  player_index = driver->GetDevicePlayerIndex(driver_device_index);
934  }
935  if (player_index < 0 && SDL_IsGameController(device_index)) {
936  player_index = SDL_FindFreePlayerIndex();
937  }
938  if (player_index >= 0) {
939  SDL_SetJoystickIDForPlayerIndex(player_index, device_instance);
940  }
942 
943 #if !SDL_EVENTS_DISABLED
944  {
946 
947  event.type = SDL_JOYDEVICEADDED;
948 
949  if (SDL_GetEventState(event.type) == SDL_ENABLE) {
950  event.jdevice.which = device_index;
952  }
953  }
954 #endif /* !SDL_EVENTS_DISABLED */
955 }
956 
957 /*
958  * If there is an existing add event in the queue, it needs to be modified
959  * to have the right value for which, because the number of controllers in
960  * the system is now one less.
961  */
963 {
964  int i, num_events;
965  SDL_Event *events;
966  SDL_bool isstack;
967 
969  if (num_events <= 0) {
970  return;
971  }
972 
973  events = SDL_small_alloc(SDL_Event, num_events, &isstack);
974  if (!events) {
975  return;
976  }
977 
979  for (i = 0; i < num_events; ++i) {
980  --events[i].jdevice.which;
981  }
982  SDL_PeepEvents(events, num_events, SDL_ADDEVENT, 0, 0);
983 
984  SDL_small_free(events, isstack);
985 }
986 
988 {
989  SDL_Joystick *joystick;
990  int player_index;
991 
992 #if !SDL_EVENTS_DISABLED
994 
995  event.type = SDL_JOYDEVICEREMOVED;
996 
997  if (SDL_GetEventState(event.type) == SDL_ENABLE) {
998  event.jdevice.which = device_instance;
1000  }
1001 
1003 #endif /* !SDL_EVENTS_DISABLED */
1004 
1005  /* Mark this joystick as no longer attached */
1006  for (joystick = SDL_joysticks; joystick; joystick = joystick->next) {
1007  if (joystick->instance_id == device_instance) {
1008  joystick->attached = SDL_FALSE;
1009  joystick->force_recentering = SDL_TRUE;
1010  break;
1011  }
1012  }
1013 
1015  player_index = SDL_GetPlayerIndexForJoystickID(device_instance);
1016  if (player_index >= 0) {
1017  SDL_joystick_players[player_index] = -1;
1018  }
1020 }
1021 
1022 int
1023 SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
1024 {
1025  int posted;
1026  SDL_JoystickAxisInfo *info;
1027 
1028  /* Make sure we're not getting garbage or duplicate events */
1029  if (axis >= joystick->naxes) {
1030  return 0;
1031  }
1032 
1033  info = &joystick->axes[axis];
1034  if (!info->has_initial_value ||
1035  (!info->has_second_value && (info->initial_value == -32768 || info->initial_value == 32767) && SDL_abs(value) < (SDL_JOYSTICK_AXIS_MAX / 4))) {
1036  info->initial_value = value;
1037  info->value = value;
1038  info->zero = value;
1039  info->has_initial_value = SDL_TRUE;
1040  } else {
1041  info->has_second_value = SDL_TRUE;
1042  }
1043  if (value == info->value) {
1044  return 0;
1045  }
1046  if (!info->sent_initial_value) {
1047  /* Make sure we don't send motion until there's real activity on this axis */
1048  const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */
1049  if (SDL_abs(value - info->value) <= MAX_ALLOWED_JITTER) {
1050  return 0;
1051  }
1052  info->sent_initial_value = SDL_TRUE;
1053  info->value = value; /* Just so we pass the check above */
1054  SDL_PrivateJoystickAxis(joystick, axis, info->initial_value);
1055  }
1056 
1057  /* We ignore events if we don't have keyboard focus, except for centering
1058  * events.
1059  */
1061  if ((value > info->zero && value >= info->value) ||
1063  return 0;
1064  }
1065  }
1066 
1067  /* Update internal joystick state */
1068  info->value = value;
1069 
1070  /* Post the event, if desired */
1071  posted = 0;
1072 #if !SDL_EVENTS_DISABLED
1074  SDL_Event event;
1075  event.type = SDL_JOYAXISMOTION;
1076  event.jaxis.which = joystick->instance_id;
1077  event.jaxis.axis = axis;
1078  event.jaxis.value = value;
1079  posted = SDL_PushEvent(&event) == 1;
1080  }
1081 #endif /* !SDL_EVENTS_DISABLED */
1082  return posted;
1083 }
1084 
1085 int
1086 SDL_PrivateJoystickHat(SDL_Joystick * joystick, Uint8 hat, Uint8 value)
1087 {
1088  int posted;
1089 
1090  /* Make sure we're not getting garbage or duplicate events */
1091  if (hat >= joystick->nhats) {
1092  return 0;
1093  }
1094  if (value == joystick->hats[hat]) {
1095  return 0;
1096  }
1097 
1098  /* We ignore events if we don't have keyboard focus, except for centering
1099  * events.
1100  */
1102  if (value != SDL_HAT_CENTERED) {
1103  return 0;
1104  }
1105  }
1106 
1107  /* Update internal joystick state */
1108  joystick->hats[hat] = value;
1109 
1110  /* Post the event, if desired */
1111  posted = 0;
1112 #if !SDL_EVENTS_DISABLED
1114  SDL_Event event;
1115  event.jhat.type = SDL_JOYHATMOTION;
1116  event.jhat.which = joystick->instance_id;
1117  event.jhat.hat = hat;
1118  event.jhat.value = value;
1119  posted = SDL_PushEvent(&event) == 1;
1120  }
1121 #endif /* !SDL_EVENTS_DISABLED */
1122  return posted;
1123 }
1124 
1125 int
1126 SDL_PrivateJoystickBall(SDL_Joystick * joystick, Uint8 ball,
1127  Sint16 xrel, Sint16 yrel)
1128 {
1129  int posted;
1130 
1131  /* Make sure we're not getting garbage events */
1132  if (ball >= joystick->nballs) {
1133  return 0;
1134  }
1135 
1136  /* We ignore events if we don't have keyboard focus. */
1138  return 0;
1139  }
1140 
1141  /* Update internal mouse state */
1142  joystick->balls[ball].dx += xrel;
1143  joystick->balls[ball].dy += yrel;
1144 
1145  /* Post the event, if desired */
1146  posted = 0;
1147 #if !SDL_EVENTS_DISABLED
1149  SDL_Event event;
1150  event.jball.type = SDL_JOYBALLMOTION;
1151  event.jball.which = joystick->instance_id;
1152  event.jball.ball = ball;
1153  event.jball.xrel = xrel;
1154  event.jball.yrel = yrel;
1155  posted = SDL_PushEvent(&event) == 1;
1156  }
1157 #endif /* !SDL_EVENTS_DISABLED */
1158  return posted;
1159 }
1160 
1161 int
1163 {
1164  int posted;
1165 #if !SDL_EVENTS_DISABLED
1166  SDL_Event event;
1167 
1168  switch (state) {
1169  case SDL_PRESSED:
1170  event.type = SDL_JOYBUTTONDOWN;
1171  break;
1172  case SDL_RELEASED:
1173  event.type = SDL_JOYBUTTONUP;
1174  break;
1175  default:
1176  /* Invalid state -- bail */
1177  return 0;
1178  }
1179 #endif /* !SDL_EVENTS_DISABLED */
1180 
1181  /* Make sure we're not getting garbage or duplicate events */
1182  if (button >= joystick->nbuttons) {
1183  return 0;
1184  }
1185  if (state == joystick->buttons[button]) {
1186  return 0;
1187  }
1188 
1189  /* We ignore events if we don't have keyboard focus, except for button
1190  * release. */
1192  if (state == SDL_PRESSED) {
1193  return 0;
1194  }
1195  }
1196 
1197  /* Update internal joystick state */
1198  joystick->buttons[button] = state;
1199 
1200  /* Post the event, if desired */
1201  posted = 0;
1202 #if !SDL_EVENTS_DISABLED
1203  if (SDL_GetEventState(event.type) == SDL_ENABLE) {
1204  event.jbutton.which = joystick->instance_id;
1205  event.jbutton.button = button;
1206  event.jbutton.state = state;
1207  posted = SDL_PushEvent(&event) == 1;
1208  }
1209 #endif /* !SDL_EVENTS_DISABLED */
1210  return posted;
1211 }
1212 
1213 void
1215 {
1216  int i;
1217  SDL_Joystick *joystick, *next;
1218 
1220  return;
1221  }
1222 
1224 
1225  if (SDL_updating_joystick) {
1226  /* The joysticks are already being updated */
1228  return;
1229  }
1230 
1232 
1233  /* Make sure the list is unlocked while dispatching events to prevent application deadlocks */
1235 
1236 #ifdef SDL_JOYSTICK_HIDAPI
1237  /* Special function for HIDAPI devices, as a single device can provide multiple SDL_Joysticks */
1239 #endif /* SDL_JOYSTICK_HIDAPI */
1240 
1241  for (joystick = SDL_joysticks; joystick; joystick = joystick->next) {
1242  if (joystick->attached) {
1243  /* This should always be true, but seeing a crash in the wild...? */
1244  if (joystick->driver) {
1245  joystick->driver->Update(joystick);
1246  }
1247 
1248  if (joystick->delayed_guide_button) {
1250  }
1251  }
1252 
1253  if (joystick->rumble_expiration) {
1255  /* Double check now that the lock is held */
1256  if (joystick->rumble_expiration &&
1257  SDL_TICKS_PASSED(SDL_GetTicks(), joystick->rumble_expiration)) {
1258  SDL_JoystickRumble(joystick, 0, 0, 0);
1259  }
1261  }
1262 
1263  if (joystick->force_recentering) {
1264  /* Tell the app that everything is centered/unpressed... */
1265  for (i = 0; i < joystick->naxes; i++) {
1266  if (joystick->axes[i].has_initial_value) {
1267  SDL_PrivateJoystickAxis(joystick, i, joystick->axes[i].zero);
1268  }
1269  }
1270 
1271  for (i = 0; i < joystick->nbuttons; i++) {
1272  SDL_PrivateJoystickButton(joystick, i, 0);
1273  }
1274 
1275  for (i = 0; i < joystick->nhats; i++) {
1277  }
1278 
1279  joystick->force_recentering = SDL_FALSE;
1280  }
1281  }
1282 
1284 
1286 
1287  /* If any joysticks were closed while updating, free them here */
1288  for (joystick = SDL_joysticks; joystick; joystick = next) {
1289  next = joystick->next;
1290  if (joystick->ref_count <= 0) {
1291  SDL_JoystickClose(joystick);
1292  }
1293  }
1294 
1295  /* this needs to happen AFTER walking the joystick list above, so that any
1296  dangling hardware data from removed devices can be free'd
1297  */
1298  for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) {
1300  }
1301 
1303 }
1304 
1305 int
1307 {
1308 #if SDL_EVENTS_DISABLED
1309  return SDL_DISABLE;
1310 #else
1311  const Uint32 event_list[] = {
1314  };
1315  unsigned int i;
1316 
1317  switch (state) {
1318  case SDL_QUERY:
1319  state = SDL_DISABLE;
1320  for (i = 0; i < SDL_arraysize(event_list); ++i) {
1321  state = SDL_EventState(event_list[i], SDL_QUERY);
1322  if (state == SDL_ENABLE) {
1323  break;
1324  }
1325  }
1326  break;
1327  default:
1328  for (i = 0; i < SDL_arraysize(event_list); ++i) {
1329  SDL_EventState(event_list[i], state);
1330  }
1331  break;
1332  }
1333  return state;
1334 #endif /* SDL_EVENTS_DISABLED */
1335 }
1336 
1337 void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version)
1338 {
1339  Uint16 *guid16 = (Uint16 *)guid.data;
1340 
1341  /* If the GUID fits the form of BUS 0000 VENDOR 0000 PRODUCT 0000, return the data */
1342  if (/* guid16[0] is device bus type */
1343  guid16[1] == 0x0000 &&
1344  /* guid16[2] is vendor ID */
1345  guid16[3] == 0x0000 &&
1346  /* guid16[4] is product ID */
1347  guid16[5] == 0x0000
1348  /* guid16[6] is product version */
1349  ) {
1350  if (vendor) {
1351  *vendor = guid16[2];
1352  }
1353  if (product) {
1354  *product = guid16[4];
1355  }
1356  if (version) {
1357  *version = guid16[6];
1358  }
1359  } else {
1360  if (vendor) {
1361  *vendor = 0;
1362  }
1363  if (product) {
1364  *product = 0;
1365  }
1366  if (version) {
1367  *version = 0;
1368  }
1369  }
1370 }
1371 
1372 const char *
1373 SDL_GetCustomJoystickManufacturer(const char *manufacturer)
1374 {
1375  if (manufacturer) {
1376  if (SDL_strcmp(manufacturer, "Performance Designed Products") == 0) {
1377  return "PDP";
1378  } else if (SDL_strcmp(manufacturer, "HORI CO.,LTD") == 0) {
1379  return "HORI";
1380  }
1381  }
1382  return manufacturer;
1383 }
1384 
1385 const char *
1387 {
1388  return GuessControllerName(vendor, product);
1389 }
1390 
1393 {
1395  Uint16 vendor, product;
1396 
1397  SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
1398  type = SDL_GetJoystickGameControllerType(name, vendor, product, -1, 0, 0, 0);
1400  if (SDL_IsJoystickXInput(guid)) {
1401  /* This is probably an Xbox One controller */
1403  }
1404  }
1405  return type;
1406 }
1407 
1409 SDL_GetJoystickGameControllerType(const char *name, Uint16 vendor, Uint16 product, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
1410 {
1411  static const int LIBUSB_CLASS_VENDOR_SPEC = 0xFF;
1412  static const int XB360_IFACE_SUBCLASS = 93;
1413  static const int XB360_IFACE_PROTOCOL = 1; /* Wired */
1414  static const int XB360W_IFACE_PROTOCOL = 129; /* Wireless */
1415  static const int XBONE_IFACE_SUBCLASS = 71;
1416  static const int XBONE_IFACE_PROTOCOL = 208;
1417 
1419 
1420  /* This code should match the checks in libusb/hid.c and HIDDeviceManager.java */
1421  if (interface_class == LIBUSB_CLASS_VENDOR_SPEC &&
1422  interface_subclass == XB360_IFACE_SUBCLASS &&
1423  (interface_protocol == XB360_IFACE_PROTOCOL ||
1424  interface_protocol == XB360W_IFACE_PROTOCOL)) {
1425 
1426  static const int SUPPORTED_VENDORS[] = {
1427  0x0079, /* GPD Win 2 */
1428  0x044f, /* Thrustmaster */
1429  0x045e, /* Microsoft */
1430  0x046d, /* Logitech */
1431  0x056e, /* Elecom */
1432  0x06a3, /* Saitek */
1433  0x0738, /* Mad Catz */
1434  0x07ff, /* Mad Catz */
1435  0x0e6f, /* PDP */
1436  0x0f0d, /* Hori */
1437  0x1038, /* SteelSeries */
1438  0x11c9, /* Nacon */
1439  0x12ab, /* Unknown */
1440  0x1430, /* RedOctane */
1441  0x146b, /* BigBen */
1442  0x1532, /* Razer Sabertooth */
1443  0x15e4, /* Numark */
1444  0x162e, /* Joytech */
1445  0x1689, /* Razer Onza */
1446  0x1bad, /* Harmonix */
1447  0x24c6, /* PowerA */
1448  };
1449 
1450  int i;
1451  for (i = 0; i < SDL_arraysize(SUPPORTED_VENDORS); ++i) {
1452  if (vendor == SUPPORTED_VENDORS[i]) {
1454  break;
1455  }
1456  }
1457  }
1458 
1459  if (interface_number == 0 &&
1460  interface_class == LIBUSB_CLASS_VENDOR_SPEC &&
1461  interface_subclass == XBONE_IFACE_SUBCLASS &&
1462  interface_protocol == XBONE_IFACE_PROTOCOL) {
1463 
1464  static const int SUPPORTED_VENDORS[] = {
1465  0x045e, /* Microsoft */
1466  0x0738, /* Mad Catz */
1467  0x0e6f, /* PDP */
1468  0x0f0d, /* Hori */
1469  0x1532, /* Razer Wildcat */
1470  0x24c6, /* PowerA */
1471  0x2e24, /* Hyperkin */
1472  };
1473 
1474  int i;
1475  for (i = 0; i < SDL_arraysize(SUPPORTED_VENDORS); ++i) {
1476  if (vendor == SUPPORTED_VENDORS[i]) {
1478  break;
1479  }
1480  }
1481  }
1482 
1484  if (vendor == 0x0000 && product == 0x0000) {
1485  /* Some devices are only identifiable by their name */
1486  if (SDL_strcmp(name, "Lic Pro Controller") == 0 ||
1487  SDL_strcmp(name, "Nintendo Wireless Gamepad") == 0 ||
1488  SDL_strcmp(name, "Wireless Gamepad") == 0) {
1489  /* HORI or PowerA Switch Pro Controller clone */
1491  } else {
1493  }
1494 
1495  } else if (vendor == 0x0001 && product == 0x0001) {
1497 
1498  } else {
1499  switch (GuessControllerType(vendor, product)) {
1502  break;
1505  break;
1508  break;
1511  break;
1515  break;
1516  default:
1518  break;
1519  }
1520  }
1521  }
1522  return type;
1523 }
1524 
1525 SDL_bool
1527 {
1528  EControllerType eType = GuessControllerType(vendor, product);
1530 }
1531 
1532 SDL_bool
1534 {
1535  EControllerType eType = GuessControllerType(vendor, product);
1536  return (eType == k_eControllerType_SteamController ||
1538 }
1539 
1540 SDL_bool
1542 {
1543  return (guid.data[14] == 'x') ? SDL_TRUE : SDL_FALSE;
1544 }
1545 
1546 SDL_bool
1548 {
1549  return (guid.data[14] == 'h') ? SDL_TRUE : SDL_FALSE;
1550 }
1551 
1553 {
1554  static Uint32 wheel_joysticks[] = {
1555  MAKE_VIDPID(0x046d, 0xc294), /* Logitech generic wheel */
1556  MAKE_VIDPID(0x046d, 0xc295), /* Logitech Momo Force */
1557  MAKE_VIDPID(0x046d, 0xc298), /* Logitech Driving Force Pro */
1558  MAKE_VIDPID(0x046d, 0xc299), /* Logitech G25 */
1559  MAKE_VIDPID(0x046d, 0xc29a), /* Logitech Driving Force GT */
1560  MAKE_VIDPID(0x046d, 0xc29b), /* Logitech G27 */
1561  MAKE_VIDPID(0x046d, 0xc261), /* Logitech G920 (initial mode) */
1562  MAKE_VIDPID(0x046d, 0xc262), /* Logitech G920 (active mode) */
1563  MAKE_VIDPID(0x044f, 0xb65d), /* Thrustmaster Wheel FFB */
1564  MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster Wheel FFB */
1565  MAKE_VIDPID(0x044f, 0xb677), /* Thrustmaster T150 */
1566  MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */
1567  MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */
1568  };
1569  int i;
1570 
1571  for (i = 0; i < SDL_arraysize(wheel_joysticks); ++i) {
1572  if (vidpid == wheel_joysticks[i]) {
1573  return SDL_TRUE;
1574  }
1575  }
1576  return SDL_FALSE;
1577 }
1578 
1580 {
1581  static Uint32 flightstick_joysticks[] = {
1582  MAKE_VIDPID(0x044f, 0x0402), /* HOTAS Warthog Joystick */
1583  MAKE_VIDPID(0x0738, 0x2221), /* Saitek Pro Flight X-56 Rhino Stick */
1584  };
1585  int i;
1586 
1587  for (i = 0; i < SDL_arraysize(flightstick_joysticks); ++i) {
1588  if (vidpid == flightstick_joysticks[i]) {
1589  return SDL_TRUE;
1590  }
1591  }
1592  return SDL_FALSE;
1593 }
1594 
1596 {
1597  static Uint32 throttle_joysticks[] = {
1598  MAKE_VIDPID(0x044f, 0x0404), /* HOTAS Warthog Throttle */
1599  MAKE_VIDPID(0x0738, 0xa221), /* Saitek Pro Flight X-56 Rhino Throttle */
1600  };
1601  int i;
1602 
1603  for (i = 0; i < SDL_arraysize(throttle_joysticks); ++i) {
1604  if (vidpid == throttle_joysticks[i]) {
1605  return SDL_TRUE;
1606  }
1607  }
1608  return SDL_FALSE;
1609 }
1610 
1612 {
1613  Uint16 vendor;
1614  Uint16 product;
1615  Uint32 vidpid;
1616 
1617  if (SDL_IsJoystickXInput(guid)) {
1618  /* XInput GUID, get the type based on the XInput device subtype */
1619  switch (guid.data[15]) {
1620  case 0x01: /* XINPUT_DEVSUBTYPE_GAMEPAD */
1622  case 0x02: /* XINPUT_DEVSUBTYPE_WHEEL */
1623  return SDL_JOYSTICK_TYPE_WHEEL;
1624  case 0x03: /* XINPUT_DEVSUBTYPE_ARCADE_STICK */
1626  case 0x04: /* XINPUT_DEVSUBTYPE_FLIGHT_STICK */
1628  case 0x05: /* XINPUT_DEVSUBTYPE_DANCE_PAD */
1630  case 0x06: /* XINPUT_DEVSUBTYPE_GUITAR */
1631  case 0x07: /* XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE */
1632  case 0x0B: /* XINPUT_DEVSUBTYPE_GUITAR_BASS */
1633  return SDL_JOYSTICK_TYPE_GUITAR;
1634  case 0x08: /* XINPUT_DEVSUBTYPE_DRUM_KIT */
1636  case 0x13: /* XINPUT_DEVSUBTYPE_ARCADE_PAD */
1638  default:
1640  }
1641  }
1642 
1643  SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
1644  vidpid = MAKE_VIDPID(vendor, product);
1645 
1646  if (SDL_IsJoystickProductWheel(vidpid)) {
1647  return SDL_JOYSTICK_TYPE_WHEEL;
1648  }
1649 
1650  if (SDL_IsJoystickProductFlightStick(vidpid)) {
1652  }
1653 
1654  if (SDL_IsJoystickProductThrottle(vidpid)) {
1656  }
1657 
1660  }
1661 
1663 }
1664 
1666 {
1667 #ifdef __WIN32__
1668  const char *mapper_processes[] = {
1669  "DS4Windows.exe",
1670  "InputMapper.exe",
1671  };
1672  int i;
1673  PROCESSENTRY32 pe32;
1674  SDL_bool found = SDL_FALSE;
1675 
1676  /* Take a snapshot of all processes in the system */
1677  HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
1678  if (hProcessSnap != INVALID_HANDLE_VALUE) {
1679  pe32.dwSize = sizeof(PROCESSENTRY32);
1680  if (Process32First(hProcessSnap, &pe32)) {
1681  do
1682  {
1683  for (i = 0; i < SDL_arraysize(mapper_processes); ++i) {
1684  if (SDL_strcasecmp(pe32.szExeFile, mapper_processes[i]) == 0) {
1685  found = SDL_TRUE;
1686  }
1687  }
1688  } while (Process32Next(hProcessSnap, &pe32) && !found);
1689  }
1690  CloseHandle(hProcessSnap);
1691  }
1692  return found;
1693 #else
1694  return SDL_FALSE;
1695 #endif
1696 }
1697 
1699 {
1700  /* This list is taken from:
1701  https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/generate_rules.py
1702  */
1703  static Uint32 joystick_blacklist[] = {
1704  /* Microsoft Microsoft Wireless Optical Desktop® 2.10 */
1705  /* Microsoft Wireless Desktop - Comfort Edition */
1706  MAKE_VIDPID(0x045e, 0x009d),
1707 
1708  /* Microsoft Microsoft® Digital Media Pro Keyboard */
1709  /* Microsoft Corp. Digital Media Pro Keyboard */
1710  MAKE_VIDPID(0x045e, 0x00b0),
1711 
1712  /* Microsoft Microsoft® Digital Media Keyboard */
1713  /* Microsoft Corp. Digital Media Keyboard 1.0A */
1714  MAKE_VIDPID(0x045e, 0x00b4),
1715 
1716  /* Microsoft Microsoft® Digital Media Keyboard 3000 */
1717  MAKE_VIDPID(0x045e, 0x0730),
1718 
1719  /* Microsoft Microsoft® 2.4GHz Transceiver v6.0 */
1720  /* Microsoft Microsoft® 2.4GHz Transceiver v8.0 */
1721  /* Microsoft Corp. Nano Transceiver v1.0 for Bluetooth */
1722  /* Microsoft Wireless Mobile Mouse 1000 */
1723  /* Microsoft Wireless Desktop 3000 */
1724  MAKE_VIDPID(0x045e, 0x0745),
1725 
1726  /* Microsoft® SideWinder(TM) 2.4GHz Transceiver */
1727  MAKE_VIDPID(0x045e, 0x0748),
1728 
1729  /* Microsoft Corp. Wired Keyboard 600 */
1730  MAKE_VIDPID(0x045e, 0x0750),
1731 
1732  /* Microsoft Corp. Sidewinder X4 keyboard */
1733  MAKE_VIDPID(0x045e, 0x0768),
1734 
1735  /* Microsoft Corp. Arc Touch Mouse Transceiver */
1736  MAKE_VIDPID(0x045e, 0x0773),
1737 
1738  /* Microsoft® 2.4GHz Transceiver v9.0 */
1739  /* Microsoft® Nano Transceiver v2.1 */
1740  /* Microsoft Sculpt Ergonomic Keyboard (5KV-00001) */
1741  MAKE_VIDPID(0x045e, 0x07a5),
1742 
1743  /* Microsoft® Nano Transceiver v1.0 */
1744  /* Microsoft Wireless Keyboard 800 */
1745  MAKE_VIDPID(0x045e, 0x07b2),
1746 
1747  /* Microsoft® Nano Transceiver v2.0 */
1748  MAKE_VIDPID(0x045e, 0x0800),
1749 
1750  MAKE_VIDPID(0x046d, 0xc30a), /* Logitech, Inc. iTouch Composite keboard */
1751 
1752  MAKE_VIDPID(0x04d9, 0xa0df), /* Tek Syndicate Mouse (E-Signal USB Gaming Mouse) */
1753 
1754  /* List of Wacom devices at: http://linuxwacom.sourceforge.net/wiki/index.php/Device_IDs */
1755  MAKE_VIDPID(0x056a, 0x0010), /* Wacom ET-0405 Graphire */
1756  MAKE_VIDPID(0x056a, 0x0011), /* Wacom ET-0405A Graphire2 (4x5) */
1757  MAKE_VIDPID(0x056a, 0x0012), /* Wacom ET-0507A Graphire2 (5x7) */
1758  MAKE_VIDPID(0x056a, 0x0013), /* Wacom CTE-430 Graphire3 (4x5) */
1759  MAKE_VIDPID(0x056a, 0x0014), /* Wacom CTE-630 Graphire3 (6x8) */
1760  MAKE_VIDPID(0x056a, 0x0015), /* Wacom CTE-440 Graphire4 (4x5) */
1761  MAKE_VIDPID(0x056a, 0x0016), /* Wacom CTE-640 Graphire4 (6x8) */
1762  MAKE_VIDPID(0x056a, 0x0017), /* Wacom CTE-450 Bamboo Fun (4x5) */
1763  MAKE_VIDPID(0x056a, 0x0018), /* Wacom CTE-650 Bamboo Fun 6x8 */
1764  MAKE_VIDPID(0x056a, 0x0019), /* Wacom CTE-631 Bamboo One */
1765  MAKE_VIDPID(0x056a, 0x00d1), /* Wacom Bamboo Pen and Touch CTH-460 */
1766  MAKE_VIDPID(0x056a, 0x030e), /* Wacom Intuos Pen (S) CTL-480 */
1767 
1768  MAKE_VIDPID(0x09da, 0x054f), /* A4 Tech Co., G7 750 mouse */
1769  MAKE_VIDPID(0x09da, 0x1410), /* A4 Tech Co., Ltd Bloody AL9 mouse */
1770  MAKE_VIDPID(0x09da, 0x3043), /* A4 Tech Co., Ltd Bloody R8A Gaming Mouse */
1771  MAKE_VIDPID(0x09da, 0x31b5), /* A4 Tech Co., Ltd Bloody TL80 Terminator Laser Gaming Mouse */
1772  MAKE_VIDPID(0x09da, 0x3997), /* A4 Tech Co., Ltd Bloody RT7 Terminator Wireless */
1773  MAKE_VIDPID(0x09da, 0x3f8b), /* A4 Tech Co., Ltd Bloody V8 mouse */
1774  MAKE_VIDPID(0x09da, 0x51f4), /* Modecom MC-5006 Keyboard */
1775  MAKE_VIDPID(0x09da, 0x5589), /* A4 Tech Co., Ltd Terminator TL9 Laser Gaming Mouse */
1776  MAKE_VIDPID(0x09da, 0x7b22), /* A4 Tech Co., Ltd Bloody V5 */
1777  MAKE_VIDPID(0x09da, 0x7f2d), /* A4 Tech Co., Ltd Bloody R3 mouse */
1778  MAKE_VIDPID(0x09da, 0x8090), /* A4 Tech Co., Ltd X-718BK Oscar Optical Gaming Mouse */
1779  MAKE_VIDPID(0x09da, 0x9033), /* A4 Tech Co., X7 X-705K */
1780  MAKE_VIDPID(0x09da, 0x9066), /* A4 Tech Co., Sharkoon Fireglider Optical */
1781  MAKE_VIDPID(0x09da, 0x9090), /* A4 Tech Co., Ltd XL-730K / XL-750BK / XL-755BK Laser Mouse */
1782  MAKE_VIDPID(0x09da, 0x90c0), /* A4 Tech Co., Ltd X7 G800V keyboard */
1783  MAKE_VIDPID(0x09da, 0xf012), /* A4 Tech Co., Ltd Bloody V7 mouse */
1784  MAKE_VIDPID(0x09da, 0xf32a), /* A4 Tech Co., Ltd Bloody B540 keyboard */
1785  MAKE_VIDPID(0x09da, 0xf613), /* A4 Tech Co., Ltd Bloody V2 mouse */
1786  MAKE_VIDPID(0x09da, 0xf624), /* A4 Tech Co., Ltd Bloody B120 Keyboard */
1787 
1788  MAKE_VIDPID(0x1b1c, 0x1b3c), /* Corsair Harpoon RGB gaming mouse */
1789 
1790  MAKE_VIDPID(0x1d57, 0xad03), /* [T3] 2.4GHz and IR Air Mouse Remote Control */
1791 
1792  MAKE_VIDPID(0x1e7d, 0x2e4a), /* Roccat Tyon Mouse */
1793 
1794  MAKE_VIDPID(0x20a0, 0x422d), /* Winkeyless.kr Keyboards */
1795 
1796  MAKE_VIDPID(0x2516, 0x001f), /* Cooler Master Storm Mizar Mouse */
1797  MAKE_VIDPID(0x2516, 0x0028), /* Cooler Master Storm Alcor Mouse */
1798  };
1799 
1800  unsigned int i;
1801  Uint32 id;
1802  Uint16 vendor;
1803  Uint16 product;
1804 
1805  SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
1806 
1807  /* Check the joystick blacklist */
1808  id = MAKE_VIDPID(vendor, product);
1809  for (i = 0; i < SDL_arraysize(joystick_blacklist); ++i) {
1810  if (id == joystick_blacklist[i]) {
1811  return SDL_TRUE;
1812  }
1813  }
1814 
1815  if (SDL_GetJoystickGameControllerType(name, vendor, product, -1, 0, 0, 0) == SDL_CONTROLLER_TYPE_PS4 && SDL_IsPS4RemapperRunning()) {
1816  return SDL_TRUE;
1817  }
1818 
1821  return SDL_TRUE;
1822  }
1823 
1824  return SDL_FALSE;
1825 }
1826 
1827 /* return the guid for this index */
1829 {
1830  SDL_JoystickDriver *driver;
1831  SDL_JoystickGUID guid;
1832 
1834  if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) {
1835  guid = driver->GetDeviceGUID(device_index);
1836  } else {
1837  SDL_zero(guid);
1838  }
1840 
1841  return guid;
1842 }
1843 
1845 {
1846  Uint16 vendor;
1847  SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
1848 
1849  SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL);
1850  return vendor;
1851 }
1852 
1854 {
1855  Uint16 product;
1856  SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
1857 
1858  SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL);
1859  return product;
1860 }
1861 
1863 {
1864  Uint16 version;
1865  SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
1866 
1867  SDL_GetJoystickGUIDInfo(guid, NULL, NULL, &version);
1868  return version;
1869 }
1870 
1872 {
1874  SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
1875 
1876  type = SDL_GetJoystickGUIDType(guid);
1878  if (SDL_IsGameController(device_index)) {
1880  }
1881  }
1882  return type;
1883 }
1884 
1886 {
1887  SDL_JoystickDriver *driver;
1888  SDL_JoystickID instance_id = -1;
1889 
1891  if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) {
1892  instance_id = driver->GetDeviceInstanceID(device_index);
1893  }
1895 
1896  return instance_id;
1897 }
1898 
1900 {
1901  int i, num_joysticks, device_index = -1;
1902 
1904  num_joysticks = SDL_NumJoysticks();
1905  for (i = 0; i < num_joysticks; ++i) {
1906  if (SDL_JoystickGetDeviceInstanceID(i) == instance_id) {
1907  device_index = i;
1908  break;
1909  }
1910  }
1912 
1913  return device_index;
1914 }
1915 
1916 SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick)
1917 {
1918  if (!SDL_PrivateJoystickValid(joystick)) {
1919  SDL_JoystickGUID emptyGUID;
1920  SDL_zero(emptyGUID);
1921  return emptyGUID;
1922  }
1923  return joystick->guid;
1924 }
1925 
1926 Uint16 SDL_JoystickGetVendor(SDL_Joystick * joystick)
1927 {
1928  Uint16 vendor;
1929  SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
1930 
1931  SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL);
1932  return vendor;
1933 }
1934 
1935 Uint16 SDL_JoystickGetProduct(SDL_Joystick * joystick)
1936 {
1937  Uint16 product;
1938  SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
1939 
1940  SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL);
1941  return product;
1942 }
1943 
1944 Uint16 SDL_JoystickGetProductVersion(SDL_Joystick * joystick)
1945 {
1946  Uint16 version;
1947  SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
1948 
1949  SDL_GetJoystickGUIDInfo(guid, NULL, NULL, &version);
1950  return version;
1951 }
1952 
1953 SDL_JoystickType SDL_JoystickGetType(SDL_Joystick * joystick)
1954 {
1956  SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
1957 
1958  type = SDL_GetJoystickGUIDType(guid);
1960  if (joystick && joystick->is_game_controller) {
1962  }
1963  }
1964  return type;
1965 }
1966 
1967 /* convert the guid to a printable string */
1968 void SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID)
1969 {
1970  static const char k_rgchHexToASCII[] = "0123456789abcdef";
1971  int i;
1972 
1973  if ((pszGUID == NULL) || (cbGUID <= 0)) {
1974  return;
1975  }
1976 
1977  for (i = 0; i < sizeof(guid.data) && i < (cbGUID-1)/2; i++) {
1978  /* each input byte writes 2 ascii chars, and might write a null byte. */
1979  /* If we don't have room for next input byte, stop */
1980  unsigned char c = guid.data[i];
1981 
1982  *pszGUID++ = k_rgchHexToASCII[c >> 4];
1983  *pszGUID++ = k_rgchHexToASCII[c & 0x0F];
1984  }
1985  *pszGUID = '\0';
1986 }
1987 
1988 /*-----------------------------------------------------------------------------
1989  * Purpose: Returns the 4 bit nibble for a hex character
1990  * Input : c -
1991  * Output : unsigned char
1992  *-----------------------------------------------------------------------------*/
1993 static unsigned char nibble(char c)
1994 {
1995  if ((c >= '0') && (c <= '9')) {
1996  return (unsigned char)(c - '0');
1997  }
1998 
1999  if ((c >= 'A') && (c <= 'F')) {
2000  return (unsigned char)(c - 'A' + 0x0a);
2001  }
2002 
2003  if ((c >= 'a') && (c <= 'f')) {
2004  return (unsigned char)(c - 'a' + 0x0a);
2005  }
2006 
2007  /* received an invalid character, and no real way to return an error */
2008  /* AssertMsg1(false, "Q_nibble invalid hex character '%c' ", c); */
2009  return 0;
2010 }
2011 
2012 /* convert the string version of a joystick guid to the struct */
2014 {
2015  SDL_JoystickGUID guid;
2016  int maxoutputbytes= sizeof(guid);
2017  size_t len = SDL_strlen(pchGUID);
2018  Uint8 *p;
2019  size_t i;
2020 
2021  /* Make sure it's even */
2022  len = (len) & ~0x1;
2023 
2024  SDL_memset(&guid, 0x00, sizeof(guid));
2025 
2026  p = (Uint8 *)&guid;
2027  for (i = 0; (i < len) && ((p - (Uint8 *)&guid) < maxoutputbytes); i+=2, p++) {
2028  *p = (nibble(pchGUID[i]) << 4) | nibble(pchGUID[i+1]);
2029  }
2030 
2031  return guid;
2032 }
2033 
2034 /* update the power level for this joystick */
2035 void SDL_PrivateJoystickBatteryLevel(SDL_Joystick * joystick, SDL_JoystickPowerLevel ePowerLevel)
2036 {
2037  joystick->epowerlevel = ePowerLevel;
2038 }
2039 
2040 /* return its power level */
2042 {
2043  if (!SDL_PrivateJoystickValid(joystick)) {
2045  }
2046  return joystick->epowerlevel;
2047 }
2048 
2049 /* vi: set ts=4 sw=4 expandtab: */
SDL.h
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:418
SDL_JoystickEventState
int SDL_JoystickEventState(int state)
Definition: SDL_joystick.c:1306
SDL_JOYSTICK_TYPE_GAMECONTROLLER
@ SDL_JOYSTICK_TYPE_GAMECONTROLLER
Definition: SDL_joystick.h:86
SDL_ShouldIgnoreJoystick
SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid)
Definition: SDL_joystick.c:1698
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179
SDL_IsJoystickHIDAPI
SDL_bool SDL_IsJoystickHIDAPI(SDL_JoystickGUID guid)
Definition: SDL_joystick.c:1547
k_eControllerType_SteamController
@ k_eControllerType_SteamController
Definition: controller_type.h:38
SDL_memset
#define SDL_memset
Definition: SDL_dynapi_overrides.h:386
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11096
SDL_JoystickGetDeviceType
SDL_JoystickType SDL_JoystickGetDeviceType(int device_index)
Definition: SDL_joystick.c:1871
SDL_MAX_RUMBLE_DURATION_MS
#define SDL_MAX_RUMBLE_DURATION_MS
Definition: SDL_sysjoystick.h:143
k_eControllerType_SwitchInputOnlyController
@ k_eControllerType_SwitchInputOnlyController
Definition: controller_type.h:54
SDL_events.h
SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
A variable that lets you enable joystick (and gamecontroller) events even when your app is in the bac...
Definition: SDL_hints.h:569
SDL_GetCustomJoystickName
const char * SDL_GetCustomJoystickName(Uint16 vendor, Uint16 product)
Definition: SDL_joystick.c:1386
SDL_small_free
#define SDL_small_free(ptr, isstack)
Definition: SDL_internal.h:40
SDL_JoystickNumButtons
int SDL_JoystickNumButtons(SDL_Joystick *joystick)
Definition: SDL_joystick.c:534
GuessControllerType
static SDL_INLINE EControllerType GuessControllerType(int nVID, int nPID)
Definition: controller_type.h:567
Uint16
uint16_t Uint16
Definition: SDL_stdinc.h:191
SDL_IsGameController
#define SDL_IsGameController
Definition: SDL_dynapi_overrides.h:138
SDL_JoystickGetGUIDString
void SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID)
Definition: SDL_joystick.c:1968
SDL_sysjoystick.h
SDL_abs
#define SDL_abs
Definition: SDL_dynapi_overrides.h:381
if
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
Definition: pixman-arm-neon-asm.h:469
SDL_JoystickAxesCenteredAtZero
static SDL_bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick)
Definition: SDL_joystick.c:338
SDL_JoystickDriver::SetDevicePlayerIndex
void(* SetDevicePlayerIndex)(int device_index, int player_index)
Definition: SDL_sysjoystick.h:109
SDL_LockMutex
#define SDL_LockMutex
Definition: SDL_dynapi_overrides.h:260
SDL_atomic.h
SDL_HAT_CENTERED
#define SDL_HAT_CENTERED
Definition: SDL_joystick.h:339
SDL_ADDEVENT
@ SDL_ADDEVENT
Definition: SDL_events.h:616
NULL
#define NULL
Definition: begin_code.h:167
SDL_JoystickGetAxisInitialState
SDL_bool SDL_JoystickGetAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state)
Definition: SDL_joystick.c:566
SDL_JoystickInit
int SDL_JoystickInit(void)
Definition: SDL_joystick.c:201
SDL_JoystickNameForIndex
const char * SDL_JoystickNameForIndex(int device_index)
Definition: SDL_joystick.c:302
k_eControllerType_SwitchProController
@ k_eControllerType_SwitchProController
Definition: controller_type.h:50
SDL_JoystickGetDeviceIndexFromInstanceID
int SDL_JoystickGetDeviceIndexFromInstanceID(SDL_JoystickID instance_id)
Definition: SDL_joystick.c:1899
SDL_JoystickID
Sint32 SDL_JoystickID
Definition: SDL_joystick.h:81
SDL_GetJoystickGameControllerTypeFromGUID
SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGUID guid, const char *name)
Definition: SDL_joystick.c:1392
SDL_IsPS4RemapperRunning
static SDL_bool SDL_IsPS4RemapperRunning(void)
Definition: SDL_joystick.c:1665
SDL_INIT_JOYSTICK
#define SDL_INIT_JOYSTICK
Definition: SDL.h:81
SDL_FixupJoystickName
static const char * SDL_FixupJoystickName(const char *name)
Definition: SDL_joystick.c:285
SDL_INIT_EVENTS
#define SDL_INIT_EVENTS
Definition: SDL.h:84
SDL_mutex
Definition: SDL_sysmutex.c:30
SDL_JoystickGetGUIDFromString
SDL_JoystickGUID SDL_JoystickGetGUIDFromString(const char *pchGUID)
Definition: SDL_joystick.c:2013
SDL_BSD_JoystickDriver
SDL_JoystickDriver SDL_BSD_JoystickDriver
SDL_CONTROLLER_TYPE_UNKNOWN
@ SDL_CONTROLLER_TYPE_UNKNOWN
Definition: SDL_gamecontroller.h:62
mutex
static SDL_mutex * mutex
Definition: testlock.c:23
SDL_joystick_allows_background_events
static SDL_bool SDL_joystick_allows_background_events
Definition: SDL_joystick.c:81
SDL_JoystickDriver::GetDeviceInstanceID
SDL_JoystickID(* GetDeviceInstanceID)(int device_index)
Definition: SDL_sysjoystick.h:115
SDLCALL
#define SDLCALL
Definition: SDL_internal.h:49
SDL_JoystickPowerLevel
SDL_JoystickPowerLevel
Definition: SDL_joystick.h:98
SDL_SetJoystickIDForPlayerIndex
static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id)
Definition: SDL_joystick.c:144
SDL_realloc
#define SDL_realloc
Definition: SDL_dynapi_overrides.h:376
SDL_AtomicIncRef
#define SDL_AtomicIncRef(a)
Increment an atomic variable used as a reference count.
Definition: SDL_atomic.h:252
SDL_QuitSubSystem
#define SDL_QuitSubSystem
Definition: SDL_dynapi_overrides.h:56
SDL_Event::jdevice
SDL_JoyDeviceEvent jdevice
Definition: SDL_events.h:574
SDL_PrivateJoystickAdded
void SDL_PrivateJoystickAdded(SDL_JoystickID device_instance)
Definition: SDL_joystick.c:921
SDL_CreateMutex
#define SDL_CreateMutex
Definition: SDL_dynapi_overrides.h:259
SDL_JoystickDriver::Detect
void(* Detect)(void)
Definition: SDL_sysjoystick.h:100
SDL_JoystickDriver::Open
int(* Open)(SDL_Joystick *joystick, int device_index)
Definition: SDL_sysjoystick.h:122
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:203
SDL_ENABLE
#define SDL_ENABLE
Definition: SDL_events.h:760
SDL_GetNextJoystickInstanceID
SDL_JoystickID SDL_GetNextJoystickInstanceID()
Definition: SDL_joystick.c:250
SDL_NumJoysticks
int SDL_NumJoysticks(void)
Definition: SDL_joystick.c:235
SDL_JOYSTICK_TYPE_GUITAR
@ SDL_JOYSTICK_TYPE_GUITAR
Definition: SDL_joystick.h:91
SDL_JoystickGUID::data
Uint8 data[16]
Definition: SDL_joystick.h:71
SDL_UnlockJoysticks
void SDL_UnlockJoysticks(void)
Definition: SDL_joystick.c:98
SDL_JOYDEVICEREMOVED
@ SDL_JOYDEVICEREMOVED
Definition: SDL_events.h:117
SDL_strncmp
#define SDL_strncmp
Definition: SDL_dynapi_overrides.h:418
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8586
SDL_GetJoystickGameControllerType
SDL_GameControllerType SDL_GetJoystickGameControllerType(const char *name, Uint16 vendor, Uint16 product, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
Definition: SDL_joystick.c:1409
SDL_RELEASED
#define SDL_RELEASED
Definition: SDL_events.h:49
SDL_JoystickGetDeviceInstanceID
SDL_JoystickID SDL_JoystickGetDeviceInstanceID(int device_index)
Definition: SDL_joystick.c:1885
SDL_InitSubSystem
#define SDL_InitSubSystem
Definition: SDL_dynapi_overrides.h:55
SDL_small_alloc
#define SDL_small_alloc(type, count, pisstack)
Definition: SDL_internal.h:39
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9435
SDL_JoystickGetAxis
Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis)
Definition: SDL_joystick.c:546
SDL_GetCustomJoystickManufacturer
const char * SDL_GetCustomJoystickManufacturer(const char *manufacturer)
Definition: SDL_joystick.c:1373
SDL_ShouldIgnoreGameController
SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid)
Definition: SDL_gamecontroller.c:1511
SDL_JOYSTICK_TYPE_DANCE_PAD
@ SDL_JOYSTICK_TYPE_DANCE_PAD
Definition: SDL_joystick.h:90
SDL_JoystickGetVendor
Uint16 SDL_JoystickGetVendor(SDL_Joystick *joystick)
Definition: SDL_joystick.c:1926
SDL_GetKeyboardFocus
#define SDL_GetKeyboardFocus
Definition: SDL_dynapi_overrides.h:216
SDL_JoystickAxisInfo::has_initial_value
SDL_bool has_initial_value
Definition: SDL_sysjoystick.h:37
SDL_strcasecmp
#define SDL_strcasecmp
Definition: SDL_dynapi_overrides.h:419
SDL_PrivateJoystickRemoved
void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance)
Definition: SDL_joystick.c:987
SDL_PrivateJoystickAxis
int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
Definition: SDL_joystick.c:1023
k_eControllerType_PS4Controller
@ k_eControllerType_PS4Controller
Definition: controller_type.h:46
SDL_hidapijoystick_c.h
SDL_CONTROLLER_TYPE_PS3
@ SDL_CONTROLLER_TYPE_PS3
Definition: SDL_gamecontroller.h:65
SDL_JoystickGetGUID
SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick *joystick)
Definition: SDL_joystick.c:1916
SDL_JoystickDriver::GetCount
int(* GetCount)(void)
Definition: SDL_sysjoystick.h:97
SDL_JOYSTICK_TYPE_DRUM_KIT
@ SDL_JOYSTICK_TYPE_DRUM_KIT
Definition: SDL_joystick.h:92
SDL_QUERY
#define SDL_QUERY
Definition: SDL_events.h:757
GuessControllerName
static SDL_INLINE const char * GuessControllerName(int nVID, int nPID)
Definition: controller_type.h:635
SDL_PRESSED
#define SDL_PRESSED
Definition: SDL_events.h:50
Sint16
int16_t Sint16
Definition: SDL_stdinc.h:185
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2929
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2652
SDL_JoystickGetDeviceProduct
Uint16 SDL_JoystickGetDeviceProduct(int device_index)
Definition: SDL_joystick.c:1853
SDL_GameControllerHandleDelayedGuideButton
void SDL_GameControllerHandleDelayedGuideButton(SDL_Joystick *joystick)
Definition: SDL_gamecontroller.c:2151
SDL_IsJoystickSteamController
SDL_bool SDL_IsJoystickSteamController(Uint16 vendor, Uint16 product)
Definition: SDL_joystick.c:1533
p
GLfloat GLfloat p
Definition: SDL_opengl_glext.h:11093
SDL_CONTROLLER_TYPE_PS4
@ SDL_CONTROLLER_TYPE_PS4
Definition: SDL_gamecontroller.h:66
SDL_JoystickInstanceID
SDL_JoystickID SDL_JoystickInstanceID(SDL_Joystick *joystick)
Definition: SDL_joystick.c:667
controller_type.h
retval
SDL_bool retval
Definition: testgamecontroller.c:65
SDL_IsJoystickXInput
SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid)
Definition: SDL_joystick.c:1541
SDL_JoystickGetPlayerIndex
int SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick)
Definition: SDL_joystick.c:731
SDL_JoystickDriver::Update
void(* Update)(SDL_Joystick *joystick)
Definition: SDL_sysjoystick.h:132
SDL_PrivateJoystickValid
SDL_bool SDL_PrivateJoystickValid(SDL_Joystick *joystick)
Definition: SDL_joystick.c:480
SDL_GetEventState
#define SDL_GetEventState(type)
Definition: SDL_events.h:773
k_eControllerType_XBox360Controller
@ k_eControllerType_XBox360Controller
Definition: controller_type.h:43
SDL_JOYSTICK_POWER_UNKNOWN
@ SDL_JOYSTICK_POWER_UNKNOWN
Definition: SDL_joystick.h:99
SDL_GetJoystickGUIDInfo
void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version)
Definition: SDL_joystick.c:1337
SDL_GetJoystickGUIDType
static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid)
Definition: SDL_joystick.c:1611
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_HAIKU_JoystickDriver
SDL_JoystickDriver SDL_HAIKU_JoystickDriver
SDL_JoystickFromInstanceID
SDL_Joystick * SDL_JoystickFromInstanceID(SDL_JoystickID instance_id)
Definition: SDL_joystick.c:680
SDL_updating_joystick
static SDL_bool SDL_updating_joystick
Definition: SDL_joystick.c:83
SDL_JOYSTICK_TYPE_FLIGHT_STICK
@ SDL_JOYSTICK_TYPE_FLIGHT_STICK
Definition: SDL_joystick.h:89
UpdateEventsForDeviceRemoval
static void UpdateEventsForDeviceRemoval()
Definition: SDL_joystick.c:962
SDL_PushEvent
#define SDL_PushEvent
Definition: SDL_dynapi_overrides.h:125
SDL_JoystickGetProductVersion
Uint16 SDL_JoystickGetProductVersion(SDL_Joystick *joystick)
Definition: SDL_joystick.c:1944
SDL_DARWIN_JoystickDriver
SDL_JoystickDriver SDL_DARWIN_JoystickDriver
SDL_JoystickFromPlayerIndex
SDL_Joystick * SDL_JoystickFromPlayerIndex(int player_index)
Definition: SDL_joystick.c:698
SDL_PrivateJoystickShouldIgnoreEvent
static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent()
Definition: SDL_joystick.c:906
SDL_JoystickDriver::Quit
void(* Quit)(void)
Definition: SDL_sysjoystick.h:138
name
GLuint const GLchar * name
Definition: SDL_opengl_glext.h:663
SDL_JoystickAxisInfo
Definition: SDL_sysjoystick.h:33
SDL_PrivateJoystickButton
int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
Definition: SDL_joystick.c:1162
SDL_JOYSTICK_TYPE_THROTTLE
@ SDL_JOYSTICK_TYPE_THROTTLE
Definition: SDL_joystick.h:94
SDL_JoystickQuit
void SDL_JoystickQuit(void)
Definition: SDL_joystick.c:858
SDL_JoystickGetDeviceProductVersion
Uint16 SDL_JoystickGetDeviceProductVersion(int device_index)
Definition: SDL_joystick.c:1862
SDL_GameControllerInitMappings
int SDL_GameControllerInitMappings(void)
Definition: SDL_gamecontroller.c:1370
SDL_PeepEvents
#define SDL_PeepEvents
Definition: SDL_dynapi_overrides.h:117
SDL_DUMMY_JoystickDriver
SDL_JoystickDriver SDL_DUMMY_JoystickDriver
nibble
static unsigned char nibble(char c)
Definition: SDL_joystick.c:1993
k_eControllerType_SteamControllerV2
@ k_eControllerType_SteamControllerV2
Definition: controller_type.h:39
SDL_JoystickAxisInfo::value
Sint16 value
Definition: SDL_sysjoystick.h:35
SDL_assert.h
SDL_GetTicks
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
SDL_GetDriverAndJoystickIndex
SDL_bool SDL_GetDriverAndJoystickIndex(int device_index, SDL_JoystickDriver **driver, int *driver_index)
Definition: SDL_joystick.c:260
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
MAKE_VIDPID
#define MAKE_VIDPID(VID, PID)
Definition: SDL_sysjoystick.h:86
SDL_JOYAXISMOTION
@ SDL_JOYAXISMOTION
Definition: SDL_events.h:111
SDL_next_joystick_instance_id
static SDL_atomic_t SDL_next_joystick_instance_id
Definition: SDL_joystick.c:85
SDL_PrivateJoystickBall
int SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball, Sint16 xrel, Sint16 yrel)
Definition: SDL_joystick.c:1126
SDL_JoystickNumAxes
int SDL_JoystickNumAxes(SDL_Joystick *joystick)
Definition: SDL_joystick.c:498
SDL_PrivateJoystickBatteryLevel
void SDL_PrivateJoystickBatteryLevel(SDL_Joystick *joystick, SDL_JoystickPowerLevel ePowerLevel)
Definition: SDL_joystick.c:2035
SDL_JoystickAllowBackgroundEventsChanged
static void SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
Definition: SDL_joystick.c:191
SDL_JoyDeviceEvent::which
Sint32 which
Definition: SDL_events.h:370
SDL_JoystickGetProduct
Uint16 SDL_JoystickGetProduct(SDL_Joystick *joystick)
Definition: SDL_joystick.c:1935
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
SDL_Delay
#define SDL_Delay
Definition: SDL_dynapi_overrides.h:486
SDL_joystick_lock
static SDL_mutex * SDL_joystick_lock
Definition: SDL_joystick.c:84
SDL_JOYSTICK_AXIS_MAX
#define SDL_JOYSTICK_AXIS_MAX
Definition: SDL_joystick.h:311
SDL_joystick_player_count
static int SDL_joystick_player_count
Definition: SDL_joystick.c:86
k_eControllerType_UnknownNonSteamController
@ k_eControllerType_UnknownNonSteamController
Definition: controller_type.h:42
SDL_LockJoysticks
void SDL_LockJoysticks(void)
Definition: SDL_joystick.c:90
SDL_JoystickGetDevicePlayerIndex
int SDL_JoystickGetDevicePlayerIndex(int device_index)
Definition: SDL_joystick.c:321
SDL_joystick_drivers
static SDL_JoystickDriver * SDL_joystick_drivers[]
Definition: SDL_joystick.c:49
SDL_JoystickGetType
SDL_JoystickType SDL_JoystickGetType(SDL_Joystick *joystick)
Definition: SDL_joystick.c:1953
SDL_DISABLE
#define SDL_DISABLE
Definition: SDL_events.h:759
SDL_JoystickGetDeviceVendor
Uint16 SDL_JoystickGetDeviceVendor(int device_index)
Definition: SDL_joystick.c:1844
axis
SDL_Texture * axis
Definition: testgamecontroller.c:67
_SDL_GameController::joystick
SDL_Joystick * joystick
Definition: SDL_gamecontroller.c:113
SDL_WINDOWS_JoystickDriver
SDL_JoystickDriver SDL_WINDOWS_JoystickDriver
SDL_JoystickName
const char * SDL_JoystickName(SDL_Joystick *joystick)
Definition: SDL_joystick.c:718
SDL_JoystickDriver
Definition: SDL_sysjoystick.h:89
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_PrivateJoystickHat
int SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value)
Definition: SDL_joystick.c:1086
id
GLuint id
Definition: SDL_opengl_glext.h:531
SDL_IsJoystickProductWheel
static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid)
Definition: SDL_joystick.c:1552
SDL_JoystickGetAttached
SDL_bool SDL_JoystickGetAttached(SDL_Joystick *joystick)
Definition: SDL_joystick.c:654
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:115
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
SDL_GameControllerQuitMappings
void SDL_GameControllerQuitMappings(void)
Definition: SDL_gamecontroller.c:2005
SDL_JoystickAxisInfo::initial_value
Sint16 initial_value
Definition: SDL_sysjoystick.h:34
events
static SDL_Event events[EVENT_BUF_SIZE]
Definition: testgesture.c:39
SDL_IsJoystickProductFlightStick
static SDL_bool SDL_IsJoystickProductFlightStick(Uint32 vidpid)
Definition: SDL_joystick.c:1579
SDL_AddHintCallback
#define SDL_AddHintCallback
Definition: SDL_dynapi_overrides.h:192
SDL_JoystickDriver::GetDeviceName
const char *(* GetDeviceName)(int device_index)
Definition: SDL_sysjoystick.h:103
SDL_GetJoystickIDForPlayerIndex
static SDL_JoystickID SDL_GetJoystickIDForPlayerIndex(int player_index)
Definition: SDL_joystick.c:135
SDL_JoystickClose
void SDL_JoystickClose(SDL_Joystick *joystick)
Definition: SDL_joystick.c:800
SDL_JoystickNumHats
int SDL_JoystickNumHats(SDL_Joystick *joystick)
Definition: SDL_joystick.c:510
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:701
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_GameControllerType
SDL_GameControllerType
Definition: SDL_gamecontroller.h:61
k_eControllerType_PS3Controller
@ k_eControllerType_PS3Controller
Definition: controller_type.h:45
SDL_JoystickAxisInfo::sent_initial_value
SDL_bool sent_initial_value
Definition: SDL_sysjoystick.h:39
SDL_JoystickAxisInfo::zero
Sint16 zero
Definition: SDL_sysjoystick.h:36
SDL_IsGameControllerNameAndGUID
SDL_bool SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid)
Definition: SDL_gamecontroller.c:1486
SDL_JOYBUTTONUP
@ SDL_JOYBUTTONUP
Definition: SDL_events.h:115
SDL_hints.h
SDL_atomic_t
A type representing an atomic integer value. It is a struct so people don't accidentally use numeric ...
Definition: SDL_atomic.h:216
SDL_DestroyMutex
#define SDL_DestroyMutex
Definition: SDL_dynapi_overrides.h:263
zero
static const double zero
Definition: e_atan2.c:44
SDL_JOYSTICK_TYPE_ARCADE_PAD
@ SDL_JOYSTICK_TYPE_ARCADE_PAD
Definition: SDL_joystick.h:93
SDL_HasWindows
SDL_bool SDL_HasWindows(void)
Definition: SDL_video.c:1732
SDL_JoystickUpdate
void SDL_JoystickUpdate(void)
Definition: SDL_joystick.c:1214
SDL_JoystickNumBalls
int SDL_JoystickNumBalls(SDL_Joystick *joystick)
Definition: SDL_joystick.c:522
SDL_GETEVENT
@ SDL_GETEVENT
Definition: SDL_events.h:618
EControllerType
EControllerType
Definition: controller_type.h:32
SDL_EventState
#define SDL_EventState
Definition: SDL_dynapi_overrides.h:131
SDL_strdup
#define SDL_strdup
Definition: SDL_dynapi_overrides.h:397
SDL_joystick_players
static SDL_JoystickID * SDL_joystick_players
Definition: SDL_joystick.c:87
SDL_joysticks
static SDL_Joystick * SDL_joysticks
Definition: SDL_joystick.c:82
SDL_GetPlayerIndexForJoystickID
static int SDL_GetPlayerIndexForJoystickID(SDL_JoystickID instance_id)
Definition: SDL_joystick.c:119
SDL_strlen
#define SDL_strlen
Definition: SDL_dynapi_overrides.h:393
SDL_JOYDEVICEADDED
@ SDL_JOYDEVICEADDED
Definition: SDL_events.h:116
SDL_LINUX_JoystickDriver
SDL_JoystickDriver SDL_LINUX_JoystickDriver
SDL_JoystickRumble
int SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
Definition: SDL_joystick.c:762
SDL_JoystickGetHat
Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat)
Definition: SDL_joystick.c:585
SDL_JoystickDriver::GetDeviceGUID
SDL_JoystickGUID(* GetDeviceGUID)(int device_index)
Definition: SDL_sysjoystick.h:112
SDL_TICKS_PASSED
#define SDL_TICKS_PASSED(A, B)
Compare SDL ticks values, and return true if A has passed B.
Definition: SDL_timer.h:56
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:162
SDL_CONTROLLER_TYPE_XBOX360
@ SDL_CONTROLLER_TYPE_XBOX360
Definition: SDL_gamecontroller.h:63
SDL_IsJoystickProductThrottle
static SDL_bool SDL_IsJoystickProductThrottle(Uint32 vidpid)
Definition: SDL_joystick.c:1595
SDL_JoystickAxisInfo::has_second_value
SDL_bool has_second_value
Definition: SDL_sysjoystick.h:38
SDL_JoystickGetBall
int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
Definition: SDL_joystick.c:605
SDL_Event
General event structure.
Definition: SDL_events.h:559
SDL_IOS_JoystickDriver
SDL_JoystickDriver SDL_IOS_JoystickDriver
Definition: SDL_sysjoystick.m:846
SDL_DelHintCallback
#define SDL_DelHintCallback
Definition: SDL_dynapi_overrides.h:193
SDL_JoystickSetPlayerIndex
void SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index)
Definition: SDL_joystick.c:750
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
HIDAPI_UpdateDevices
void HIDAPI_UpdateDevices(void)
SDL_JoystickGetDeviceGUID
SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index)
Definition: SDL_joystick.c:1828
SDL_JOYBUTTONDOWN
@ SDL_JOYBUTTONDOWN
Definition: SDL_events.h:114
SDL_JoystickOpen
SDL_Joystick * SDL_JoystickOpen(int device_index)
Definition: SDL_joystick.c:372
SDL_strcmp
#define SDL_strcmp
Definition: SDL_dynapi_overrides.h:417
SDL_UnlockMutex
#define SDL_UnlockMutex
Definition: SDL_dynapi_overrides.h:262
SDL_WasInit
#define SDL_WasInit
Definition: SDL_dynapi_overrides.h:57
SDL_JoystickGUID
Definition: SDL_joystick.h:70
SDL_JoystickDriver::GetDevicePlayerIndex
int(* GetDevicePlayerIndex)(int device_index)
Definition: SDL_sysjoystick.h:106
SDL_JOYSTICK_TYPE_WHEEL
@ SDL_JOYSTICK_TYPE_WHEEL
Definition: SDL_joystick.h:87
SDL_JoystickGetButton
Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button)
Definition: SDL_joystick.c:633
SDL_CONTROLLER_TYPE_XBOXONE
@ SDL_CONTROLLER_TYPE_XBOXONE
Definition: SDL_gamecontroller.h:64
type
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
SDL_EMSCRIPTEN_JoystickDriver
SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver
state
struct xkb_state * state
Definition: SDL_waylandsym.h:114
SDL_JoystickCurrentPowerLevel
SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel(SDL_Joystick *joystick)
Definition: SDL_joystick.c:2041
SDL_JOYHATMOTION
@ SDL_JOYHATMOTION
Definition: SDL_events.h:113
SDL_JOYSTICK_TYPE_UNKNOWN
@ SDL_JOYSTICK_TYPE_UNKNOWN
Definition: SDL_joystick.h:85
button
SDL_Texture * button
Definition: testgamecontroller.c:67
k_eControllerType_XBoxOneController
@ k_eControllerType_XBoxOneController
Definition: controller_type.h:44
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO
@ SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO
Definition: SDL_gamecontroller.h:67
i
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
SDL_FindFreePlayerIndex
static int SDL_FindFreePlayerIndex()
Definition: SDL_joystick.c:106
SDL_HIDAPI_JoystickDriver
SDL_JoystickDriver SDL_HIDAPI_JoystickDriver
SDL_JOYBALLMOTION
@ SDL_JOYBALLMOTION
Definition: SDL_events.h:112
SDL_PEEKEVENT
@ SDL_PEEKEVENT
Definition: SDL_events.h:617
SDL_JoystickType
SDL_JoystickType
Definition: SDL_joystick.h:84
SDL_JOYSTICK_TYPE_ARCADE_STICK
@ SDL_JOYSTICK_TYPE_ARCADE_STICK
Definition: SDL_joystick.h:88
SDL_IsJoystickNintendoSwitchProInputOnly
SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor, Uint16 product)
Definition: SDL_joystick.c:1526
SDL_ANDROID_JoystickDriver
SDL_JoystickDriver SDL_ANDROID_JoystickDriver