#1stworldproblems – I have a lot of very old joysticks. Too many? No, don’t be silly, no such thing. This hoarding habit is related to my collection of 80s and 90s flight sim paraphernalia in general.

It’s not too bad owning a lot of old flight sim software, because you can just crank up an emulator like DosBox or VICE and enjoy your clunky old untextured polygons. But using your retro flight sim hardware is not quite so easy. You can get an adaptor that allows you to use even the more complex joysticks such as the Thrustmaster FCS, but they have two problems: (1) They only convert PC 15 pin joysticks, and not the Atari/Commodore 9 pin digital sticks and (2) where’s the fun in that? Anyway, what I really wanted was a converter that:

  1. Accepted 9 pin and 15 pin joysticks, including those using the CH Flightstick Pro and Thrustmaster FCS hat switch standards
  2. Accepted two retro joystick simultaneously to allow for joystick/throttle/rudder combos
  3. Converted an analog 15 pin joystick into digital output (for use with emulated 8 bit games)
  4. Converted a digital 9 pin joystick into analog USB joystick (for using digital joysticks with PC sims)
  5. Converted a digital 9 pin joystick into USB mouse input
  6. Accepted arbitrary switches and converted them into joystick buttons for creating new custom input devices (like my previous Strike Fighters 2 radar/armament panel project)

That’s a tall order – this will need to be a microprocessor based project (my first). My first instinct was to use the Arduino Leonardo, which I really like and already have some experience with, but a couple of things put me off – it’s light on memory (2.5k), which limits growth potential for code; it has few digital inputs (20) and although it can be HID-configured as a joystick, it’s not trivial to make it be simultaneously a HID joystick, mouse and keyboard. Plus, it’s physically pretty big. Instead, I went with the Teensy++ 2.0, which uses the AT90USB1286, an 8 bit AVR running at 16MHz. It has 128k of flash, 8k of RAM, 40 digital inputs, 8 analog inputs, and more importantly, it can be easily configured as a Joystick (6 axis, 32 buttons), keyboard and mouse on the same HID device. It’s the size of two postage stamps, and costs $24. And it’s manufactured in the garage of an adorable Portland couple. Perfect.

First thing was to work out the electronics and firmware. For the two analog devices (15 pin joysticks), I would accept one as a full flight stick (i.e. 3 axis plus hat switch plus 4 buttons), and the other would be two axes and four buttons (I only have six output axes after all) – this one would be used as a throttle and/or rudder pedals. This step was fairly easy – get the pinout for a PC joystick, and then remember that PC joysticks use their potentiometers as voltage dividers – this means you need to add a 100kΩ resistor between the Teensy pin and ground:

This is required for each axis. The buttons are a simple case of connecting the Teensy’s digital pin to ground. The hat switches are a bit more complex, because CH Products and Thrustmaster came up with quite different ways of implementing those – more on that in this post. Now for the digital devices (9 pin joysticks), which are very simple – the joystick just connects the input to ground. I decided to expand slightly from the Atari standard by allowing two buttons (like the Commodore Amiga used). Here is the pinout. I also added a 37 pin input to expose all 32 buttons for a custom devices – it surfaces one pin per button, plus one for +5v and one for ground.

Those are the device inputs. In order to implement the various modes for the device, I also needed to add some support inputs:

  1. For each digital device input, a ‘gain’ potentiometer to scale the amount of output on the mouse/joystick.
  2. Because the digital and analog devices share joystick axis outputs, a switch to inhibit the digital devices (otherwise you get interference between them)
  3. A switch to select joystick/keyboard mode output on digital device 1
  4. A switch to select joystick/mouse mode output in digital device 2
  5. A switch to select if analog device 1 uses Thrustmaster FCS or Flightstick Pro hat switch
  6. A switch to select if analog device 2 outputs keyboard or joystick signals
  7. A reset button (needed to reprogram the Teensy).

I also decided to add LEDs to indicate the whole box was live (plugged in), and another to show if the digital devices were inhibited. When you lay all that over the Teensy’s pins, this is what you get:

Note that not all the Teensy’s pins are surfaced on its two side edges – some are in the center of the board. Once all that was locked, I soldered 0.1″ pitch headers on some perf board, and plugged the Teensy in (like a shield). I then got to soldering headers for all the plugs and switches. At this point it is worth pointing out that this is project that used a lot of soldering – somewhere around 400 points. Here I was taking a hand-cramping break:

This took several evenings, because I decided to go slow and test each set of connections as I finished them. As there was a lot of cables in a  small space, I would not be able to reach every spot at the end to fix issues.

Notice how I added little labels to connections – this is because I wanted to easily be able to determine which switch connected to which part of the board. When the rat’s nest was all wired up, it would not be possible to visually trace the connections.

As I added physical connections to the board, I updated the firmware to expose the functionality. The code itself was fairly straight forward, and didn’t require a lot of bells and whistles (I did add some code to automatically detect when an analog device was unplugged which I am very chuffed with).

So much for the electronics – now on to the enclosure. I decided to keep the design simple; it would look avionics panel like and hardcore – I took inspiration from the great Cockpits of the Cold War. Last time I tried this, I used a large decal to add the captions to the panel; but after a couple of years, the decal corners have lost their glue, and are peeling slightly. I would avoid that this time by using a sheet of acrylic, with a printed overlay behind it. I also wanted the enclosure to have a clamp so that I could attach it to my desk, and flip switches without it sliding around. Here is the OpenSCAD render of the final design:

The clamp would be the difficult part, so I started on that. The original plan was to have one large, monolithic 3D printed PLA clamp piece (in yellow above), and then have another printed PLA part – essentially a threaded bolt – that would screw upwards to attach the clamp to the desk. Unfortunately that did not work, because the clamp and bolt had to be printed in different orientations which led to the threads sticking horribly. Because the clamp part took a little over 5 hours to print, I decided I wanted to keep that. So I switched to a #6 steel threaded rod and built an adapter for the clamp. This consisted of a tube that holds a steel nut in the hole of the clamp, sandwiched between two flat parts which are glued (using Super Glue/Cyanoacrylate) in place. Here is the tube with one half of the sandwich (the nut is already embedded in the tube):

And here it is sandwiched and glued into the clamp:

This wheel is what applies pressure to the bottom of the desk. It also has an embedded nut which accepts the threaded rod:

The enclosure body is just two simple flat U-shaped halves glued together with the help of some interior straps. Here is the whole thing (probably around 12 hours of printing in all these parts):

The back of the enclosure would be 1/8″ MDF (sprayed black), while the face plate would be 1/8″ acrylic. The faceplate really was the key to the whole thing. To ensure the profiles for the plugs, switches and buttons were the right size, I first did a trial run on MDF (which costs around 15% compared to acrylic) on the CnC router. Amazingly, I got the sizes right on the first try:

Then came the real cuts – I am not a fan of cutting acrylic on the CnC because the plastic melts and sticks to the router bit, slowly increasing it’s diameter, which leads to inaccurate cuts. Apparently you can get around this by increasing cutting speeds, but I have not yet gotten that to work for me. Another way to solve that would be to buy a laser engraver, but I don’t really want to drop $11k to improve my plastic parts by 10% or so (hardly seems worth it when you put it that way, Dave). Here is the acrylic, still with the blue adhesive protector in place. Actually turned out pretty well:

Once that was done, it was time to design the faceplate art (which labels all the switches, etc). I used OpenSCAD’s projection() function to export the outlines as DXF to Inkscape. Once there, I used the miso font to finish up the art:

I printed the art on my regular printer. Now onto the cutting. This had to be done carefully as the plugs have no bezel, so the edges of the cut would be visible. I used a plain old Exacto knife with a new blade and a lot of patience:

And then add in all the switches and plugs. This is actually the most fun part of the project, because you start to see the interface take shape. You need to be careful not to scratch the acrylic while you do this (which of course I did, but luckily it was a small one):

Instead of using regular screws, I decided to use some Hex-headed 3mm screws, which give a nicer aircraft panel-like look.

You’ll remember that part of the design was two LEDs – one to show if the device is live, and another to show if the digital devices have been inhibited. One of the pictures I saw in the Cockpits book showed indicator lights where the text itself lit up – this was very cool and I decided to replicate that. I 3D printed some housings for the LEDs in natural PLA (which is translucent). This is basically a square cone with the LED at the apex, and a transparency with the caption text at the base. I painted these (except for the base) using silver enamel paint to prevent the light from leaking out of the back of the housing. The entire thing is then attached to the face plate with two screws:

The effect is very cool – while the LED is off, the text is barely legible, and then really lights up in the color of the LED when it is turned on. I will be using this trick in future projects. Here is the entire enclosure coming together:

Next I hot-glued glued the perf to the back plate using some 3D printed standoffs (needed to provide space for the cables beneath). I also, as is my wont, signed the plate with my bunny sketch. You should be aware that when you make your own, this is an optional step:

I decided to done one last round of thorough testing before trying to stuff everything in the enclosure. There are many, many cables in this project:

Here you can see how the LED housing is bolted to the faceplate (top center of the plate):

It’s actually kind of hypnotic trying to see where all the cables connect. You can see why it was important to label everything before we got to this stage:

And here I am testing the mouse functionality – the Atari stick is actually moving the mouse cursor around. Very cool!

I also found a number of bugs around how the switches were labelled relative to what the code actually did (e.g. in the image above, the switches are set to use joystick mode, but the code was actually running in mouse mode). I also found one short circuit which nulled out one of the analog device axes. It always amazes how some bugs manage to hide till the bitter end.

Once everything was tested, it was time to compress it into the enclosure. I had to unplug everything, bolt the back plate (with electronics now attached) to the body, and then re-plug everything in (using tweezers) inside the enclosed space. In order to get everything to fit, I pre-folded some of the ribbon cables so that they collapsed in predictable ways as you squished them in. Then finally I grabbed an Allen key and bolted the faceplate in place:

Looks pretty good. Here it is with the desk clamp fitted, and running – notice how the light housings give you nice illuminated text captions (the red LED is brighter than the green):

I did some final testing by setting up Strike Fighters 2 to use the device, plugged in my Thrustmaster Top Gun Platinum stick, jumped in an Israeli Mirage IIIC, and started a huge furball with some Syrian MiG-21s. These two aircraft are very well matched, so there was a lot of stick pulling and grunting, but I got away with two kills before I ran out of ammo and had to run home with bingo fuel. Fantastic! My next round will be to set up Dos Box and use my CH Flightstick Pro to play through the US Navy Fighters Crimea campaign again.

This was a difficult project for sure – large 3D prints, lots of electronics/soldering and firmware coding on top of it all. But being able to use all my old controllers again makes it totally worth it. Total cost in parts was probably around $40 (the only “expensive” piece is the Teensy – the rest is plugs, switches and ribbon cable). If you’d like to make your own, you can get all the STL files as well as the source code for the firmware at Thingiverse.

During the 1990s, as flight simulators began to gain popularity with PC gamers, several companies started producing dedicated flight simulation joysticks. One of the cool features of these sticks was the hat switch – a four direction digital mini joystick which was operated by the thumb (usually used to control the view direction). The problem faced in designing such a joystick was how to encode the hat positions given the shortage of pins in the standard 15 pin PC gameport. Essentially, the PC’s gameport has enough pins for two joysticks each with two axes and two buttons (pinout here). Many of these joysticks used three axes already (aileron, elevator and throttle), and all four buttons, which left very little to encode the hat on.

Reading the hat switch of a classic PC joysticks on a modern microprocessor/dev board such as the Teensy USB or Arduino is fairly easy – there are only two major solutions you need to support (depending on the type of stick you want to read).

Thrustmaster FCS method – encode the hat in the fourth axis

The Thrustmaster FCS was the first PC flight stick to include a hat switch.The Thrustmaster Top Gun stick works the same way (it is essentially a re-branded FCS).

Thrustmaster encodes the hat position on the second Y axis (pin 13 on the plug). Moving the hat switch in any direction sets a particular resistance which can be easily read on one of the analog pins of the Teensy USB or Arduino (use analogRead(), which will return a value from 0-1023). The following table defines buckets for each hat position (High and Low are the top and bottom values you can expect the pin 13 analogRead() to be):

CH Products Flightstick Pro method – encode the hat using button chords

The second method of encoding hat switch positions was defined by CH Products for their Flight Stick Pro. It was used by several other sticks, such as the Suncom F-15 SFS, and the Logitech Wingman Extreme.

In this design, moving the hat switch produces multiple button presses simultaneously (i.e. a chord). A side effect of this is that these joysticks do not support pressing more than one of the regular buttons together – doing so produces a ghosting effect where the lowest numbered button wins. For example, if you press buttons 1 and 3 simultaneously, only button 1 registers; and if you press buttons 2, 3 and 4 simultaneously, only button 2 registers. The following table shows the chords that are produced by pressing the hat switch in each direction (the absence of a defined chord means the hat is in the center position). You will need to intercept these chords to use in your project:

Developing HIDBox

Lots going on at work, so little time for projects lately. I have been working on two large projects (one of which is in “secret” status), while the other is this: The working name is HIDBox. The goal is to create a box which will act as a USB HID device, and convert classic computer controllers (Atari/Commodore style 9 pin joysticks as well as PC 15 pin joysticks) for use with a modern PC.

The basis of this project is the TeensyUSB++ 2.0 microprocessor board, which can easily be programmed to become a USB joystick, mouse or keyboard (or all three at once if you prefer). Here I am testing an Atari CX-40 joystick on my PC (the switches were set up to have it become cursor keys plus the Z key, for using on VICE). I have also tested it using an old Thrustmaster FCS (playing US Navy Fighters in DOS Box – good times).

Lots of soldering and programming left, but so far all the concepts are proven, just need to get it finished.


The last two patent cubes for 2013′s work came in over the holiday, so I can have a pyramid again.

And so the new year begins – already slogging on the work for the next set.

Mini Apple II

The Apple II was the first commercial success for Apple, and led many thousands of kids down the Oregon Trail.

Relive your memories in 2″ (they seemed a lot bigger back then, didn’t they?) – get the files on Thingiverse.

To commemorate the pardoning of Alan Turing, I decided to make some 1980s British home computers – the Sinclair ZX80 and Jupiter ACE (the first home computer to run something other than BASIC – FORTH in this case). The ACE comes with a detachable 16K RAM pack. To think Cambridge used to be as inventive as Silicon Valley in those days.

Get the files to print on Thingiverse – the Sinclair ZX80 and the Jupiter ACE.

Mini Apple Macintosh

1984 was a simpler time – when computer companies actually built computers, and there were no app stores. But here is a micro transaction you might enjoy, a 2″ Apple Macintosh (before it was known as “Mac Classic”).

Get the files to build your own at Thingiverse.


Get every new post delivered to your Inbox.

Join 161 other followers