SDL  2.0
SDL_joystick.c File Reference
#include "../SDL_internal.h"
#include "SDL.h"
#include "SDL_atomic.h"
#include "SDL_events.h"
#include "SDL_sysjoystick.h"
#include "SDL_assert.h"
#include "SDL_hints.h"
#include "../events/SDL_events_c.h"
#include "../video/SDL_sysvideo.h"
#include "hidapi/SDL_hidapijoystick_c.h"
#include "controller_type.h"
#include "../core/windows/SDL_windows.h"
#include <tlhelp32.h>
+ Include dependency graph for SDL_joystick.c:

Go to the source code of this file.

Functions

void SDL_LockJoysticks (void)
 
void SDL_UnlockJoysticks (void)
 
static int SDL_FindFreePlayerIndex ()
 
static int SDL_GetPlayerIndexForJoystickID (SDL_JoystickID instance_id)
 
static SDL_JoystickID SDL_GetJoystickIDForPlayerIndex (int player_index)
 
static SDL_bool SDL_SetJoystickIDForPlayerIndex (int player_index, SDL_JoystickID instance_id)
 
static void SDL_JoystickAllowBackgroundEventsChanged (void *userdata, const char *name, const char *oldValue, const char *hint)
 
int SDL_JoystickInit (void)
 
int SDL_NumJoysticks (void)
 
SDL_JoystickID SDL_GetNextJoystickInstanceID ()
 
SDL_bool SDL_GetDriverAndJoystickIndex (int device_index, SDL_JoystickDriver **driver, int *driver_index)
 
static const char * SDL_FixupJoystickName (const char *name)
 
const char * SDL_JoystickNameForIndex (int device_index)
 
int SDL_JoystickGetDevicePlayerIndex (int device_index)
 
static SDL_bool SDL_JoystickAxesCenteredAtZero (SDL_Joystick *joystick)
 
SDL_Joystick * SDL_JoystickOpen (int device_index)
 
SDL_bool SDL_PrivateJoystickValid (SDL_Joystick *joystick)
 
int SDL_JoystickNumAxes (SDL_Joystick *joystick)
 
int SDL_JoystickNumHats (SDL_Joystick *joystick)
 
int SDL_JoystickNumBalls (SDL_Joystick *joystick)
 
int SDL_JoystickNumButtons (SDL_Joystick *joystick)
 
Sint16 SDL_JoystickGetAxis (SDL_Joystick *joystick, int axis)
 
SDL_bool SDL_JoystickGetAxisInitialState (SDL_Joystick *joystick, int axis, Sint16 *state)
 
Uint8 SDL_JoystickGetHat (SDL_Joystick *joystick, int hat)
 
int SDL_JoystickGetBall (SDL_Joystick *joystick, int ball, int *dx, int *dy)
 
Uint8 SDL_JoystickGetButton (SDL_Joystick *joystick, int button)
 
SDL_bool SDL_JoystickGetAttached (SDL_Joystick *joystick)
 
SDL_JoystickID SDL_JoystickInstanceID (SDL_Joystick *joystick)
 
SDL_Joystick * SDL_JoystickFromInstanceID (SDL_JoystickID instance_id)
 
SDL_Joystick * SDL_JoystickFromPlayerIndex (int player_index)
 
const char * SDL_JoystickName (SDL_Joystick *joystick)
 
int SDL_JoystickGetPlayerIndex (SDL_Joystick *joystick)
 
void SDL_JoystickSetPlayerIndex (SDL_Joystick *joystick, int player_index)
 
int SDL_JoystickRumble (SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
 
void SDL_JoystickClose (SDL_Joystick *joystick)
 
void SDL_JoystickQuit (void)
 
static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent ()
 
void SDL_PrivateJoystickAdded (SDL_JoystickID device_instance)
 
static void UpdateEventsForDeviceRemoval ()
 
void SDL_PrivateJoystickRemoved (SDL_JoystickID device_instance)
 
int SDL_PrivateJoystickAxis (SDL_Joystick *joystick, Uint8 axis, Sint16 value)
 
int SDL_PrivateJoystickHat (SDL_Joystick *joystick, Uint8 hat, Uint8 value)
 
int SDL_PrivateJoystickBall (SDL_Joystick *joystick, Uint8 ball, Sint16 xrel, Sint16 yrel)
 
int SDL_PrivateJoystickButton (SDL_Joystick *joystick, Uint8 button, Uint8 state)
 
void SDL_JoystickUpdate (void)
 
int SDL_JoystickEventState (int state)
 
void SDL_GetJoystickGUIDInfo (SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version)
 
const char * SDL_GetCustomJoystickManufacturer (const char *manufacturer)
 
const char * SDL_GetCustomJoystickName (Uint16 vendor, Uint16 product)
 
SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromGUID (SDL_JoystickGUID guid, const char *name)
 
SDL_GameControllerType SDL_GetJoystickGameControllerType (const char *name, Uint16 vendor, Uint16 product, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
 
SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly (Uint16 vendor, Uint16 product)
 
SDL_bool SDL_IsJoystickSteamController (Uint16 vendor, Uint16 product)
 
SDL_bool SDL_IsJoystickXInput (SDL_JoystickGUID guid)
 
SDL_bool SDL_IsJoystickHIDAPI (SDL_JoystickGUID guid)
 
static SDL_bool SDL_IsJoystickProductWheel (Uint32 vidpid)
 
static SDL_bool SDL_IsJoystickProductFlightStick (Uint32 vidpid)
 
static SDL_bool SDL_IsJoystickProductThrottle (Uint32 vidpid)
 
static SDL_JoystickType SDL_GetJoystickGUIDType (SDL_JoystickGUID guid)
 
static SDL_bool SDL_IsPS4RemapperRunning (void)
 
SDL_bool SDL_ShouldIgnoreJoystick (const char *name, SDL_JoystickGUID guid)
 
SDL_JoystickGUID SDL_JoystickGetDeviceGUID (int device_index)
 
Uint16 SDL_JoystickGetDeviceVendor (int device_index)
 
Uint16 SDL_JoystickGetDeviceProduct (int device_index)
 
Uint16 SDL_JoystickGetDeviceProductVersion (int device_index)
 
SDL_JoystickType SDL_JoystickGetDeviceType (int device_index)
 
SDL_JoystickID SDL_JoystickGetDeviceInstanceID (int device_index)
 
int SDL_JoystickGetDeviceIndexFromInstanceID (SDL_JoystickID instance_id)
 
SDL_JoystickGUID SDL_JoystickGetGUID (SDL_Joystick *joystick)
 
Uint16 SDL_JoystickGetVendor (SDL_Joystick *joystick)
 
Uint16 SDL_JoystickGetProduct (SDL_Joystick *joystick)
 
Uint16 SDL_JoystickGetProductVersion (SDL_Joystick *joystick)
 
SDL_JoystickType SDL_JoystickGetType (SDL_Joystick *joystick)
 
void SDL_JoystickGetGUIDString (SDL_JoystickGUID guid, char *pszGUID, int cbGUID)
 
static unsigned char nibble (char c)
 
SDL_JoystickGUID SDL_JoystickGetGUIDFromString (const char *pchGUID)
 
void SDL_PrivateJoystickBatteryLevel (SDL_Joystick *joystick, SDL_JoystickPowerLevel ePowerLevel)
 
SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel (SDL_Joystick *joystick)
 

Variables

static SDL_JoystickDriverSDL_joystick_drivers []
 
static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE
 
static SDL_Joystick * SDL_joysticks = NULL
 
static SDL_bool SDL_updating_joystick = SDL_FALSE
 
static SDL_mutexSDL_joystick_lock = NULL
 
static SDL_atomic_t SDL_next_joystick_instance_id
 
static int SDL_joystick_player_count = 0
 
static SDL_JoystickIDSDL_joystick_players = NULL
 

Function Documentation

◆ nibble()

static unsigned char nibble ( char  c)
static

Definition at line 1993 of file SDL_joystick.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 }

Referenced by LAW_Decode(), and SDL_JoystickGetGUIDFromString().

◆ SDL_FindFreePlayerIndex()

static int SDL_FindFreePlayerIndex ( )
static

Definition at line 106 of file SDL_joystick.c.

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 }

References SDL_joystick_player_count, and SDL_joystick_players.

Referenced by SDL_PrivateJoystickAdded(), and SDL_SetJoystickIDForPlayerIndex().

◆ SDL_FixupJoystickName()

static const char* SDL_FixupJoystickName ( const char *  name)
static

Definition at line 285 of file SDL_joystick.c.

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 }

References SDL_strlen, and SDL_strncmp.

Referenced by SDL_JoystickName(), and SDL_JoystickNameForIndex().

◆ SDL_GetCustomJoystickManufacturer()

const char* SDL_GetCustomJoystickManufacturer ( const char *  manufacturer)

Definition at line 1373 of file SDL_joystick.c.

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 }

References SDL_strcmp.

◆ SDL_GetCustomJoystickName()

const char* SDL_GetCustomJoystickName ( Uint16  vendor,
Uint16  product 
)

Definition at line 1386 of file SDL_joystick.c.

1387 {
1388  return GuessControllerName(vendor, product);
1389 }

References GuessControllerName().

◆ SDL_GetDriverAndJoystickIndex()

SDL_bool SDL_GetDriverAndJoystickIndex ( int  device_index,
SDL_JoystickDriver **  driver,
int *  driver_index 
)

Definition at line 260 of file SDL_joystick.c.

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 }

References SDL_JoystickDriver::GetCount, i, SDL_arraysize, SDL_FALSE, SDL_joystick_drivers, SDL_SetError, and SDL_TRUE.

Referenced by SDL_JoystickGetDeviceGUID(), SDL_JoystickGetDeviceInstanceID(), SDL_JoystickNameForIndex(), SDL_JoystickOpen(), SDL_PrivateJoystickAdded(), and SDL_SetJoystickIDForPlayerIndex().

◆ 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 at line 1409 of file SDL_joystick.c.

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 }

References GuessControllerType(), i, k_eControllerType_PS3Controller, k_eControllerType_PS4Controller, k_eControllerType_SwitchInputOnlyController, k_eControllerType_SwitchProController, k_eControllerType_XBox360Controller, k_eControllerType_XBoxOneController, SDL_arraysize, SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO, SDL_CONTROLLER_TYPE_PS3, SDL_CONTROLLER_TYPE_PS4, SDL_CONTROLLER_TYPE_UNKNOWN, SDL_CONTROLLER_TYPE_XBOX360, SDL_CONTROLLER_TYPE_XBOXONE, and SDL_strcmp.

Referenced by SDL_GetJoystickGameControllerTypeFromGUID(), and SDL_ShouldIgnoreJoystick().

◆ SDL_GetJoystickGameControllerTypeFromGUID()

SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromGUID ( SDL_JoystickGUID  guid,
const char *  name 
)

Definition at line 1392 of file SDL_joystick.c.

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 }

References NULL, SDL_CONTROLLER_TYPE_UNKNOWN, SDL_CONTROLLER_TYPE_XBOXONE, SDL_GetJoystickGameControllerType(), SDL_GetJoystickGUIDInfo(), and SDL_IsJoystickXInput().

Referenced by SDL_GameControllerGetType(), and SDL_GameControllerTypeForIndex().

◆ SDL_GetJoystickGUIDInfo()

void SDL_GetJoystickGUIDInfo ( SDL_JoystickGUID  guid,
Uint16 vendor,
Uint16 product,
Uint16 version 
)

Definition at line 1337 of file SDL_joystick.c.

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 }

References SDL_JoystickGUID::data, and if.

Referenced by SDL_GetJoystickGameControllerTypeFromGUID(), SDL_GetJoystickGUIDType(), SDL_JoystickGetDeviceProduct(), SDL_JoystickGetDeviceProductVersion(), SDL_JoystickGetDeviceVendor(), SDL_JoystickGetProduct(), SDL_JoystickGetProductVersion(), SDL_JoystickGetVendor(), SDL_ShouldIgnoreGameController(), and SDL_ShouldIgnoreJoystick().

◆ SDL_GetJoystickGUIDType()

static SDL_JoystickType SDL_GetJoystickGUIDType ( SDL_JoystickGUID  guid)
static

Definition at line 1611 of file SDL_joystick.c.

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 }

References SDL_JoystickGUID::data, GuessControllerType(), k_eControllerType_UnknownNonSteamController, MAKE_VIDPID, NULL, SDL_GetJoystickGUIDInfo(), SDL_IsJoystickProductFlightStick(), SDL_IsJoystickProductThrottle(), SDL_IsJoystickProductWheel(), SDL_IsJoystickXInput(), SDL_JOYSTICK_TYPE_ARCADE_PAD, SDL_JOYSTICK_TYPE_ARCADE_STICK, SDL_JOYSTICK_TYPE_DANCE_PAD, SDL_JOYSTICK_TYPE_DRUM_KIT, SDL_JOYSTICK_TYPE_FLIGHT_STICK, SDL_JOYSTICK_TYPE_GAMECONTROLLER, SDL_JOYSTICK_TYPE_GUITAR, SDL_JOYSTICK_TYPE_THROTTLE, SDL_JOYSTICK_TYPE_UNKNOWN, and SDL_JOYSTICK_TYPE_WHEEL.

Referenced by SDL_JoystickGetDeviceType(), and SDL_JoystickGetType().

◆ SDL_GetJoystickIDForPlayerIndex()

static SDL_JoystickID SDL_GetJoystickIDForPlayerIndex ( int  player_index)
static

Definition at line 135 of file SDL_joystick.c.

136 {
137  if (player_index < 0 || player_index >= SDL_joystick_player_count) {
138  return -1;
139  }
140  return SDL_joystick_players[player_index];
141 }

References SDL_joystick_player_count, and SDL_joystick_players.

Referenced by SDL_JoystickFromPlayerIndex(), and SDL_SetJoystickIDForPlayerIndex().

◆ SDL_GetNextJoystickInstanceID()

SDL_JoystickID SDL_GetNextJoystickInstanceID ( )

Definition at line 250 of file SDL_joystick.c.

251 {
253 }

References SDL_AtomicIncRef, and SDL_next_joystick_instance_id.

Referenced by IOS_AddJoystickDevice().

◆ SDL_GetPlayerIndexForJoystickID()

static int SDL_GetPlayerIndexForJoystickID ( SDL_JoystickID  instance_id)
static

Definition at line 119 of file SDL_joystick.c.

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 }

References SDL_joystick_player_count, and SDL_joystick_players.

Referenced by SDL_JoystickGetDevicePlayerIndex(), SDL_JoystickGetPlayerIndex(), SDL_PrivateJoystickRemoved(), and SDL_SetJoystickIDForPlayerIndex().

◆ SDL_IsJoystickHIDAPI()

SDL_bool SDL_IsJoystickHIDAPI ( SDL_JoystickGUID  guid)

Definition at line 1547 of file SDL_joystick.c.

1548 {
1549  return (guid.data[14] == 'h') ? SDL_TRUE : SDL_FALSE;
1550 }

References SDL_JoystickGUID::data, SDL_FALSE, and SDL_TRUE.

Referenced by SDL_PrivateGetControllerMappingForGUID(), and SDL_PrivateGetControllerMappingForNameAndGUID().

◆ SDL_IsJoystickNintendoSwitchProInputOnly()

SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly ( Uint16  vendor,
Uint16  product 
)

Definition at line 1526 of file SDL_joystick.c.

1527 {
1528  EControllerType eType = GuessControllerType(vendor, product);
1530 }

References GuessControllerType(), and k_eControllerType_SwitchInputOnlyController.

◆ SDL_IsJoystickProductFlightStick()

static SDL_bool SDL_IsJoystickProductFlightStick ( Uint32  vidpid)
static

Definition at line 1579 of file SDL_joystick.c.

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 }

References i, MAKE_VIDPID, SDL_arraysize, SDL_FALSE, and SDL_TRUE.

Referenced by SDL_GetJoystickGUIDType().

◆ SDL_IsJoystickProductThrottle()

static SDL_bool SDL_IsJoystickProductThrottle ( Uint32  vidpid)
static

Definition at line 1595 of file SDL_joystick.c.

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 }

References i, MAKE_VIDPID, SDL_arraysize, SDL_FALSE, and SDL_TRUE.

Referenced by SDL_GetJoystickGUIDType().

◆ SDL_IsJoystickProductWheel()

static SDL_bool SDL_IsJoystickProductWheel ( Uint32  vidpid)
static

Definition at line 1552 of file SDL_joystick.c.

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 }

References i, MAKE_VIDPID, SDL_arraysize, SDL_FALSE, and SDL_TRUE.

Referenced by SDL_GetJoystickGUIDType().

◆ SDL_IsJoystickSteamController()

SDL_bool SDL_IsJoystickSteamController ( Uint16  vendor,
Uint16  product 
)

Definition at line 1533 of file SDL_joystick.c.

1534 {
1535  EControllerType eType = GuessControllerType(vendor, product);
1536  return (eType == k_eControllerType_SteamController ||
1538 }

References GuessControllerType(), k_eControllerType_SteamController, and k_eControllerType_SteamControllerV2.

◆ SDL_IsJoystickXInput()

SDL_bool SDL_IsJoystickXInput ( SDL_JoystickGUID  guid)

Definition at line 1541 of file SDL_joystick.c.

1542 {
1543  return (guid.data[14] == 'x') ? SDL_TRUE : SDL_FALSE;
1544 }

References SDL_JoystickGUID::data, SDL_FALSE, and SDL_TRUE.

Referenced by SDL_GetJoystickGameControllerTypeFromGUID(), SDL_GetJoystickGUIDType(), and SDL_PrivateGetControllerMappingForGUID().

◆ SDL_IsPS4RemapperRunning()

static SDL_bool SDL_IsPS4RemapperRunning ( void  )
static

Definition at line 1665 of file SDL_joystick.c.

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 }

References i, SDL_arraysize, SDL_FALSE, SDL_strcasecmp, and SDL_TRUE.

Referenced by SDL_ShouldIgnoreJoystick().

◆ SDL_JoystickAllowBackgroundEventsChanged()

static void SDL_JoystickAllowBackgroundEventsChanged ( void userdata,
const char *  name,
const char *  oldValue,
const char *  hint 
)
static

Definition at line 191 of file SDL_joystick.c.

192 {
193  if (hint && *hint == '1') {
195  } else {
197  }
198 }

References SDL_FALSE, SDL_joystick_allows_background_events, and SDL_TRUE.

Referenced by SDL_JoystickInit(), and SDL_JoystickQuit().

◆ SDL_JoystickAxesCenteredAtZero()

static SDL_bool SDL_JoystickAxesCenteredAtZero ( SDL_Joystick *  joystick)
static

Definition at line 338 of file SDL_joystick.c.

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;
347  SDL_JoystickGetProduct(joystick));
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 }

References i, SDL_GameController::joystick, MAKE_VIDPID, SDL_arraysize, SDL_FALSE, SDL_JoystickGetProduct(), SDL_JoystickGetVendor(), and SDL_TRUE.

Referenced by SDL_JoystickOpen().

◆ SDL_JoystickClose()

void SDL_JoystickClose ( SDL_Joystick *  joystick)

Close a joystick previously opened with SDL_JoystickOpen().

Definition at line 800 of file SDL_joystick.c.

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 }

References NULL, SDL_free, SDL_JoystickRumble(), SDL_joysticks, SDL_LockJoysticks(), SDL_PrivateJoystickValid(), SDL_UnlockJoysticks(), and SDL_updating_joystick.

Referenced by SDL_JoystickOpen(), SDL_JoystickQuit(), and SDL_JoystickUpdate().

◆ SDL_JoystickCurrentPowerLevel()

SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel ( SDL_Joystick *  joystick)

Return the battery level of this joystick

Definition at line 2041 of file SDL_joystick.c.

2042 {
2043  if (!SDL_PrivateJoystickValid(joystick)) {
2045  }
2046  return joystick->epowerlevel;
2047 }

References SDL_JOYSTICK_POWER_UNKNOWN, and SDL_PrivateJoystickValid().

◆ SDL_JoystickEventState()

int SDL_JoystickEventState ( int  state)

Enable/disable joystick event polling.

If joystick events are disabled, you must call SDL_JoystickUpdate() yourself and check the state of the joystick when you want joystick information.

The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.

Definition at line 1306 of file SDL_joystick.c.

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 }

References i, SDL_arraysize, SDL_DISABLE, SDL_ENABLE, SDL_EventState, SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED, SDL_JOYHATMOTION, SDL_QUERY, and state.

◆ SDL_JoystickFromInstanceID()

SDL_Joystick* SDL_JoystickFromInstanceID ( SDL_JoystickID  instance_id)

Return the SDL_Joystick associated with an instance id.

Definition at line 680 of file SDL_joystick.c.

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 }

References SDL_joysticks, SDL_LockJoysticks(), and SDL_UnlockJoysticks().

◆ SDL_JoystickFromPlayerIndex()

SDL_Joystick* SDL_JoystickFromPlayerIndex ( int  player_index)

Return the SDL_Joystick associated with a player index.

Definition at line 698 of file SDL_joystick.c.

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 }

References SDL_GetJoystickIDForPlayerIndex(), SDL_joysticks, SDL_LockJoysticks(), and SDL_UnlockJoysticks().

◆ SDL_JoystickGetAttached()

SDL_bool SDL_JoystickGetAttached ( SDL_Joystick *  joystick)

Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.

Definition at line 654 of file SDL_joystick.c.

655 {
656  if (!SDL_PrivateJoystickValid(joystick)) {
657  return SDL_FALSE;
658  }
659 
660  return joystick->attached;
661 }

References SDL_FALSE, and SDL_PrivateJoystickValid().

◆ SDL_JoystickGetAxis()

Sint16 SDL_JoystickGetAxis ( SDL_Joystick *  joystick,
int  axis 
)

Get the current state of an axis control on a joystick.

The state is a value ranging from -32768 to 32767.

The axis indices start at index 0.

Definition at line 546 of file SDL_joystick.c.

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 }

References axis, SDL_PrivateJoystickValid(), SDL_SetError, and state.

◆ SDL_JoystickGetAxisInitialState()

SDL_bool SDL_JoystickGetAxisInitialState ( SDL_Joystick *  joystick,
int  axis,
Sint16 state 
)

Get the initial state of an axis control on a joystick.

The state is a value ranging from -32768 to 32767.

The axis indices start at index 0.

Returns
SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.

Definition at line 566 of file SDL_joystick.c.

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 }

References axis, SDL_FALSE, SDL_PrivateJoystickValid(), SDL_SetError, and state.

◆ SDL_JoystickGetBall()

int SDL_JoystickGetBall ( SDL_Joystick *  joystick,
int  ball,
int *  dx,
int *  dy 
)

Get the ball axis change since the last poll.

Returns
0, or -1 if you passed it invalid parameters.

The ball indices start at index 0.

Definition at line 605 of file SDL_joystick.c.

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 }

References retval, SDL_PrivateJoystickValid(), and SDL_SetError.

◆ SDL_JoystickGetButton()

Uint8 SDL_JoystickGetButton ( SDL_Joystick *  joystick,
int  button 
)

Get the current state of a button on a joystick.

The button indices start at index 0.

Definition at line 633 of file SDL_joystick.c.

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 }

References button, SDL_PrivateJoystickValid(), SDL_SetError, and state.

◆ SDL_JoystickGetDeviceGUID()

SDL_JoystickGUID SDL_JoystickGetDeviceGUID ( int  device_index)

Return the GUID for the joystick at this index This can be called before any joysticks are opened.

Definition at line 1828 of file SDL_joystick.c.

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 }

References SDL_JoystickDriver::GetDeviceGUID, SDL_GetDriverAndJoystickIndex(), SDL_LockJoysticks(), SDL_UnlockJoysticks(), and SDL_zero.

Referenced by SDL_JoystickGetDeviceProduct(), SDL_JoystickGetDeviceProductVersion(), SDL_JoystickGetDeviceType(), and SDL_JoystickGetDeviceVendor().

◆ SDL_JoystickGetDeviceIndexFromInstanceID()

int SDL_JoystickGetDeviceIndexFromInstanceID ( SDL_JoystickID  instance_id)

Definition at line 1899 of file SDL_joystick.c.

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 }

References i, SDL_JoystickGetDeviceInstanceID(), SDL_LockJoysticks(), SDL_NumJoysticks(), and SDL_UnlockJoysticks().

Referenced by SDL_PrivateJoystickAdded(), and SDL_SetJoystickIDForPlayerIndex().

◆ SDL_JoystickGetDeviceInstanceID()

SDL_JoystickID SDL_JoystickGetDeviceInstanceID ( int  device_index)

Get the instance ID of a joystick. This can be called before any joysticks are opened. If the index is out of range, this function will return -1.

Definition at line 1885 of file SDL_joystick.c.

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 }

References SDL_JoystickDriver::GetDeviceInstanceID, SDL_GetDriverAndJoystickIndex(), SDL_LockJoysticks(), and SDL_UnlockJoysticks().

Referenced by SDL_JoystickGetDeviceIndexFromInstanceID(), and SDL_JoystickGetDevicePlayerIndex().

◆ SDL_JoystickGetDevicePlayerIndex()

int SDL_JoystickGetDevicePlayerIndex ( int  device_index)

Get the player index of a joystick, or -1 if it's not available This can be called before any joysticks are opened.

Definition at line 321 of file SDL_joystick.c.

322 {
323  int player_index;
324 
328 
329  return player_index;
330 }

References SDL_GetPlayerIndexForJoystickID(), SDL_JoystickGetDeviceInstanceID(), SDL_LockJoysticks(), and SDL_UnlockJoysticks().

◆ SDL_JoystickGetDeviceProduct()

Uint16 SDL_JoystickGetDeviceProduct ( int  device_index)

Get the USB product ID of a joystick, if available. This can be called before any joysticks are opened. If the product ID isn't available this function returns 0.

Definition at line 1853 of file SDL_joystick.c.

1854 {
1855  Uint16 product;
1856  SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
1857 
1858  SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL);
1859  return product;
1860 }

References NULL, SDL_GetJoystickGUIDInfo(), and SDL_JoystickGetDeviceGUID().

◆ SDL_JoystickGetDeviceProductVersion()

Uint16 SDL_JoystickGetDeviceProductVersion ( int  device_index)

Get the product version of a joystick, if available. This can be called before any joysticks are opened. If the product version isn't available this function returns 0.

Definition at line 1862 of file SDL_joystick.c.

1863 {
1864  Uint16 version;
1865  SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
1866 
1867  SDL_GetJoystickGUIDInfo(guid, NULL, NULL, &version);
1868  return version;
1869 }

References NULL, SDL_GetJoystickGUIDInfo(), and SDL_JoystickGetDeviceGUID().

◆ SDL_JoystickGetDeviceType()

SDL_JoystickType SDL_JoystickGetDeviceType ( int  device_index)

Get the type of a joystick, if available. This can be called before any joysticks are opened.

Definition at line 1871 of file SDL_joystick.c.

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 }

References SDL_GetJoystickGUIDType(), SDL_IsGameController, SDL_JOYSTICK_TYPE_GAMECONTROLLER, SDL_JOYSTICK_TYPE_UNKNOWN, and SDL_JoystickGetDeviceGUID().

◆ SDL_JoystickGetDeviceVendor()

Uint16 SDL_JoystickGetDeviceVendor ( int  device_index)

Get the USB vendor ID of a joystick, if available. This can be called before any joysticks are opened. If the vendor ID isn't available this function returns 0.

Definition at line 1844 of file SDL_joystick.c.

1845 {
1846  Uint16 vendor;
1847  SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
1848 
1849  SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL);
1850  return vendor;
1851 }

References NULL, SDL_GetJoystickGUIDInfo(), and SDL_JoystickGetDeviceGUID().

◆ SDL_JoystickGetGUID()

SDL_JoystickGUID SDL_JoystickGetGUID ( SDL_Joystick *  joystick)

Return the GUID for this opened joystick

Definition at line 1916 of file SDL_joystick.c.

1917 {
1918  if (!SDL_PrivateJoystickValid(joystick)) {
1919  SDL_JoystickGUID emptyGUID;
1920  SDL_zero(emptyGUID);
1921  return emptyGUID;
1922  }
1923  return joystick->guid;
1924 }

References SDL_PrivateJoystickValid(), and SDL_zero.

Referenced by SDL_JoystickGetProduct(), SDL_JoystickGetProductVersion(), SDL_JoystickGetType(), and SDL_JoystickGetVendor().

◆ SDL_JoystickGetGUIDFromString()

SDL_JoystickGUID SDL_JoystickGetGUIDFromString ( const char *  pchGUID)

Convert a string into a joystick guid

Definition at line 2013 of file SDL_joystick.c.

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 }

References i, nibble(), SDL_memset, and SDL_strlen.

◆ SDL_JoystickGetGUIDString()

void SDL_JoystickGetGUIDString ( SDL_JoystickGUID  guid,
char *  pszGUID,
int  cbGUID 
)

Return a string representation for this guid. pszGUID must point to at least 33 bytes (32 for the string plus a NULL terminator).

Definition at line 1968 of file SDL_joystick.c.

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 }

References SDL_JoystickGUID::data, i, and NULL.

◆ SDL_JoystickGetHat()

Uint8 SDL_JoystickGetHat ( SDL_Joystick *  joystick,
int  hat 
)

Get the current state of a POV hat on a joystick.

The hat indices start at index 0.

Returns
The return value is one of the following positions:

Definition at line 585 of file SDL_joystick.c.

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 }

References SDL_PrivateJoystickValid(), SDL_SetError, and state.

◆ SDL_JoystickGetPlayerIndex()

int SDL_JoystickGetPlayerIndex ( SDL_Joystick *  joystick)

Get the player index of an opened joystick, or -1 if it's not available

Definition at line 731 of file SDL_joystick.c.

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 }

References SDL_GetPlayerIndexForJoystickID(), SDL_LockJoysticks(), SDL_PrivateJoystickValid(), and SDL_UnlockJoysticks().

◆ SDL_JoystickGetProduct()

Uint16 SDL_JoystickGetProduct ( SDL_Joystick *  joystick)

Get the USB product ID of an opened joystick, if available. If the product ID isn't available this function returns 0.

Definition at line 1935 of file SDL_joystick.c.

1936 {
1937  Uint16 product;
1938  SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
1939 
1940  SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL);
1941  return product;
1942 }

References NULL, SDL_GetJoystickGUIDInfo(), and SDL_JoystickGetGUID().

Referenced by SDL_JoystickAxesCenteredAtZero().

◆ SDL_JoystickGetProductVersion()

Uint16 SDL_JoystickGetProductVersion ( SDL_Joystick *  joystick)

Get the product version of an opened joystick, if available. If the product version isn't available this function returns 0.

Definition at line 1944 of file SDL_joystick.c.

1945 {
1946  Uint16 version;
1947  SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
1948 
1949  SDL_GetJoystickGUIDInfo(guid, NULL, NULL, &version);
1950  return version;
1951 }

References NULL, SDL_GetJoystickGUIDInfo(), and SDL_JoystickGetGUID().

◆ SDL_JoystickGetType()

SDL_JoystickType SDL_JoystickGetType ( SDL_Joystick *  joystick)

Get the type of an opened joystick.

Definition at line 1953 of file SDL_joystick.c.

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 }

References SDL_GetJoystickGUIDType(), SDL_JOYSTICK_TYPE_GAMECONTROLLER, SDL_JOYSTICK_TYPE_UNKNOWN, and SDL_JoystickGetGUID().

◆ SDL_JoystickGetVendor()

Uint16 SDL_JoystickGetVendor ( SDL_Joystick *  joystick)

Get the USB vendor ID of an opened joystick, if available. If the vendor ID isn't available this function returns 0.

Definition at line 1926 of file SDL_joystick.c.

1927 {
1928  Uint16 vendor;
1929  SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
1930 
1931  SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL);
1932  return vendor;
1933 }

References NULL, SDL_GetJoystickGUIDInfo(), and SDL_JoystickGetGUID().

Referenced by SDL_JoystickAxesCenteredAtZero().

◆ SDL_JoystickInit()

int SDL_JoystickInit ( void  )

Definition at line 201 of file SDL_joystick.c.

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 }

References i, NULL, SDL_AddHintCallback, SDL_arraysize, SDL_CreateMutex, SDL_GameControllerInitMappings(), SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_INIT_EVENTS, SDL_InitSubSystem, SDL_joystick_drivers, SDL_joystick_lock, and SDL_JoystickAllowBackgroundEventsChanged().

Referenced by SDL_InitSubSystem().

◆ SDL_JoystickInstanceID()

SDL_JoystickID SDL_JoystickInstanceID ( SDL_Joystick *  joystick)

Get the instance ID of an opened joystick or -1 if the joystick is invalid.

Definition at line 667 of file SDL_joystick.c.

668 {
669  if (!SDL_PrivateJoystickValid(joystick)) {
670  return -1;
671  }
672 
673  return joystick->instance_id;
674 }

References SDL_PrivateJoystickValid().

◆ SDL_JoystickName()

const char* SDL_JoystickName ( SDL_Joystick *  joystick)

Return the name for this currently opened joystick. If no name can be found, this function returns NULL.

Definition at line 718 of file SDL_joystick.c.

719 {
720  if (!SDL_PrivateJoystickValid(joystick)) {
721  return NULL;
722  }
723 
724  return SDL_FixupJoystickName(joystick->name);
725 }

References NULL, SDL_FixupJoystickName(), and SDL_PrivateJoystickValid().

◆ SDL_JoystickNameForIndex()

const char* SDL_JoystickNameForIndex ( int  device_index)

Get the implementation dependent name of a joystick. This can be called before any joysticks are opened. If no name can be found, this function returns NULL.

Definition at line 302 of file SDL_joystick.c.

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 }

References SDL_JoystickDriver::GetDeviceName, NULL, SDL_FixupJoystickName(), SDL_GetDriverAndJoystickIndex(), SDL_LockJoysticks(), and SDL_UnlockJoysticks().

◆ SDL_JoystickNumAxes()

int SDL_JoystickNumAxes ( SDL_Joystick *  joystick)

Get the number of general axis controls on a joystick.

Definition at line 498 of file SDL_joystick.c.

499 {
500  if (!SDL_PrivateJoystickValid(joystick)) {
501  return -1;
502  }
503  return joystick->naxes;
504 }

References SDL_PrivateJoystickValid().

◆ SDL_JoystickNumBalls()

int SDL_JoystickNumBalls ( SDL_Joystick *  joystick)

Get the number of trackballs on a joystick.

Joystick trackballs have only relative motion events associated with them and their state cannot be polled.

Definition at line 522 of file SDL_joystick.c.

523 {
524  if (!SDL_PrivateJoystickValid(joystick)) {
525  return -1;
526  }
527  return joystick->nballs;
528 }

References SDL_PrivateJoystickValid().

◆ SDL_JoystickNumButtons()

int SDL_JoystickNumButtons ( SDL_Joystick *  joystick)

Get the number of buttons on a joystick.

Definition at line 534 of file SDL_joystick.c.

535 {
536  if (!SDL_PrivateJoystickValid(joystick)) {
537  return -1;
538  }
539  return joystick->nbuttons;
540 }

References SDL_PrivateJoystickValid().

◆ SDL_JoystickNumHats()

int SDL_JoystickNumHats ( SDL_Joystick *  joystick)

Get the number of POV hats on a joystick.

Definition at line 510 of file SDL_joystick.c.

511 {
512  if (!SDL_PrivateJoystickValid(joystick)) {
513  return -1;
514  }
515  return joystick->nhats;
516 }

References SDL_PrivateJoystickValid().

◆ SDL_JoystickOpen()

SDL_Joystick* SDL_JoystickOpen ( int  device_index)

Open a joystick for use. The index passed as an argument refers to the N'th joystick on the system. This index is not the value which will identify this joystick in future joystick events. The joystick's instance id (SDL_JoystickID) will be used there instead.

Returns
A joystick identifier, or NULL if an error occurred.

Definition at line 372 of file SDL_joystick.c.

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) {
415  SDL_free(joystick);
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) {
430  joystick->axes = (SDL_JoystickAxisInfo *) SDL_calloc(joystick->naxes, sizeof(SDL_JoystickAxisInfo));
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 }

References SDL_JoystickDriver::GetDeviceGUID, SDL_JoystickDriver::GetDeviceInstanceID, SDL_JoystickDriver::GetDeviceName, i, SDL_GameController::joystick, NULL, SDL_JoystickDriver::Open, SDL_calloc, SDL_free, SDL_GetDriverAndJoystickIndex(), SDL_IsGameController, SDL_JOYSTICK_POWER_UNKNOWN, SDL_JoystickAxesCenteredAtZero(), SDL_JoystickClose(), SDL_joysticks, SDL_LockJoysticks(), SDL_OutOfMemory, SDL_strdup, SDL_TRUE, SDL_UnlockJoysticks(), and SDL_JoystickDriver::Update.

◆ SDL_JoystickQuit()

void SDL_JoystickQuit ( void  )

Definition at line 858 of file SDL_joystick.c.

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 }

References i, mutex, NULL, SDL_JoystickDriver::Quit, SDL_arraysize, SDL_Delay, SDL_DelHintCallback, SDL_DestroyMutex, SDL_free, SDL_GameControllerQuitMappings(), SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_INIT_EVENTS, SDL_joystick_drivers, SDL_joystick_lock, SDL_joystick_player_count, SDL_joystick_players, SDL_JoystickAllowBackgroundEventsChanged(), SDL_JoystickClose(), SDL_joysticks, SDL_LockJoysticks(), SDL_QuitSubSystem, SDL_UnlockJoysticks(), and SDL_updating_joystick.

Referenced by SDL_QuitSubSystem().

◆ SDL_JoystickRumble()

int SDL_JoystickRumble ( SDL_Joystick *  joystick,
Uint16  low_frequency_rumble,
Uint16  high_frequency_rumble,
Uint32  duration_ms 
)

Trigger a rumble effect Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.

Parameters
joystickThe joystick to vibrate
low_frequency_rumbleThe intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
high_frequency_rumbleThe intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
duration_msThe duration of the rumble effect, in milliseconds
Returns
0, or -1 if rumble isn't supported on this joystick

Definition at line 762 of file SDL_joystick.c.

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 }

References SDL_GetTicks(), SDL_LockJoysticks(), SDL_MAX_RUMBLE_DURATION_MS, SDL_min, SDL_PrivateJoystickValid(), and SDL_UnlockJoysticks().

Referenced by SDL_JoystickClose(), and SDL_JoystickUpdate().

◆ SDL_JoystickSetPlayerIndex()

void SDL_JoystickSetPlayerIndex ( SDL_Joystick *  joystick,
int  player_index 
)

Set the player index of an opened joystick

Definition at line 750 of file SDL_joystick.c.

751 {
752  if (!SDL_PrivateJoystickValid(joystick)) {
753  return;
754  }
755 
757  SDL_SetJoystickIDForPlayerIndex(player_index, joystick->instance_id);
759 }

References SDL_LockJoysticks(), SDL_PrivateJoystickValid(), SDL_SetJoystickIDForPlayerIndex(), and SDL_UnlockJoysticks().

◆ SDL_JoystickUpdate()

void SDL_JoystickUpdate ( void  )

Update the current state of the open joysticks.

This is called automatically by the event loop if any joystick events are enabled.

Definition at line 1214 of file SDL_joystick.c.

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 }

References SDL_JoystickDriver::Detect, HIDAPI_UpdateDevices(), i, SDL_arraysize, SDL_FALSE, SDL_GameControllerHandleDelayedGuideButton(), SDL_GetTicks(), SDL_HAT_CENTERED, SDL_INIT_JOYSTICK, SDL_joystick_drivers, SDL_JoystickClose(), SDL_JoystickRumble(), SDL_joysticks, SDL_LockJoysticks(), SDL_PrivateJoystickAxis(), SDL_PrivateJoystickButton(), SDL_PrivateJoystickHat(), SDL_TICKS_PASSED, SDL_TRUE, SDL_UnlockJoysticks(), SDL_updating_joystick, and SDL_WasInit.

◆ SDL_LockJoysticks()

void SDL_LockJoysticks ( void  )

Locking for multi-threaded access to the joystick API

If you are using the joystick API or handling events from multiple threads you should use these locking functions to protect access to the joysticks.

In particular, you are guaranteed that the joystick list won't change, so the API functions that take a joystick index will be valid, and joystick and game controller events will not be delivered.

Definition at line 90 of file SDL_joystick.c.

91 {
92  if (SDL_joystick_lock) {
94  }
95 }

References SDL_joystick_lock, and SDL_LockMutex.

Referenced by SDL_JoystickClose(), SDL_JoystickFromInstanceID(), SDL_JoystickFromPlayerIndex(), SDL_JoystickGetDeviceGUID(), SDL_JoystickGetDeviceIndexFromInstanceID(), SDL_JoystickGetDeviceInstanceID(), SDL_JoystickGetDevicePlayerIndex(), SDL_JoystickGetPlayerIndex(), SDL_JoystickNameForIndex(), SDL_JoystickOpen(), SDL_JoystickQuit(), SDL_JoystickRumble(), SDL_JoystickSetPlayerIndex(), SDL_JoystickUpdate(), SDL_NumJoysticks(), SDL_PrivateJoystickAdded(), and SDL_PrivateJoystickRemoved().

◆ SDL_NumJoysticks()

int SDL_NumJoysticks ( void  )

Count the number of joysticks attached to the system right now

Definition at line 235 of file SDL_joystick.c.

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 }

References SDL_JoystickDriver::GetCount, i, SDL_arraysize, SDL_joystick_drivers, SDL_LockJoysticks(), and SDL_UnlockJoysticks().

Referenced by SDL_JoystickGetDeviceIndexFromInstanceID().

◆ SDL_PrivateJoystickAdded()

void SDL_PrivateJoystickAdded ( SDL_JoystickID  device_instance)

Definition at line 921 of file SDL_joystick.c.

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 }

References SDL_JoystickDriver::GetDevicePlayerIndex, SDL_ENABLE, SDL_FindFreePlayerIndex(), SDL_GetDriverAndJoystickIndex(), SDL_GetEventState, SDL_IsGameController, SDL_JOYDEVICEADDED, SDL_JoystickGetDeviceIndexFromInstanceID(), SDL_LockJoysticks(), SDL_PushEvent, SDL_SetJoystickIDForPlayerIndex(), and SDL_UnlockJoysticks().

Referenced by IOS_AddJoystickDevice().

◆ SDL_PrivateJoystickAxis()

int SDL_PrivateJoystickAxis ( SDL_Joystick *  joystick,
Uint8  axis,
Sint16  value 
)

Definition at line 1023 of file SDL_joystick.c.

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 }

References axis, SDL_JoystickAxisInfo::has_initial_value, SDL_JoystickAxisInfo::has_second_value, SDL_JoystickAxisInfo::initial_value, SDL_abs, SDL_ENABLE, SDL_GetEventState, SDL_JOYAXISMOTION, SDL_JOYSTICK_AXIS_MAX, SDL_PrivateJoystickAxis(), SDL_PrivateJoystickShouldIgnoreEvent(), SDL_PushEvent, SDL_TRUE, SDL_JoystickAxisInfo::sent_initial_value, SDL_JoystickAxisInfo::value, SDL_JoystickAxisInfo::zero, and zero.

Referenced by IOS_AccelerometerUpdate(), IOS_MFIJoystickUpdate(), SDL_JoystickUpdate(), and SDL_PrivateJoystickAxis().

◆ SDL_PrivateJoystickBall()

int SDL_PrivateJoystickBall ( SDL_Joystick *  joystick,
Uint8  ball,
Sint16  xrel,
Sint16  yrel 
)

Definition at line 1126 of file SDL_joystick.c.

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 }

References SDL_ENABLE, SDL_GetEventState, SDL_JOYBALLMOTION, SDL_PrivateJoystickShouldIgnoreEvent(), and SDL_PushEvent.

◆ SDL_PrivateJoystickBatteryLevel()

void SDL_PrivateJoystickBatteryLevel ( SDL_Joystick *  joystick,
SDL_JoystickPowerLevel  ePowerLevel 
)

Definition at line 2035 of file SDL_joystick.c.

2036 {
2037  joystick->epowerlevel = ePowerLevel;
2038 }

◆ SDL_PrivateJoystickButton()

int SDL_PrivateJoystickButton ( SDL_Joystick *  joystick,
Uint8  button,
Uint8  state 
)

Definition at line 1162 of file SDL_joystick.c.

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 }

References button, SDL_ENABLE, SDL_GetEventState, SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_PRESSED, SDL_PrivateJoystickShouldIgnoreEvent(), SDL_PushEvent, SDL_RELEASED, and state.

Referenced by IOS_MFIJoystickUpdate(), and SDL_JoystickUpdate().

◆ SDL_PrivateJoystickHat()

int SDL_PrivateJoystickHat ( SDL_Joystick *  joystick,
Uint8  hat,
Uint8  value 
)

Definition at line 1086 of file SDL_joystick.c.

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 }

References SDL_ENABLE, SDL_GetEventState, SDL_HAT_CENTERED, SDL_JOYHATMOTION, SDL_PrivateJoystickShouldIgnoreEvent(), and SDL_PushEvent.

Referenced by IOS_MFIJoystickUpdate(), and SDL_JoystickUpdate().

◆ SDL_PrivateJoystickRemoved()

void SDL_PrivateJoystickRemoved ( SDL_JoystickID  device_instance)

Definition at line 987 of file SDL_joystick.c.

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 }

References SDL_ENABLE, SDL_FALSE, SDL_GetEventState, SDL_GetPlayerIndexForJoystickID(), SDL_JOYDEVICEREMOVED, SDL_joystick_players, SDL_joysticks, SDL_LockJoysticks(), SDL_PushEvent, SDL_TRUE, SDL_UnlockJoysticks(), and UpdateEventsForDeviceRemoval().

Referenced by IOS_RemoveJoystickDevice().

◆ SDL_PrivateJoystickShouldIgnoreEvent()

static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent ( )
static

Definition at line 906 of file SDL_joystick.c.

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 }

References NULL, SDL_FALSE, SDL_GetKeyboardFocus, SDL_HasWindows(), SDL_joystick_allows_background_events, and SDL_TRUE.

Referenced by SDL_PrivateJoystickAxis(), SDL_PrivateJoystickBall(), SDL_PrivateJoystickButton(), and SDL_PrivateJoystickHat().

◆ SDL_PrivateJoystickValid()

◆ SDL_SetJoystickIDForPlayerIndex()

static SDL_bool SDL_SetJoystickIDForPlayerIndex ( int  player_index,
SDL_JoystickID  instance_id 
)
static

Definition at line 144 of file SDL_joystick.c.

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 }

References SDL_FALSE, SDL_FindFreePlayerIndex(), SDL_GetDriverAndJoystickIndex(), SDL_GetJoystickIDForPlayerIndex(), SDL_GetPlayerIndexForJoystickID(), SDL_joystick_player_count, SDL_joystick_players, SDL_JoystickGetDeviceIndexFromInstanceID(), SDL_memset, SDL_OutOfMemory, SDL_realloc, SDL_TRUE, and SDL_JoystickDriver::SetDevicePlayerIndex.

Referenced by SDL_JoystickSetPlayerIndex(), and SDL_PrivateJoystickAdded().

◆ SDL_ShouldIgnoreJoystick()

SDL_bool SDL_ShouldIgnoreJoystick ( const char *  name,
SDL_JoystickGUID  guid 
)

Definition at line 1698 of file SDL_joystick.c.

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 }

References i, MAKE_VIDPID, NULL, SDL_arraysize, SDL_CONTROLLER_TYPE_PS4, SDL_FALSE, SDL_GetJoystickGameControllerType(), SDL_GetJoystickGUIDInfo(), SDL_IsGameControllerNameAndGUID(), SDL_IsPS4RemapperRunning(), SDL_ShouldIgnoreGameController(), and SDL_TRUE.

◆ SDL_UnlockJoysticks()

◆ UpdateEventsForDeviceRemoval()

static void UpdateEventsForDeviceRemoval ( )
static

Definition at line 962 of file SDL_joystick.c.

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 }

References events, i, SDL_Event::jdevice, NULL, SDL_ADDEVENT, SDL_GETEVENT, SDL_JOYDEVICEADDED, SDL_PEEKEVENT, SDL_PeepEvents, SDL_small_alloc, SDL_small_free, and SDL_JoyDeviceEvent::which.

Referenced by SDL_PrivateJoystickRemoved().

Variable Documentation

◆ SDL_joystick_allows_background_events

SDL_bool SDL_joystick_allows_background_events = SDL_FALSE
static

◆ SDL_joystick_drivers

◆ SDL_joystick_lock

SDL_mutex* SDL_joystick_lock = NULL
static

◆ SDL_joystick_player_count

◆ SDL_joystick_players

◆ SDL_joysticks

◆ SDL_next_joystick_instance_id

SDL_atomic_t SDL_next_joystick_instance_id
static

Definition at line 85 of file SDL_joystick.c.

Referenced by SDL_GetNextJoystickInstanceID().

◆ SDL_updating_joystick

SDL_bool SDL_updating_joystick = SDL_FALSE
static

Definition at line 83 of file SDL_joystick.c.

Referenced by SDL_JoystickClose(), SDL_JoystickQuit(), and SDL_JoystickUpdate().

SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:418
SDL_JOYSTICK_TYPE_GAMECONTROLLER
@ SDL_JOYSTICK_TYPE_GAMECONTROLLER
Definition: SDL_joystick.h:86
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179
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
hid_device_info::interface_subclass
int interface_subclass
Definition: hidapi.h:88
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_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
hid_device_info::interface_number
int interface_number
Definition: hidapi.h:83
SDL_small_free
#define SDL_small_free(ptr, isstack)
Definition: SDL_internal.h:40
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_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_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
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_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_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
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_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_NumJoysticks
int SDL_NumJoysticks(void)
Definition: SDL_joystick.c:235
SDL_JOYSTICK_TYPE_GUITAR
@ SDL_JOYSTICK_TYPE_GUITAR
Definition: SDL_joystick.h:91
SDL_UnlockJoysticks
void SDL_UnlockJoysticks(void)
Definition: SDL_joystick.c:98
SDL_JoystickGUID::data
Uint8 data[16]
Definition: SDL_joystick.h:71
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_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_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_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_GameControllerHandleDelayedGuideButton
void SDL_GameControllerHandleDelayedGuideButton(SDL_Joystick *joystick)
Definition: SDL_gamecontroller.c:2151
p
GLfloat GLfloat p
Definition: SDL_opengl_glext.h:11093
SDL_CONTROLLER_TYPE_PS4
@ SDL_CONTROLLER_TYPE_PS4
Definition: SDL_gamecontroller.h:66
retval
SDL_bool retval
Definition: testgamecontroller.c:65
SDL_IsJoystickXInput
SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid)
Definition: SDL_joystick.c:1541
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_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_PrivateJoystickShouldIgnoreEvent
static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent()
Definition: SDL_joystick.c:906
hid_device_info::interface_class
int interface_class
Definition: hidapi.h:87
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_GameControllerInitMappings
int SDL_GameControllerInitMappings(void)
Definition: SDL_gamecontroller.c:1370
SDL_PeepEvents
#define SDL_PeepEvents
Definition: SDL_dynapi_overrides.h:117
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_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_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_joystick_drivers
static SDL_JoystickDriver * SDL_joystick_drivers[]
Definition: SDL_joystick.c:49
SDL_DISABLE
#define SDL_DISABLE
Definition: SDL_events.h:759
axis
SDL_Texture * axis
Definition: testgamecontroller.c:67
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
hid_device_info::interface_protocol
int interface_protocol
Definition: hidapi.h:89
id
GLuint id
Definition: SDL_opengl_glext.h:531
SDL_IsJoystickProductWheel
static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid)
Definition: SDL_joystick.c:1552
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
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_DestroyMutex
#define SDL_DestroyMutex
Definition: SDL_dynapi_overrides.h:263
zero
static const double zero
Definition: e_atan2.c:44
SDL_HasWindows
SDL_bool SDL_HasWindows(void)
Definition: SDL_video.c:1732
SDL_JOYSTICK_TYPE_ARCADE_PAD
@ SDL_JOYSTICK_TYPE_ARCADE_PAD
Definition: SDL_joystick.h:93
SDL_GETEVENT
@ SDL_GETEVENT
Definition: SDL_events.h:618
SDL_EventState
#define SDL_EventState
Definition: SDL_dynapi_overrides.h:131
EControllerType
EControllerType
Definition: controller_type.h:32
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_JoystickRumble
int SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
Definition: SDL_joystick.c:762
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_Event
General event structure.
Definition: SDL_events.h:559
SDL_DelHintCallback
#define SDL_DelHintCallback
Definition: SDL_dynapi_overrides.h:193
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_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_CONTROLLER_TYPE_XBOXONE
@ SDL_CONTROLLER_TYPE_XBOXONE
Definition: SDL_gamecontroller.h:64
type
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
state
struct xkb_state * state
Definition: SDL_waylandsym.h:114
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_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