DIY USB HID Joystick Device and Game Controller

For many projects it would be cool to build a custom USB Joystick device, either as custom game controller for Windows or any USB host which can be used with a USB Joystick. Instead buying one, why not build my version? All what I need is a USB capable board, some kind of input (potentiometer, push buttons) and some software, and I have my USB Joystick:

DIY USB HID Joystick Device

DIY USB HID Joystick Device

In this article I’m using the NXP FRDM-KL25Z (ARM Cortex-M0+) with a Joystick (e.g. from Dx.com) shield:

NXP FRDM-KL25Z with Joystick Shieldv

NXP FRDM-KL25Z with Joystick Shield

The USB HID Joystick class is very similar to the USB Keyboard one, so follow the “Using the FRDM-KL25Z as USB Keyboard” tutorial for the basic USB setup.

Select the HID Joystick Device:

HID Joystick Device

HID Joystick Device

Then configure the HID device settings, especially the CPU/device used:

HID Device Settings

HID Device Settings

The component offers methods to set buttons, throttle, hat position and X/Y joystick position:

USB HID Joystick Subcomponent

USB HID Joystick Sub-component

I have published on GitHub an example project which uses X/Y analog position, 4 hat switches, a throttle setting plus 3 push buttons:

USB HID Joystick Example Project

USB HID Joystick Example Project

The USB HID device shows up with two devices in the Windows device manager:

USB HID Joystick in Device Manager

USB HID Joystick in Device Manager

Inside the Windows Control Panel, there is a dialog to set up any USB game controller:

Setup USB Game Controller

Setup USB Game Controller

That dialog shows the controls and is used to calibrate them:

Setup USB Game Controller

Setup USB Game Controller

Summary

Building a DIY game controller is easy with the addition of the USB HID Joystick component and software. With a USB capable device and a joystick shield I’m able to create my gaming controller.

Happy Gaming 🙂

Links

Advertisements

3 thoughts on “DIY USB HID Joystick Device and Game Controller

  1. Hi Erich,

    HID Joystick Device class is not available in mine SDK 2.0. It must be in MCUC1. How to get it?

    Regards,
    Marceli

    Like

  2. Pingback: McuOnEclipse Components: 09-July-2017 Release | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s