mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Linux: Add hint for disabling deadzones
This commit is contained in:
parent
86517d3eda
commit
c3ecf18cc4
@ -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] =
|
||||
|
Loading…
Reference in New Issue
Block a user