Forums » Linux

How to map the hat switch axes to keyboard buttons

Feb 11, 2011 draugath link
Since linux identifies the hat switch on joysticks as being two axes rather than 4 buttons, we are currently unable to map each direction to a separate command.

After doing some searching, I came across a forum post which got me searching for a program called 'jhat.' I eventually found this blog post from the creator of the program. After a little hunting for additional utilities and modifying a script, it was up and running and I can now use my hat switch properly in linux within VO.

jhat maps the hat switch to the keyboard scan codes of the arrow keys. If this will not work for you, then you'll need to hack the jhat.c code to change them. If you use two joysticks, and need access to the hat switch on both of them, you'll need to modify jhat.c and vendetta.sh a little more extensively.

The installation instructions I provide below will require you to understand how to use the command-line and be able to compile software. I will not be giving an in-depth account of how to perform all of the necessary tasks to properly install this application.

Instructions:

Download jhat
Download xautomation
Download vendetta.sh
Install input-utils if you don't have the program jstest
Compile and install jhat and xautomation
Modify vendetta.sh according to instructions found within it.
Run vendetta.sh and enjoy being able to use your joystick hat switch.