mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-19 11:18:27 +00:00
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594
This commit is contained in:
parent
14b902faca
commit
5750bcb174
781 changed files with 51659 additions and 55763 deletions
|
@ -38,7 +38,7 @@
|
|||
/* Needed for checking for input remapping programs */
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
|
||||
#undef UNICODE /* We want ASCII functions */
|
||||
#undef UNICODE /* We want ASCII functions */
|
||||
#include <tlhelp32.h>
|
||||
#endif
|
||||
|
||||
|
@ -80,7 +80,7 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = {
|
|||
#ifdef SDL_JOYSTICK_HAIKU
|
||||
&SDL_HAIKU_JoystickDriver,
|
||||
#endif
|
||||
#ifdef SDL_JOYSTICK_USBHID /* !!! FIXME: "USBHID" is a generic name, and doubly-confusing with HIDAPI next to it. This is the *BSD interface, rename this. */
|
||||
#ifdef SDL_JOYSTICK_USBHID /* !!! FIXME: "USBHID" is a generic name, and doubly-confusing with HIDAPI next to it. This is the *BSD interface, rename this. */
|
||||
&SDL_BSD_JoystickDriver,
|
||||
#endif
|
||||
#ifdef SDL_JOYSTICK_PS2
|
||||
|
@ -99,7 +99,7 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = {
|
|||
&SDL_N3DS_JoystickDriver
|
||||
#endif
|
||||
#if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED)
|
||||
&SDL_DUMMY_JoystickDriver
|
||||
&SDL_DUMMY_JoystickDriver
|
||||
#endif
|
||||
};
|
||||
static SDL_bool SDL_joysticks_initialized;
|
||||
|
@ -113,11 +113,10 @@ static SDL_JoystickID *SDL_joystick_players = NULL;
|
|||
static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE;
|
||||
static char joystick_magic;
|
||||
|
||||
|
||||
#define CHECK_JOYSTICK_MAGIC(joystick, retval) \
|
||||
#define CHECK_JOYSTICK_MAGIC(joystick, retval) \
|
||||
if (!joystick || joystick->magic != &joystick_magic) { \
|
||||
SDL_InvalidParamError("joystick"); \
|
||||
return retval; \
|
||||
SDL_InvalidParamError("joystick"); \
|
||||
return retval; \
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
|
@ -132,8 +131,7 @@ SDL_JoysticksQuitting(void)
|
|||
return SDL_joysticks_quitting;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LockJoysticks(void)
|
||||
void SDL_LockJoysticks(void)
|
||||
{
|
||||
if (SDL_joystick_lock) {
|
||||
SDL_LockMutex(SDL_joystick_lock);
|
||||
|
@ -142,8 +140,7 @@ SDL_LockJoysticks(void)
|
|||
++SDL_joysticks_locked;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_UnlockJoysticks(void)
|
||||
void SDL_UnlockJoysticks(void)
|
||||
{
|
||||
--SDL_joysticks_locked;
|
||||
|
||||
|
@ -167,8 +164,7 @@ SDL_JoysticksLocked(void)
|
|||
return (SDL_joysticks_locked > 0) ? SDL_TRUE : SDL_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_AssertJoysticksLocked(void)
|
||||
void SDL_AssertJoysticksLocked(void)
|
||||
{
|
||||
SDL_assert(SDL_JoysticksLocked());
|
||||
}
|
||||
|
@ -177,8 +173,7 @@ SDL_AssertJoysticksLocked(void)
|
|||
* Get the driver and device index for an API device index
|
||||
* This should be called while the joystick lock is held, to prevent another thread from updating the list
|
||||
*/
|
||||
static SDL_bool
|
||||
SDL_GetDriverAndJoystickIndex(int device_index, SDL_JoystickDriver **driver, int *driver_index)
|
||||
static SDL_bool SDL_GetDriverAndJoystickIndex(int device_index, SDL_JoystickDriver **driver, int *driver_index)
|
||||
{
|
||||
int i, num_joysticks, total_joysticks = 0;
|
||||
|
||||
|
@ -201,8 +196,7 @@ SDL_GetDriverAndJoystickIndex(int device_index, SDL_JoystickDriver **driver, int
|
|||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_FindFreePlayerIndex()
|
||||
static int SDL_FindFreePlayerIndex()
|
||||
{
|
||||
int player_index;
|
||||
|
||||
|
@ -216,8 +210,7 @@ SDL_FindFreePlayerIndex()
|
|||
return player_index;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_GetPlayerIndexForJoystickID(SDL_JoystickID instance_id)
|
||||
static int SDL_GetPlayerIndexForJoystickID(SDL_JoystickID instance_id)
|
||||
{
|
||||
int player_index;
|
||||
|
||||
|
@ -234,8 +227,7 @@ SDL_GetPlayerIndexForJoystickID(SDL_JoystickID instance_id)
|
|||
return player_index;
|
||||
}
|
||||
|
||||
static SDL_JoystickID
|
||||
SDL_GetJoystickIDForPlayerIndex(int player_index)
|
||||
static SDL_JoystickID SDL_GetJoystickIDForPlayerIndex(int player_index)
|
||||
{
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
|
@ -245,8 +237,7 @@ SDL_GetJoystickIDForPlayerIndex(int player_index)
|
|||
return SDL_joystick_players[player_index];
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id)
|
||||
static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id)
|
||||
{
|
||||
SDL_JoystickID existing_instance = SDL_GetJoystickIDForPlayerIndex(player_index);
|
||||
SDL_JoystickDriver *driver;
|
||||
|
@ -256,7 +247,7 @@ SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id)
|
|||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (player_index >= SDL_joystick_player_count) {
|
||||
SDL_JoystickID *new_players = (SDL_JoystickID *)SDL_realloc(SDL_joystick_players, (player_index + 1)*sizeof(*SDL_joystick_players));
|
||||
SDL_JoystickID *new_players = (SDL_JoystickID *)SDL_realloc(SDL_joystick_players, (player_index + 1) * sizeof(*SDL_joystick_players));
|
||||
if (new_players == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
|
@ -293,8 +284,7 @@ SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id)
|
|||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static void SDLCALL
|
||||
SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
static void SDLCALL SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
if (SDL_GetStringBoolean(hint, SDL_FALSE)) {
|
||||
SDL_joystick_allows_background_events = SDL_TRUE;
|
||||
|
@ -303,8 +293,7 @@ SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickInit(void)
|
||||
int SDL_JoystickInit(void)
|
||||
{
|
||||
int i, status;
|
||||
|
||||
|
@ -347,8 +336,7 @@ SDL_JoystickInit(void)
|
|||
/*
|
||||
* Count the number of joysticks attached to the system
|
||||
*/
|
||||
int
|
||||
SDL_NumJoysticks(void)
|
||||
int SDL_NumJoysticks(void)
|
||||
{
|
||||
int i, total_joysticks = 0;
|
||||
SDL_LockJoysticks();
|
||||
|
@ -412,8 +400,7 @@ SDL_JoystickPathForIndex(int device_index)
|
|||
/*
|
||||
* Get the player index of a joystick, or -1 if it's not available
|
||||
*/
|
||||
int
|
||||
SDL_JoystickGetDevicePlayerIndex(int device_index)
|
||||
int SDL_JoystickGetDevicePlayerIndex(int device_index)
|
||||
{
|
||||
int player_index;
|
||||
|
||||
|
@ -429,15 +416,14 @@ SDL_JoystickGetDevicePlayerIndex(int device_index)
|
|||
* This isn't generally needed unless the joystick never generates an initial axis value near zero,
|
||||
* e.g. it's emulating axes with digital buttons
|
||||
*/
|
||||
static SDL_bool
|
||||
SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick)
|
||||
static SDL_bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick)
|
||||
{
|
||||
#ifdef __WINRT__
|
||||
return SDL_TRUE;
|
||||
#else
|
||||
static Uint32 zero_centered_joysticks[] = {
|
||||
MAKE_VIDPID(0x0e8f, 0x3013), /* HuiJia SNES USB adapter */
|
||||
MAKE_VIDPID(0x05a0, 0x3232), /* 8Bitdo Zero Gamepad */
|
||||
MAKE_VIDPID(0x0e8f, 0x3013), /* HuiJia SNES USB adapter */
|
||||
MAKE_VIDPID(0x05a0, 0x3232), /* 8Bitdo Zero Gamepad */
|
||||
};
|
||||
|
||||
int i;
|
||||
|
@ -492,16 +478,16 @@ SDL_JoystickOpen(int device_index)
|
|||
instance_id = driver->GetDeviceInstanceID(device_index);
|
||||
while (joysticklist) {
|
||||
if (instance_id == joysticklist->instance_id) {
|
||||
joystick = joysticklist;
|
||||
++joystick->ref_count;
|
||||
SDL_UnlockJoysticks();
|
||||
return joystick;
|
||||
joystick = joysticklist;
|
||||
++joystick->ref_count;
|
||||
SDL_UnlockJoysticks();
|
||||
return joystick;
|
||||
}
|
||||
joysticklist = joysticklist->next;
|
||||
}
|
||||
|
||||
/* Create and initialize the joystick */
|
||||
joystick = (SDL_Joystick *) SDL_calloc(sizeof(*joystick), 1);
|
||||
joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1);
|
||||
if (joystick == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_UnlockJoysticks();
|
||||
|
@ -537,21 +523,18 @@ SDL_JoystickOpen(int device_index)
|
|||
joystick->guid = driver->GetDeviceGUID(device_index);
|
||||
|
||||
if (joystick->naxes > 0) {
|
||||
joystick->axes = (SDL_JoystickAxisInfo *) SDL_calloc(joystick->naxes, sizeof(SDL_JoystickAxisInfo));
|
||||
joystick->axes = (SDL_JoystickAxisInfo *)SDL_calloc(joystick->naxes, sizeof(SDL_JoystickAxisInfo));
|
||||
}
|
||||
if (joystick->nhats > 0) {
|
||||
joystick->hats = (Uint8 *) SDL_calloc(joystick->nhats, sizeof(Uint8));
|
||||
joystick->hats = (Uint8 *)SDL_calloc(joystick->nhats, sizeof(Uint8));
|
||||
}
|
||||
if (joystick->nballs > 0) {
|
||||
joystick->balls = (struct balldelta *) SDL_calloc(joystick->nballs, sizeof(*joystick->balls));
|
||||
joystick->balls = (struct balldelta *)SDL_calloc(joystick->nballs, sizeof(*joystick->balls));
|
||||
}
|
||||
if (joystick->nbuttons > 0) {
|
||||
joystick->buttons = (Uint8 *) SDL_calloc(joystick->nbuttons, sizeof(Uint8));
|
||||
joystick->buttons = (Uint8 *)SDL_calloc(joystick->nbuttons, sizeof(Uint8));
|
||||
}
|
||||
if (((joystick->naxes > 0) && !joystick->axes)
|
||||
|| ((joystick->nhats > 0) && !joystick->hats)
|
||||
|| ((joystick->nballs > 0) && !joystick->balls)
|
||||
|| ((joystick->nbuttons > 0) && !joystick->buttons)) {
|
||||
if (((joystick->naxes > 0) && !joystick->axes) || ((joystick->nhats > 0) && !joystick->hats) || ((joystick->nballs > 0) && !joystick->balls) || ((joystick->nbuttons > 0) && !joystick->buttons)) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_JoystickClose(joystick);
|
||||
SDL_UnlockJoysticks();
|
||||
|
@ -587,9 +570,8 @@ SDL_JoystickOpen(int device_index)
|
|||
return joystick;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickAttachVirtual(SDL_JoystickType type,
|
||||
int naxes, int nbuttons, int nhats)
|
||||
int SDL_JoystickAttachVirtual(SDL_JoystickType type,
|
||||
int naxes, int nbuttons, int nhats)
|
||||
{
|
||||
SDL_VirtualJoystickDesc desc;
|
||||
|
||||
|
@ -602,8 +584,7 @@ SDL_JoystickAttachVirtual(SDL_JoystickType type,
|
|||
return SDL_JoystickAttachVirtualEx(&desc);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystickDesc *desc)
|
||||
int SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystickDesc *desc)
|
||||
{
|
||||
#if SDL_JOYSTICK_VIRTUAL
|
||||
int result;
|
||||
|
@ -617,8 +598,7 @@ SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystickDesc *desc)
|
|||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickDetachVirtual(int device_index)
|
||||
int SDL_JoystickDetachVirtual(int device_index)
|
||||
{
|
||||
#if SDL_JOYSTICK_VIRTUAL
|
||||
SDL_JoystickDriver *driver;
|
||||
|
@ -661,8 +641,7 @@ SDL_JoystickIsVirtual(int device_index)
|
|||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value)
|
||||
int SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value)
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
|
@ -673,8 +652,7 @@ SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value)
|
|||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value)
|
||||
int SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value)
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
|
@ -685,8 +663,7 @@ SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value)
|
|||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value)
|
||||
int SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value)
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
|
@ -708,7 +685,7 @@ SDL_PrivateJoystickValid(SDL_Joystick *joystick)
|
|||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_PrivateJoystickGetAutoGamepadMapping(int device_index, SDL_GamepadMapping * out)
|
||||
SDL_PrivateJoystickGetAutoGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
||||
{
|
||||
SDL_JoystickDriver *driver;
|
||||
SDL_bool is_ok = SDL_FALSE;
|
||||
|
@ -725,8 +702,7 @@ SDL_PrivateJoystickGetAutoGamepadMapping(int device_index, SDL_GamepadMapping *
|
|||
/*
|
||||
* Get the number of multi-dimensional axis controls on a joystick
|
||||
*/
|
||||
int
|
||||
SDL_JoystickNumAxes(SDL_Joystick *joystick)
|
||||
int SDL_JoystickNumAxes(SDL_Joystick *joystick)
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
|
@ -736,8 +712,7 @@ SDL_JoystickNumAxes(SDL_Joystick *joystick)
|
|||
/*
|
||||
* Get the number of hats on a joystick
|
||||
*/
|
||||
int
|
||||
SDL_JoystickNumHats(SDL_Joystick *joystick)
|
||||
int SDL_JoystickNumHats(SDL_Joystick *joystick)
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
|
@ -747,8 +722,7 @@ SDL_JoystickNumHats(SDL_Joystick *joystick)
|
|||
/*
|
||||
* Get the number of trackballs on a joystick
|
||||
*/
|
||||
int
|
||||
SDL_JoystickNumBalls(SDL_Joystick *joystick)
|
||||
int SDL_JoystickNumBalls(SDL_Joystick *joystick)
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
|
@ -758,8 +732,7 @@ SDL_JoystickNumBalls(SDL_Joystick *joystick)
|
|||
/*
|
||||
* Get the number of buttons on a joystick
|
||||
*/
|
||||
int
|
||||
SDL_JoystickNumButtons(SDL_Joystick *joystick)
|
||||
int SDL_JoystickNumButtons(SDL_Joystick *joystick)
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
|
@ -806,8 +779,7 @@ SDL_JoystickGetAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state)
|
|||
/*
|
||||
* Get the current state of a hat on a joystick
|
||||
*/
|
||||
Uint8
|
||||
SDL_JoystickGetHat(SDL_Joystick *joystick, int hat)
|
||||
Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat)
|
||||
{
|
||||
Uint8 state;
|
||||
|
||||
|
@ -825,8 +797,7 @@ SDL_JoystickGetHat(SDL_Joystick *joystick, int hat)
|
|||
/*
|
||||
* Get the ball axis change since the last poll
|
||||
*/
|
||||
int
|
||||
SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
|
||||
int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
|
||||
{
|
||||
int retval;
|
||||
|
||||
|
@ -851,8 +822,7 @@ SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
|
|||
/*
|
||||
* Get the current state of a button on a joystick
|
||||
*/
|
||||
Uint8
|
||||
SDL_JoystickGetButton(SDL_Joystick *joystick, int button)
|
||||
Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button)
|
||||
{
|
||||
Uint8 state;
|
||||
|
||||
|
@ -957,8 +927,7 @@ SDL_JoystickPath(SDL_Joystick *joystick)
|
|||
/**
|
||||
* Get the player index of an opened joystick, or -1 if it's not available
|
||||
*/
|
||||
int
|
||||
SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick)
|
||||
int SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick)
|
||||
{
|
||||
int player_index;
|
||||
|
||||
|
@ -974,8 +943,7 @@ SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick)
|
|||
/**
|
||||
* Set the player index of an opened joystick
|
||||
*/
|
||||
void
|
||||
SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index)
|
||||
void SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index)
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, );
|
||||
|
||||
|
@ -984,8 +952,7 @@ SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index)
|
|||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
|
||||
int SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
|
||||
{
|
||||
int result;
|
||||
|
||||
|
@ -1023,8 +990,7 @@ SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 h
|
|||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms)
|
||||
int SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms)
|
||||
{
|
||||
int result;
|
||||
|
||||
|
@ -1104,8 +1070,7 @@ SDL_JoystickHasRumbleTriggers(SDL_Joystick *joystick)
|
|||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
int SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
{
|
||||
int result;
|
||||
SDL_bool isfreshvalue;
|
||||
|
@ -1136,8 +1101,7 @@ SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
|||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size)
|
||||
int SDL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size)
|
||||
{
|
||||
int result;
|
||||
|
||||
|
@ -1155,8 +1119,7 @@ SDL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size)
|
|||
/*
|
||||
* Close a joystick previously opened with SDL_JoystickOpen()
|
||||
*/
|
||||
void
|
||||
SDL_JoystickClose(SDL_Joystick *joystick)
|
||||
void SDL_JoystickClose(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_Joystick *joysticklist;
|
||||
SDL_Joystick *joysticklistprev;
|
||||
|
@ -1219,8 +1182,7 @@ SDL_JoystickClose(SDL_Joystick *joystick)
|
|||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
void
|
||||
SDL_JoystickQuit(void)
|
||||
void SDL_JoystickQuit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1236,7 +1198,7 @@ SDL_JoystickQuit(void)
|
|||
|
||||
/* Quit drivers in reverse order to avoid breaking dependencies between drivers */
|
||||
for (i = SDL_arraysize(SDL_joystick_drivers) - 1; i >= 0; --i) {
|
||||
SDL_joystick_drivers[i]->Quit();
|
||||
SDL_joystick_drivers[i]->Quit();
|
||||
}
|
||||
|
||||
if (SDL_joystick_players) {
|
||||
|
@ -1260,9 +1222,7 @@ SDL_JoystickQuit(void)
|
|||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
|
||||
static SDL_bool
|
||||
SDL_PrivateJoystickShouldIgnoreEvent()
|
||||
static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent()
|
||||
{
|
||||
if (SDL_joystick_allows_background_events) {
|
||||
return SDL_FALSE;
|
||||
|
@ -1425,8 +1385,7 @@ static void UpdateEventsForDeviceRemoval(int device_index, Uint32 type)
|
|||
SDL_small_free(events, isstack);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick)
|
||||
void SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
@ -1498,8 +1457,7 @@ void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
|
||||
int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
|
||||
{
|
||||
int posted;
|
||||
SDL_JoystickAxisInfo *info;
|
||||
|
@ -1527,7 +1485,7 @@ SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
|
|||
}
|
||||
if (!info->sent_initial_value) {
|
||||
/* Make sure we don't send motion until there's real activity on this axis */
|
||||
const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */
|
||||
const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */
|
||||
if (SDL_abs(value - info->value) <= MAX_ALLOWED_JITTER &&
|
||||
!SDL_IsJoystickVirtual(joystick->guid)) {
|
||||
return 0;
|
||||
|
@ -1567,8 +1525,7 @@ SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
|
|||
return posted;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value)
|
||||
int SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value)
|
||||
{
|
||||
int posted;
|
||||
|
||||
|
@ -1611,9 +1568,8 @@ SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value)
|
|||
return posted;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball,
|
||||
Sint16 xrel, Sint16 yrel)
|
||||
int SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball,
|
||||
Sint16 xrel, Sint16 yrel)
|
||||
{
|
||||
int posted;
|
||||
|
||||
|
@ -1651,8 +1607,7 @@ SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball,
|
|||
return posted;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
|
||||
int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
|
||||
{
|
||||
int posted;
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
|
@ -1707,8 +1662,7 @@ SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
|
|||
return posted;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_JoystickUpdate(void)
|
||||
void SDL_JoystickUpdate(void)
|
||||
{
|
||||
int i;
|
||||
Uint32 now;
|
||||
|
@ -1766,8 +1720,7 @@ SDL_JoystickUpdate(void)
|
|||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_JoystickEventState(int state)
|
||||
int SDL_JoystickEventState(int state)
|
||||
{
|
||||
#if SDL_EVENTS_DISABLED
|
||||
return SDL_DISABLE;
|
||||
|
@ -1862,12 +1815,11 @@ void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *prod
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
PrefixMatch(const char *a, const char *b)
|
||||
static int PrefixMatch(const char *a, const char *b)
|
||||
{
|
||||
int matchlen = 0;
|
||||
while (*a && *b) {
|
||||
if (SDL_tolower((unsigned char) *a++) == SDL_tolower((unsigned char) *b++)) {
|
||||
if (SDL_tolower((unsigned char)*a++) == SDL_tolower((unsigned char)*b++)) {
|
||||
++matchlen;
|
||||
} else {
|
||||
break;
|
||||
|
@ -1879,7 +1831,8 @@ PrefixMatch(const char *a, const char *b)
|
|||
char *
|
||||
SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name)
|
||||
{
|
||||
static struct {
|
||||
static struct
|
||||
{
|
||||
const char *prefix;
|
||||
const char *replacement;
|
||||
} replacements[] = {
|
||||
|
@ -1969,9 +1922,9 @@ SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, c
|
|||
name[len] = '\0';
|
||||
|
||||
/* Compress duplicate spaces */
|
||||
for (i = 0; i < (len - 1); ) {
|
||||
if (name[i] == ' ' && name[i+1] == ' ') {
|
||||
SDL_memmove(&name[i], &name[i+1], (len - i));
|
||||
for (i = 0; i < (len - 1);) {
|
||||
if (name[i] == ' ' && name[i + 1] == ' ') {
|
||||
SDL_memmove(&name[i], &name[i + 1], (len - i));
|
||||
--len;
|
||||
} else {
|
||||
++i;
|
||||
|
@ -1985,7 +1938,7 @@ SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, c
|
|||
size_t replacementlen = SDL_strlen(replacements[i].replacement);
|
||||
if (replacementlen <= prefixlen) {
|
||||
SDL_memcpy(name, replacements[i].replacement, replacementlen);
|
||||
SDL_memmove(name+replacementlen, name+prefixlen, (len-prefixlen)+1);
|
||||
SDL_memmove(name + replacementlen, name + prefixlen, (len - prefixlen) + 1);
|
||||
len -= (prefixlen - replacementlen);
|
||||
} else {
|
||||
/* FIXME: Need to handle the expand case by reallocating the string */
|
||||
|
@ -2048,7 +2001,7 @@ SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version
|
|||
guid.data[14] = driver_signature;
|
||||
guid.data[15] = driver_data;
|
||||
}
|
||||
SDL_strlcpy((char*)guid16, name, available_space);
|
||||
SDL_strlcpy((char *)guid16, name, available_space);
|
||||
}
|
||||
return guid;
|
||||
}
|
||||
|
@ -2080,8 +2033,7 @@ void SDL_SetJoystickGUIDVersion(SDL_JoystickGUID *guid, Uint16 version)
|
|||
guid16[6] = SDL_SwapLE16(version);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetJoystickGUIDCRC(SDL_JoystickGUID *guid, Uint16 crc)
|
||||
void SDL_SetJoystickGUIDCRC(SDL_JoystickGUID *guid, Uint16 crc)
|
||||
{
|
||||
Uint16 *guid16 = (Uint16 *)guid->data;
|
||||
|
||||
|
@ -2385,28 +2337,28 @@ SDL_IsJoystickVirtual(SDL_JoystickGUID guid)
|
|||
static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid)
|
||||
{
|
||||
static Uint32 wheel_joysticks[] = {
|
||||
MAKE_VIDPID(0x046d, 0xc294), /* Logitech generic wheel */
|
||||
MAKE_VIDPID(0x046d, 0xc295), /* Logitech Momo Force */
|
||||
MAKE_VIDPID(0x046d, 0xc298), /* Logitech Driving Force Pro */
|
||||
MAKE_VIDPID(0x046d, 0xc299), /* Logitech G25 */
|
||||
MAKE_VIDPID(0x046d, 0xc29a), /* Logitech Driving Force GT */
|
||||
MAKE_VIDPID(0x046d, 0xc29b), /* Logitech G27 */
|
||||
MAKE_VIDPID(0x046d, 0xc24f), /* Logitech G29 (PS3) */
|
||||
MAKE_VIDPID(0x046d, 0xc260), /* Logitech G29 (PS4) */
|
||||
MAKE_VIDPID(0x046d, 0xc261), /* Logitech G920 (initial mode) */
|
||||
MAKE_VIDPID(0x046d, 0xc262), /* Logitech G920 (active mode) */
|
||||
MAKE_VIDPID(0x046d, 0xc26e), /* Logitech G923 */
|
||||
MAKE_VIDPID(0x046d, 0xca03), /* Logitech Momo Racing */
|
||||
MAKE_VIDPID(0x044f, 0xb65d), /* Thrustmaster Wheel FFB */
|
||||
MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster Wheel FFB */
|
||||
MAKE_VIDPID(0x044f, 0xb677), /* Thrustmaster T150 */
|
||||
MAKE_VIDPID(0x044f, 0xb696), /* Thrustmaster T248 */
|
||||
MAKE_VIDPID(0x044f, 0xb66e), /* Thrustmaster T300RS (normal mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb66f), /* Thrustmaster T300RS (advanced mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster T300RS (PS4 mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb65e), /* Thrustmaster T500RS */
|
||||
MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */
|
||||
MAKE_VIDPID(0x046d, 0xc294), /* Logitech generic wheel */
|
||||
MAKE_VIDPID(0x046d, 0xc295), /* Logitech Momo Force */
|
||||
MAKE_VIDPID(0x046d, 0xc298), /* Logitech Driving Force Pro */
|
||||
MAKE_VIDPID(0x046d, 0xc299), /* Logitech G25 */
|
||||
MAKE_VIDPID(0x046d, 0xc29a), /* Logitech Driving Force GT */
|
||||
MAKE_VIDPID(0x046d, 0xc29b), /* Logitech G27 */
|
||||
MAKE_VIDPID(0x046d, 0xc24f), /* Logitech G29 (PS3) */
|
||||
MAKE_VIDPID(0x046d, 0xc260), /* Logitech G29 (PS4) */
|
||||
MAKE_VIDPID(0x046d, 0xc261), /* Logitech G920 (initial mode) */
|
||||
MAKE_VIDPID(0x046d, 0xc262), /* Logitech G920 (active mode) */
|
||||
MAKE_VIDPID(0x046d, 0xc26e), /* Logitech G923 */
|
||||
MAKE_VIDPID(0x046d, 0xca03), /* Logitech Momo Racing */
|
||||
MAKE_VIDPID(0x044f, 0xb65d), /* Thrustmaster Wheel FFB */
|
||||
MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster Wheel FFB */
|
||||
MAKE_VIDPID(0x044f, 0xb677), /* Thrustmaster T150 */
|
||||
MAKE_VIDPID(0x044f, 0xb696), /* Thrustmaster T248 */
|
||||
MAKE_VIDPID(0x044f, 0xb66e), /* Thrustmaster T300RS (normal mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb66f), /* Thrustmaster T300RS (advanced mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster T300RS (PS4 mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb65e), /* Thrustmaster T500RS */
|
||||
MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */
|
||||
};
|
||||
int i;
|
||||
|
||||
|
@ -2421,37 +2373,37 @@ static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid)
|
|||
static SDL_bool SDL_IsJoystickProductArcadeStick(Uint32 vidpid)
|
||||
{
|
||||
static Uint32 arcadestick_joysticks[] = {
|
||||
MAKE_VIDPID(0x0079, 0x181a), /* Venom Arcade Stick */
|
||||
MAKE_VIDPID(0x0079, 0x181b), /* Venom Arcade Stick */
|
||||
MAKE_VIDPID(0x0c12, 0x0ef6), /* Hitbox Arcade Stick */
|
||||
MAKE_VIDPID(0x0e6f, 0x0109), /* PDP Versus Fighting Pad */
|
||||
MAKE_VIDPID(0x0f0d, 0x0016), /* Hori Real Arcade Pro.EX */
|
||||
MAKE_VIDPID(0x0f0d, 0x001b), /* Hori Real Arcade Pro VX */
|
||||
MAKE_VIDPID(0x0f0d, 0x0063), /* Hori Real Arcade Pro Hayabusa (USA) Xbox One */
|
||||
MAKE_VIDPID(0x0f0d, 0x006a), /* Real Arcade Pro 4 */
|
||||
MAKE_VIDPID(0x0f0d, 0x0078), /* Hori Real Arcade Pro V Kai Xbox One */
|
||||
MAKE_VIDPID(0x0f0d, 0x008a), /* HORI Real Arcade Pro 4 */
|
||||
MAKE_VIDPID(0x0f0d, 0x008c), /* Hori Real Arcade Pro 4 */
|
||||
MAKE_VIDPID(0x0f0d, 0x00aa), /* HORI Real Arcade Pro V Hayabusa in Switch Mode */
|
||||
MAKE_VIDPID(0x0f0d, 0x00ed), /* Hori Fighting Stick mini 4 kai */
|
||||
MAKE_VIDPID(0x0f0d, 0x011c), /* Hori Fighting Stick α in PS4 Mode */
|
||||
MAKE_VIDPID(0x0f0d, 0x011e), /* Hori Fighting Stick α in PC Mode */
|
||||
MAKE_VIDPID(0x0f0d, 0x0184), /* Hori Fighting Stick α in PS5 Mode */
|
||||
MAKE_VIDPID(0x1532, 0x0a00), /* Razer Atrox Arcade Stick */
|
||||
MAKE_VIDPID(0x1bad, 0xf03d), /* Street Fighter IV Arcade Stick TE - Chun Li */
|
||||
MAKE_VIDPID(0x1bad, 0xf502), /* Hori Real Arcade Pro.VX SA */
|
||||
MAKE_VIDPID(0x1bad, 0xf504), /* Hori Real Arcade Pro. EX */
|
||||
MAKE_VIDPID(0x1bad, 0xf506), /* Hori Real Arcade Pro.EX Premium VLX */
|
||||
MAKE_VIDPID(0x20d6, 0xa715), /* PowerA Nintendo Switch Fusion Arcade Stick */
|
||||
MAKE_VIDPID(0x24c6, 0x5000), /* Razer Atrox Arcade Stick */
|
||||
MAKE_VIDPID(0x24c6, 0x5501), /* Hori Real Arcade Pro VX-SA */
|
||||
MAKE_VIDPID(0x24c6, 0x550e), /* Hori Real Arcade Pro V Kai 360 */
|
||||
MAKE_VIDPID(0x2c22, 0x2300), /* Qanba Obsidian Arcade Joystick in PS4 Mode */
|
||||
MAKE_VIDPID(0x2c22, 0x2302), /* Qanba Obsidian Arcade Joystick in PS3 Mode */
|
||||
MAKE_VIDPID(0x2c22, 0x2303), /* Qanba Obsidian Arcade Joystick in PC Mode */
|
||||
MAKE_VIDPID(0x2c22, 0x2500), /* Qanba Dragon Arcade Joystick in PS4 Mode */
|
||||
MAKE_VIDPID(0x2c22, 0x2502), /* Qanba Dragon Arcade Joystick in PS3 Mode */
|
||||
MAKE_VIDPID(0x2c22, 0x2503), /* Qanba Dragon Arcade Joystick in PC Mode */
|
||||
MAKE_VIDPID(0x0079, 0x181a), /* Venom Arcade Stick */
|
||||
MAKE_VIDPID(0x0079, 0x181b), /* Venom Arcade Stick */
|
||||
MAKE_VIDPID(0x0c12, 0x0ef6), /* Hitbox Arcade Stick */
|
||||
MAKE_VIDPID(0x0e6f, 0x0109), /* PDP Versus Fighting Pad */
|
||||
MAKE_VIDPID(0x0f0d, 0x0016), /* Hori Real Arcade Pro.EX */
|
||||
MAKE_VIDPID(0x0f0d, 0x001b), /* Hori Real Arcade Pro VX */
|
||||
MAKE_VIDPID(0x0f0d, 0x0063), /* Hori Real Arcade Pro Hayabusa (USA) Xbox One */
|
||||
MAKE_VIDPID(0x0f0d, 0x006a), /* Real Arcade Pro 4 */
|
||||
MAKE_VIDPID(0x0f0d, 0x0078), /* Hori Real Arcade Pro V Kai Xbox One */
|
||||
MAKE_VIDPID(0x0f0d, 0x008a), /* HORI Real Arcade Pro 4 */
|
||||
MAKE_VIDPID(0x0f0d, 0x008c), /* Hori Real Arcade Pro 4 */
|
||||
MAKE_VIDPID(0x0f0d, 0x00aa), /* HORI Real Arcade Pro V Hayabusa in Switch Mode */
|
||||
MAKE_VIDPID(0x0f0d, 0x00ed), /* Hori Fighting Stick mini 4 kai */
|
||||
MAKE_VIDPID(0x0f0d, 0x011c), /* Hori Fighting Stick α in PS4 Mode */
|
||||
MAKE_VIDPID(0x0f0d, 0x011e), /* Hori Fighting Stick α in PC Mode */
|
||||
MAKE_VIDPID(0x0f0d, 0x0184), /* Hori Fighting Stick α in PS5 Mode */
|
||||
MAKE_VIDPID(0x1532, 0x0a00), /* Razer Atrox Arcade Stick */
|
||||
MAKE_VIDPID(0x1bad, 0xf03d), /* Street Fighter IV Arcade Stick TE - Chun Li */
|
||||
MAKE_VIDPID(0x1bad, 0xf502), /* Hori Real Arcade Pro.VX SA */
|
||||
MAKE_VIDPID(0x1bad, 0xf504), /* Hori Real Arcade Pro. EX */
|
||||
MAKE_VIDPID(0x1bad, 0xf506), /* Hori Real Arcade Pro.EX Premium VLX */
|
||||
MAKE_VIDPID(0x20d6, 0xa715), /* PowerA Nintendo Switch Fusion Arcade Stick */
|
||||
MAKE_VIDPID(0x24c6, 0x5000), /* Razer Atrox Arcade Stick */
|
||||
MAKE_VIDPID(0x24c6, 0x5501), /* Hori Real Arcade Pro VX-SA */
|
||||
MAKE_VIDPID(0x24c6, 0x550e), /* Hori Real Arcade Pro V Kai 360 */
|
||||
MAKE_VIDPID(0x2c22, 0x2300), /* Qanba Obsidian Arcade Joystick in PS4 Mode */
|
||||
MAKE_VIDPID(0x2c22, 0x2302), /* Qanba Obsidian Arcade Joystick in PS3 Mode */
|
||||
MAKE_VIDPID(0x2c22, 0x2303), /* Qanba Obsidian Arcade Joystick in PC Mode */
|
||||
MAKE_VIDPID(0x2c22, 0x2500), /* Qanba Dragon Arcade Joystick in PS4 Mode */
|
||||
MAKE_VIDPID(0x2c22, 0x2502), /* Qanba Dragon Arcade Joystick in PS3 Mode */
|
||||
MAKE_VIDPID(0x2c22, 0x2503), /* Qanba Dragon Arcade Joystick in PC Mode */
|
||||
};
|
||||
int i;
|
||||
|
||||
|
@ -2466,12 +2418,12 @@ static SDL_bool SDL_IsJoystickProductArcadeStick(Uint32 vidpid)
|
|||
static SDL_bool SDL_IsJoystickProductFlightStick(Uint32 vidpid)
|
||||
{
|
||||
static Uint32 flightstick_joysticks[] = {
|
||||
MAKE_VIDPID(0x044f, 0x0402), /* HOTAS Warthog Joystick */
|
||||
MAKE_VIDPID(0x0738, 0x2221), /* Saitek Pro Flight X-56 Rhino Stick */
|
||||
MAKE_VIDPID(0x044f, 0xb10a), /* ThrustMaster, Inc. T.16000M Joystick */
|
||||
MAKE_VIDPID(0x046d, 0xc215), /* Logitech Extreme 3D */
|
||||
MAKE_VIDPID(0x231d, 0x0126), /* Gunfighter Mk.III ‘Space Combat Edition’ (right) */
|
||||
MAKE_VIDPID(0x231d, 0x0127), /* Gunfighter Mk.III ‘Space Combat Edition’ (left) */
|
||||
MAKE_VIDPID(0x044f, 0x0402), /* HOTAS Warthog Joystick */
|
||||
MAKE_VIDPID(0x0738, 0x2221), /* Saitek Pro Flight X-56 Rhino Stick */
|
||||
MAKE_VIDPID(0x044f, 0xb10a), /* ThrustMaster, Inc. T.16000M Joystick */
|
||||
MAKE_VIDPID(0x046d, 0xc215), /* Logitech Extreme 3D */
|
||||
MAKE_VIDPID(0x231d, 0x0126), /* Gunfighter Mk.III ‘Space Combat Edition’ (right) */
|
||||
MAKE_VIDPID(0x231d, 0x0127), /* Gunfighter Mk.III ‘Space Combat Edition’ (left) */
|
||||
};
|
||||
int i;
|
||||
|
||||
|
@ -2486,8 +2438,8 @@ static SDL_bool SDL_IsJoystickProductFlightStick(Uint32 vidpid)
|
|||
static SDL_bool SDL_IsJoystickProductThrottle(Uint32 vidpid)
|
||||
{
|
||||
static Uint32 throttle_joysticks[] = {
|
||||
MAKE_VIDPID(0x044f, 0x0404), /* HOTAS Warthog Throttle */
|
||||
MAKE_VIDPID(0x0738, 0xa221), /* Saitek Pro Flight X-56 Rhino Throttle */
|
||||
MAKE_VIDPID(0x044f, 0x0404), /* HOTAS Warthog Throttle */
|
||||
MAKE_VIDPID(0x0738, 0xa221), /* Saitek Pro Flight X-56 Rhino Throttle */
|
||||
};
|
||||
int i;
|
||||
|
||||
|
@ -2508,23 +2460,23 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid)
|
|||
if (SDL_IsJoystickXInput(guid)) {
|
||||
/* XInput GUID, get the type based on the XInput device subtype */
|
||||
switch (guid.data[15]) {
|
||||
case 0x01: /* XINPUT_DEVSUBTYPE_GAMEPAD */
|
||||
case 0x01: /* XINPUT_DEVSUBTYPE_GAMEPAD */
|
||||
return SDL_JOYSTICK_TYPE_GAMECONTROLLER;
|
||||
case 0x02: /* XINPUT_DEVSUBTYPE_WHEEL */
|
||||
case 0x02: /* XINPUT_DEVSUBTYPE_WHEEL */
|
||||
return SDL_JOYSTICK_TYPE_WHEEL;
|
||||
case 0x03: /* XINPUT_DEVSUBTYPE_ARCADE_STICK */
|
||||
case 0x03: /* XINPUT_DEVSUBTYPE_ARCADE_STICK */
|
||||
return SDL_JOYSTICK_TYPE_ARCADE_STICK;
|
||||
case 0x04: /* XINPUT_DEVSUBTYPE_FLIGHT_STICK */
|
||||
case 0x04: /* XINPUT_DEVSUBTYPE_FLIGHT_STICK */
|
||||
return SDL_JOYSTICK_TYPE_FLIGHT_STICK;
|
||||
case 0x05: /* XINPUT_DEVSUBTYPE_DANCE_PAD */
|
||||
case 0x05: /* XINPUT_DEVSUBTYPE_DANCE_PAD */
|
||||
return SDL_JOYSTICK_TYPE_DANCE_PAD;
|
||||
case 0x06: /* XINPUT_DEVSUBTYPE_GUITAR */
|
||||
case 0x07: /* XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE */
|
||||
case 0x0B: /* XINPUT_DEVSUBTYPE_GUITAR_BASS */
|
||||
case 0x06: /* XINPUT_DEVSUBTYPE_GUITAR */
|
||||
case 0x07: /* XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE */
|
||||
case 0x0B: /* XINPUT_DEVSUBTYPE_GUITAR_BASS */
|
||||
return SDL_JOYSTICK_TYPE_GUITAR;
|
||||
case 0x08: /* XINPUT_DEVSUBTYPE_DRUM_KIT */
|
||||
case 0x08: /* XINPUT_DEVSUBTYPE_DRUM_KIT */
|
||||
return SDL_JOYSTICK_TYPE_DRUM_KIT;
|
||||
case 0x13: /* XINPUT_DEVSUBTYPE_ARCADE_PAD */
|
||||
case 0x13: /* XINPUT_DEVSUBTYPE_ARCADE_PAD */
|
||||
return SDL_JOYSTICK_TYPE_ARCADE_PAD;
|
||||
default:
|
||||
return SDL_JOYSTICK_TYPE_UNKNOWN;
|
||||
|
@ -2623,76 +2575,76 @@ SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid)
|
|||
/* Microsoft Nano Transceiver v2.0 */
|
||||
MAKE_VIDPID(0x045e, 0x0800),
|
||||
|
||||
MAKE_VIDPID(0x046d, 0xc30a), /* Logitech, Inc. iTouch Composite keboard */
|
||||
MAKE_VIDPID(0x046d, 0xc30a), /* Logitech, Inc. iTouch Composite keboard */
|
||||
|
||||
MAKE_VIDPID(0x04d9, 0xa0df), /* Tek Syndicate Mouse (E-Signal USB Gaming Mouse) */
|
||||
MAKE_VIDPID(0x04d9, 0xa0df), /* Tek Syndicate Mouse (E-Signal USB Gaming Mouse) */
|
||||
|
||||
/* List of Wacom devices at: http://linuxwacom.sourceforge.net/wiki/index.php/Device_IDs */
|
||||
MAKE_VIDPID(0x056a, 0x0010), /* Wacom ET-0405 Graphire */
|
||||
MAKE_VIDPID(0x056a, 0x0011), /* Wacom ET-0405A Graphire2 (4x5) */
|
||||
MAKE_VIDPID(0x056a, 0x0012), /* Wacom ET-0507A Graphire2 (5x7) */
|
||||
MAKE_VIDPID(0x056a, 0x0013), /* Wacom CTE-430 Graphire3 (4x5) */
|
||||
MAKE_VIDPID(0x056a, 0x0014), /* Wacom CTE-630 Graphire3 (6x8) */
|
||||
MAKE_VIDPID(0x056a, 0x0015), /* Wacom CTE-440 Graphire4 (4x5) */
|
||||
MAKE_VIDPID(0x056a, 0x0016), /* Wacom CTE-640 Graphire4 (6x8) */
|
||||
MAKE_VIDPID(0x056a, 0x0017), /* Wacom CTE-450 Bamboo Fun (4x5) */
|
||||
MAKE_VIDPID(0x056a, 0x0018), /* Wacom CTE-650 Bamboo Fun 6x8 */
|
||||
MAKE_VIDPID(0x056a, 0x0019), /* Wacom CTE-631 Bamboo One */
|
||||
MAKE_VIDPID(0x056a, 0x00d1), /* Wacom Bamboo Pen and Touch CTH-460 */
|
||||
MAKE_VIDPID(0x056a, 0x030e), /* Wacom Intuos Pen (S) CTL-480 */
|
||||
MAKE_VIDPID(0x056a, 0x0010), /* Wacom ET-0405 Graphire */
|
||||
MAKE_VIDPID(0x056a, 0x0011), /* Wacom ET-0405A Graphire2 (4x5) */
|
||||
MAKE_VIDPID(0x056a, 0x0012), /* Wacom ET-0507A Graphire2 (5x7) */
|
||||
MAKE_VIDPID(0x056a, 0x0013), /* Wacom CTE-430 Graphire3 (4x5) */
|
||||
MAKE_VIDPID(0x056a, 0x0014), /* Wacom CTE-630 Graphire3 (6x8) */
|
||||
MAKE_VIDPID(0x056a, 0x0015), /* Wacom CTE-440 Graphire4 (4x5) */
|
||||
MAKE_VIDPID(0x056a, 0x0016), /* Wacom CTE-640 Graphire4 (6x8) */
|
||||
MAKE_VIDPID(0x056a, 0x0017), /* Wacom CTE-450 Bamboo Fun (4x5) */
|
||||
MAKE_VIDPID(0x056a, 0x0018), /* Wacom CTE-650 Bamboo Fun 6x8 */
|
||||
MAKE_VIDPID(0x056a, 0x0019), /* Wacom CTE-631 Bamboo One */
|
||||
MAKE_VIDPID(0x056a, 0x00d1), /* Wacom Bamboo Pen and Touch CTH-460 */
|
||||
MAKE_VIDPID(0x056a, 0x030e), /* Wacom Intuos Pen (S) CTL-480 */
|
||||
|
||||
MAKE_VIDPID(0x09da, 0x054f), /* A4 Tech Co., G7 750 mouse */
|
||||
MAKE_VIDPID(0x09da, 0x1410), /* A4 Tech Co., Ltd Bloody AL9 mouse */
|
||||
MAKE_VIDPID(0x09da, 0x3043), /* A4 Tech Co., Ltd Bloody R8A Gaming Mouse */
|
||||
MAKE_VIDPID(0x09da, 0x31b5), /* A4 Tech Co., Ltd Bloody TL80 Terminator Laser Gaming Mouse */
|
||||
MAKE_VIDPID(0x09da, 0x3997), /* A4 Tech Co., Ltd Bloody RT7 Terminator Wireless */
|
||||
MAKE_VIDPID(0x09da, 0x3f8b), /* A4 Tech Co., Ltd Bloody V8 mouse */
|
||||
MAKE_VIDPID(0x09da, 0x51f4), /* Modecom MC-5006 Keyboard */
|
||||
MAKE_VIDPID(0x09da, 0x5589), /* A4 Tech Co., Ltd Terminator TL9 Laser Gaming Mouse */
|
||||
MAKE_VIDPID(0x09da, 0x7b22), /* A4 Tech Co., Ltd Bloody V5 */
|
||||
MAKE_VIDPID(0x09da, 0x7f2d), /* A4 Tech Co., Ltd Bloody R3 mouse */
|
||||
MAKE_VIDPID(0x09da, 0x8090), /* A4 Tech Co., Ltd X-718BK Oscar Optical Gaming Mouse */
|
||||
MAKE_VIDPID(0x09da, 0x9033), /* A4 Tech Co., X7 X-705K */
|
||||
MAKE_VIDPID(0x09da, 0x9066), /* A4 Tech Co., Sharkoon Fireglider Optical */
|
||||
MAKE_VIDPID(0x09da, 0x9090), /* A4 Tech Co., Ltd XL-730K / XL-750BK / XL-755BK Laser Mouse */
|
||||
MAKE_VIDPID(0x09da, 0x90c0), /* A4 Tech Co., Ltd X7 G800V keyboard */
|
||||
MAKE_VIDPID(0x09da, 0xf012), /* A4 Tech Co., Ltd Bloody V7 mouse */
|
||||
MAKE_VIDPID(0x09da, 0xf32a), /* A4 Tech Co., Ltd Bloody B540 keyboard */
|
||||
MAKE_VIDPID(0x09da, 0xf613), /* A4 Tech Co., Ltd Bloody V2 mouse */
|
||||
MAKE_VIDPID(0x09da, 0xf624), /* A4 Tech Co., Ltd Bloody B120 Keyboard */
|
||||
MAKE_VIDPID(0x09da, 0x054f), /* A4 Tech Co., G7 750 mouse */
|
||||
MAKE_VIDPID(0x09da, 0x1410), /* A4 Tech Co., Ltd Bloody AL9 mouse */
|
||||
MAKE_VIDPID(0x09da, 0x3043), /* A4 Tech Co., Ltd Bloody R8A Gaming Mouse */
|
||||
MAKE_VIDPID(0x09da, 0x31b5), /* A4 Tech Co., Ltd Bloody TL80 Terminator Laser Gaming Mouse */
|
||||
MAKE_VIDPID(0x09da, 0x3997), /* A4 Tech Co., Ltd Bloody RT7 Terminator Wireless */
|
||||
MAKE_VIDPID(0x09da, 0x3f8b), /* A4 Tech Co., Ltd Bloody V8 mouse */
|
||||
MAKE_VIDPID(0x09da, 0x51f4), /* Modecom MC-5006 Keyboard */
|
||||
MAKE_VIDPID(0x09da, 0x5589), /* A4 Tech Co., Ltd Terminator TL9 Laser Gaming Mouse */
|
||||
MAKE_VIDPID(0x09da, 0x7b22), /* A4 Tech Co., Ltd Bloody V5 */
|
||||
MAKE_VIDPID(0x09da, 0x7f2d), /* A4 Tech Co., Ltd Bloody R3 mouse */
|
||||
MAKE_VIDPID(0x09da, 0x8090), /* A4 Tech Co., Ltd X-718BK Oscar Optical Gaming Mouse */
|
||||
MAKE_VIDPID(0x09da, 0x9033), /* A4 Tech Co., X7 X-705K */
|
||||
MAKE_VIDPID(0x09da, 0x9066), /* A4 Tech Co., Sharkoon Fireglider Optical */
|
||||
MAKE_VIDPID(0x09da, 0x9090), /* A4 Tech Co., Ltd XL-730K / XL-750BK / XL-755BK Laser Mouse */
|
||||
MAKE_VIDPID(0x09da, 0x90c0), /* A4 Tech Co., Ltd X7 G800V keyboard */
|
||||
MAKE_VIDPID(0x09da, 0xf012), /* A4 Tech Co., Ltd Bloody V7 mouse */
|
||||
MAKE_VIDPID(0x09da, 0xf32a), /* A4 Tech Co., Ltd Bloody B540 keyboard */
|
||||
MAKE_VIDPID(0x09da, 0xf613), /* A4 Tech Co., Ltd Bloody V2 mouse */
|
||||
MAKE_VIDPID(0x09da, 0xf624), /* A4 Tech Co., Ltd Bloody B120 Keyboard */
|
||||
|
||||
MAKE_VIDPID(0x1b1c, 0x1b3c), /* Corsair Harpoon RGB gaming mouse */
|
||||
MAKE_VIDPID(0x1b1c, 0x1b3c), /* Corsair Harpoon RGB gaming mouse */
|
||||
|
||||
MAKE_VIDPID(0x1d57, 0xad03), /* [T3] 2.4GHz and IR Air Mouse Remote Control */
|
||||
MAKE_VIDPID(0x1d57, 0xad03), /* [T3] 2.4GHz and IR Air Mouse Remote Control */
|
||||
|
||||
MAKE_VIDPID(0x1e7d, 0x2e4a), /* Roccat Tyon Mouse */
|
||||
MAKE_VIDPID(0x1e7d, 0x2e4a), /* Roccat Tyon Mouse */
|
||||
|
||||
MAKE_VIDPID(0x20a0, 0x422d), /* Winkeyless.kr Keyboards */
|
||||
MAKE_VIDPID(0x20a0, 0x422d), /* Winkeyless.kr Keyboards */
|
||||
|
||||
MAKE_VIDPID(0x2516, 0x001f), /* Cooler Master Storm Mizar Mouse */
|
||||
MAKE_VIDPID(0x2516, 0x0028), /* Cooler Master Storm Alcor Mouse */
|
||||
MAKE_VIDPID(0x2516, 0x001f), /* Cooler Master Storm Mizar Mouse */
|
||||
MAKE_VIDPID(0x2516, 0x0028), /* Cooler Master Storm Alcor Mouse */
|
||||
|
||||
/*****************************************************************/
|
||||
/* Additional entries */
|
||||
/*****************************************************************/
|
||||
|
||||
MAKE_VIDPID(0x04d9, 0x8008), /* OBINLB USB-HID Keyboard (Anne Pro II) */
|
||||
MAKE_VIDPID(0x04d9, 0x8009), /* OBINLB USB-HID Keyboard (Anne Pro II) */
|
||||
MAKE_VIDPID(0x04d9, 0xa292), /* OBINLB USB-HID Keyboard (Anne Pro II) */
|
||||
MAKE_VIDPID(0x04d9, 0xa293), /* OBINLB USB-HID Keyboard (Anne Pro II) */
|
||||
MAKE_VIDPID(0x1532, 0x0266), /* Razer Huntman V2 Analog, non-functional DInput device */
|
||||
MAKE_VIDPID(0x1532, 0x0282), /* Razer Huntman Mini Analog, non-functional DInput device */
|
||||
MAKE_VIDPID(0x26ce, 0x01a2), /* ASRock LED Controller */
|
||||
MAKE_VIDPID(0x20d6, 0x0002), /* PowerA Enhanced Wireless Controller for Nintendo Switch (charging port only) */
|
||||
MAKE_VIDPID(0x04d9, 0x8008), /* OBINLB USB-HID Keyboard (Anne Pro II) */
|
||||
MAKE_VIDPID(0x04d9, 0x8009), /* OBINLB USB-HID Keyboard (Anne Pro II) */
|
||||
MAKE_VIDPID(0x04d9, 0xa292), /* OBINLB USB-HID Keyboard (Anne Pro II) */
|
||||
MAKE_VIDPID(0x04d9, 0xa293), /* OBINLB USB-HID Keyboard (Anne Pro II) */
|
||||
MAKE_VIDPID(0x1532, 0x0266), /* Razer Huntman V2 Analog, non-functional DInput device */
|
||||
MAKE_VIDPID(0x1532, 0x0282), /* Razer Huntman Mini Analog, non-functional DInput device */
|
||||
MAKE_VIDPID(0x26ce, 0x01a2), /* ASRock LED Controller */
|
||||
MAKE_VIDPID(0x20d6, 0x0002), /* PowerA Enhanced Wireless Controller for Nintendo Switch (charging port only) */
|
||||
};
|
||||
|
||||
static Uint32 rog_chakram_list[] = {
|
||||
MAKE_VIDPID(0x0b05, 0x1958), /* ROG Chakram Core Mouse */
|
||||
MAKE_VIDPID(0x0b05, 0x18e3), /* ROG Chakram (wired) Mouse */
|
||||
MAKE_VIDPID(0x0b05, 0x18e5), /* ROG Chakram (wireless) Mouse */
|
||||
MAKE_VIDPID(0x0b05, 0x1a18), /* ROG Chakram X (wired) Mouse */
|
||||
MAKE_VIDPID(0x0b05, 0x1a1a), /* ROG Chakram X (wireless) Mouse */
|
||||
MAKE_VIDPID(0x0b05, 0x1a1c), /* ROG Chakram X (Bluetooth) Mouse */
|
||||
MAKE_VIDPID(0x0b05, 0x1958), /* ROG Chakram Core Mouse */
|
||||
MAKE_VIDPID(0x0b05, 0x18e3), /* ROG Chakram (wired) Mouse */
|
||||
MAKE_VIDPID(0x0b05, 0x18e5), /* ROG Chakram (wireless) Mouse */
|
||||
MAKE_VIDPID(0x0b05, 0x1a18), /* ROG Chakram X (wired) Mouse */
|
||||
MAKE_VIDPID(0x0b05, 0x1a1a), /* ROG Chakram X (wireless) Mouse */
|
||||
MAKE_VIDPID(0x0b05, 0x1a1c), /* ROG Chakram X (Bluetooth) Mouse */
|
||||
};
|
||||
|
||||
unsigned int i;
|
||||
|
@ -3027,7 +2979,7 @@ int SDL_PrivateJoystickSensor(SDL_Joystick *joystick, SDL_SensorType type, Uint6
|
|||
num_values = SDL_min(num_values, SDL_arraysize(sensor->data));
|
||||
|
||||
/* Update internal sensor state */
|
||||
SDL_memcpy(sensor->data, data, num_values*sizeof(*data));
|
||||
SDL_memcpy(sensor->data, data, num_values * sizeof(*data));
|
||||
sensor->timestamp_us = timestamp_us;
|
||||
|
||||
/* Post the event, if desired */
|
||||
|
@ -3039,7 +2991,7 @@ int SDL_PrivateJoystickSensor(SDL_Joystick *joystick, SDL_SensorType type, Uint6
|
|||
event.csensor.sensor = type;
|
||||
num_values = SDL_min(num_values, SDL_arraysize(event.csensor.data));
|
||||
SDL_memset(event.csensor.data, 0, sizeof(event.csensor.data));
|
||||
SDL_memcpy(event.csensor.data, data, num_values*sizeof(*data));
|
||||
SDL_memcpy(event.csensor.data, data, num_values * sizeof(*data));
|
||||
event.csensor.timestamp_us = timestamp_us;
|
||||
posted = SDL_PushEvent(&event) == 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue