Many people have created their own Kerbal Space Program controller, from the simplest buttons to full-size panels or cockpits with various readout displays. After playing KSP for a while, I thought I'd make something similar - something also simple - on my spare Arduino Leonardo.
The Leonardo and some of the Arduino microcontrollers can be used to "emulate" a keyboard and/or a mouse, by simply using the official Keyboard library to output keys (there are samples in the Arduino IDE). So I bought a bunch of cheap regular buttons/switches (couldn't find the fancy ones), install everything in a cardboard box and wired them up:
- a 2-axis joystick with switch button
- a 5-button board (using 1-wire to send different analog signal)
- a rotary encoder with switch button
- 3 push buttons
- 2 switch
- 4 LEDs
- a speaker with very simple amplifier
In effect there are 18 different switches. Obviously only part of the keys can be set on the controller - then again, you still need the mouse to do some stuff in KSP. One of the switch is used to enable/disable keyboard output. The LEDs are used to indicate the status of certain switches (keyboard output, engine, RCS and SAS).
Keyboard modifiers (special keys for Keyboard.h)
Since I wanted to keep it simple, I did not use any software plugins or mods to get data from the game. The good thing is that my controller will always be a plug-and-play device, no extra setup needed.
Oh, right. I changed throttle up/down keys in the KSP to left Ctrl and right Ctrl. My Win 10 OS went nuts when my rotary encoder tried to press a lot of left Shift in a short time.
I also used a speech library called Talkie, which is is a software implementation of Texas Instruments speech synthesizer on TI products and Atari arcade games, etc. I used Vocab_US_Large.h which are consisted of military/aircraft-related words. Not totally fit for KSP, but I always wanted to use it somewhere. (For example, when I press the map key, it would say "INFLIGHT AREA DISPLAY" :p there are just no "MAP" in the library. The voice also serves as delay for some buttons so that they would not be pressed too quickly.)
A small NPN transistor is used to amplify the sound for the speaker, but due to the power limitation of the microcontroller itself (and my lack of advanced knowledge of circuits) it is not loud. Just barely loud enough for the player.
Comments