Linux HORI Fighting Stick EX 2 - Gen_Witt

redgen_witt wrote
on October 25th, 2009 at 06:59 pm
Previous Entry Share Next Entry

Linux HORI Fighting Stick EX 2

I got back from my second trip to Taipei this weekend. I'm hoping I don't have to go again for sometime as that trip is pretty grueling. In a glorious fit of procrastination, instead of packing I decided to try and get my joystick to work under Linux. I have a Hori Xbox360 Fighting Stick EX 2 which I am relatively happy with. The buttons are a little to stiff and make a bit too much noise, but it's about the best you can buy at that price point.

Step 1. Patch the kernel XBox controller driver to recognize Hori brand controllers.

This is all you have to do to get the controller working. But you'll soon find that the controller is mapped very funny, owing to the way it's used on the XBox. You'll have the same problem in windows, but there are readily available 3rd party tools to remap joystick buttons. To remap the buttons in Linux, you'll have to do some more work.

Step 2. Get the right kernel version. You're going to need a kernel <2.6.28 or >=2.6.31. In particular you're going to need this change.

Step 3. Patch the joystick calibration tools to support button remapping. Some smart guy already had done most of the work, but his patch doesn't work with the changes to button remapping in the kernel. My patch combines Laszlo Kajan's patch with a fix to the change in the ioctls. If you're using a kernel <2.6.28 and a Debian based distribution the joystick utils installed should work.

Step 4. Add udev rules to calibrate the joystick on connect,

KERNEL=="js[0-9]*", ATTRS{name}=="HORI Fighting Stick EX2", ACTION=="add", RUN+="/etc/udev/setup_hori_joystick"

Runs a script, "/etc/udev/setup_hori_joystick", whenever the joystick is attached. The script contains calls to jscal to remap buttons and calibrate the joystick. It looks like this,

jscal -u 8,16,17,0,1,2,3,4,5,11,304,305,307,308,310,311,315,316,317,318,278 "${DEVNAME}"
jscal -s 8,1,0,0,0,536854528,536854528,1,0,0,0,536854528,536854528,1,0,0,0,-2147483648,-2147483648,1,0,0,0,-2147483648,-2147483648,1,0,0,0,-2147483648,-2147483648,1,0,0,0,-2147483648,-2147483648,1,0,0,0,-2147483648,-2147483648,1,0,0,0,-2147483648,-2147483648 "${DEVNAME}"

As you can clearly tell, Linux is ready for the desktop.
mood: amused amused

(Leave a comment)