SDL  2.0
SDL_joystick_c.h File Reference
#include "../SDL_internal.h"
#include "SDL_gamecontroller.h"
#include "SDL_joystick.h"
+ Include dependency graph for SDL_joystick_c.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SDL_InputMapping
 
struct  SDL_GamepadMapping
 

Enumerations

enum  EMappingKind {
  EMappingKind_None = 0 ,
  EMappingKind_Button = 1 ,
  EMappingKind_Axis = 2 ,
  EMappingKind_Hat = 3
}
 

Functions

int SDL_JoystickInit (void)
 
void SDL_JoystickQuit (void)
 
SDL_JoystickID SDL_GetNextJoystickInstanceID (void)
 
int SDL_GameControllerInitMappings (void)
 
void SDL_GameControllerQuitMappings (void)
 
int SDL_GameControllerInit (void)
 
void SDL_GameControllerQuit (void)
 
SDL_bool SDL_GetDriverAndJoystickIndex (int device_index, struct _SDL_JoystickDriver **driver, int *driver_index)
 
int SDL_JoystickGetDeviceIndexFromInstanceID (SDL_JoystickID instance_id)
 
void SDL_GetJoystickGUIDInfo (SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version)
 
char * SDL_CreateJoystickName (Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name)
 
SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromVIDPID (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_IsJoystickXboxOneElite (Uint16 vendor_id, Uint16 product_id)
 
SDL_bool SDL_IsJoystickXboxOneSeriesX (Uint16 vendor_id, Uint16 product_id)
 
SDL_bool SDL_IsJoystickPS4 (Uint16 vendor_id, Uint16 product_id)
 
SDL_bool SDL_IsJoystickPS5 (Uint16 vendor_id, Uint16 product_id)
 
SDL_bool SDL_IsJoystickNintendoSwitchPro (Uint16 vendor_id, Uint16 product_id)
 
SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly (Uint16 vendor_id, Uint16 product_id)
 
SDL_bool SDL_IsJoystickSteamController (Uint16 vendor_id, Uint16 product_id)
 
SDL_bool SDL_IsJoystickXInput (SDL_JoystickGUID guid)
 
SDL_bool SDL_IsJoystickWGI (SDL_JoystickGUID guid)
 
SDL_bool SDL_IsJoystickHIDAPI (SDL_JoystickGUID guid)
 
SDL_bool SDL_IsJoystickRAWINPUT (SDL_JoystickGUID guid)
 
SDL_bool SDL_IsJoystickVirtual (SDL_JoystickGUID guid)
 
SDL_bool SDL_ShouldIgnoreJoystick (const char *name, SDL_JoystickGUID guid)
 
SDL_bool SDL_IsGameControllerNameAndGUID (const char *name, SDL_JoystickGUID guid)
 
SDL_bool SDL_ShouldIgnoreGameController (const char *name, SDL_JoystickGUID guid)
 
void SDL_GameControllerHandleDelayedGuideButton (SDL_Joystick *joystick)
 
void SDL_PrivateJoystickAddTouchpad (SDL_Joystick *joystick, int nfingers)
 
void SDL_PrivateJoystickAddSensor (SDL_Joystick *joystick, SDL_SensorType type)
 
void SDL_PrivateJoystickAdded (SDL_JoystickID device_instance)
 
void SDL_PrivateJoystickRemoved (SDL_JoystickID device_instance)
 
int SDL_PrivateJoystickAxis (SDL_Joystick *joystick, Uint8 axis, Sint16 value)
 
int SDL_PrivateJoystickBall (SDL_Joystick *joystick, Uint8 ball, Sint16 xrel, Sint16 yrel)
 
int SDL_PrivateJoystickHat (SDL_Joystick *joystick, Uint8 hat, Uint8 value)
 
int SDL_PrivateJoystickButton (SDL_Joystick *joystick, Uint8 button, Uint8 state)
 
int SDL_PrivateJoystickTouchpad (SDL_Joystick *joystick, int touchpad, int finger, Uint8 state, float x, float y, float pressure)
 
int SDL_PrivateJoystickSensor (SDL_Joystick *joystick, SDL_SensorType type, const float *data, int num_values)
 
void SDL_PrivateJoystickBatteryLevel (SDL_Joystick *joystick, SDL_JoystickPowerLevel ePowerLevel)
 
SDL_bool SDL_PrivateJoystickValid (SDL_Joystick *joystick)
 
SDL_bool SDL_PrivateJoystickGetAutoGamepadMapping (int device_index, SDL_GamepadMapping *out)
 

Enumeration Type Documentation

◆ EMappingKind

Enumerator
EMappingKind_None 
EMappingKind_Button 
EMappingKind_Axis 
EMappingKind_Hat 

Definition at line 134 of file SDL_joystick_c.h.

135 {
136  EMappingKind_None = 0,
138  EMappingKind_Axis = 2,
139  EMappingKind_Hat = 3
140 } EMappingKind;
EMappingKind
@ EMappingKind_Hat
@ EMappingKind_Button
@ EMappingKind_Axis
@ EMappingKind_None

Function Documentation

◆ SDL_CreateJoystickName()

char* SDL_CreateJoystickName ( Uint16  vendor,
Uint16  product,
const char *  vendor_name,
const char *  product_name 
)

Definition at line 1649 of file SDL_joystick.c.

1650 {
1651  static struct {
1652  const char *prefix;
1653  const char *replacement;
1654  } replacements[] = {
1655  { "NVIDIA Corporation ", "" },
1656  { "Performance Designed Products", "PDP" },
1657  { "HORI CO.,LTD.", "HORI" },
1658  { "HORI CO.,LTD", "HORI" },
1659  };
1660  const char *custom_name;
1661  char *name;
1662  size_t i, len;
1663 
1664  custom_name = GuessControllerName(vendor, product);
1665  if (custom_name) {
1666  return SDL_strdup(custom_name);
1667  }
1668 
1669  if (!vendor_name) {
1670  vendor_name = "";
1671  }
1672  if (!product_name) {
1673  product_name = "";
1674  }
1675 
1676  while (*vendor_name == ' ') {
1677  ++vendor_name;
1678  }
1679  while (*product_name == ' ') {
1680  ++product_name;
1681  }
1682 
1683  if (*vendor_name && *product_name) {
1684  len = (SDL_strlen(vendor_name) + 1 + SDL_strlen(product_name) + 1);
1685  name = (char *)SDL_malloc(len);
1686  if (!name) {
1687  return NULL;
1688  }
1689  SDL_snprintf(name, len, "%s %s", vendor_name, product_name);
1690  } else if (*product_name) {
1691  name = SDL_strdup(product_name);
1692  } else if (vendor || product) {
1693  len = (6 + 1 + 6 + 1);
1694  name = (char *)SDL_malloc(len);
1695  if (!name) {
1696  return NULL;
1697  }
1698  SDL_snprintf(name, len, "0x%.4x/0x%.4x", vendor, product);
1699  } else {
1700  name = SDL_strdup("Controller");
1701  }
1702 
1703  /* Trim trailing whitespace */
1704  for (len = SDL_strlen(name); (len > 0 && name[len - 1] == ' '); --len) {
1705  /* continue */
1706  }
1707  name[len] = '\0';
1708 
1709  /* Compress duplicate spaces */
1710  for (i = 0; i < (len - 1); ) {
1711  if (name[i] == ' ' && name[i+1] == ' ') {
1712  SDL_memmove(&name[i], &name[i+1], (len - i));
1713  --len;
1714  } else {
1715  ++i;
1716  }
1717  }
1718 
1719  /* Remove duplicate manufacturer or product in the name */
1720  for (i = 1; i < (len - 1); ++i) {
1721  int matchlen = PrefixMatch(name, &name[i]);
1722  if (matchlen > 0 && name[matchlen-1] == ' ') {
1723  SDL_memmove(name, name+matchlen, len-matchlen+1);
1724  len -= matchlen;
1725  break;
1726  } else if (matchlen > 0 && name[matchlen] == ' ') {
1727  SDL_memmove(name, name+matchlen+1, len-matchlen);
1728  len -= (matchlen + 1);
1729  break;
1730  }
1731  }
1732 
1733  /* Perform any manufacturer replacements */
1734  for (i = 0; i < SDL_arraysize(replacements); ++i) {
1735  size_t prefixlen = SDL_strlen(replacements[i].prefix);
1736  if (SDL_strncasecmp(name, replacements[i].prefix, prefixlen) == 0) {
1737  size_t replacementlen = SDL_strlen(replacements[i].replacement);
1738  SDL_memcpy(name, replacements[i].replacement, replacementlen);
1739  SDL_memmove(name+replacementlen, name+prefixlen, (len-prefixlen+1));
1740  break;
1741  }
1742  }
1743 
1744  return name;
1745 }
#define SDL_malloc
#define SDL_strlen
#define SDL_strdup
#define SDL_memcpy
#define SDL_snprintf
#define SDL_memmove
#define SDL_strncasecmp
static int PrefixMatch(const char *a, const char *b)
GLenum GLsizei len
GLuint const GLchar * name
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:121
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
#define NULL
Definition: begin_code.h:163
static SDL_INLINE const char * GuessControllerName(int nVID, int nPID)

References GuessControllerName(), i, NULL, PrefixMatch(), SDL_arraysize, SDL_malloc, SDL_memcpy, SDL_memmove, SDL_snprintf, SDL_strdup, SDL_strlen, and SDL_strncasecmp.

◆ SDL_GameControllerHandleDelayedGuideButton()

void SDL_GameControllerHandleDelayedGuideButton ( SDL_Joystick *  joystick)

Definition at line 2596 of file SDL_gamecontroller.c.

2597 {
2598  SDL_GameController *controllerlist = SDL_gamecontrollers;
2599  while (controllerlist) {
2600  if (controllerlist->joystick == joystick) {
2602  break;
2603  }
2604  controllerlist = controllerlist->next;
2605  }
2606 }
#define SDL_RELEASED
Definition: SDL_events.h:49
static int SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button, Uint8 state)
static SDL_GameController * SDL_gamecontrollers
@ SDL_CONTROLLER_BUTTON_GUIDE
static SDL_Joystick * joystick
Definition: testjoystick.c:37

References joystick, SDL_CONTROLLER_BUTTON_GUIDE, SDL_gamecontrollers, SDL_PrivateGameControllerButton(), and SDL_RELEASED.

Referenced by SDL_JoystickUpdate().

◆ SDL_GameControllerInit()

int SDL_GameControllerInit ( void  )

Definition at line 1629 of file SDL_gamecontroller.c.

1630 {
1631  int i;
1632 
1633  /* watch for joy events and fire controller ones if needed */
1635 
1636  /* Send added events for controllers currently attached */
1637  for (i = 0; i < SDL_NumJoysticks(); ++i) {
1638  if (SDL_IsGameController(i)) {
1639  SDL_Event deviceevent;
1640  deviceevent.type = SDL_CONTROLLERDEVICEADDED;
1641  deviceevent.cdevice.which = i;
1642  SDL_PushEvent(&deviceevent);
1643  }
1644  }
1645 
1646  return (0);
1647 }
#define SDL_PushEvent
#define SDL_NumJoysticks
#define SDL_AddEventWatch
@ SDL_CONTROLLERDEVICEADDED
Definition: SDL_events.h:125
SDL_bool SDL_IsGameController(int device_index)
static int SDL_GameControllerEventWatcher(void *userdata, SDL_Event *event)
General event structure.
Definition: SDL_events.h:592
Uint32 type
Definition: SDL_events.h:593
SDL_ControllerDeviceEvent cdevice
Definition: SDL_events.h:610

References SDL_Event::cdevice, i, NULL, SDL_AddEventWatch, SDL_CONTROLLERDEVICEADDED, SDL_GameControllerEventWatcher(), SDL_IsGameController(), SDL_NumJoysticks, SDL_PushEvent, SDL_Event::type, and SDL_ControllerDeviceEvent::which.

Referenced by SDL_InitSubSystem().

◆ SDL_GameControllerInitMappings()

int SDL_GameControllerInitMappings ( void  )

Definition at line 1600 of file SDL_gamecontroller.c.

1601 {
1602  char szControllerMapPath[1024];
1603  int i = 0;
1604  const char *pMappingString = NULL;
1605  pMappingString = s_ControllerMappings[i];
1606  while (pMappingString) {
1608 
1609  i++;
1610  pMappingString = s_ControllerMappings[i];
1611  }
1612 
1613  if (SDL_GetControllerMappingFilePath(szControllerMapPath, sizeof(szControllerMapPath))) {
1614  SDL_GameControllerAddMappingsFromFile(szControllerMapPath);
1615  }
1616 
1617  /* load in any user supplied config */
1619 
1624 
1625  return (0);
1626 }
#define SDL_AddHintCallback
static void SDL_GameControllerLoadHints()
static SDL_bool SDL_GetControllerMappingFilePath(char *path, size_t size)
@ SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT
static void SDL_GameControllerIgnoreDevicesChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
static void SDL_GameControllerIgnoreDevicesExceptChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_ControllerMappingPriority priority)
#define SDL_GameControllerAddMappingsFromFile(file)
static const char * s_ControllerMappings[]
#define SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT
Definition: SDL_hints.h:547
#define SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES
Definition: SDL_hints.h:534

References i, NULL, s_ControllerMappings, SDL_AddHintCallback, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT, SDL_GameControllerAddMappingsFromFile, SDL_GameControllerIgnoreDevicesChanged(), SDL_GameControllerIgnoreDevicesExceptChanged(), SDL_GameControllerLoadHints(), SDL_GetControllerMappingFilePath(), SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, and SDL_PrivateGameControllerAddMapping().

Referenced by SDL_JoystickInit().

◆ SDL_GameControllerQuit()

void SDL_GameControllerQuit ( void  )

Definition at line 2439 of file SDL_gamecontroller.c.

2440 {
2442  while (SDL_gamecontrollers) {
2443  SDL_gamecontrollers->ref_count = 1;
2445  }
2447 }
#define SDL_LockJoysticks
#define SDL_UnlockJoysticks
void SDL_GameControllerClose(SDL_GameController *gamecontroller)

References SDL_GameControllerClose(), SDL_gamecontrollers, SDL_LockJoysticks, and SDL_UnlockJoysticks.

Referenced by SDL_QuitSubSystem().

◆ SDL_GameControllerQuitMappings()

void SDL_GameControllerQuitMappings ( void  )

Definition at line 2450 of file SDL_gamecontroller.c.

2451 {
2452  ControllerMapping_t *pControllerMap;
2453 
2454  while (s_pSupportedControllers) {
2455  pControllerMap = s_pSupportedControllers;
2457  SDL_free(pControllerMap->name);
2458  SDL_free(pControllerMap->mapping);
2459  SDL_free(pControllerMap);
2460  }
2461 
2463 
2468 
2472  }
2476  }
2477 }
#define SDL_DelHintCallback
#define SDL_DelEventWatch
#define SDL_free
static SDL_vidpid_list SDL_allowed_controllers
static SDL_vidpid_list SDL_ignored_controllers
static ControllerMapping_t * s_pSupportedControllers
#define SDL_zero(x)
Definition: SDL_stdinc.h:426
struct _ControllerMapping_t * next

References SDL_vidpid_list::entries, ControllerMapping_t::mapping, ControllerMapping_t::name, ControllerMapping_t::next, NULL, s_pSupportedControllers, SDL_allowed_controllers, SDL_DelEventWatch, SDL_DelHintCallback, SDL_free, SDL_GameControllerEventWatcher(), SDL_GameControllerIgnoreDevicesChanged(), SDL_GameControllerIgnoreDevicesExceptChanged(), SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, SDL_ignored_controllers, and SDL_zero.

Referenced by SDL_JoystickQuit().

◆ SDL_GetDriverAndJoystickIndex()

SDL_bool SDL_GetDriverAndJoystickIndex ( int  device_index,
struct _SDL_JoystickDriver **  driver,
int driver_index 
)

◆ 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 1771 of file SDL_joystick.c.

1772 {
1773  static const int LIBUSB_CLASS_VENDOR_SPEC = 0xFF;
1774  static const int XB360_IFACE_SUBCLASS = 93;
1775  static const int XB360_IFACE_PROTOCOL = 1; /* Wired */
1776  static const int XB360W_IFACE_PROTOCOL = 129; /* Wireless */
1777  static const int XBONE_IFACE_SUBCLASS = 71;
1778  static const int XBONE_IFACE_PROTOCOL = 208;
1779 
1781 
1782  /* This code should match the checks in libusb/hid.c and HIDDeviceManager.java */
1783  if (interface_class == LIBUSB_CLASS_VENDOR_SPEC &&
1784  interface_subclass == XB360_IFACE_SUBCLASS &&
1785  (interface_protocol == XB360_IFACE_PROTOCOL ||
1786  interface_protocol == XB360W_IFACE_PROTOCOL)) {
1787 
1788  static const int SUPPORTED_VENDORS[] = {
1789  0x0079, /* GPD Win 2 */
1790  0x044f, /* Thrustmaster */
1791  0x045e, /* Microsoft */
1792  0x046d, /* Logitech */
1793  0x056e, /* Elecom */
1794  0x06a3, /* Saitek */
1795  0x0738, /* Mad Catz */
1796  0x07ff, /* Mad Catz */
1797  0x0e6f, /* PDP */
1798  0x0f0d, /* Hori */
1799  0x1038, /* SteelSeries */
1800  0x11c9, /* Nacon */
1801  0x12ab, /* Unknown */
1802  0x1430, /* RedOctane */
1803  0x146b, /* BigBen */
1804  0x1532, /* Razer Sabertooth */
1805  0x15e4, /* Numark */
1806  0x162e, /* Joytech */
1807  0x1689, /* Razer Onza */
1808  0x1bad, /* Harmonix */
1809  0x24c6, /* PowerA */
1810  };
1811 
1812  int i;
1813  for (i = 0; i < SDL_arraysize(SUPPORTED_VENDORS); ++i) {
1814  if (vendor == SUPPORTED_VENDORS[i]) {
1816  break;
1817  }
1818  }
1819  }
1820 
1821  if (interface_number == 0 &&
1822  interface_class == LIBUSB_CLASS_VENDOR_SPEC &&
1823  interface_subclass == XBONE_IFACE_SUBCLASS &&
1824  interface_protocol == XBONE_IFACE_PROTOCOL) {
1825 
1826  static const int SUPPORTED_VENDORS[] = {
1827  0x045e, /* Microsoft */
1828  0x0738, /* Mad Catz */
1829  0x0e6f, /* PDP */
1830  0x0f0d, /* Hori */
1831  0x1532, /* Razer Wildcat */
1832  0x24c6, /* PowerA */
1833  0x2e24, /* Hyperkin */
1834  };
1835 
1836  int i;
1837  for (i = 0; i < SDL_arraysize(SUPPORTED_VENDORS); ++i) {
1838  if (vendor == SUPPORTED_VENDORS[i]) {
1840  break;
1841  }
1842  }
1843  }
1844 
1846  if (vendor == 0x0000 && product == 0x0000) {
1847  /* Some devices are only identifiable by their name */
1848  if (name &&
1849  (SDL_strcmp(name, "Lic Pro Controller") == 0 ||
1850  SDL_strcmp(name, "Nintendo Wireless Gamepad") == 0 ||
1851  SDL_strcmp(name, "Wireless Gamepad") == 0)) {
1852  /* HORI or PowerA Switch Pro Controller clone */
1854  } else if (name && SDL_strcmp(name, "Virtual Joystick") == 0) {
1856  } else {
1858  }
1859 
1860  } else if (vendor == 0x0001 && product == 0x0001) {
1862 
1863  } else {
1864  switch (GuessControllerType(vendor, product)) {
1867  break;
1870  break;
1873  break;
1876  break;
1879  break;
1883  break;
1884  default:
1886  break;
1887  }
1888  }
1889  }
1890  return type;
1891 }
#define SDL_strcmp
SDL_GameControllerType
@ SDL_CONTROLLER_TYPE_VIRTUAL
@ SDL_CONTROLLER_TYPE_XBOX360
@ SDL_CONTROLLER_TYPE_PS4
@ SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO
@ SDL_CONTROLLER_TYPE_PS3
@ SDL_CONTROLLER_TYPE_PS5
@ SDL_CONTROLLER_TYPE_XBOXONE
@ SDL_CONTROLLER_TYPE_UNKNOWN
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
@ k_eControllerType_PS3Controller
@ k_eControllerType_PS5Controller
@ k_eControllerType_SwitchProController
@ k_eControllerType_PS4Controller
@ k_eControllerType_XBox360Controller
@ k_eControllerType_XBoxOneController
@ k_eControllerType_SwitchInputOnlyController
static SDL_INLINE EControllerType GuessControllerType(int nVID, int nPID)

References GuessControllerType(), i, k_eControllerType_PS3Controller, k_eControllerType_PS4Controller, k_eControllerType_PS5Controller, 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_PS5, SDL_CONTROLLER_TYPE_UNKNOWN, SDL_CONTROLLER_TYPE_VIRTUAL, SDL_CONTROLLER_TYPE_XBOX360, SDL_CONTROLLER_TYPE_XBOXONE, and SDL_strcmp.

Referenced by SDL_GetJoystickGameControllerTypeFromGUID(), SDL_GetJoystickGameControllerTypeFromVIDPID(), and SDL_ShouldIgnoreJoystick().

◆ SDL_GetJoystickGameControllerTypeFromGUID()

SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromGUID ( SDL_JoystickGUID  guid,
const char *  name 
)

Definition at line 1754 of file SDL_joystick.c.

1755 {
1757  Uint16 vendor, product;
1758 
1759  SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
1760  type = SDL_GetJoystickGameControllerType(name, vendor, product, -1, 0, 0, 0);
1762  if (SDL_IsJoystickXInput(guid)) {
1763  /* This is probably an Xbox One controller */
1765  }
1766  }
1767  return type;
1768 }
SDL_GameControllerType SDL_GetJoystickGameControllerType(const char *name, Uint16 vendor, Uint16 product, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version)
SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid)
uint16_t Uint16
Definition: SDL_stdinc.h:197

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

Referenced by SDL_CreateMappingForHIDAPIController(), SDL_GameControllerGetType(), and SDL_GameControllerTypeForIndex().

◆ SDL_GetJoystickGameControllerTypeFromVIDPID()

SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromVIDPID ( Uint16  vendor,
Uint16  product 
)

Definition at line 1748 of file SDL_joystick.c.

1749 {
1750  return SDL_GetJoystickGameControllerType(NULL, vendor, product, -1, 0, 0, 0);
1751 }

References NULL, and SDL_GetJoystickGameControllerType().

◆ SDL_GetJoystickGUIDInfo()

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

Definition at line 1599 of file SDL_joystick.c.

1600 {
1601  Uint16 *guid16 = (Uint16 *)guid.data;
1602 
1603  /* If the GUID fits the form of BUS 0000 VENDOR 0000 PRODUCT 0000, return the data */
1604  if (/* guid16[0] is device bus type */
1605  guid16[1] == 0x0000 &&
1606  /* guid16[2] is vendor ID */
1607  guid16[3] == 0x0000 &&
1608  /* guid16[4] is product ID */
1609  guid16[5] == 0x0000
1610  /* guid16[6] is product version */
1611  ) {
1612  if (vendor) {
1613  *vendor = guid16[2];
1614  }
1615  if (product) {
1616  *product = guid16[4];
1617  }
1618  if (version) {
1619  *version = guid16[6];
1620  }
1621  } else {
1622  if (vendor) {
1623  *vendor = 0;
1624  }
1625  if (product) {
1626  *product = 0;
1627  }
1628  if (version) {
1629  *version = 0;
1630  }
1631  }
1632 }
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
Uint8 data[16]
Definition: SDL_joystick.h:71

References SDL_JoystickGUID::data, and if.

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

◆ SDL_GetNextJoystickInstanceID()

SDL_JoystickID SDL_GetNextJoystickInstanceID ( void  )

Definition at line 262 of file SDL_joystick.c.

263 {
265 }
#define SDL_AtomicIncRef(a)
Increment an atomic variable used as a reference count.
Definition: SDL_atomic.h:252
static SDL_atomic_t SDL_next_joystick_instance_id
Definition: SDL_joystick.c:97

References SDL_AtomicIncRef, and SDL_next_joystick_instance_id.

◆ SDL_IsGameControllerNameAndGUID()

SDL_bool SDL_IsGameControllerNameAndGUID ( const char *  name,
SDL_JoystickGUID  guid 
)

Definition at line 1716 of file SDL_gamecontroller.c.

1717 {
1719  if (pSupportedController) {
1720  return SDL_TRUE;
1721  }
1722  return SDL_FALSE;
1723 }
static ControllerMapping_t * SDL_PrivateGetControllerMappingForNameAndGUID(const char *name, SDL_JoystickGUID guid)
@ SDL_TRUE
Definition: SDL_stdinc.h:170
@ SDL_FALSE
Definition: SDL_stdinc.h:169

References SDL_FALSE, SDL_PrivateGetControllerMappingForNameAndGUID(), and SDL_TRUE.

Referenced by SDL_ShouldIgnoreJoystick().

◆ SDL_IsJoystickHIDAPI()

SDL_bool SDL_IsJoystickHIDAPI ( SDL_JoystickGUID  guid)

Definition at line 1968 of file SDL_joystick.c.

1969 {
1970  return (guid.data[14] == 'h') ? SDL_TRUE : SDL_FALSE;
1971 }

References SDL_JoystickGUID::data, SDL_FALSE, and SDL_TRUE.

Referenced by SDL_PrivateGetControllerMappingForGUID().

◆ SDL_IsJoystickNintendoSwitchPro()

SDL_bool SDL_IsJoystickNintendoSwitchPro ( Uint16  vendor_id,
Uint16  product_id 
)

◆ SDL_IsJoystickNintendoSwitchProInputOnly()

SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly ( Uint16  vendor_id,
Uint16  product_id 
)

Definition at line 1941 of file SDL_joystick.c.

1942 {
1943  EControllerType eType = GuessControllerType(vendor_id, product_id);
1945 }

References GuessControllerType(), and k_eControllerType_SwitchInputOnlyController.

◆ SDL_IsJoystickPS4()

SDL_bool SDL_IsJoystickPS4 ( Uint16  vendor_id,
Uint16  product_id 
)

Definition at line 1919 of file SDL_joystick.c.

1920 {
1921  EControllerType eType = GuessControllerType(vendor_id, product_id);
1922  return (eType == k_eControllerType_PS4Controller);
1923 }

References GuessControllerType(), and k_eControllerType_PS4Controller.

◆ SDL_IsJoystickPS5()

SDL_bool SDL_IsJoystickPS5 ( Uint16  vendor_id,
Uint16  product_id 
)

Definition at line 1926 of file SDL_joystick.c.

1927 {
1928  EControllerType eType = GuessControllerType(vendor_id, product_id);
1929  return (eType == k_eControllerType_PS5Controller);
1930 }

References GuessControllerType(), and k_eControllerType_PS5Controller.

◆ SDL_IsJoystickRAWINPUT()

SDL_bool SDL_IsJoystickRAWINPUT ( SDL_JoystickGUID  guid)

Definition at line 1974 of file SDL_joystick.c.

1975 {
1976  return (guid.data[14] == 'r') ? SDL_TRUE : SDL_FALSE;
1977 }

References SDL_JoystickGUID::data, SDL_FALSE, and SDL_TRUE.

Referenced by SDL_PrivateGetControllerMappingForGUID().

◆ SDL_IsJoystickSteamController()

SDL_bool SDL_IsJoystickSteamController ( Uint16  vendor_id,
Uint16  product_id 
)

Definition at line 1948 of file SDL_joystick.c.

1949 {
1950  EControllerType eType = GuessControllerType(vendor_id, product_id);
1951  return (eType == k_eControllerType_SteamController ||
1953 }
@ k_eControllerType_SteamController
@ k_eControllerType_SteamControllerV2

References GuessControllerType(), k_eControllerType_SteamController, and k_eControllerType_SteamControllerV2.

Referenced by SDL_CreateMappingForHIDAPIController().

◆ SDL_IsJoystickVirtual()

SDL_bool SDL_IsJoystickVirtual ( SDL_JoystickGUID  guid)

Definition at line 1980 of file SDL_joystick.c.

1981 {
1982  return (guid.data[14] == 'v') ? SDL_TRUE : SDL_FALSE;
1983 }

References SDL_JoystickGUID::data, SDL_FALSE, and SDL_TRUE.

Referenced by SDL_GetJoystickGUIDType().

◆ SDL_IsJoystickWGI()

SDL_bool SDL_IsJoystickWGI ( SDL_JoystickGUID  guid)

Definition at line 1962 of file SDL_joystick.c.

1963 {
1964  return (guid.data[14] == 'w') ? SDL_TRUE : SDL_FALSE;
1965 }

References SDL_JoystickGUID::data, SDL_FALSE, and SDL_TRUE.

Referenced by SDL_GetJoystickGUIDType(), and SDL_PrivateGetControllerMappingForNameAndGUID().

◆ SDL_IsJoystickXboxOneElite()

SDL_bool SDL_IsJoystickXboxOneElite ( Uint16  vendor_id,
Uint16  product_id 
)

Definition at line 1894 of file SDL_joystick.c.

1895 {
1896  if (vendor_id == USB_VENDOR_MICROSOFT) {
1897  if (product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_1 ||
1898  product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2 ||
1900  return SDL_TRUE;
1901  }
1902  }
1903  return SDL_FALSE;
1904 }
#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2
Definition: usb_ids.h:48
#define USB_VENDOR_MICROSOFT
Definition: usb_ids.h:29
#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH
Definition: usb_ids.h:49
#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_1
Definition: usb_ids.h:47

References SDL_FALSE, SDL_TRUE, USB_PRODUCT_XBOX_ONE_ELITE_SERIES_1, USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2, USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH, and USB_VENDOR_MICROSOFT.

Referenced by SDL_CreateMappingForHIDAPIController().

◆ SDL_IsJoystickXboxOneSeriesX()

SDL_bool SDL_IsJoystickXboxOneSeriesX ( Uint16  vendor_id,
Uint16  product_id 
)

Definition at line 1907 of file SDL_joystick.c.

1908 {
1909  if (vendor_id == USB_VENDOR_MICROSOFT) {
1910  if (product_id == USB_PRODUCT_XBOX_ONE_SERIES_X ||
1912  return SDL_TRUE;
1913  }
1914  }
1915  return SDL_FALSE;
1916 }
#define USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH
Definition: usb_ids.h:54
#define USB_PRODUCT_XBOX_ONE_SERIES_X
Definition: usb_ids.h:53

References SDL_FALSE, SDL_TRUE, USB_PRODUCT_XBOX_ONE_SERIES_X, USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH, and USB_VENDOR_MICROSOFT.

Referenced by SDL_CreateMappingForHIDAPIController().

◆ SDL_IsJoystickXInput()

SDL_bool SDL_IsJoystickXInput ( SDL_JoystickGUID  guid)

Definition at line 1956 of file SDL_joystick.c.

1957 {
1958  return (guid.data[14] == 'x') ? SDL_TRUE : SDL_FALSE;
1959 }

References SDL_JoystickGUID::data, SDL_FALSE, and SDL_TRUE.

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

◆ SDL_JoystickGetDeviceIndexFromInstanceID()

int SDL_JoystickGetDeviceIndexFromInstanceID ( SDL_JoystickID  instance_id)

Definition at line 2343 of file SDL_joystick.c.

2344 {
2345  int i, num_joysticks, device_index = -1;
2346 
2348  num_joysticks = SDL_NumJoysticks();
2349  for (i = 0; i < num_joysticks; ++i) {
2350  if (SDL_JoystickGetDeviceInstanceID(i) == instance_id) {
2351  device_index = i;
2352  break;
2353  }
2354  }
2356 
2357  return device_index;
2358 }
SDL_JoystickID SDL_JoystickGetDeviceInstanceID(int device_index)
int SDL_NumJoysticks(void)
Definition: SDL_joystick.c:247
void SDL_LockJoysticks(void)
Definition: SDL_joystick.c:102
void SDL_UnlockJoysticks(void)
Definition: SDL_joystick.c:110

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

Referenced by SDL_PrivateJoystickAdded(), and SDL_SetJoystickIDForPlayerIndex().

◆ SDL_JoystickInit()

int SDL_JoystickInit ( void  )

Definition at line 213 of file SDL_joystick.c.

214 {
215  int i, status;
216 
218 
219  /* Create the joystick list lock */
220  if (!SDL_joystick_lock) {
222  }
223 
224  /* See if we should allow joystick events while in the background */
227 
228 #if !SDL_EVENTS_DISABLED
230  return -1;
231  }
232 #endif /* !SDL_EVENTS_DISABLED */
233 
234  status = -1;
235  for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) {
236  if (SDL_joystick_drivers[i]->Init() >= 0) {
237  status = 0;
238  }
239  }
240  return status;
241 }
#define SDL_INIT_EVENTS
Definition: SDL.h:86
#define SDL_InitSubSystem
#define SDL_CreateMutex
int SDL_GameControllerInitMappings(void)
#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:583
static SDL_JoystickDriver * SDL_joystick_drivers[]
Definition: SDL_joystick.c:52
static void SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
Definition: SDL_joystick.c:203
static SDL_mutex * SDL_joystick_lock
Definition: SDL_joystick.c:96

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_JoystickQuit()

void SDL_JoystickQuit ( void  )

Definition at line 1045 of file SDL_joystick.c.

1046 {
1047  int i;
1048 
1049  /* Make sure we're not getting called in the middle of updating joysticks */
1051  while (SDL_updating_joystick) {
1053  SDL_Delay(1);
1055  }
1056 
1057  /* Stop the event polling */
1058  while (SDL_joysticks) {
1059  SDL_joysticks->ref_count = 1;
1061  }
1062 
1063  /* Quit the joystick setup */
1064  for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) {
1066  }
1067 
1068  if (SDL_joystick_players) {
1072  }
1074 
1075 #if !SDL_EVENTS_DISABLED
1077 #endif
1078 
1081 
1082  if (SDL_joystick_lock) {
1086  }
1087 
1089 }
#define SDL_Delay
#define SDL_DestroyMutex
#define SDL_QuitSubSystem
void SDL_GameControllerQuitMappings(void)
static int SDL_joystick_player_count
Definition: SDL_joystick.c:98
void SDL_JoystickClose(SDL_Joystick *joystick)
Definition: SDL_joystick.c:976
static SDL_JoystickID * SDL_joystick_players
Definition: SDL_joystick.c:99
static SDL_bool SDL_updating_joystick
Definition: SDL_joystick.c:95
static SDL_Joystick * SDL_joysticks
Definition: SDL_joystick.c:94
void(* Quit)(void)
static SDL_mutex * mutex
Definition: testlock.c:23

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_PrivateJoystickAdded()

void SDL_PrivateJoystickAdded ( SDL_JoystickID  device_instance)

Definition at line 1145 of file SDL_joystick.c.

1146 {
1147  SDL_JoystickDriver *driver;
1148  int driver_device_index;
1149  int player_index = -1;
1150  int device_index = SDL_JoystickGetDeviceIndexFromInstanceID(device_instance);
1151  if (device_index < 0) {
1152  return;
1153  }
1154 
1156  if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &driver_device_index)) {
1157  player_index = driver->GetDevicePlayerIndex(driver_device_index);
1158  }
1159  if (player_index < 0 && SDL_IsGameController(device_index)) {
1160  player_index = SDL_FindFreePlayerIndex();
1161  }
1162  if (player_index >= 0) {
1163  SDL_SetJoystickIDForPlayerIndex(player_index, device_instance);
1164  }
1166 
1167 #if !SDL_EVENTS_DISABLED
1168  {
1169  SDL_Event event;
1170 
1171  event.type = SDL_JOYDEVICEADDED;
1172 
1173  if (SDL_GetEventState(event.type) == SDL_ENABLE) {
1174  event.jdevice.which = device_index;
1175  SDL_PushEvent(&event);
1176  }
1177  }
1178 #endif /* !SDL_EVENTS_DISABLED */
1179 }
#define SDL_IsGameController
@ SDL_JOYDEVICEADDED
Definition: SDL_events.h:118
#define SDL_GetEventState(type)
Definition: SDL_events.h:808
#define SDL_ENABLE
Definition: SDL_events.h:795
static int SDL_FindFreePlayerIndex()
Definition: SDL_joystick.c:118
SDL_bool SDL_GetDriverAndJoystickIndex(int device_index, SDL_JoystickDriver **driver, int *driver_index)
Definition: SDL_joystick.c:272
static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id)
Definition: SDL_joystick.c:156
int SDL_JoystickGetDeviceIndexFromInstanceID(SDL_JoystickID instance_id)
struct _cl_event * event
int(* GetDevicePlayerIndex)(int device_index)

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().

◆ SDL_PrivateJoystickAddSensor()

void SDL_PrivateJoystickAddSensor ( SDL_Joystick *  joystick,
SDL_SensorType  type 
)

Definition at line 1130 of file SDL_joystick.c.

1131 {
1132  int nsensors = joystick->nsensors + 1;
1133  SDL_JoystickSensorInfo *sensors = (SDL_JoystickSensorInfo *)SDL_realloc(joystick->sensors, (nsensors * sizeof(SDL_JoystickSensorInfo)));
1134  if (sensors) {
1135  SDL_JoystickSensorInfo *sensor = &sensors[nsensors - 1];
1136 
1137  SDL_zerop(sensor);
1138  sensor->type = type;
1139 
1140  joystick->nsensors = nsensors;
1141  joystick->sensors = sensors;
1142  }
1143 }
#define SDL_realloc
#define SDL_zerop(x)
Definition: SDL_stdinc.h:427

References joystick, SDL_realloc, SDL_zerop, and SDL_JoystickSensorInfo::type.

Referenced by IOS_JoystickOpen().

◆ SDL_PrivateJoystickAddTouchpad()

void SDL_PrivateJoystickAddTouchpad ( SDL_Joystick *  joystick,
int  nfingers 
)

Definition at line 1108 of file SDL_joystick.c.

1109 {
1110  int ntouchpads = joystick->ntouchpads + 1;
1111  SDL_JoystickTouchpadInfo *touchpads = (SDL_JoystickTouchpadInfo *)SDL_realloc(joystick->touchpads, (ntouchpads * sizeof(SDL_JoystickTouchpadInfo)));
1112  if (touchpads) {
1113  SDL_JoystickTouchpadInfo *touchpad = &touchpads[ntouchpads - 1];
1115 
1116  if (fingers) {
1117  touchpad->nfingers = nfingers;
1118  touchpad->fingers = fingers;
1119  } else {
1120  /* Out of memory, this touchpad won't be active */
1121  touchpad->nfingers = 0;
1122  touchpad->fingers = NULL;
1123  }
1124 
1125  joystick->ntouchpads = ntouchpads;
1126  joystick->touchpads = touchpads;
1127  }
1128 }
#define SDL_calloc
SDL_JoystickTouchpadFingerInfo * fingers

References SDL_JoystickTouchpadInfo::fingers, joystick, SDL_JoystickTouchpadInfo::nfingers, NULL, SDL_calloc, and SDL_realloc.

Referenced by IOS_JoystickOpen().

◆ SDL_PrivateJoystickAxis()

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

Definition at line 1295 of file SDL_joystick.c.

1296 {
1297  int posted;
1298  SDL_JoystickAxisInfo *info;
1299 
1300  /* Make sure we're not getting garbage or duplicate events */
1301  if (axis >= joystick->naxes) {
1302  return 0;
1303  }
1304 
1305  info = &joystick->axes[axis];
1306  if (!info->has_initial_value ||
1307  (!info->has_second_value && (info->initial_value <= -32767 || info->initial_value == 32767) && SDL_abs(value) < (SDL_JOYSTICK_AXIS_MAX / 4))) {
1308  info->initial_value = value;
1309  info->value = value;
1310  info->zero = value;
1311  info->has_initial_value = SDL_TRUE;
1312  } else if (value == info->value) {
1313  return 0;
1314  } else {
1315  info->has_second_value = SDL_TRUE;
1316  }
1317  if (!info->sent_initial_value) {
1318  /* Make sure we don't send motion until there's real activity on this axis */
1319  const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */
1320  if (SDL_abs(value - info->value) <= MAX_ALLOWED_JITTER) {
1321  return 0;
1322  }
1323  info->sent_initial_value = SDL_TRUE;
1324  info->value = ~value; /* Just so we pass the check above */
1326  }
1327 
1328  /* We ignore events if we don't have keyboard focus, except for centering
1329  * events.
1330  */
1332  if ((value > info->zero && value >= info->value) ||
1334  return 0;
1335  }
1336  }
1337 
1338  /* Update internal joystick state */
1339  info->value = value;
1340 
1341  /* Post the event, if desired */
1342  posted = 0;
1343 #if !SDL_EVENTS_DISABLED
1345  SDL_Event event;
1346  event.type = SDL_JOYAXISMOTION;
1347  event.jaxis.which = joystick->instance_id;
1348  event.jaxis.axis = axis;
1349  event.jaxis.value = value;
1350  posted = SDL_PushEvent(&event) == 1;
1351  }
1352 #endif /* !SDL_EVENTS_DISABLED */
1353  return posted;
1354 }
#define SDL_abs
@ SDL_JOYAXISMOTION
Definition: SDL_events.h:113
static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent()
int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
#define SDL_JOYSTICK_AXIS_MAX
Definition: SDL_joystick.h:358
GLsizei const GLfloat * value
static const double zero
Definition: e_atan2.c:44
SDL_Texture * axis

References axis, SDL_JoystickAxisInfo::has_initial_value, SDL_JoystickAxisInfo::has_second_value, SDL_JoystickAxisInfo::initial_value, joystick, SDL_abs, SDL_ENABLE, SDL_GetEventState, SDL_JOYAXISMOTION, SDL_JOYSTICK_AXIS_MAX, 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(), and SDL_PrivateJoystickForceRecentering().

◆ SDL_PrivateJoystickBall()

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

Definition at line 1397 of file SDL_joystick.c.

1399 {
1400  int posted;
1401 
1402  /* Make sure we're not getting garbage events */
1403  if (ball >= joystick->nballs) {
1404  return 0;
1405  }
1406 
1407  /* We ignore events if we don't have keyboard focus. */
1409  return 0;
1410  }
1411 
1412  /* Update internal mouse state */
1413  joystick->balls[ball].dx += xrel;
1414  joystick->balls[ball].dy += yrel;
1415 
1416  /* Post the event, if desired */
1417  posted = 0;
1418 #if !SDL_EVENTS_DISABLED
1420  SDL_Event event;
1421  event.jball.type = SDL_JOYBALLMOTION;
1422  event.jball.which = joystick->instance_id;
1423  event.jball.ball = ball;
1424  event.jball.xrel = xrel;
1425  event.jball.yrel = yrel;
1426  posted = SDL_PushEvent(&event) == 1;
1427  }
1428 #endif /* !SDL_EVENTS_DISABLED */
1429  return posted;
1430 }
@ SDL_JOYBALLMOTION
Definition: SDL_events.h:114

References joystick, 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 2487 of file SDL_joystick.c.

2488 {
2489  joystick->epowerlevel = ePowerLevel;
2490 }

References joystick.

Referenced by IOS_MFIJoystickUpdate().

◆ SDL_PrivateJoystickButton()

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

Definition at line 1433 of file SDL_joystick.c.

1434 {
1435  int posted;
1436 #if !SDL_EVENTS_DISABLED
1437  SDL_Event event;
1438 
1439  switch (state) {
1440  case SDL_PRESSED:
1441  event.type = SDL_JOYBUTTONDOWN;
1442  break;
1443  case SDL_RELEASED:
1444  event.type = SDL_JOYBUTTONUP;
1445  break;
1446  default:
1447  /* Invalid state -- bail */
1448  return 0;
1449  }
1450 #endif /* !SDL_EVENTS_DISABLED */
1451 
1452  /* Make sure we're not getting garbage or duplicate events */
1453  if (button >= joystick->nbuttons) {
1454  return 0;
1455  }
1456  if (state == joystick->buttons[button]) {
1457  return 0;
1458  }
1459 
1460  /* We ignore events if we don't have keyboard focus, except for button
1461  * release. */
1463  if (state == SDL_PRESSED) {
1464  return 0;
1465  }
1466  }
1467 
1468  /* Update internal joystick state */
1469  joystick->buttons[button] = state;
1470 
1471  /* Post the event, if desired */
1472  posted = 0;
1473 #if !SDL_EVENTS_DISABLED
1474  if (SDL_GetEventState(event.type) == SDL_ENABLE) {
1475  event.jbutton.which = joystick->instance_id;
1476  event.jbutton.button = button;
1477  event.jbutton.state = state;
1478  posted = SDL_PushEvent(&event) == 1;
1479  }
1480 #endif /* !SDL_EVENTS_DISABLED */
1481  return posted;
1482 }
@ SDL_JOYBUTTONDOWN
Definition: SDL_events.h:116
@ SDL_JOYBUTTONUP
Definition: SDL_events.h:117
#define SDL_PRESSED
Definition: SDL_events.h:50
struct xkb_state * state
SDL_Texture * button

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

Referenced by IOS_MFIJoystickUpdate(), and SDL_PrivateJoystickForceRecentering().

◆ SDL_PrivateJoystickGetAutoGamepadMapping()

SDL_bool SDL_PrivateJoystickGetAutoGamepadMapping ( int  device_index,
SDL_GamepadMapping out 
)

Definition at line 574 of file SDL_joystick.c.

575 {
576  SDL_JoystickDriver *driver;
577  SDL_bool is_ok = SDL_FALSE;
578 
580  if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) {
581  is_ok = driver->GetGamepadMapping(device_index, out);
582  }
584 
585  return is_ok;
586 }
SDL_bool
Definition: SDL_stdinc.h:168
SDL_bool(* GetGamepadMapping)(int device_index, SDL_GamepadMapping *out)

References SDL_JoystickDriver::GetGamepadMapping, SDL_FALSE, SDL_GetDriverAndJoystickIndex(), SDL_LockJoysticks(), and SDL_UnlockJoysticks().

Referenced by SDL_PrivateGetControllerMapping().

◆ SDL_PrivateJoystickHat()

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

Definition at line 1357 of file SDL_joystick.c.

1358 {
1359  int posted;
1360 
1361  /* Make sure we're not getting garbage or duplicate events */
1362  if (hat >= joystick->nhats) {
1363  return 0;
1364  }
1365  if (value == joystick->hats[hat]) {
1366  return 0;
1367  }
1368 
1369  /* We ignore events if we don't have keyboard focus, except for centering
1370  * events.
1371  */
1373  if (value != SDL_HAT_CENTERED) {
1374  return 0;
1375  }
1376  }
1377 
1378  /* Update internal joystick state */
1379  joystick->hats[hat] = value;
1380 
1381  /* Post the event, if desired */
1382  posted = 0;
1383 #if !SDL_EVENTS_DISABLED
1385  SDL_Event event;
1386  event.jhat.type = SDL_JOYHATMOTION;
1387  event.jhat.which = joystick->instance_id;
1388  event.jhat.hat = hat;
1389  event.jhat.value = value;
1390  posted = SDL_PushEvent(&event) == 1;
1391  }
1392 #endif /* !SDL_EVENTS_DISABLED */
1393  return posted;
1394 }
@ SDL_JOYHATMOTION
Definition: SDL_events.h:115
#define SDL_HAT_CENTERED
Definition: SDL_joystick.h:386

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

Referenced by IOS_MFIJoystickUpdate(), and SDL_PrivateJoystickForceRecentering().

◆ SDL_PrivateJoystickRemoved()

void SDL_PrivateJoystickRemoved ( SDL_JoystickID  device_instance)

Definition at line 1253 of file SDL_joystick.c.

1254 {
1255  SDL_Joystick *joystick = NULL;
1256  int player_index;
1257  int device_index;
1258 #if !SDL_EVENTS_DISABLED
1259  SDL_Event event;
1260 #endif
1261 
1262  /* Find this joystick... */
1263  device_index = 0;
1264  for (joystick = SDL_joysticks; joystick; joystick = joystick->next) {
1265  if (joystick->instance_id == device_instance) {
1267  joystick->attached = SDL_FALSE;
1268  break;
1269  }
1270 
1271  ++device_index;
1272  }
1273 
1274 #if !SDL_EVENTS_DISABLED
1275  SDL_zero(event);
1276  event.type = SDL_JOYDEVICEREMOVED;
1277 
1278  if (SDL_GetEventState(event.type) == SDL_ENABLE) {
1279  event.jdevice.which = device_instance;
1280  SDL_PushEvent(&event);
1281  }
1282 
1283  UpdateEventsForDeviceRemoval(device_index);
1284 #endif /* !SDL_EVENTS_DISABLED */
1285 
1287  player_index = SDL_GetPlayerIndexForJoystickID(device_instance);
1288  if (player_index >= 0) {
1289  SDL_joystick_players[player_index] = -1;
1290  }
1292 }
@ SDL_JOYDEVICEREMOVED
Definition: SDL_events.h:119
static void UpdateEventsForDeviceRemoval(int device_index)
static int SDL_GetPlayerIndexForJoystickID(SDL_JoystickID instance_id)
Definition: SDL_joystick.c:131
static void SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick)

References joystick, NULL, SDL_ENABLE, SDL_FALSE, SDL_GetEventState, SDL_GetPlayerIndexForJoystickID(), SDL_JOYDEVICEREMOVED, SDL_joystick_players, SDL_joysticks, SDL_LockJoysticks(), SDL_PrivateJoystickForceRecentering(), SDL_PushEvent, SDL_UnlockJoysticks(), SDL_zero, and UpdateEventsForDeviceRemoval().

Referenced by IOS_RemoveJoystickDevice().

◆ SDL_PrivateJoystickSensor()

int SDL_PrivateJoystickSensor ( SDL_Joystick *  joystick,
SDL_SensorType  type,
const float *  data,
int  num_values 
)

Definition at line 2586 of file SDL_joystick.c.

2587 {
2588  int i;
2589  int posted = 0;
2590 
2591  for (i = 0; i < joystick->nsensors; ++i) {
2592  SDL_JoystickSensorInfo *sensor = &joystick->sensors[i];
2593 
2594  if (sensor->type == type) {
2595  if (sensor->enabled) {
2596  num_values = SDL_min(num_values, SDL_arraysize(sensor->data));
2597  if (SDL_memcmp(data, sensor->data, num_values*sizeof(*data)) != 0) {
2598 
2599  /* Update internal sensor state */
2600  SDL_memcpy(sensor->data, data, num_values*sizeof(*data));
2601 
2602  /* Post the event, if desired */
2603 #if !SDL_EVENTS_DISABLED
2605  SDL_Event event;
2606  event.type = SDL_CONTROLLERSENSORUPDATE;
2607  event.csensor.which = joystick->instance_id;
2608  event.csensor.sensor = type;
2609  num_values = SDL_min(num_values, SDL_arraysize(event.csensor.data));
2610  SDL_memset(event.csensor.data, 0, sizeof(event.csensor.data));
2611  SDL_memcpy(event.csensor.data, data, num_values*sizeof(*data));
2612  posted = SDL_PushEvent(&event) == 1;
2613  }
2614 #endif /* !SDL_EVENTS_DISABLED */
2615  }
2616  }
2617  break;
2618  }
2619  }
2620  return posted;
2621 }
#define SDL_memset
#define SDL_memcmp
@ SDL_CONTROLLERSENSORUPDATE
Definition: SDL_events.h:131
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
#define SDL_min(x, y)
Definition: SDL_stdinc.h:412

References SDL_JoystickSensorInfo::data, SDL_JoystickSensorInfo::enabled, i, joystick, SDL_arraysize, SDL_CONTROLLERSENSORUPDATE, SDL_ENABLE, SDL_GetEventState, SDL_memcmp, SDL_memcpy, SDL_memset, SDL_min, SDL_PushEvent, and SDL_JoystickSensorInfo::type.

Referenced by IOS_MFIJoystickUpdate().

◆ SDL_PrivateJoystickTouchpad()

int SDL_PrivateJoystickTouchpad ( SDL_Joystick *  joystick,
int  touchpad,
int  finger,
Uint8  state,
float  x,
float  y,
float  pressure 
)

Definition at line 2501 of file SDL_joystick.c.

2502 {
2503  SDL_JoystickTouchpadInfo *touchpad_info;
2504  SDL_JoystickTouchpadFingerInfo *finger_info;
2505  int posted;
2506 #if !SDL_EVENTS_DISABLED
2507  Uint32 event_type;
2508 #endif
2509 
2510  if (touchpad < 0 || touchpad >= joystick->ntouchpads) {
2511  return 0;
2512  }
2513 
2514  touchpad_info = &joystick->touchpads[touchpad];
2515  if (finger < 0 || finger >= touchpad_info->nfingers) {
2516  return 0;
2517  }
2518 
2519  finger_info = &touchpad_info->fingers[finger];
2520 
2521  if (!state) {
2522  if (x == 0.0f && y == 0.0f) {
2523  x = finger_info->x;
2524  y = finger_info->y;
2525  }
2526  pressure = 0.0f;
2527  }
2528 
2529  if (x < 0.0f) {
2530  x = 0.0f;
2531  } else if (x > 1.0f) {
2532  x = 1.0f;
2533  }
2534  if (y < 0.0f) {
2535  y = 0.0f;
2536  } else if (y > 1.0f) {
2537  y = 1.0f;
2538  }
2539  if (pressure < 0.0f) {
2540  pressure = 0.0f;
2541  } else if (pressure > 1.0f) {
2542  pressure = 1.0f;
2543  }
2544 
2545  if (state == finger_info->state) {
2546  if (!state ||
2547  (x == finger_info->x && y == finger_info->y && pressure == finger_info->pressure)) {
2548  return 0;
2549  }
2550  }
2551 
2552 #if !SDL_EVENTS_DISABLED
2553  if (state == finger_info->state) {
2554  event_type = SDL_CONTROLLERTOUCHPADMOTION;
2555  } else if (state) {
2556  event_type = SDL_CONTROLLERTOUCHPADDOWN;
2557  } else {
2558  event_type = SDL_CONTROLLERTOUCHPADUP;
2559  }
2560 #endif
2561 
2562  /* Update internal joystick state */
2563  finger_info->state = state;
2564  finger_info->x = x;
2565  finger_info->y = y;
2566  finger_info->pressure = pressure;
2567 
2568  /* Post the event, if desired */
2569  posted = 0;
2570 #if !SDL_EVENTS_DISABLED
2571  if (SDL_GetEventState(event_type) == SDL_ENABLE) {
2572  SDL_Event event;
2573  event.type = event_type;
2574  event.ctouchpad.which = joystick->instance_id;
2575  event.ctouchpad.touchpad = touchpad;
2576  event.ctouchpad.finger = finger;
2577  event.ctouchpad.x = x;
2578  event.ctouchpad.y = y;
2579  event.ctouchpad.pressure = pressure;
2580  posted = SDL_PushEvent(&event) == 1;
2581  }
2582 #endif /* !SDL_EVENTS_DISABLED */
2583  return posted;
2584 }
@ SDL_CONTROLLERTOUCHPADDOWN
Definition: SDL_events.h:128
@ SDL_CONTROLLERTOUCHPADMOTION
Definition: SDL_events.h:129
@ SDL_CONTROLLERTOUCHPADUP
Definition: SDL_events.h:130
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
uint32_t Uint32
Definition: SDL_stdinc.h:209

References SDL_JoystickTouchpadInfo::fingers, joystick, SDL_JoystickTouchpadInfo::nfingers, SDL_JoystickTouchpadFingerInfo::pressure, SDL_CONTROLLERTOUCHPADDOWN, SDL_CONTROLLERTOUCHPADMOTION, SDL_CONTROLLERTOUCHPADUP, SDL_ENABLE, SDL_GetEventState, SDL_PushEvent, SDL_JoystickTouchpadFingerInfo::state, state, SDL_JoystickTouchpadFingerInfo::x, and SDL_JoystickTouchpadFingerInfo::y.

Referenced by IOS_MFIJoystickUpdate(), and SDL_PrivateJoystickForceRecentering().

◆ SDL_PrivateJoystickValid()

◆ SDL_ShouldIgnoreGameController()

SDL_bool SDL_ShouldIgnoreGameController ( const char *  name,
SDL_JoystickGUID  guid 
)

Definition at line 1741 of file SDL_gamecontroller.c.

1742 {
1743  int i;
1744  Uint16 vendor;
1745  Uint16 product;
1746  Uint16 version;
1747  Uint32 vidpid;
1748 
1749 #if defined(__LINUX__)
1750  if (name && SDL_strstr(name, "Motion Sensors")) {
1751  /* Don't treat the PS3 and PS4 motion controls as a separate game controller */
1752  return SDL_TRUE;
1753  }
1754 #endif
1755 
1758  return SDL_FALSE;
1759  }
1760 
1761  SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version);
1762 
1763  if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE)) {
1764  /* We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real controllers so it can remap input for the virtual controller */
1765  SDL_bool bSteamVirtualGamepad = SDL_FALSE;
1766 #if defined(__LINUX__)
1767  bSteamVirtualGamepad = (vendor == 0x28DE && product == 0x11FF);
1768 #elif defined(__MACOSX__)
1769  bSteamVirtualGamepad = (vendor == 0x045E && product == 0x028E && version == 1);
1770 #elif defined(__WIN32__)
1771  /* We can't tell on Windows, but Steam will block others in input hooks */
1772  bSteamVirtualGamepad = SDL_TRUE;
1773 #endif
1774  if (bSteamVirtualGamepad) {
1775  return SDL_FALSE;
1776  }
1777  }
1778 
1779  vidpid = MAKE_VIDPID(vendor, product);
1780 
1782  for (i = 0; i < SDL_allowed_controllers.num_entries; ++i) {
1783  if (vidpid == SDL_allowed_controllers.entries[i]) {
1784  return SDL_FALSE;
1785  }
1786  }
1787  return SDL_TRUE;
1788  } else {
1789  for (i = 0; i < SDL_ignored_controllers.num_entries; ++i) {
1790  if (vidpid == SDL_ignored_controllers.entries[i]) {
1791  return SDL_TRUE;
1792  }
1793  }
1794  return SDL_FALSE;
1795  }
1796 }
#define SDL_strstr
#define SDL_GetHintBoolean
#define MAKE_VIDPID(VID, PID)

References SDL_vidpid_list::entries, i, MAKE_VIDPID, SDL_vidpid_list::num_entries, SDL_allowed_controllers, SDL_FALSE, SDL_GetHintBoolean, SDL_GetJoystickGUIDInfo(), SDL_ignored_controllers, SDL_strstr, and SDL_TRUE.

Referenced by SDL_ShouldIgnoreJoystick().

◆ SDL_ShouldIgnoreJoystick()

SDL_bool SDL_ShouldIgnoreJoystick ( const char *  name,
SDL_JoystickGUID  guid 
)

Definition at line 2140 of file SDL_joystick.c.

2141 {
2142  /* This list is taken from:
2143  https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/generate_rules.py
2144  */
2145  static Uint32 joystick_blacklist[] = {
2146  /* Microsoft Microsoft Wireless Optical Desktop 2.10 */
2147  /* Microsoft Wireless Desktop - Comfort Edition */
2148  MAKE_VIDPID(0x045e, 0x009d),
2149 
2150  /* Microsoft Microsoft Digital Media Pro Keyboard */
2151  /* Microsoft Corp. Digital Media Pro Keyboard */
2152  MAKE_VIDPID(0x045e, 0x00b0),
2153 
2154  /* Microsoft Microsoft Digital Media Keyboard */
2155  /* Microsoft Corp. Digital Media Keyboard 1.0A */
2156  MAKE_VIDPID(0x045e, 0x00b4),
2157 
2158  /* Microsoft Microsoft Digital Media Keyboard 3000 */
2159  MAKE_VIDPID(0x045e, 0x0730),
2160 
2161  /* Microsoft Microsoft 2.4GHz Transceiver v6.0 */
2162  /* Microsoft Microsoft 2.4GHz Transceiver v8.0 */
2163  /* Microsoft Corp. Nano Transceiver v1.0 for Bluetooth */
2164  /* Microsoft Wireless Mobile Mouse 1000 */
2165  /* Microsoft Wireless Desktop 3000 */
2166  MAKE_VIDPID(0x045e, 0x0745),
2167 
2168  /* Microsoft SideWinder(TM) 2.4GHz Transceiver */
2169  MAKE_VIDPID(0x045e, 0x0748),
2170 
2171  /* Microsoft Corp. Wired Keyboard 600 */
2172  MAKE_VIDPID(0x045e, 0x0750),
2173 
2174  /* Microsoft Corp. Sidewinder X4 keyboard */
2175  MAKE_VIDPID(0x045e, 0x0768),
2176 
2177  /* Microsoft Corp. Arc Touch Mouse Transceiver */
2178  MAKE_VIDPID(0x045e, 0x0773),
2179 
2180  /* Microsoft 2.4GHz Transceiver v9.0 */
2181  /* Microsoft Nano Transceiver v2.1 */
2182  /* Microsoft Sculpt Ergonomic Keyboard (5KV-00001) */
2183  MAKE_VIDPID(0x045e, 0x07a5),
2184 
2185  /* Microsoft Nano Transceiver v1.0 */
2186  /* Microsoft Wireless Keyboard 800 */
2187  MAKE_VIDPID(0x045e, 0x07b2),
2188 
2189  /* Microsoft Nano Transceiver v2.0 */
2190  MAKE_VIDPID(0x045e, 0x0800),
2191 
2192  MAKE_VIDPID(0x046d, 0xc30a), /* Logitech, Inc. iTouch Composite keboard */
2193 
2194  MAKE_VIDPID(0x04d9, 0xa0df), /* Tek Syndicate Mouse (E-Signal USB Gaming Mouse) */
2195 
2196  /* List of Wacom devices at: http://linuxwacom.sourceforge.net/wiki/index.php/Device_IDs */
2197  MAKE_VIDPID(0x056a, 0x0010), /* Wacom ET-0405 Graphire */
2198  MAKE_VIDPID(0x056a, 0x0011), /* Wacom ET-0405A Graphire2 (4x5) */
2199  MAKE_VIDPID(0x056a, 0x0012), /* Wacom ET-0507A Graphire2 (5x7) */
2200  MAKE_VIDPID(0x056a, 0x0013), /* Wacom CTE-430 Graphire3 (4x5) */
2201  MAKE_VIDPID(0x056a, 0x0014), /* Wacom CTE-630 Graphire3 (6x8) */
2202  MAKE_VIDPID(0x056a, 0x0015), /* Wacom CTE-440 Graphire4 (4x5) */
2203  MAKE_VIDPID(0x056a, 0x0016), /* Wacom CTE-640 Graphire4 (6x8) */
2204  MAKE_VIDPID(0x056a, 0x0017), /* Wacom CTE-450 Bamboo Fun (4x5) */
2205  MAKE_VIDPID(0x056a, 0x0018), /* Wacom CTE-650 Bamboo Fun 6x8 */
2206  MAKE_VIDPID(0x056a, 0x0019), /* Wacom CTE-631 Bamboo One */
2207  MAKE_VIDPID(0x056a, 0x00d1), /* Wacom Bamboo Pen and Touch CTH-460 */
2208  MAKE_VIDPID(0x056a, 0x030e), /* Wacom Intuos Pen (S) CTL-480 */
2209 
2210  MAKE_VIDPID(0x09da, 0x054f), /* A4 Tech Co., G7 750 mouse */
2211  MAKE_VIDPID(0x09da, 0x1410), /* A4 Tech Co., Ltd Bloody AL9 mouse */
2212  MAKE_VIDPID(0x09da, 0x3043), /* A4 Tech Co., Ltd Bloody R8A Gaming Mouse */
2213  MAKE_VIDPID(0x09da, 0x31b5), /* A4 Tech Co., Ltd Bloody TL80 Terminator Laser Gaming Mouse */
2214  MAKE_VIDPID(0x09da, 0x3997), /* A4 Tech Co., Ltd Bloody RT7 Terminator Wireless */
2215  MAKE_VIDPID(0x09da, 0x3f8b), /* A4 Tech Co., Ltd Bloody V8 mouse */
2216  MAKE_VIDPID(0x09da, 0x51f4), /* Modecom MC-5006 Keyboard */
2217  MAKE_VIDPID(0x09da, 0x5589), /* A4 Tech Co., Ltd Terminator TL9 Laser Gaming Mouse */
2218  MAKE_VIDPID(0x09da, 0x7b22), /* A4 Tech Co., Ltd Bloody V5 */
2219  MAKE_VIDPID(0x09da, 0x7f2d), /* A4 Tech Co., Ltd Bloody R3 mouse */
2220  MAKE_VIDPID(0x09da, 0x8090), /* A4 Tech Co., Ltd X-718BK Oscar Optical Gaming Mouse */
2221  MAKE_VIDPID(0x09da, 0x9033), /* A4 Tech Co., X7 X-705K */
2222  MAKE_VIDPID(0x09da, 0x9066), /* A4 Tech Co., Sharkoon Fireglider Optical */
2223  MAKE_VIDPID(0x09da, 0x9090), /* A4 Tech Co., Ltd XL-730K / XL-750BK / XL-755BK Laser Mouse */
2224  MAKE_VIDPID(0x09da, 0x90c0), /* A4 Tech Co., Ltd X7 G800V keyboard */
2225  MAKE_VIDPID(0x09da, 0xf012), /* A4 Tech Co., Ltd Bloody V7 mouse */
2226  MAKE_VIDPID(0x09da, 0xf32a), /* A4 Tech Co., Ltd Bloody B540 keyboard */
2227  MAKE_VIDPID(0x09da, 0xf613), /* A4 Tech Co., Ltd Bloody V2 mouse */
2228  MAKE_VIDPID(0x09da, 0xf624), /* A4 Tech Co., Ltd Bloody B120 Keyboard */
2229 
2230  MAKE_VIDPID(0x1b1c, 0x1b3c), /* Corsair Harpoon RGB gaming mouse */
2231 
2232  MAKE_VIDPID(0x1d57, 0xad03), /* [T3] 2.4GHz and IR Air Mouse Remote Control */
2233 
2234  MAKE_VIDPID(0x1e7d, 0x2e4a), /* Roccat Tyon Mouse */
2235 
2236  MAKE_VIDPID(0x20a0, 0x422d), /* Winkeyless.kr Keyboards */
2237 
2238  MAKE_VIDPID(0x2516, 0x001f), /* Cooler Master Storm Mizar Mouse */
2239  MAKE_VIDPID(0x2516, 0x0028), /* Cooler Master Storm Alcor Mouse */
2240  };
2241 
2242  unsigned int i;
2243  Uint32 id;
2244  Uint16 vendor;
2245  Uint16 product;
2247 
2248  SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
2249 
2250  /* Check the joystick blacklist */
2251  id = MAKE_VIDPID(vendor, product);
2252  for (i = 0; i < SDL_arraysize(joystick_blacklist); ++i) {
2253  if (id == joystick_blacklist[i]) {
2254  return SDL_TRUE;
2255  }
2256  }
2257 
2258  type = SDL_GetJoystickGameControllerType(name, vendor, product, -1, 0, 0, 0);
2260  return SDL_TRUE;
2261  }
2262 
2265  return SDL_TRUE;
2266  }
2267 
2268  return SDL_FALSE;
2269 }
SDL_bool SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid)
SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid)
static SDL_bool SDL_IsPS4RemapperRunning(void)
GLuint id

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