Skip to content
Permalink
Browse files
Linux: Add hint for disabling deadzones
  • Loading branch information
kakra committed Jul 21, 2020
1 parent 86517d3 commit c3ecf18cc43881cd4060f3af6f1903b28cc284b7
Showing with 15 additions and 1 deletion.
  1. +12 −0 include/SDL_hints.h
  2. +3 −1 src/joystick/linux/SDL_sysjoystick.c
@@ -696,6 +696,18 @@ extern "C" {
*/
#define SDL_HINT_JOYSTICK_RAWINPUT "SDL_JOYSTICK_RAWINPUT"

/**
* \brief A variable controlling whether Linux joysticks adhere their HID-defined deadzones or return unfiltered values.
* This is useful for Wine which implements its own deadzone handler if requested by games, also it enables xinput
* games to receive unfiltered values as required from the API.
*
* This variable can be set to the following values:
* "0" - Linux deadzones are not used by SDL
* "1" - Linux deadzones are used by SDL (the default)
*
*/
#define SDL_HINT_LINUX_JOYSTICK_DEADZONES "SDL_LINUX_JOYSTICK_DEADZONES"

/**
* \brief If set to "0" then never set the top most bit on a SDL Window, even if the video mode expects it.
* This is a debugging aid for developers and not expected to be used by end users. The default is "1"
@@ -38,6 +38,7 @@
#include <linux/joystick.h>

#include "SDL_assert.h"
#include "SDL_hints.h"
#include "SDL_joystick.h"
#include "SDL_endian.h"
#include "SDL_timer.h"
@@ -706,6 +707,7 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
}
if (test_bit(i, absbit)) {
struct input_absinfo absinfo;
SDL_bool hint_used = SDL_GetHintBoolean(SDL_HINT_LINUX_JOYSTICK_DEADZONES, SDL_TRUE);

if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0) {
continue;
@@ -721,7 +723,7 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
if (absinfo.minimum == absinfo.maximum) {
joystick->hwdata->abs_correct[i].used = 0;
} else {
joystick->hwdata->abs_correct[i].used = 1;
joystick->hwdata->abs_correct[i].used = hint_used;
joystick->hwdata->abs_correct[i].coef[0] =
(absinfo.maximum + absinfo.minimum) - 2 * absinfo.flat;
joystick->hwdata->abs_correct[i].coef[1] =

0 comments on commit c3ecf18

Please sign in to comment.