Cheap GamePad Under Linux

I wanted a cheap gamepad to play TuxCart on my Linux desktop – found a PowerPlay Gamepad PC / PS3 / PS2 for NZ$25 at the red sheds.



On plugging into a USB port I could see the device recognised as a Xbox360 gamepad, but with no outputs.

A bit of google searching for the fix:

Simple fix: https://github.com/fcorsino/gamesir-g3w-fix

Make a python script, save onto desktop as fixgamepad.py:

#!/usr/bin/env python3
import usb.core
import usb.util
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)

Run it as sudo via a script .sh file
sudo python3 /home/graeme/Desktop/fixgamepad.py
You may need to download the Python USB interface

This initialises the gamepad with some bytes that lets it then be seen by Linux

Make a new file in 
/usr/share/X11/xorg.conf.d/50-joystick.conf

As follows:

Section "InputClass"
  Identifier "joystick catchall"
  MatchIsJoystick "on"
  MatchDevicePath "/dev/input/event*"
  Driver "joystick"
  Option "StartKeysEnabled" "off" # Disable mouse support of joypad 
  Option "StartMouseEnabled" "off"
EndSection

This stops the gamepad pretending to be a mouse.

I also installed Xboxdrv from the Package Manager as the driver, the gamepad seems a bit hit and miss with the stock xpad kernel driver.

I use JSTest GTK to test the inputs, and QJoypad to configure keyboard mapping for it.