Building an arcade style joystick with the EFM32 Giant Gecko starter kit

Hack-a-Gecko project by Mads

photo (8)


Building an awesome arcade style joystick using the EFM32 Giant Gecko starter kit, learn how easy it is to make an HID device and play some fun retro games.

Project Member(s):


Project description:

The goal was to make a great arcade style joystick with 6 buttons using a USB so I could play some cool retro games during Christmas. The joystick should be the standard HID class so that no drivers are needed and it will work on any PC operating system.

The Giant Gecko STK usbdhidkbd example was used as a starting point, and first a HID descriptor was made by using the USB.SIG provided tool: Descriptor Tool


This tool allows you to build any HID descriptor and in this case it is a gamepad with 6 buttons and a 2 axis joystick

Next the descriptors.h file was updated:

First the ReportDescriptor array was replaced with the one generated from the Descriptor tool. Next the name of the product was changed:

STATIC_CONST_STRING_DESC( iProduct       , L”EFM32 USB HID Gamepad” );

Finally KeyReport_TypeDef, noKeyReport and report table were deleted and replaced with a gamepad report type definition that matches the report described above:

/*gamepad report structure*/
typedef struct
uint16_t buttons;
int8_t leftX;
int8_t leftY;
} gamepadReport_t;

Note that the report descriptor and the type definition have a 16 bit variable to contain the 6 buttons. This is because further buttons could be added in the future.

Now it was time to make the hardware support all those buttons and a joystick. A pin row was attached to the GG STK top test points to allow for an easy way to dis-assemble the joystick:


Then a small joystick mock-up was made in order to test that the correct values were sent in the report:


The main program was then modified temporarily to sample the mock up joystick and PB0 and PB1 as fire buttons in order to test the code.

Windows comes with a control panel for testing joysticks. To start this control panel easily, go to Start->run and type “joy.cpl” and hit enter. This allows for testing that all the axis and buttons work:


With the core functionalities done, it was time to make a cool joystick casing with room for a proper micro-switch joystick and six buttons. The box was designed in inkscape using the box maker extension:


I then went to my local hacker space OSAA where I could cut an acrylic box using the amazing laser cutter Flemming has built:


Finally the box, STK, joystick and buttons were assembled by using wires, and the code was modified to sample the new joystick and buttons. The code was also modified to have separate timers for the idle rate and poll rate.


Final step was to try out the new joystick on some good old retro games!


This is a small video demonstrating the joystick.

Materials used:

  • EFM 32 Giant Gecko STK
  • Pin row and header for easy remove of wires on STK.
  • Swana joystick (JLF-TP-8YT)
  • Joystick harness (JLF-H)
  • 6 Swana buttons (OBSF-30)
  • Some wires for the button and joystick
  • 3mm acrylic sheet.

Source files and box svg file:

To use the source files, make a copy of the Giant Gecko STK usbdhidkbd example in …..AppData\Roaming\energymicro\kits\EFM32GG_STK3700\examples\ and replace the source code files from github.

HaG logo

This Hack a Gecko project is a result of a “fun hacking session” and are provided as is, free of charge with no guarantees or support from Energy Micro, to partially or fully show and demonstrate EFM32 Gecko microcontroller capabilities. Get inspired, use at own risk, and build some awesome and cool applications.”


For technical questions about this project, please use our support forum. The Hack-a-Gecko team will answer your questions directly.