From 85961b61a187bd77540804105112f79f5faab8dc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 16 Jan 2022 09:01:56 -0800 Subject: [PATCH] Disable Xbox axis deadzone handling by default Fixes https://github.com/libsdl-org/SDL/issues/5227 --- src/joystick/hidapi/SDL_hidapi_xboxone.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index e325c9fca..a98d7d997 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -40,6 +40,12 @@ /* Define this if you want to log all packets from the controller */ /*#define DEBUG_XBOX_PROTOCOL*/ +/* Define this if you want deadzone filtering done at this level. + * This introduces several issues, so this is disabled by default: + * https://github.com/libsdl-org/SDL/issues/5227 + */ +/* #define ENABLE_AXIS_FILTERING */ + #define CONTROLLER_NEGOTIATION_TIMEOUT_MS 300 #define CONTROLLER_PREPARE_INPUT_TIMEOUT_MS 50 @@ -480,25 +486,31 @@ HIDAPI_DriverXboxOne_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Jo static Sint16 FilterLeftThumb(Sint16 axis) { +#ifdef ENABLE_AXIS_FILTERING if (axis <= XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE && axis >= -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { return 0; } +#endif return axis; } static Sint16 FilterRightThumb(Sint16 axis) { +#ifdef ENABLE_AXIS_FILTERING if (axis <= XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE && axis >= -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { return 0; } +#endif return axis; } static Sint16 FilterTrigger(Sint16 axis) { +#ifdef ENABLE_AXIS_FILTERING if (axis <= XINPUT_GAMEPAD_TRIGGER_THRESHOLD) { return SDL_MIN_SINT16; } +#endif return axis; }