Parsing data from the Logitech F310 gamepad On Linux


So today I recieved my Logitech F310 gamepad in the mail today from Amazon. I initially bought this to see if I could get retropie set up.

I got that set up, but I had no ROMs to play. At that point, I sort of lost interest and didn't really feel like finding games to play with (another day of course!)

As it turns out, this plug-and-play gamepad I bought for myself is quite easy to read. Every device plugged into a linux machine is abstracted as a file. For this reason you can stream raw data with "cat /dev/input/js0" and then press a few buttons. Raw data isn't all that interesting to look at, nor is it all that helpful. Much more useful would be the ability to read the data as hex values. This is a trivial task that can be done by piping the raw data into xxd.

After a little bit of trial and error with flags in xxd, I found the ideal command to read the incoming data:

cat /dev/intput/js0 | xxd -g 2 -c 8 

At this point, I spent the next 15 minutes or so pressing buttons and figuring out what was going on. I've had experience reading hex data before from MIDI controllers, and there were many similarities.

Through my own observations, I have discovered the following so far:

Some cool ideas for the future: