Arduino Gamepad Emulator

Hi, im new with Arduino and i want to introduce my project which is called Arduino Gamepad Emulator and a minimalistic arduino library that enables to make use of the main application.

I wanted to make a gamepad with my Arduino UNO clone by attaching buttons and joysticks to it. I found out that in case of Arduino UNO or NANO its not as easy as it may seem to be because they don’t have a ATmega32u4 chip which supports HID class. In this case we cannot use directly the most popular library called “Joystick.h”.
I read that to achieve the desired effect it is needed to use Flip application and reprogram chip firmware which is possible only when having ATmega16u4 (im not sure). But cheaper clones have a CH340 chip too… I don’t know what to do then.

Inspired by a youtube video i wrote a minimalistic arduino library which handles buttons and joysticks and sends messages about its state changes via serial port.

Additionally i wrote a C++ console application which tracks the messages sent via serial port from arduino and enables to assign actions to components connected to arduino. Buttons can emulate keys. Joystick can emulate either mouse or 4 buttons.

I think the whole thing met my expectations, all you need is a few lines of code in arduino and a very fast configuration in application and you have a working
gamepad ! :slight_smile:

A disadvantage of the app is that it has to run in the background…
But I tested it in the Witcher 3, and on my machine(i7-6820hq) i noticed increase in CPU usage within only 1 percent.

Links to github repositories :

Arduino gamepad library
Gamepad emulator

I’d love to hear your feedback :slight_smile:

Tried to understand how you managed to emulate key presses on PC but failed. There’s no documentation on how this thing works. If you want feedback, you need to provide the basic things for others to first understand how your PC code works, and maybe how it should be compiled?

Is that a lot different than what the Arduino Esplora was?
https://www.arduino.cc/en/Main/Products

(Esplora specific links are not working at the moment)

I think OP didn’t have a Leonardo with a 32u4 like the esplora does. They sent key presss via serial port and the PC-side code reads the serial port and emulates keyboard actions which I am interested in.

You are right, i should have described it better. I updated the application github repository. Since now there are some instructions provided for building the project(with premake).

I also added two sentences to the explanation of how it works.
So i can copy and paste it here :
The way it does it is pretty simple. I used two functions provided in <windows.h> library :
SetCursorPos
keybd_event
The first to handle mouse movement, and the second to handle key pressing.

And actually thats it, everything else is briefly described and i think its enough for the presentation purpose. I don’t know what else I can write.

If someone wants to get deeper always can dive into the code, its only like 500 lines.

Here is a youtube video which inspired me to do this :
LINK

The key/mouse emulating mechanisms used are the same, but the serial communication was realized in slightly different way.

Great! Thanks for considering my recommendation. I’ll have a look right after work today. I’m quite interested in emulating HID on a PC, with or without an arduino :wink: