Hacklet #5 - PS2 dualshock controller with Raspberry Pi plus Python
Following on from getting the dualshock controller talking to Raspberry Pi yesterday, we now want to look at a way of binding the controller to events. jkeys allows us to do that with Python.
I took the jkeys source and hacked it about (also taking some cues from the Playing sounds and using buttons with Raspberry Pi Adafruit tutorial).
Basically removing the need for a display and putting the names of the sound files in the config instead of the key presses (the joypad is kept as-is, with the sound files renamed to Right, Left, Up, Down for simplicity).
We can now kick off the program like this:-
./soundkeys.py config.joy
Here is the result; pressing a button on the PS2 controller plays a sound on the RPi:-
Here is the code:-