Configuring XInput (Xbox Controller) Support for Linux
The purpose of this article is to help you setup xbox controller input using XInput on a Linux OS
Background
Linux does not officially support Xinput. There's a few drivers available such as xpad
(Kernel Module) or xboxdrv
to support these Xinput controllers, since Linux 6.1 the xpad
has native support for Xbox Controller mode on Wooting keyboards up to Two HE AVR and 60HE ARM. So for these models, the Xbox Controller mode should work out of the box. So for most users, this guide is not necessary
This guide helps setup the configuration so that the aforementioned drivers can be used for Xinput analog input.
There's two configuration scenarios:
- The Xinput driver is automatically applied every time a Wooting keyboard is connected
- The driver is applied manually by the user
For the first scenario, a service has to be added to handle the driver which is controlled by udev rules every time a Wooting keyboard is detected.
For the second scenario, other rules need to be added to grant a dedicated group access to the device and the driver. This will require the user to start it with a command and higher privileges.
Preconditions
Some Linux distributions already have "xboxdrv" installed, but if not you need to install that package first by running this command:
Debian based (Ubuntu / Linux Mint / Pop! OS etc)
sudo apt-get install xboxdrv -y
Arch based
The official repos do not contain a package for xboxdrv, it's only available in the AUR. If you're using an AUR helper such as yay
you can just run this:
yay -S xboxdrv
Scenario 1 – Automatic driver assignment
Creating the service for driver assignment
Create a new file called 'wooting-xinput@.service' under the path '/etc/systemd/system/' with the following content. The name should not be changed because it’s used in the udev rules later on and the file extension must be 'service' otherwise it won't work.
'/etc/systemd/system/wooting-xinput@.service'
[Unit]
Description=Loads the xboxdrv user-space-driver for the native Xbox 360 interface of the Wootings
StopWhenUnneeded=true
[Service]
Type=simple
ExecStart=/usr/bin/xboxdrv --type xbox360 --device-by-id %I --silent --quiet --detach-kernel-driver --mimic-xpad
Applying the service
In order the service can be used the changed systemd manager configuration need to be reloaded by running this command: sudo systemctl daemon-reload
Creating the rules for controlling the service
Create a new file called 'wooting-xinput.rules' under the path '/etc/udev/rules.d/' with the following content. The name can be changed but the file extension must be 'rules' otherwise it won't work.
'/etc/udev/rules.d/wooting-xinput.rules'
# Wooting One (Legacy / v3 Wootility)
SUBSYSTEM=="usb", ENV{PRODUCT}=="3eb/ff01/*", ENV{INTERFACE}=="255/93/1", TAG+="systemd", ENV{SYSTEMD_WANTS}="wooting-xinput@03eb:ff01"
# Wooting Two (Legacy / v3 Wootility)
SUBSYSTEM=="usb", ENV{PRODUCT}=="3eb/ff02/*", ENV{INTERFACE}=="255/93/1", TAG+="systemd", ENV{SYSTEMD_WANTS}="wooting-xinput@03eb:ff02"
# Wooting One
SUBSYSTEM=="usb", ENV{PRODUCT}=="31e3/1100/*", ENV{INTERFACE}=="255/93/1", TAG+="systemd", ENV{SYSTEMD_WANTS}="wooting-xinput@31e3:1100"
# Wooting Two
SUBSYSTEM=="usb", ENV{PRODUCT}=="31e3/1200/*", ENV{INTERFACE}=="255/93/1", TAG+="systemd", ENV{SYSTEMD_WANTS}="wooting-xinput@31e3:1200"
# Wooting Two Lekker Edition
SUBSYSTEM=="usb", ENV{PRODUCT}=="31e3/1210/*", ENV{INTERFACE}=="255/93/1", TAG+="systemd", ENV{SYSTEMD_WANTS}="wooting-xinput@31e3:1210"
# Wooting Two HE
SUBSYSTEM=="usb", ENV{PRODUCT}=="31e3/1220/*", ENV{INTERFACE}=="255/93/1", TAG+="systemd", ENV{SYSTEMD_WANTS}="wooting-xinput@31e3:1220"
# Wooting Two HE (ARM)
SUBSYSTEM=="usb", ENV{PRODUCT}=="31e3/1230/*", ENV{INTERFACE}=="255/93/1", TAG+="systemd", ENV{SYSTEMD_WANTS}="wooting-xinput@31e3:1230"
# Wooting 60HE
SUBSYSTEM=="usb", ENV{PRODUCT}=="31e3/1300/*", ENV{INTERFACE}=="255/93/1", TAG+="systemd", ENV{SYSTEMD_WANTS}="wooting-xinput@31e3:1300"
# Wooting 60HE (ARM)
SUBSYSTEM=="usb", ENV{PRODUCT}=="31e3/1310/*", ENV{INTERFACE}=="255/93/1", TAG+="systemd", ENV{SYSTEMD_WANTS}="wooting-xinput@31e3:1310"
Applying the new rules
To activate the rules they must be loaded and applied by the following command:
sudo udevadm control --reload-rules && sudo udevadm trigger
It can happen that this still doesn't apply and activate the rules, then a reboot of your whole system is required.
Scenario 2 – Manual driver assignment
Creating the rules for granting user access
Create a new file called 'wooting-xinput.rules' under the path '/etc/udev/rules.d/' with the following content. The name can be changed but the file extension must be 'rules' otherwise it won't work.
'/etc/udev/rules.d/wooting-xinput.rules'
# Granting all members of the group "input" user access the XInput driver "xboxdrv"
KERNEL=="uinput", MODE="0660", GROUP="input", OPTIONS+="static_node=uinput"
# Wooting One (Legacy / v3 Wootility)
SUBSYSTEM=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="ff01", MODE="0660", GROUP="input"
# Wooting Two (Legacy / v3 Wootility)
SUBSYSTEM=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="ff02", MODE="0660", GROUP="input"
# Generic Wooting devices
SUBSYSTEM=="usb", ATTRS{idVendor}=="31e3", MODE="0660", GROUP="input"
These rules will provide every user in the group 'input' the ability to load the driver manually without the need of running the command with advanced privileges such as sudo. This is needed because xboxdrv needs access to the RAW data of the interfaces of the device.
Applying the new rules
To activate the rules they must be loaded and applied by the following command:
sudo udevadm control --reload-rules && sudo udevadm trigger
It can happen that this still doesn't apply and activate the rules, then a reboot of your whole system is required.
Loading the driver
For a Wooting One (Legacy/v3 Wootility) the driver can be manually loaded by this command:
xboxdrv --type xbox360 --device-by-id 03eb:ff01 --silent --quiet --detach-kernel-driver --mimic-xpad
For a Wooting Two (Legacy/v3 Wootility) with this command:
xboxdrv --type xbox360 --device-by-id 03eb:ff02 --silent --quiet --detach-kernel-driver --mimic-xpad
For a Wooting Two Lekker Edition with this command:
xboxdrv --type xbox360 --device-by-id 31e3:1210 --silent --quiet --detach-kernel-driver --mimic-xpad
For a Wooting Two HE with this command:
xboxdrv --type xbox360 --device-by-id 31e3:1220 --silent --quiet --detach-kernel-driver --mimic-xpad
For a Wooting Two HE (ARM) with this command:
xboxdrv --type xbox360 --device-by-id 31e3:1230 --silent --quiet --detach-kernel-driver --mimic-xpad
For a Wooting 60HE with this command:
xboxdrv --type xbox360 --device-by-id 31e3:1300 --silent --quiet --detach-kernel-driver --mimic-xpad
For a Wooting 60HE (ARM) with this command:
xboxdrv --type xbox360 --device-by-id 31e3:1300 --silent --quiet --detach-kernel-driver --mimic-xpad
The option "silent" and "quiet" suppresses the output of the controls of the device, "detach-kernel-driver" unloads any already used kernel driver for the device like if "xpad" is used and "mimic-xpad" forces the driver to use the same controls and appearance like xpad to provide compatibility for games.
Credit for this helpdoc: @Rocky_4 on Discord