Skip to content

Commit

Permalink
Add wireless dongle driver
Browse files Browse the repository at this point in the history
  • Loading branch information
medusalix committed Feb 6, 2022
1 parent 0c6e22d commit 9de0b2c
Show file tree
Hide file tree
Showing 11 changed files with 3,334 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Kbuild
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
xone-wired-y := transport/wired.o
xone-dongle-y := transport/dongle.o transport/mt76.o
xone-gip-bus-y := bus/bus.o bus/protocol.o
xone-gip-common-y := driver/common.o
xone-gip-gamepad-y := driver/gamepad.o
xone-gip-headset-y := driver/headset.o
xone-gip-chatpad-y := driver/chatpad.o
obj-m := xone-wired.o xone-gip-bus.o xone-gip-common.o xone-gip-gamepad.o xone-gip-headset.o xone-gip-chatpad.o
obj-m := xone-wired.o xone-dongle.o xone-gip-bus.o xone-gip-common.o xone-gip-gamepad.o xone-gip-headset.o xone-gip-chatpad.o
37 changes: 34 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Always update your Xbox devices to the latest firmware version!
- [x] Battery reporting (`UPower` integration)
- [x] LED control (using `/sys/class/leds`)
- [x] Audio capture/playback (through `ALSA`)
- [x] Power management (suspend/resume and remote wakeup)
- [ ] Wireless connectivity (via dongle)
- [x] Power management (suspend/resume and remote/wireless wakeup)
- [x] Wired and wireless connectivity (via dongle)

## Supported devices

Expand All @@ -38,6 +38,8 @@ Always update your Xbox devices to the latest firmware version!
- [x] Xbox One Chatpad
- [x] Xbox Adaptive Controller

⚠️ Standalone wireless headsets are currently not supported!

## Releases

[![Packaging status](https://repology.org/badge/vertical-allrepos/xone.svg)](https://repology.org/project/xone/versions)
Expand All @@ -51,6 +53,8 @@ Any issues regarding the packaging should be reported to the respective maintain

- Linux (kernel 4.15+ and headers)
- DKMS
- curl (for firmware download)
- cabextract (for firmware extraction)

### Guide

Expand All @@ -71,7 +75,15 @@ sudo ./install.sh --release

**NOTE:** Please omit the `--release` flag when asked for your debug logs.

4. Plug in your Xbox devices.
4. Download the firmware for the wireless dongle:

```
sudo xone-get-firmware.sh
```

**NOTE:** The `--skip-disclaimer` flag might be useful for scripting purposes.

5. Plug in your Xbox devices.

### Updating

Expand All @@ -95,12 +107,31 @@ echo 5 | sudo tee /sys/class/leds/gip*/brightness
Replace the wildcard (`gip*`) if you want to control the LED of a specific device.
The modes and the maximum brightness can vary from device to device.

### Pairing mode

The pairing mode of the dongle can be queried via `sysfs`:

```
cat /sys/bus/usb/drivers/xone-dongle/*/pairing
```

You can enable (`1`) or disable (`0`) the pairing using the following command:

```
echo 1 | sudo tee /sys/bus/usb/drivers/xone-dongle/*/pairing
```

## Troubleshooting

Uninstall the release version and install a debug build of `xone` (see installation guide).
Run `sudo dmesg` to gather logs and check for any error messages related to `xone`.
If `xone` is not being loaded automatically you might have to reboot your system.

### Error messages

- `Direct firmware load for xow_dongle.bin failed with error -2`
- Download the firmware for the wireless dongle (see installation guide).

### Input issues

You can use `evtest` to check if your input devices are working correctly.
Expand Down
12 changes: 7 additions & 5 deletions dkms.conf
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
PACKAGE_NAME="xone"
PACKAGE_VERSION="#VERSION#"
BUILT_MODULE_NAME[0]="xone-wired"
BUILT_MODULE_NAME[1]="xone-gip-bus"
BUILT_MODULE_NAME[2]="xone-gip-common"
BUILT_MODULE_NAME[3]="xone-gip-gamepad"
BUILT_MODULE_NAME[4]="xone-gip-headset"
BUILT_MODULE_NAME[5]="xone-gip-chatpad"
BUILT_MODULE_NAME[1]="xone-dongle"
BUILT_MODULE_NAME[2]="xone-gip-bus"
BUILT_MODULE_NAME[3]="xone-gip-common"
BUILT_MODULE_NAME[4]="xone-gip-gamepad"
BUILT_MODULE_NAME[5]="xone-gip-headset"
BUILT_MODULE_NAME[6]="xone-gip-chatpad"
DEST_MODULE_LOCATION[0]="/kernel/drivers/input/joystick"
DEST_MODULE_LOCATION[1]="/kernel/drivers/input/joystick"
DEST_MODULE_LOCATION[2]="/kernel/drivers/input/joystick"
DEST_MODULE_LOCATION[3]="/kernel/drivers/input/joystick"
DEST_MODULE_LOCATION[4]="/kernel/drivers/input/joystick"
DEST_MODULE_LOCATION[5]="/kernel/drivers/input/joystick"
DEST_MODULE_LOCATION[6]="/kernel/drivers/input/joystick"
AUTOINSTALL="yes"
11 changes: 11 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ if [ -n "$(dkms status xone)" ]; then
exit 1
fi

if [ -f /usr/local/bin/xow ]; then
echo 'Please uninstall xow!' >&2
exit 1
fi

version=$(git describe --tags 2> /dev/null || echo unknown)
source="/usr/src/xone-$version"
log="/var/lib/dkms/xone/$version/build/make.log"
Expand All @@ -32,11 +37,17 @@ fi
if dkms install -m xone -v "$version"; then
# The blacklist should be placed in /usr/local/lib/modprobe.d for kmod 29+
install -D -m 644 install/modprobe.conf /etc/modprobe.d/xone-blacklist.conf
install -D -m 755 install/firmware.sh /usr/local/bin/xone-get-firmware.sh

# Avoid conflicts between xpad and xone
if lsmod | grep -q '^xpad'; then
modprobe -r xpad
fi

# Avoid conflicts between mt76x2u and xone
if lsmod | grep -q '^mt76x2u'; then
modprobe -r mt76x2u
fi
else
if [ -r "$log" ]; then
cat "$log" >&2
Expand Down
35 changes: 35 additions & 0 deletions install/firmware.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env sh

set -eu

if [ "$(id -u)" -ne 0 ]; then
echo 'This script must be run as root!' >&2
exit 1
fi

if ! [ -x "$(command -v curl)" ]; then
echo 'This script requires curl!' >&2
exit 1
fi

if ! [ -x "$(command -v cabextract)" ]; then
echo 'This script requires cabextract!' >&2
exit 1
fi

if [ "${1:-}" != --skip-disclaimer ]; then
echo "The firmware for the wireless dongle is subject to Microsoft's Terms of Use:"
echo 'https://www.microsoft.com/en-us/legal/terms-of-use'
echo
echo 'Press enter to continue!'
read -r _
fi

driver_url='http://download.windowsupdate.com/c/msdownload/update/driver/drvs/2017/07/1cd6a87c-623f-4407-a52d-c31be49e925c_e19f60808bdcbfbd3c3df6be3e71ffc52e43261e.cab'
firmware_hash='48084d9fa53b9bb04358f3bb127b7495dc8f7bb0b3ca1437bd24ef2b6eabdf66'

curl -L -o driver.cab "$driver_url"
cabextract -F FW_ACC_00U.bin driver.cab
echo "$firmware_hash" FW_ACC_00U.bin | sha256sum -c
mv FW_ACC_00U.bin /lib/firmware/xow_dongle.bin
rm driver.cab
1 change: 1 addition & 0 deletions install/modprobe.conf
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
blacklist xpad
blacklist mt76x2u
Loading

0 comments on commit 9de0b2c

Please sign in to comment.