Skip to content

Commit

Permalink
xpadneo, core: Add configuration for disabling Xbox logo shift-mode
Browse files Browse the repository at this point in the history
For use with Steam, the `Guide`+`A` is mapped to the QAM. To not lose
the profile switching behavior, let the user configure this.

Co-authored-by: Kai Krakow <[email protected]>
Fixes: #419
Closes: #435
Signed-off-by: Kai Krakow <[email protected]>
  • Loading branch information
BoukeHaarsma23 and kakra committed Feb 23, 2024
1 parent aa802d6 commit 12f4608
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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 Xbox logo button shift behavior
* '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
3 changes: 3 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ or Y while holding down the Xbox logo button. However, the following caveats app
- Full support will be available once the Xbox Elite Series 2 controller is fully supported.
- If you hold the button for too long, the controller will turn off - we cannot prevent that.

**Important:** Emulated profile switching won't work if you disabled the shift-mode of the Xbox logo button (module
parameter `disable_shift_mode`).


## Getting Started

Expand Down
9 changes: 8 additions & 1 deletion hid-xpadneo/src/hid-xpadneo.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ 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 bool param_disable_shift_mode = 0;
module_param_named(disable_shift_mode, param_disable_shift_mode, bool, 0644);
MODULE_PARM_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 @@ -947,7 +953,8 @@ 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
Expand Down

0 comments on commit 12f4608

Please sign in to comment.