Skip to content

Commit

Permalink
Add configuration for disabling chords
Browse files Browse the repository at this point in the history
For use with steam, the button chord guide + A is mapped to the QAM. To not lose the profile switching behavior let the user configure this.
  • Loading branch information
BoukeHaarsma23 committed Jul 18, 2023
1 parent 9b3b696 commit ea59943
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ files in `/sys/module/hid_xpadneo/parameters`:
* `16` if your controller boots in Linux mode (auto-detected, do not change manually)
* `32` if you prefer to use Nintendo button mappings (i.e., 8BitDo controllers, defaults to off)
* `64` if your controller has a awkwardly mapped Share button (auto-detected, do not set manually)
* 'disable_shift_mode' (default 0)
* Let's you disable the button chords used with the XBOX button
* '0' Xbox logo button will be used as shift
* '1' will pass through the Xbox logo button as is

Some settings may need to be changed at loading time of the module, take a look at the following example to see how
that works:
Expand Down
21 changes: 14 additions & 7 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_disable_shift_mode = 0;
module_param_named(disable_shift_mode, param_disable_shift_mode, bool, 0644);
MODULE_PARAM_DESC(disable_shift_mode,
"(bool) Disable use Xbox logo button as shift. Will prohibit profile switching when enabled. "
"0: disable, 1: enable.");

static struct {
char *args[17];
unsigned int nargs;
Expand Down Expand Up @@ -931,13 +937,13 @@ static int xpadneo_event(struct hid_device *hdev, struct hid_field *field,
xdata->last_abs_rz = value;
goto combine_z_axes;
}
} else if ((usage->type == EV_KEY) && (usage->code == BTN_XBOX)) {
} else if (!param_disable_shift_mode && (usage->type == EV_KEY) && (usage->code == BTN_XBOX)) {
/*
* Handle the Xbox logo button: We want to cache the button
* down event to allow for profile switching. The button will
* act as a shift key and only send the input events when
* released without pressing an additional button.
*/
* Handle the Xbox logo button: We want to cache the button
* down event to allow for profile switching. The button will
* act as a shift key and only send the input events when
* released without pressing an additional button.
*/
if (!xdata->xbox_button_down && (value == 1)) {
/* cache this event */
xdata->xbox_button_down = true;
Expand All @@ -954,7 +960,8 @@ static int xpadneo_event(struct hid_device *hdev, struct hid_field *field,
input_sync(gamepad);
}
}
goto stop_processing;
}
goto stop_processing;
} else if ((usage->type == EV_KEY) && (usage->code == BTN_SHARE)) {
/* move the Share button to the keyboard device */
if (!keyboard)
Expand Down

0 comments on commit ea59943

Please sign in to comment.