-
-
Save dnmodder/de2df973323b7c6acf45f40dc66e8db3 to your computer and use it in GitHub Desktop.
#!/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() |
This is what I have, it's some Amkette gamepad, stored this script in /usr/local/bin/fix_controller
ACTION=="add", ATTRS{idProduct}=="028e", ATTRS{idVendor}=="045e", DRIVERS=="usb", RUN+="/usr/local/bin/fix_controller"
Ahh ok, I was putting 0x028e and 0x045e
Hi,
I used this script to make work my controller. And it worked ... Since I updated to linux kernel 5.9 from 5.8
I don't know if it's related or not ?Here is dmesg related
[ 6420.822948] xpad 1-2.2:1.0: xpad_try_sending_next_out_packet - usb_submit_urb failed with result -19
[ 6423.200370] usb 1-2.2: new full-speed USB device number 12 using xhci_hcd
[ 6423.532529] usb 1-2.2: New USB device found, idVendor=2563, idProduct=0575, bcdDevice= 2.00
[ 6423.532532] usb 1-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 6423.532534] usb 1-2.2: Product: PS3/PC Gamepad
[ 6423.532535] usb 1-2.2: Manufacturer: SHANWAN
[ 6423.565903] input: SHANWAN PS3/PC Gamepad as /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-2/1-2.2/1-2.2:1.0/0003:2563:0575.000A/input/input31And lsusb
Bus 001 Device 013: ID 045e:028e Microsoft Corp. Xbox360 Controller
Any idea ?
Thank's !
i just tried it for the first time with a gamepad from the same manufacturer and it works. i'm on kernel 5.10
@dnmodder thanks a lot mate! i finally have this thing working as it was supposed to.
Thank you for the fix! My gamepad 'GameSir G3w' now works great on MX Linux.
Edit: I notcied that you have to run the script each time after a reboot. It's no big deal, but is there a way to make the changes permanently?
I forked this into a standalone udev rule that doesn't require an external script to run: https://gist.github.com/pavel-kirienko/86b9d039151405451130a0fb3896887c
Thank you for the fix! My gamepad 'GameSir G3w' now works great on MX Linux.
Edit: I notcied that you have to run the script each time after a reboot. It's no big deal, but is there a way to make the changes permanently?
If you still didn't resolved your question, add udev rule as in https://gist.github.com/dnmodder/de2df973323b7c6acf45f40dc66e8db3#gistcomment-3582029 or https://gist.github.com/pavel-kirienko/86b9d039151405451130a0fb3896887c
Thank you!
This also fixes Corsair Esperanza EG106 wired PC/PS2/PS3 controller :-)
Had to modify this script to make it work with my ANT Esports GP100 controller. I have posted the modified script to https://github.com/flashrocket/shanwan-controller-fix.
wow, its working on Trust GXT540
Bus 001 Device 005: ID 045e:028e Microsoft Corp. Xbox360 Controller
THANKS ~!
Guys. The xpad driver now has the shanwan controller support built in. No need for workaround scripts. You can install the new driver from https://github.com/paroj/xpad and help test the controller and iron out any problems.
@flashrocket any idea if they're planning on upstreaming those changes to mainline later?
@Technohacker No idea bud. @paroj may be able to let us know.
these changes are now in https://github.com/paroj/xpad master. If they turn out to work without side-effects, we can think of sending them to linux upstream.
thank you so much for this
@Lumin4ry you can use the new xpad driver itself instead of using the script.
(FIXED)when i try to execute the script it tells me to install the pyusb module even tho i installed it already. i don't know whats wrong
I install pyusb then i do "python fixcontroller.py" and then it says ''First, install the pyusb module with PIP or your package manager.''
I was using pythton 2.7 then i switch to python 3.8 and the it worked
If you are using ubuntu try installing using apt. That seems to work for me.
thank you so much for this fix.
Can confirm it makes my USB device 045e:028e work on Ubuntu 20.04 with kernel 5.15.0-52-generic
Both xpad
kernel module and xboxdrv
receive no events from the joystick until I run this fix, and then the controller works fine after.
@Breakthru have you tried using the updated xpad driver?
Try the one in paroj xpad repo with branch fantech. It has all the fixes for the game pad and needs more testing.
(FIXED)when i try to execute the script it tells me to install the pyusb module even tho i installed it already. i don't know whats wrong I install pyusb then i do "python fixcontroller.py" and then it says ''First, install the pyusb module with PIP or your package manager.''
I was using pythton 2.7 then i switch to python 3.8 and the it worked
I'm facing the same problem, Please tell me how you managed to fix this issue.
@itsSagarBro
Two options.
sudo apt install python3-pyusb
sudo pip3 install pyusb
@amardhruva I have tried the xpad kernel driver and can confirm it fixes the problem without having to run the workaround script.
Thank you! I've tried everything on the net and this fixed my controller being detected but not outputting anything on Kali Linux 6.0.0
Unfortunately this script does nothing in my G-LAB Thorium Gamepad (detected as Shanwan Android gamepad), even when usb ids are 25a7:fa23 :-(
Hi @dnmodder, Could you give me a clue of how to extract the required hex sequence from the wireshark usb capture? I suppose control sequence must be among the Configuration Requests I read in my capture file, but I do not know what values are.
Also works well on Ubuntu Budgie 22.04.3 LTS - Kernel 6.2.0-26-generic
Make sure to sudo apt install python3-usb
first and run the script with sudo
I also have to run xboxdrv
(and let it run) beforehand
You da man
Here, if you have trouble with pip, try this: fork
i have a fake ps3 controller that doesn't work even with these scripts i need help
dmesg :
[ 3224.411687] sony 0003:054C:0268.0010: input,hiddev97,hidraw2: USB HID v81.10 Joystick [Nintendo Co., Ltd. USB Gamepad] on usb-0000:00:14.0-1/input0
lsusb :
Bus 003 Device 012: ID 045e:028e Microsoft Corp. Xbox360 Controller
journalctl -f :
Jun 30 19:55:17 Abdulhafez-PC mtp-probe[87962]: checking bus 3, device 45: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1"
Jun 30 19:55:17 Abdulhafez-PC mtp-probe[87962]: bus: 3, device: 45 was not an MTP device
Jun 30 19:55:17 Abdulhafez-PC mtp-probe[87997]: checking bus 3, device 45: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1"
Jun 30 19:55:17 Abdulhafez-PC mtp-probe[87997]: bus: 3, device: 45 was not an MTP device
Jun 30 19:58:06 Abdulhafez-PC sudo[89041]: pam_systemd_home(sudo:auth): New sd-bus connection (system-bus-pam-systemd-home-89041) opened.
Jun 30 19:58:10 Abdulhafez-PC sudo[89041]: abdulhafez : TTY=pts/14 ; PWD=/home/abdulhafez ; USER=root ; COMMAND=/usr/bin/udevadm control --log-priority=info
Jun 30 19:58:10 Abdulhafez-PC sudo[89041]: pam_unix(sudo:session): session opened for user root(uid=0) by abdulhafez(uid=1000)
Jun 30 19:58:10 Abdulhafez-PC sudo[89041]: pam_unix(sudo:session): session closed for user root
Jun 30 19:58:19 Abdulhafez-PC kernel: usb 3-1: USB disconnect, device number 45
Jun 30 19:58:19 Abdulhafez-PC kernel: xpad 3-1:1.0: xpad_try_sending_next_out_packet - usb_submit_urb failed with result -19
Jun 30 19:58:40 Abdulhafez-PC kernel: usb 3-1: new full-speed USB device number 46 using xhci_hcd
Jun 30 19:58:40 Abdulhafez-PC kernel: usb 3-1: device descriptor read/64, error -71
Jun 30 19:58:41 Abdulhafez-PC kernel: usb 3-1: New USB device found, idVendor=054c, idProduct=0268, bcdDevice= 1.00
Jun 30 19:58:41 Abdulhafez-PC kernel: usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Jun 30 19:58:41 Abdulhafez-PC kernel: usb 3-1: Product: USB Gamepad
Jun 30 19:58:41 Abdulhafez-PC kernel: usb 3-1: Manufacturer: Nintendo Co., Ltd.
Jun 30 19:58:41 Abdulhafez-PC kernel: input: Nintendo Co., Ltd. USB Gamepad Motion Sensors as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/0003:054C:0268.0017/input/input79
Jun 30 19:58:41 Abdulhafez-PC kernel: input: Nintendo Co., Ltd. USB Gamepad as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/0003:054C:0268.0017/input/input78
Jun 30 19:58:41 Abdulhafez-PC kernel: sony 0003:054C:0268.0017: input,hiddev97,hidraw2: USB HID v81.10 Joystick [Nintendo Co., Ltd. USB Gamepad] on usb-0000:00:14.0-1/input0
Jun 30 19:58:41 Abdulhafez-PC mtp-probe[89255]: checking bus 3, device 46: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1"
Jun 30 19:58:41 Abdulhafez-PC mtp-probe[89255]: bus: 3, device: 46 was not an MTP device
Jun 30 19:58:41 Abdulhafez-PC kernel: usb 3-1: USB disconnect, device number 46
Jun 30 19:58:41 Abdulhafez-PC mtp-probe[89269]: checking bus 3, device 46: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1"
Jun 30 19:58:41 Abdulhafez-PC mtp-probe[89269]: bus: 3, device: 46 was not an MTP device
Jun 30 19:58:41 Abdulhafez-PC kernel: usb 3-1: new full-speed USB device number 47 using xhci_hcd
Jun 30 19:58:41 Abdulhafez-PC kernel: usb 3-1: New USB device found, idVendor=045e, idProduct=028e, bcdDevice= 5.72
Jun 30 19:58:41 Abdulhafez-PC kernel: usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jun 30 19:58:41 Abdulhafez-PC kernel: usb 3-1: Product: XBOX 360 For Windows
Jun 30 19:58:41 Abdulhafez-PC kernel: usb 3-1: Manufacturer: Nintendo Co., Ltd.
Jun 30 19:58:41 Abdulhafez-PC kernel: usb 3-1: SerialNumber: 000000000001
Jun 30 19:58:41 Abdulhafez-PC kernel: input: Microsoft X-Box 360 pad as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/input/input80
Jun 30 19:58:41 Abdulhafez-PC mtp-probe[89291]: checking bus 3, device 47: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1"
Jun 30 19:58:41 Abdulhafez-PC mtp-probe[89291]: bus: 3, device: 47 was not an MTP device
Jun 30 19:58:42 Abdulhafez-PC mtp-probe[89337]: checking bus 3, device 47: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1"
Jun 30 19:58:42 Abdulhafez-PC mtp-probe[89337]: bus: 3, device: 47 was not an MTP device
This is what I have, it's some Amkette gamepad, stored this script in /usr/local/bin/fix_controller