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

#include <SimRacing.h>;

const int Pin_ShifterX   = A0;
const int Pin_ShifterY   = A1;
const int Pin_ShifterRev = 2;

SimRacing::LogitechShifter shifter(Pin_ShifterX, Pin_ShifterY, Pin_ShifterRev);

void setup() {
	Serial.begin(115200);
	shifter.begin();
}

void loop() {
	shifter.update();

	if (shifter.gearChanged()) {
		Serial.println(shifter.getGear());
	}
}

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!


2 Comments

Corey Felix · February 12, 2024 at 2:16 pm

Hi Dave, came across your YouTube channel. Im on a quest to use a USB C shifter from Amazon with my G29 wheel. Since I saw your usb adapter video I thought I’d ask if you have come up with a way to make the wheel recognize a different shifter. I’m not proficient with code but have a friend who is, so if you have any ideas I’m sure he can help me accomplish it. Thanks for all you do!

    Dave · February 12, 2024 at 2:53 pm

    Hi Corey! I haven’t done any work on reverse engineering the other side of the connection, but I’d imagine it would be more trouble than it’s worth. At a minimum you would need a USB host capable microcontroller and two digital potentiometers to mimic the shifter axes. The shifter also contains a small memory chip which may or may not be read by the wheel base. The pinout in the library documentation is a good start, but you’d really need to hook up a Logitech shifter to the wheel and start sniffing the pins to see what’s going on.

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

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

Would you like to know more?