Fixed Xbox controller when using the default Linux gamepad mapping Tested with the Xbox Series X controller and the xow driver
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c
index 2064168..33d965b 100644
--- a/src/joystick/linux/SDL_sysjoystick.c
+++ b/src/joystick/linux/SDL_sysjoystick.c
@@ -1444,24 +1444,24 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
/* We have a gamepad, start filling out the mappings */
- if (joystick->hwdata->has_key[BTN_SOUTH]) {
+ if (joystick->hwdata->has_key[BTN_A]) {
out->a.kind = EMappingKind_Button;
- out->a.target = joystick->hwdata->key_map[BTN_SOUTH];
+ out->a.target = joystick->hwdata->key_map[BTN_A];
}
- if (joystick->hwdata->has_key[BTN_EAST]) {
+ if (joystick->hwdata->has_key[BTN_B]) {
out->b.kind = EMappingKind_Button;
- out->b.target = joystick->hwdata->key_map[BTN_EAST];
+ out->b.target = joystick->hwdata->key_map[BTN_B];
}
- if (joystick->hwdata->has_key[BTN_NORTH]) {
- out->y.kind = EMappingKind_Button;
- out->y.target = joystick->hwdata->key_map[BTN_NORTH];
+ if (joystick->hwdata->has_key[BTN_X]) {
+ out->x.kind = EMappingKind_Button;
+ out->x.target = joystick->hwdata->key_map[BTN_X];
}
- if (joystick->hwdata->has_key[BTN_WEST]) {
- out->x.kind = EMappingKind_Button;
- out->x.target = joystick->hwdata->key_map[BTN_WEST];
+ if (joystick->hwdata->has_key[BTN_Y]) {
+ out->y.kind = EMappingKind_Button;
+ out->y.target = joystick->hwdata->key_map[BTN_Y];
}
if (joystick->hwdata->has_key[BTN_SELECT]) {
@@ -1525,11 +1525,17 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
if (joystick->hwdata->has_key[BTN_TL2]) {
out->lefttrigger.kind = EMappingKind_Button;
out->lefttrigger.target = joystick->hwdata->key_map[BTN_TL2];
+ } else if (joystick->hwdata->has_abs[ABS_Z]) {
+ out->lefttrigger.kind = EMappingKind_Axis;
+ out->lefttrigger.target = joystick->hwdata->abs_map[ABS_Z];
}
if (joystick->hwdata->has_key[BTN_TR2]) {
out->righttrigger.kind = EMappingKind_Button;
out->righttrigger.target = joystick->hwdata->key_map[BTN_TR2];
+ } else if (joystick->hwdata->has_abs[ABS_RZ]) {
+ out->righttrigger.kind = EMappingKind_Axis;
+ out->righttrigger.target = joystick->hwdata->abs_map[ABS_RZ];
}
}