I am a huge fan of American Truck Simulator and really enjoy playing it on my MacBook. Over the last year I have looked into the possibility of buying a steering wheel / pedal kit for my Mac. The more I looked into it the less satisfied I got. I really wanted the tactile feel of actually pressing buttons and operating clunky switches to make things happen in ATS.
My philosophy here at the Maker Cupboard (and more generally in life) is if the product doesn’t exist (or if I can’t afford it) then make my own one.
After a few failed attempts (particularly around Bluetooth) I eventually settled on making a device which emulated a USB keyboard.
The core of the project is the Sparkfun Arduino 5V pro Micro controller. This was the perfect device as it can easily emulate a USB HID keyboard.
This was relatively easy to program and my code was based on an example by Jim Lindblom from SparkFun Electronics and made use of the Keyboard.write() and Keyboard.press() function.
My full code can be found here and hopefully with the comments it should be clear which button is connected to which pin.
At the moment I have used a bit of a cheat with the analogue read of the joy stick. Essentially any upward movement will send a single character for accelerate and decelerate for downward movement. The amount of upward movement doesn’t change the speed but I will be addressing this when I get a little bit more time to work on it.
I bought a very cheap barrel switch which controls the digital switches by breaking the connection from the common ground to the board. The analogue switch needs to remain connected to ground otherwise it sends a false signal.
My next step will also be to use a rotary encoder to build a basic steering wheel.