Created
October 3, 2022 19:20
-
-
Save marcsello/f66f64a431245338a1c9a355d2f0d56a to your computer and use it in GitHub Desktop.
python script + udev rule to fix Trust Yula contoller in xinput mode on linux. Compatible with Chimera OS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SUBSYSTEM=="input", ACTION=="add", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="028e", RUN+="/usr/bin/python3 /home/gamer/fixcontroller_marcsello.py %s{busnum} %s{devnum}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # Based on: https://gist.github.com/dnmodder/de2df973323b7c6acf45f40dc66e8db3 | |
| import sys | |
| import os | |
| import usb.core | |
| import usb.util | |
| def main(): | |
| if os.geteuid() != 0: | |
| print("root privileges required!") | |
| return | |
| f = {} | |
| if len(sys.argv) == 3: # filter set | |
| f['bus'] = int(sys.argv[1]) | |
| f['address'] = int(sys.argv[2]) | |
| dev = usb.core.find(find_all=True, idVendor=0x045e, idProduct=0x028e, **f) | |
| i = 0 | |
| for d in dev: | |
| i += 1 | |
| print(f"Found device on bus {d.bus} at address {d.address}") | |
| d.ctrl_transfer(0xc1, 0x01, 0x0100, 0x00, 0x14) | |
| print(f"Fixed total {i} devices!") | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment