From 1de9060bdd7b3c54e5a14e426de8c35879020713 Mon Sep 17 00:00:00 2001 From: Kai Krakow Date: Fri, 17 Jul 2020 23:15:00 +0200 Subject: [PATCH] xpadneo, deadzones: Implement a high-precision mode without dead zones This adds a module parameter `disable_deadzones` to remove dead zone handling from upper layers. This is only useful if you're a playing games in Wine or Proton as otherwise SDL introduces a dead zone handler which seriously hurts precision compared to native Windows usage of the controller. Do not use this if you intend to play native games that make use of the `joydev` API in Linux as the removal of the dead zones introduces axis shift and phantom movement. In Windows, games are supposed to handle dead zones by themselves while in Linux the drivers to this. Fixes: https://github.com/atar-axis/xpadneo/issues/231 Signed-off-by: Kai Krakow --- configure.sh | 2 +- docs/CONFIGURATION.md | 3 +++ docs/README.md | 1 + hid-xpadneo/src/hid-xpadneo.c | 11 +++++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/configure.sh b/configure.sh index 9b8d6021..b0708758 100755 --- a/configure.sh +++ b/configure.sh @@ -110,7 +110,7 @@ function parse_args { # If line doesn't exist echo all of the defaults. mkdir -p "$(dirname "${CONF_FILE}")" touch "${CONF_FILE}" - echo "options hid_xpadneo disable_ff=0 rumble_attenuation=0 trigger_rumble_mode=0 combined_z_axis=n" >> "$CONF_FILE" + echo "options hid_xpadneo disable_ff=0 disable_deadzones=0 rumble_attenuation=0 trigger_rumble_mode=0 combined_z_axis=n" >> "$CONF_FILE" fi if [[ $1 == "" ]]; diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 426960c9..1daa46b6 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -5,6 +5,9 @@ The driver can be reconfigured at runtime by accessing the following sysfs files in `/sys/module/hid_xpadneo/parameters`: +* `disable_deadzones` (default `0`) + * `0` enables standard behavior to be compatible with `joydev` expectations + * `1` enables raw passthrough of axis values without dead zones for high-precision use with modern Wine/Proton games * `trigger_rumble_mode` (default `0`) * `0` rumbles triggers by pressure and current rumble effect * `1` rumbles triggers by force direction (non-conformant) diff --git a/docs/README.md b/docs/README.md index 6bc982f4..5e55fddb 100644 --- a/docs/README.md +++ b/docs/README.md @@ -41,6 +41,7 @@ These other projects may not support some of the advanced features of xpadneo. * Easy Installation * Agile Support and Development * Supports customization through profiles +* Optional high-precision mode for Wine/Proton users ### Xbox One S Wireless controller diff --git a/hid-xpadneo/src/hid-xpadneo.c b/hid-xpadneo/src/hid-xpadneo.c index ba3f4399..6d1905fd 100644 --- a/hid-xpadneo/src/hid-xpadneo.c +++ b/hid-xpadneo/src/hid-xpadneo.c @@ -76,6 +76,12 @@ MODULE_PARM_DESC(gamepad_compliance, "(bool) Adhere to Linux Gamepad Specification by using signed axis values. " "1: enable, 0: disable."); +static bool param_disable_deadzones = 0; +module_param_named(disable_deadzones, param_disable_deadzones, bool, 0444); +MODULE_PARM_DESC(disable_deadzones, + "(bool) Disable dead zone handling for raw processing by Wine/Proton, confuses joydev. " + "0: disable, 1: enable."); + #define XPADNEO_QUIRK_NO_PULSE 1 #define XPADNEO_QUIRK_NO_TRIGGER_RUMBLE 2 #define XPADNEO_QUIRK_NO_MOTOR_MASK 4 @@ -949,6 +955,11 @@ static int xpadneo_input_configured(struct hid_device *hdev, struct hid_input *h break; } + if (param_disable_deadzones) { + hid_warn(hdev, "disabling dead zones\n"); + deadzone = 0; + } + if (param_gamepad_compliance) { hid_info(hdev, "enabling compliance with Linux Gamepad Specification\n"); abs_min = -32768;