Skip to content

Instantly share code, notes, and snippets.

@rockavoldy
Last active August 17, 2021 04:44
Show Gist options
  • Save rockavoldy/c8fcd62707677adfa88b7cd5576339c6 to your computer and use it in GitHub Desktop.
Save rockavoldy/c8fcd62707677adfa88b7cd5576339c6 to your computer and use it in GitHub Desktop.
Fix knock-off china controller on linux
ACTION=="add", ATTRS{idProduct}=="028e", ATTRS{idVendor}=="045e", DRIVERS=="usb", RUN+="/opt/fixcontroller.py"
#!/usr/bin/env python3
import os
import sys
try:
import usb.core
import usb.util
except ImportError:
print("First, install the pyusb module with PIP or your package manager.")
else:
if os.geteuid() != 0:
print("You need to run this script with sudo")
sys.exit()
dev = usb.core.find(find_all=True)
for d in dev:
if d.idVendor == 0x045e and d.idProduct == 0x028e:
d.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14)
finally:
sys.exit()

Workaround for knock-off china controller Linux

From paroj/xpad#119

  1. Download fixcontroller.py and 99-fixcontroller.rules to ~ (/home/<user>)
cd ~
sudo mv fixcontroller.py /opt/ && sudo mv 99-fixcontroller.rules /etc/udev/rules.d/
sudo udevadm control --reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment