Skip to content

Commit

Permalink
xpadneo, deadzones: Implement a high-precision mode without dead zones
Browse files Browse the repository at this point in the history
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: atar-axis#231
Signed-off-by: Kai Krakow <[email protected]>
  • Loading branch information
kakra committed Jul 17, 2020
1 parent 738e497 commit 1de9060
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" ]];
Expand Down
3 changes: 3 additions & 0 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions hid-xpadneo/src/hid-xpadneo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1de9060

Please sign in to comment.