Simulator racing tech is amazing. It’s an entire genre of human input devices designed to transform your home desk into the cockpit of a racecar. Wheels, pedals, shifters, handbrakes, gauge clusters, wind generators… you name it, you can find it for your home racing rig.

But with all of the hardware necessary for a comprehensive simulator experience, sim racing is expensive. To try and make it more accessible, communities of makers have sprung up to design their own custom racing devices and adapters built from scratch. Owning a bit of sim racing equipment myself, I thought I would join in on the fun and design a software library that makes it easy to interface sim racing devices with embedded development boards. Introducing the Sim Racing Library for Arduino!

Using the Library

Using the library is straightforward. After installing the library, include the <SimRacing.h> header and declare a global object for your peripheral. Peripheral objects are constructed using the relevant pin numbers for their hardware. For example, the LogitechShifter object takes three pin numbers: the X axis wiper, the Y axis wiper, and the ‘reverse’ button that is triggered when the shifter is pressed down.

Within setup(), call device.begin() to initialize the device hardware, then call device.update() within loop() to poll the hardware for its updated state. All state data is buffered on a per-update basis so that repeated retrievals are consistent within the same update loop.

The device’s state data can then be used to set HID outputs, scale values, control motors, you name it!

Supported Devices

For its initial release the library supports three devices:

  • 3-pedal Logitech pedal peripherals (G932, G29/G920, and more)
  • 2-pedal Logitech pedal peripherals (Driving Force GT)
  • Logitech Driving Force shifter

All of these use DE-9 connectors (male on the pedals, female on the shifter) and work with both 5V and 3.3V logic levels. The “Joystick” examples in the library are written for the Arduino Leonardo / Pro Micro using the Joystick library, and should work out of the box to convert the Arduino into an inexpensive USB adapter. I made sure to set the default pinout to the same pins as the most popular “Arduino to USB” adapter projects for the Logitech pedals and shifter, so the library will work as a drop-in replacement for the firmware on most existing DIY adapters.

And while I’ll bet working as a USB adapter is going to be its most common use, the library is so much more than that. It makes it easy to calibrate the devices and access both the higher level functions that the devices are designed for, as well as the lower level data that makes them work. For example: not only can you get the current gear of the gear shifter, but you can also read the output of the potentiometers for the shifter’s position. That means that in addition to using the shifter as gear shift in a racing sim, you could (for example) flip a switch and use its absolute position to navigate the sim’s menus.

Documentation

I’m trying to be more thorough with integrating documentation with the source code, and this library is no exception. Everything is fully documented in Doxygen format. The HTML documentation is generated automatically on release via GitHub Actions, and then hosted on GitHub Pages. I also added a modern CSS theme to make the documentation easier on the eyes. You can find the current library documentation here.

Download

If you want to try the library yourself, you can download the latest version from GitHub or from the libraries manager of the Arduino IDE (search for “Sim Racing”).

Have fun!


Leave a Reply

Avatar placeholder

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Would you like to know more?