Skip to content

Commit

Permalink
xpadneo, core: Deprecate synthetic rolling axis from triggers
Browse files Browse the repository at this point in the history
This causes bugs in some applications, seemingly Unity games, and maybe
a few others. This commit introduces a new module parameter
`enable_rolling_axis` defaulting to "disabled", essentially removing
the axis from default installations.

Enabling it will emit a deprecation warning. This is better solved in
user-space. Scheduled for removal after v0.10.

Maybe-affects: #457
Maybe-affects: #452
Fixes: #385
Fixes: #345
Fixes: #334
Signed-off-by: Kai Krakow <[email protected]>
  • Loading branch information
kakra committed Feb 13, 2024
1 parent 4c90d74 commit 2e3b406
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions hid-xpadneo/src/hid-xpadneo.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ MODULE_PARM_DESC(disable_deadzones,
"(bool) Disable dead zone handling for raw processing by Wine/Proton, confuses joydev. "
"0: disable, 1: enable.");

static bool param_enable_rolling_axis = 0;
module_param_named(enable_rolling_axis, param_enable_rolling_axis, bool, 0444);
MODULE_PARM_DESC(enable_rolling_axis,
"(bool) Enable rolling axis by combining both triggers, out of spec for many games. (deprecated) "
"0: disable, 1: enable.");

static struct {
char *args[17];
unsigned int nargs;
Expand Down Expand Up @@ -878,7 +884,10 @@ static int xpadneo_input_configured(struct hid_device *hdev, struct hid_input *h
input_set_abs_params(xdata->gamepad, ABS_RZ, 0, 1023, 4, 0);

/* combine triggers to form a rudder, use ABS_MISC to order after dpad */
input_set_abs_params(xdata->gamepad, ABS_MISC, -1023, 1023, 3, 63);
if (param_enable_rolling_axis) {
hid_info(hdev, "enabling rolling axis is deprecated\n");
input_set_abs_params(xdata->gamepad, ABS_MISC, -1023, 1023, 3, 63);
}

/* do not report the keyboard buttons as part of the gamepad */
__clear_bit(BTN_SHARE, xdata->gamepad->keybit);
Expand Down Expand Up @@ -995,7 +1004,8 @@ static int xpadneo_event(struct hid_device *hdev, struct hid_field *field,
combine_z_axes:
if (++xdata->count_abs_z_rz == 2) {
xdata->count_abs_z_rz = 0;
input_report_abs(gamepad, ABS_MISC, xdata->last_abs_rz - xdata->last_abs_z);
if (param_enable_rolling_axis)
input_report_abs(gamepad, ABS_MISC, xdata->last_abs_rz - xdata->last_abs_z);
}
return 0;

Expand Down

0 comments on commit 2e3b406

Please sign in to comment.