update sdl Merge commit '4d48f9d23713d94b861da7b5d41baf2a41334994'
This commit is contained in:
45
external/sdl/SDL/src/joystick/SDL_gamepad.c
vendored
45
external/sdl/SDL/src/joystick/SDL_gamepad.c
vendored
@ -362,6 +362,8 @@ void SDL_PrivateGamepadRemoved(SDL_JoystickID instance_id)
|
||||
SDL_Event event;
|
||||
SDL_Gamepad *gamepad;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (!SDL_gamepads_initialized) {
|
||||
return;
|
||||
}
|
||||
@ -466,6 +468,8 @@ static void AdjustSensorOrientation(SDL_Joystick *joystick, float *src, float *d
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
dst[i] = 0.0f;
|
||||
for (j = 0; j < 3; ++j) {
|
||||
@ -559,6 +563,8 @@ static SDL_bool HasMappingChangeTracking(MappingChangeTracker *tracker, GamepadM
|
||||
{
|
||||
int i;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
for (i = 0; i < tracker->num_changed_mappings; ++i) {
|
||||
if (tracker->changed_mappings[i] == mapping) {
|
||||
return SDL_TRUE;
|
||||
@ -746,6 +752,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid
|
||||
switch (guid.data[15]) {
|
||||
case k_eSwitchDeviceInfoControllerType_HVCLeft:
|
||||
SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,rightshoulder:b10,start:b6,", sizeof(mapping_string));
|
||||
break;
|
||||
case k_eSwitchDeviceInfoControllerType_HVCRight:
|
||||
SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,rightshoulder:b10,", sizeof(mapping_string));
|
||||
break;
|
||||
@ -1653,10 +1660,12 @@ static GamepadMapping_t *SDL_PrivateGenerateAutomaticGamepadMapping(const char *
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "dpleft", &raw_map->dpleft);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "dpright", &raw_map->dpright);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "misc1", &raw_map->misc1);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "paddle1", &raw_map->paddle1);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "paddle2", &raw_map->paddle2);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "paddle3", &raw_map->paddle3);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "paddle4", &raw_map->paddle4);
|
||||
/* Keep using paddle1-4 in the generated mapping so that it can be
|
||||
* reused with SDL2 */
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "paddle1", &raw_map->right_paddle1);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "paddle2", &raw_map->left_paddle1);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "paddle3", &raw_map->right_paddle2);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "paddle4", &raw_map->left_paddle2);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "leftx", &raw_map->leftx);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "lefty", &raw_map->lefty);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "rightx", &raw_map->rightx);
|
||||
@ -1693,40 +1702,18 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id
|
||||
/*
|
||||
* Add or update an entry into the Mappings Database
|
||||
*/
|
||||
int SDL_AddGamepadMappingsFromRW(SDL_RWops *src, int freesrc)
|
||||
int SDL_AddGamepadMappingsFromRW(SDL_RWops *src, SDL_bool freesrc)
|
||||
{
|
||||
const char *platform = SDL_GetPlatform();
|
||||
int gamepads = 0;
|
||||
char *buf, *line, *line_end, *tmp, *comma, line_platform[64];
|
||||
Sint64 db_size;
|
||||
size_t db_size;
|
||||
size_t platform_len;
|
||||
|
||||
if (src == NULL) {
|
||||
return SDL_InvalidParamError("src");
|
||||
}
|
||||
db_size = SDL_RWsize(src);
|
||||
|
||||
buf = (char *)SDL_malloc((size_t)db_size + 1);
|
||||
buf = (char *)SDL_LoadFile_RW(src, &db_size, freesrc);
|
||||
if (buf == NULL) {
|
||||
if (freesrc) {
|
||||
SDL_RWclose(src);
|
||||
}
|
||||
return SDL_SetError("Could not allocate space to read DB into memory");
|
||||
}
|
||||
|
||||
if (SDL_RWread(src, buf, db_size) != db_size) {
|
||||
if (freesrc) {
|
||||
SDL_RWclose(src);
|
||||
}
|
||||
SDL_free(buf);
|
||||
return SDL_SetError("Could not read DB");
|
||||
}
|
||||
|
||||
if (freesrc) {
|
||||
SDL_RWclose(src);
|
||||
}
|
||||
|
||||
buf[db_size] = '\0';
|
||||
line = buf;
|
||||
|
||||
PushMappingChangeTracking();
|
||||
|
@ -134,6 +134,7 @@ static const char *s_GamepadMappings[] = {
|
||||
"03000000b80500000610000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,",
|
||||
"03000000852100000201000000000000,FF-GP1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,",
|
||||
"03000000790000000600000000000000,G-Shark GS-GP702,crc:8e4f,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
|
||||
"030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"03000000300f00000b01000000000000,GGE909 Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,",
|
||||
"03000000790000002201000000000000,Game Controller for PC,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
|
||||
@ -815,6 +816,7 @@ static const char *s_GamepadMappings[] = {
|
||||
"05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,",
|
||||
"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,",
|
||||
"05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,",
|
||||
"03000000de2800000512000011010000,Steam Deck,a:b3,b:b4,back:b11,dpdown:b17,dpleft:b18,dpright:b19,dpup:b16,guide:b13,leftshoulder:b7,leftstick:b14,lefttrigger:a9,leftx:a0,lefty:a1,misc1:b2,paddle1:b21,paddle2:b20,paddle3:b23,paddle4:b22,rightshoulder:b8,rightstick:b15,righttrigger:a8,rightx:a2,righty:a3,start:b12,x:b5,y:b6,",
|
||||
"03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"0500000011010000311400001b010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b32,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,",
|
||||
"05000000110100001914000009010000,SteelSeries Stratus XL,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b18,leftshoulder:b6,leftstick:b13,lefttrigger:+a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:+a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,",
|
||||
|
29
external/sdl/SDL/src/joystick/SDL_joystick.c
vendored
29
external/sdl/SDL/src/joystick/SDL_joystick.c
vendored
@ -150,26 +150,33 @@ void SDL_LockJoysticks(void)
|
||||
|
||||
void SDL_UnlockJoysticks(void)
|
||||
{
|
||||
SDL_Mutex *joystick_lock = SDL_joystick_lock;
|
||||
SDL_bool last_unlock = SDL_FALSE;
|
||||
|
||||
--SDL_joysticks_locked;
|
||||
|
||||
if (!SDL_joysticks_initialized) {
|
||||
/* NOTE: There's a small window here where another thread could lock the mutex after we've checked for pending locks */
|
||||
if (!SDL_joysticks_locked && SDL_AtomicGet(&SDL_joystick_lock_pending) == 0) {
|
||||
/* NOTE: There's a small window here where another thread could lock the mutex */
|
||||
SDL_joystick_lock = NULL;
|
||||
last_unlock = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UnlockMutex(joystick_lock);
|
||||
|
||||
/* The last unlock after joysticks are uninitialized will cleanup the mutex,
|
||||
* allowing applications to lock joysticks while reinitializing the system.
|
||||
*/
|
||||
if (last_unlock) {
|
||||
SDL_Mutex *joystick_lock = SDL_joystick_lock;
|
||||
|
||||
SDL_LockMutex(joystick_lock);
|
||||
{
|
||||
SDL_UnlockMutex(SDL_joystick_lock);
|
||||
|
||||
SDL_joystick_lock = NULL;
|
||||
}
|
||||
SDL_UnlockMutex(joystick_lock);
|
||||
SDL_DestroyMutex(joystick_lock);
|
||||
} else {
|
||||
SDL_UnlockMutex(SDL_joystick_lock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -560,6 +567,8 @@ static SDL_bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, SDL_bool *inve
|
||||
const char *hint;
|
||||
int hint_value;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
*invert_sensors = SDL_FALSE;
|
||||
|
||||
/* The SDL controller sensor API is only available for gamepads (at the moment) */
|
||||
@ -620,6 +629,8 @@ static void AttemptSensorFusion(SDL_Joystick *joystick, SDL_bool invert_sensors)
|
||||
SDL_SensorID *sensors;
|
||||
unsigned int i, j;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_SENSOR) < 0) {
|
||||
return;
|
||||
}
|
||||
@ -686,6 +697,8 @@ static void AttemptSensorFusion(SDL_Joystick *joystick, SDL_bool invert_sensors)
|
||||
|
||||
static void CleanupSensorFusion(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (joystick->accel_sensor || joystick->gyro_sensor) {
|
||||
if (joystick->accel_sensor) {
|
||||
if (joystick->accel) {
|
||||
@ -1782,6 +1795,7 @@ int SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, S
|
||||
}
|
||||
|
||||
/* Update internal joystick state */
|
||||
SDL_assert(timestamp != 0);
|
||||
info->value = value;
|
||||
joystick->update_complete = timestamp;
|
||||
|
||||
@ -1825,6 +1839,7 @@ int SDL_SendJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 hat, Uin
|
||||
}
|
||||
|
||||
/* Update internal joystick state */
|
||||
SDL_assert(timestamp != 0);
|
||||
joystick->hats[hat] = value;
|
||||
joystick->update_complete = timestamp;
|
||||
|
||||
@ -1884,6 +1899,7 @@ int SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 butto
|
||||
}
|
||||
|
||||
/* Update internal joystick state */
|
||||
SDL_assert(timestamp != 0);
|
||||
joystick->buttons[button] = state;
|
||||
joystick->update_complete = timestamp;
|
||||
|
||||
@ -1953,7 +1969,7 @@ void SDL_UpdateJoysticks(void)
|
||||
|
||||
event.type = SDL_EVENT_JOYSTICK_UPDATE_COMPLETE;
|
||||
event.common.timestamp = joystick->update_complete;
|
||||
event.gdevice.which = joystick->instance_id;
|
||||
event.jdevice.which = joystick->instance_id;
|
||||
SDL_PushEvent(&event);
|
||||
|
||||
joystick->update_complete = 0;
|
||||
@ -3225,6 +3241,7 @@ int SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touch
|
||||
}
|
||||
|
||||
/* Update internal joystick state */
|
||||
SDL_assert(timestamp != 0);
|
||||
finger_info->state = state;
|
||||
finger_info->x = x;
|
||||
finger_info->y = y;
|
||||
|
@ -196,10 +196,10 @@ typedef struct SDL_GamepadMapping
|
||||
SDL_InputMapping dpleft;
|
||||
SDL_InputMapping dpright;
|
||||
SDL_InputMapping misc1;
|
||||
SDL_InputMapping paddle1;
|
||||
SDL_InputMapping paddle2;
|
||||
SDL_InputMapping paddle3;
|
||||
SDL_InputMapping paddle4;
|
||||
SDL_InputMapping right_paddle1;
|
||||
SDL_InputMapping left_paddle1;
|
||||
SDL_InputMapping right_paddle2;
|
||||
SDL_InputMapping left_paddle2;
|
||||
SDL_InputMapping leftx;
|
||||
SDL_InputMapping lefty;
|
||||
SDL_InputMapping rightx;
|
||||
|
@ -198,15 +198,16 @@ static SDL_Scancode button_to_scancode(int button)
|
||||
|
||||
int Android_OnPadDown(int device_id, int keycode)
|
||||
{
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
SDL_joylist_item *item;
|
||||
int button = keycode_to_SDL(keycode);
|
||||
if (button >= 0) {
|
||||
SDL_LockJoysticks();
|
||||
item = JoystickByDeviceId(device_id);
|
||||
if (item && item->joystick) {
|
||||
SDL_SendJoystickButton(0, item->joystick, button, SDL_PRESSED);
|
||||
SDL_SendJoystickButton(timestamp, item->joystick, button, SDL_PRESSED);
|
||||
} else {
|
||||
SDL_SendKeyboardKey(0, SDL_PRESSED, button_to_scancode(button));
|
||||
SDL_SendKeyboardKey(timestamp, SDL_PRESSED, button_to_scancode(button));
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
return 0;
|
||||
@ -217,15 +218,16 @@ int Android_OnPadDown(int device_id, int keycode)
|
||||
|
||||
int Android_OnPadUp(int device_id, int keycode)
|
||||
{
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
SDL_joylist_item *item;
|
||||
int button = keycode_to_SDL(keycode);
|
||||
if (button >= 0) {
|
||||
SDL_LockJoysticks();
|
||||
item = JoystickByDeviceId(device_id);
|
||||
if (item && item->joystick) {
|
||||
SDL_SendJoystickButton(0, item->joystick, button, SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, item->joystick, button, SDL_RELEASED);
|
||||
} else {
|
||||
SDL_SendKeyboardKey(0, SDL_RELEASED, button_to_scancode(button));
|
||||
SDL_SendKeyboardKey(timestamp, SDL_RELEASED, button_to_scancode(button));
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
return 0;
|
||||
@ -236,13 +238,14 @@ int Android_OnPadUp(int device_id, int keycode)
|
||||
|
||||
int Android_OnJoy(int device_id, int axis, float value)
|
||||
{
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
/* Android gives joy info normalized as [-1.0, 1.0] or [0.0, 1.0] */
|
||||
SDL_joylist_item *item;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
item = JoystickByDeviceId(device_id);
|
||||
if (item && item->joystick) {
|
||||
SDL_SendJoystickAxis(0, item->joystick, axis, (Sint16)(32767. * value));
|
||||
SDL_SendJoystickAxis(timestamp, item->joystick, axis, (Sint16)(32767. * value));
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
@ -251,6 +254,7 @@ int Android_OnJoy(int device_id, int axis, float value)
|
||||
|
||||
int Android_OnHat(int device_id, int hat_id, int x, int y)
|
||||
{
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
const int DPAD_UP_MASK = (1 << SDL_GAMEPAD_BUTTON_DPAD_UP);
|
||||
const int DPAD_DOWN_MASK = (1 << SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
||||
const int DPAD_LEFT_MASK = (1 << SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
||||
@ -278,16 +282,16 @@ int Android_OnHat(int device_id, int hat_id, int x, int y)
|
||||
dpad_delta = (dpad_state ^ item->dpad_state);
|
||||
if (dpad_delta) {
|
||||
if (dpad_delta & DPAD_UP_MASK) {
|
||||
SDL_SendJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (dpad_state & DPAD_UP_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (dpad_state & DPAD_UP_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
if (dpad_delta & DPAD_DOWN_MASK) {
|
||||
SDL_SendJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (dpad_state & DPAD_DOWN_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (dpad_state & DPAD_DOWN_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
if (dpad_delta & DPAD_LEFT_MASK) {
|
||||
SDL_SendJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (dpad_state & DPAD_LEFT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (dpad_state & DPAD_LEFT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
if (dpad_delta & DPAD_RIGHT_MASK) {
|
||||
SDL_SendJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (dpad_state & DPAD_RIGHT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (dpad_state & DPAD_RIGHT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
item->dpad_state = dpad_state;
|
||||
}
|
||||
|
@ -349,22 +349,24 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
}
|
||||
if (controller.physicalInputProfile.buttons[GCInputXboxPaddleOne] != nil) {
|
||||
device->has_xbox_paddles = SDL_TRUE;
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_PADDLE1);
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1);
|
||||
++nbuttons;
|
||||
}
|
||||
if (controller.physicalInputProfile.buttons[GCInputXboxPaddleTwo] != nil) {
|
||||
/* TODO: Is this right? SDL_gamepad.h says P2 is the lower right */
|
||||
device->has_xbox_paddles = SDL_TRUE;
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_PADDLE2);
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_LEFT_PADDLE1);
|
||||
++nbuttons;
|
||||
}
|
||||
if (controller.physicalInputProfile.buttons[GCInputXboxPaddleThree] != nil) {
|
||||
/* TODO: Is this right? SDL_gamepad.h says P3 is the upper left */
|
||||
device->has_xbox_paddles = SDL_TRUE;
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_PADDLE3);
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2);
|
||||
++nbuttons;
|
||||
}
|
||||
if (controller.physicalInputProfile.buttons[GCInputXboxPaddleFour] != nil) {
|
||||
device->has_xbox_paddles = SDL_TRUE;
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_PADDLE4);
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_LEFT_PADDLE2);
|
||||
++nbuttons;
|
||||
}
|
||||
if (controller.physicalInputProfile.buttons[GCInputXboxShareButton] != nil) {
|
||||
@ -1055,16 +1057,16 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||
}
|
||||
|
||||
if (joystick->hwdata->has_xbox_paddles) {
|
||||
if (joystick->hwdata->button_mask & (1 << SDL_GAMEPAD_BUTTON_PADDLE1)) {
|
||||
if (joystick->hwdata->button_mask & (1 << SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1)) {
|
||||
buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleOne].isPressed;
|
||||
}
|
||||
if (joystick->hwdata->button_mask & (1 << SDL_GAMEPAD_BUTTON_PADDLE2)) {
|
||||
if (joystick->hwdata->button_mask & (1 << SDL_GAMEPAD_BUTTON_LEFT_PADDLE1)) {
|
||||
buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleTwo].isPressed;
|
||||
}
|
||||
if (joystick->hwdata->button_mask & (1 << SDL_GAMEPAD_BUTTON_PADDLE3)) {
|
||||
if (joystick->hwdata->button_mask & (1 << SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2)) {
|
||||
buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleThree].isPressed;
|
||||
}
|
||||
if (joystick->hwdata->button_mask & (1 << SDL_GAMEPAD_BUTTON_PADDLE4)) {
|
||||
if (joystick->hwdata->button_mask & (1 << SDL_GAMEPAD_BUTTON_LEFT_PADDLE2)) {
|
||||
buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleFour].isPressed;
|
||||
}
|
||||
|
||||
@ -1826,16 +1828,18 @@ const char *IOS_GetAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_Gamepad
|
||||
case SDL_GAMEPAD_BUTTON_MISC1:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputDualShockTouchpadButton], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_PADDLE1:
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleOne], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_PADDLE2:
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_PADDLE1:
|
||||
/* TODO: Is this right? SDL_gamepad.h says P2 is the lower right */
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleTwo], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_PADDLE3:
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2:
|
||||
/* TODO: Is this right? SDL_gamepad.h says P3 is the upper left */
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleThree], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_PADDLE4:
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_PADDLE2:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleFour], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD:
|
||||
|
@ -97,6 +97,7 @@ static const ControllerDescription_t arrControllers[] = {
|
||||
{ MAKE_CONTROLLER_ID( 0x0c12, 0x1e10 ), k_eControllerType_PS4Controller, NULL }, // P4 Wired Gamepad generic knock off - lightbar but not trackpad or gyro
|
||||
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0203 ), k_eControllerType_PS4Controller, NULL }, // Victrix Pro FS (PS4 peripheral but no trackpad/lightbar)
|
||||
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0207 ), k_eControllerType_PS4Controller, NULL }, // Victrix Pro FS V2 w/ Touchpad for PS4
|
||||
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x020a ), k_eControllerType_PS4Controller, NULL }, // Victrix Pro FS PS4/PS5 (PS4 mode)
|
||||
{ MAKE_CONTROLLER_ID( 0x0f0d, 0x0055 ), k_eControllerType_PS4Controller, NULL }, // HORIPAD 4 FPS
|
||||
{ MAKE_CONTROLLER_ID( 0x0f0d, 0x005e ), k_eControllerType_PS4Controller, NULL }, // HORI Fighting Commander 4 PS4
|
||||
{ MAKE_CONTROLLER_ID( 0x0f0d, 0x0066 ), k_eControllerType_PS4Controller, NULL }, // HORIPAD 4 FPS Plus
|
||||
@ -148,6 +149,7 @@ static const ControllerDescription_t arrControllers[] = {
|
||||
|
||||
{ MAKE_CONTROLLER_ID( 0x054c, 0x0ce6 ), k_eControllerType_PS5Controller, NULL }, // Sony DualSense Controller
|
||||
{ MAKE_CONTROLLER_ID( 0x054c, 0x0df2 ), k_eControllerType_PS5Controller, NULL }, // Sony DualSense Edge Controller
|
||||
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0209 ), k_eControllerType_PS5Controller, NULL }, // Victrix Pro FS PS4/PS5 (PS5 mode)
|
||||
{ MAKE_CONTROLLER_ID( 0x0f0d, 0x0163 ), k_eControllerType_PS5Controller, NULL }, // HORI Fighting Commander OCTA
|
||||
{ MAKE_CONTROLLER_ID( 0x0f0d, 0x0184 ), k_eControllerType_PS5Controller, NULL }, // Hori Fighting Stick α
|
||||
{ MAKE_CONTROLLER_ID( 0x1532, 0x100b ), k_eControllerType_PS5Controller, NULL }, // Razer Wolverine V2 Pro (Wired)
|
||||
|
@ -694,20 +694,21 @@ static void HIDAPI_DriverPS4_TickleBluetooth(SDL_HIDAPI_Device *device)
|
||||
|
||||
static void HIDAPI_DriverPS4_SetEnhancedModeAvailable(SDL_DriverPS4_Context *ctx)
|
||||
{
|
||||
if (!ctx->effects_supported) {
|
||||
/* We shouldn't be sending any packets to the controller */
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->enhanced_mode_available = SDL_TRUE;
|
||||
|
||||
if (ctx->touchpad_supported) {
|
||||
SDL_PrivateJoystickAddTouchpad(ctx->joystick, 2);
|
||||
ctx->report_touchpad = SDL_TRUE;
|
||||
}
|
||||
|
||||
if (ctx->sensors_supported) {
|
||||
SDL_PrivateJoystickAddSensor(ctx->joystick, SDL_SENSOR_GYRO, 250.0f);
|
||||
SDL_PrivateJoystickAddSensor(ctx->joystick, SDL_SENSOR_ACCEL, 250.0f);
|
||||
}
|
||||
|
||||
if (ctx->device->is_bluetooth && ctx->official_controller) {
|
||||
ctx->report_battery = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void HIDAPI_DriverPS4_SetEnhancedMode(SDL_DriverPS4_Context *ctx)
|
||||
@ -716,17 +717,10 @@ static void HIDAPI_DriverPS4_SetEnhancedMode(SDL_DriverPS4_Context *ctx)
|
||||
HIDAPI_DriverPS4_SetEnhancedModeAvailable(ctx);
|
||||
}
|
||||
|
||||
if (!ctx->enhanced_mode && ctx->enhanced_mode_available) {
|
||||
if (!ctx->enhanced_mode) {
|
||||
ctx->enhanced_mode = SDL_TRUE;
|
||||
|
||||
if (ctx->touchpad_supported) {
|
||||
ctx->report_touchpad = SDL_TRUE;
|
||||
}
|
||||
|
||||
if (ctx->device->is_bluetooth && ctx->official_controller) {
|
||||
ctx->report_battery = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Switch into enhanced report mode */
|
||||
HIDAPI_DriverPS4_UpdateEffects(ctx, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
@ -888,12 +882,20 @@ static int HIDAPI_DriverPS4_InternalSendJoystickEffect(SDL_DriverPS4_Context *ct
|
||||
Uint8 data[78];
|
||||
int report_size, offset;
|
||||
|
||||
if (application_usage) {
|
||||
HIDAPI_DriverPS4_UpdateEnhancedModeOnApplicationUsage(ctx);
|
||||
if (!ctx->effects_supported) {
|
||||
/* We shouldn't be sending packets to this controller */
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
if (!ctx->enhanced_mode_available) {
|
||||
return SDL_Unsupported();
|
||||
if (!ctx->enhanced_mode) {
|
||||
if (application_usage) {
|
||||
HIDAPI_DriverPS4_UpdateEnhancedModeOnApplicationUsage(ctx);
|
||||
}
|
||||
|
||||
if (!ctx->enhanced_mode) {
|
||||
/* We're not in enhanced mode, effects aren't allowed */
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
SDL_zeroa(data);
|
||||
@ -1059,7 +1061,7 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
|
||||
axis = ((int)packet->ucRightJoystickY * 257) - 32768;
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
|
||||
if (size > 9 && ctx->report_battery) {
|
||||
if (size > 9 && ctx->report_battery && ctx->enhanced_reports) {
|
||||
/* Battery level ranges from 0 to 10 */
|
||||
int level = (packet->ucBatteryLevel & 0xF);
|
||||
if (level == 0) {
|
||||
@ -1073,7 +1075,7 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
|
||||
}
|
||||
}
|
||||
|
||||
if (size > 9 && ctx->report_touchpad) {
|
||||
if (size > 9 && ctx->report_touchpad && ctx->enhanced_reports) {
|
||||
touchpad_state = !(packet->ucTouchpadCounter1 & 0x80) ? SDL_PRESSED : SDL_RELEASED;
|
||||
touchpad_x = packet->rgucTouchpadData1[0] | (((int)packet->rgucTouchpadData1[1] & 0x0F) << 8);
|
||||
touchpad_y = (packet->rgucTouchpadData1[1] >> 4) | ((int)packet->rgucTouchpadData1[2] << 4);
|
||||
|
@ -412,7 +412,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
||||
/* Connected over Bluetooth, using simple reports (DirectInput enabled) */
|
||||
}
|
||||
|
||||
if (ctx->enhanced_reports) {
|
||||
if (device->vendor_id == USB_VENDOR_SONY && ctx->enhanced_reports) {
|
||||
/* Read the serial number (Bluetooth address in reverse byte order)
|
||||
This will also enable enhanced reports over Bluetooth
|
||||
*/
|
||||
@ -774,16 +774,13 @@ static void HIDAPI_DriverPS5_TickleBluetooth(SDL_HIDAPI_Device *device)
|
||||
|
||||
static void HIDAPI_DriverPS5_SetEnhancedModeAvailable(SDL_DriverPS5_Context *ctx)
|
||||
{
|
||||
if (!ctx->effects_supported) {
|
||||
/* We shouldn't be sending any packets to the controller */
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->enhanced_mode_available = SDL_TRUE;
|
||||
|
||||
if (ctx->touchpad_supported) {
|
||||
SDL_PrivateJoystickAddTouchpad(ctx->joystick, 2);
|
||||
ctx->report_touchpad = SDL_TRUE;
|
||||
}
|
||||
|
||||
if (ctx->sensors_supported) {
|
||||
if (ctx->device->is_bluetooth) {
|
||||
/* Bluetooth sensor update rate appears to be 1000 Hz */
|
||||
@ -794,6 +791,10 @@ static void HIDAPI_DriverPS5_SetEnhancedModeAvailable(SDL_DriverPS5_Context *ctx
|
||||
SDL_PrivateJoystickAddSensor(ctx->joystick, SDL_SENSOR_ACCEL, 250.0f);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->device->is_bluetooth) {
|
||||
ctx->report_battery = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void HIDAPI_DriverPS5_SetEnhancedMode(SDL_DriverPS5_Context *ctx)
|
||||
@ -805,14 +806,6 @@ static void HIDAPI_DriverPS5_SetEnhancedMode(SDL_DriverPS5_Context *ctx)
|
||||
if (!ctx->enhanced_mode && ctx->enhanced_mode_available) {
|
||||
ctx->enhanced_mode = SDL_TRUE;
|
||||
|
||||
if (ctx->touchpad_supported) {
|
||||
ctx->report_touchpad = SDL_TRUE;
|
||||
}
|
||||
|
||||
if (ctx->device->is_bluetooth) {
|
||||
ctx->report_battery = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Switch into enhanced report mode */
|
||||
HIDAPI_DriverPS5_UpdateEffects(ctx, 0, SDL_FALSE);
|
||||
|
||||
@ -1017,12 +1010,20 @@ static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ct
|
||||
int *pending_size;
|
||||
int maximum_size;
|
||||
|
||||
if (application_usage) {
|
||||
HIDAPI_DriverPS5_UpdateEnhancedModeOnApplicationUsage(ctx);
|
||||
if (!ctx->effects_supported) {
|
||||
/* We shouldn't be sending packets to this controller */
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
if (!ctx->enhanced_mode_available) {
|
||||
return SDL_Unsupported();
|
||||
if (!ctx->enhanced_mode) {
|
||||
if (application_usage) {
|
||||
HIDAPI_DriverPS5_UpdateEnhancedModeOnApplicationUsage(ctx);
|
||||
}
|
||||
|
||||
if (!ctx->enhanced_mode) {
|
||||
/* We're not in enhanced mode, effects aren't allowed */
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
SDL_zeroa(data);
|
||||
|
@ -1153,23 +1153,15 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
(ctx->m_state.ulButtons & STEAM_BUTTON_BACK_LEFT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1 + 1,
|
||||
(ctx->m_state.ulButtons & STEAM_BUTTON_BACK_RIGHT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
{
|
||||
/* Minimum distance from center of pad to register a direction */
|
||||
const int kPadDeadZone = 10000;
|
||||
|
||||
/* Pad coordinates are like math grid coordinates: negative is bottom left */
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP,
|
||||
(ctx->m_state.sLeftPadY > kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
(ctx->m_state.ulButtons & STEAM_TOUCH_0_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN,
|
||||
(ctx->m_state.sLeftPadY < -kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
(ctx->m_state.ulButtons & STEAM_TOUCH_3_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT,
|
||||
(ctx->m_state.sLeftPadX < -kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
(ctx->m_state.ulButtons & STEAM_TOUCH_2_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
|
||||
(ctx->m_state.sLeftPadX > kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED);
|
||||
(ctx->m_state.ulButtons & STEAM_TOUCH_1_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, (int)ctx->m_state.sTriggerL * 2 - 32768);
|
||||
|
@ -1888,8 +1888,8 @@ static void HandleCombinedControllerStateL(Uint64 timestamp, SDL_Joystick *joyst
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE4, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE2, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
axis = (data & 0x80) ? 32767 : -32768;
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
@ -1923,8 +1923,8 @@ static void HandleMiniControllerStateL(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE2, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE4, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
axis = packet->controllerState.rgucJoystickLeft[0] | ((packet->controllerState.rgucJoystickLeft[1] & 0xF) << 8);
|
||||
@ -1946,8 +1946,8 @@ static void HandleCombinedControllerStateR(Uint64 timestamp, SDL_Joystick *joyst
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE1, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE3, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
axis = (data & 0x80) ? 32767 : -32768;
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
@ -1981,8 +1981,8 @@ static void HandleMiniControllerStateR(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE1, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE3, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (packet->controllerState.rgucButtons[1] != ctx->m_lastFullState.controllerState.rgucButtons[1]) {
|
||||
|
@ -1149,7 +1149,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor)
|
||||
}
|
||||
for (i = 0; i < ABS_MAX; ++i) {
|
||||
/* Skip digital hats */
|
||||
if (joystick->hwdata->has_hat[(i - ABS_HAT0X) / 2]) {
|
||||
if (i >= ABS_HAT0X && i <= ABS_HAT3Y && joystick->hwdata->has_hat[(i - ABS_HAT0X) / 2]) {
|
||||
continue;
|
||||
}
|
||||
if (test_bit(i, absbit)) {
|
||||
@ -1553,6 +1553,8 @@ static int LINUX_JoystickSendEffect(SDL_Joystick *joystick, const void *data, in
|
||||
|
||||
static int LINUX_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled)
|
||||
{
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (!joystick->hwdata->has_accelerometer && !joystick->hwdata->has_gyro) {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
@ -1723,6 +1725,8 @@ static void PollAllSensors(Uint64 timestamp, SDL_Joystick *joystick)
|
||||
struct input_absinfo absinfo;
|
||||
int i;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
SDL_assert(joystick->hwdata->fd_sensor >= 0);
|
||||
|
||||
if (joystick->hwdata->has_gyro) {
|
||||
@ -2513,19 +2517,19 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap
|
||||
joystick->hwdata->has_key[BTN_TRIGGER_HAPPY6] &&
|
||||
joystick->hwdata->has_key[BTN_TRIGGER_HAPPY7] &&
|
||||
joystick->hwdata->has_key[BTN_TRIGGER_HAPPY8]) {
|
||||
out->paddle1.kind = EMappingKind_Button;
|
||||
out->paddle1.target = joystick->hwdata->key_map[BTN_TRIGGER_HAPPY5];
|
||||
out->paddle2.kind = EMappingKind_Button;
|
||||
out->paddle2.target = joystick->hwdata->key_map[BTN_TRIGGER_HAPPY7];
|
||||
out->paddle3.kind = EMappingKind_Button;
|
||||
out->paddle3.target = joystick->hwdata->key_map[BTN_TRIGGER_HAPPY6];
|
||||
out->paddle4.kind = EMappingKind_Button;
|
||||
out->paddle4.target = joystick->hwdata->key_map[BTN_TRIGGER_HAPPY8];
|
||||
out->right_paddle1.kind = EMappingKind_Button;
|
||||
out->right_paddle1.target = joystick->hwdata->key_map[BTN_TRIGGER_HAPPY5];
|
||||
out->left_paddle1.kind = EMappingKind_Button;
|
||||
out->left_paddle1.target = joystick->hwdata->key_map[BTN_TRIGGER_HAPPY7];
|
||||
out->right_paddle2.kind = EMappingKind_Button;
|
||||
out->right_paddle2.target = joystick->hwdata->key_map[BTN_TRIGGER_HAPPY6];
|
||||
out->left_paddle2.kind = EMappingKind_Button;
|
||||
out->left_paddle2.target = joystick->hwdata->key_map[BTN_TRIGGER_HAPPY8];
|
||||
#ifdef DEBUG_GAMEPAD_MAPPING
|
||||
SDL_Log("Mapped PADDLE1 to button %d (BTN_TRIGGER_HAPPY5)", out->paddle1.target);
|
||||
SDL_Log("Mapped PADDLE2 to button %d (BTN_TRIGGER_HAPPY7)", out->paddle2.target);
|
||||
SDL_Log("Mapped PADDLE3 to button %d (BTN_TRIGGER_HAPPY6)", out->paddle3.target);
|
||||
SDL_Log("Mapped PADDLE4 to button %d (BTN_TRIGGER_HAPPY8)", out->paddle4.target);
|
||||
SDL_Log("Mapped RIGHT_PADDLE1 to button %d (BTN_TRIGGER_HAPPY5)", out->right_paddle1.target);
|
||||
SDL_Log("Mapped LEFT_PADDLE1 to button %d (BTN_TRIGGER_HAPPY7)", out->left_paddle1.target);
|
||||
SDL_Log("Mapped RIGHT_PADDLE2 to button %d (BTN_TRIGGER_HAPPY6)", out->right_paddle2.target);
|
||||
SDL_Log("Mapped LEFT_PADDLE2 to button %d (BTN_TRIGGER_HAPPY8)", out->left_paddle2.target);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -198,10 +198,10 @@ static SDL_bool N3DS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapp
|
||||
.dpleft = { EMappingKind_Button, 5 },
|
||||
.dpright = { EMappingKind_Button, 4 },
|
||||
.misc1 = { EMappingKind_None, 255 },
|
||||
.paddle1 = { EMappingKind_None, 255 },
|
||||
.paddle2 = { EMappingKind_None, 255 },
|
||||
.paddle3 = { EMappingKind_None, 255 },
|
||||
.paddle4 = { EMappingKind_None, 255 },
|
||||
.right_paddle1 = { EMappingKind_None, 255 },
|
||||
.left_paddle1 = { EMappingKind_None, 255 },
|
||||
.right_paddle2 = { EMappingKind_None, 255 },
|
||||
.left_paddle2 = { EMappingKind_None, 255 },
|
||||
.leftx = { EMappingKind_Axis, 0 },
|
||||
.lefty = { EMappingKind_Axis, 1 },
|
||||
.rightx = { EMappingKind_Axis, 2 },
|
||||
|
@ -669,24 +669,24 @@ static SDL_bool VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadM
|
||||
out->misc1.target = current_button++;
|
||||
}
|
||||
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_PADDLE1))) {
|
||||
out->paddle1.kind = EMappingKind_Button;
|
||||
out->paddle1.target = current_button++;
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1))) {
|
||||
out->right_paddle1.kind = EMappingKind_Button;
|
||||
out->right_paddle1.target = current_button++;
|
||||
}
|
||||
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_PADDLE2))) {
|
||||
out->paddle2.kind = EMappingKind_Button;
|
||||
out->paddle2.target = current_button++;
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_LEFT_PADDLE1))) {
|
||||
out->left_paddle1.kind = EMappingKind_Button;
|
||||
out->left_paddle1.target = current_button++;
|
||||
}
|
||||
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_PADDLE3))) {
|
||||
out->paddle3.kind = EMappingKind_Button;
|
||||
out->paddle3.target = current_button++;
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2))) {
|
||||
out->right_paddle2.kind = EMappingKind_Button;
|
||||
out->right_paddle2.target = current_button++;
|
||||
}
|
||||
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_PADDLE4))) {
|
||||
out->paddle4.kind = EMappingKind_Button;
|
||||
out->paddle4.target = current_button++;
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_LEFT_PADDLE2))) {
|
||||
out->left_paddle2.kind = EMappingKind_Button;
|
||||
out->left_paddle2.target = current_button++;
|
||||
}
|
||||
|
||||
if (current_axis < hwdata->desc.naxes && (hwdata->desc.axis_mask & (1 << SDL_GAMEPAD_AXIS_LEFTX))) {
|
||||
|
Reference in New Issue
Block a user