I am new to ESP32. My goal is to create a Windows HID device that will be recognized under game controllers. This is for a flight simulator and I want to read button presses, and I will set them up in the flight simulator. I followed some tutorials and got my ESP32 board set up and reading a button press. It prints to the serial output window and that all seems to work. I originally had an ESP32D board but understood that this board can't be set up as a Windows HID device. I was under the impression that an ESP32-S3 board can, so I bought one of those. I can get the button press sketch (Arduino IED) to work on this board, just as it does on the 32D board, but I am unable to get Windows to recognize this board as a HID device. Can someone point me in the correct direction to make this work? Thanks in advance for the help. I do appreciate it.
________________________________________________________________________________________________________________
This is the sketch I most recently tried. It seems to upload fine and run fine, but Windows does not recognize it as a HID device.
________________________________________________________________________________________________________________
// Simple example application that shows how to read four Arduino
// digital pins and map them to the USB Joystick library.
//
// Ground digital pins 9, 10, 11, and 12 to press the joystick
// buttons 0, 1, 2, and 3.
//
// NOTE: This sketch file is for use with Arduino Leonardo and
// Arduino Micro only.
//
// by Matthew Heironimus
// 2015-11-20
//--------------------------------------------------------------------
#include <Joystick_ESP32S2.h>
Joystick_ Joystick;
void setup() {
// Initialize Button Pins
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
// Initialize Joystick Library
Joystick.begin();
}
// Constant that maps the phyical pin to the joystick button.
const int pinToButtonMap = 9;
// Last state of the button
int lastButtonState[4] = {0,0,0,0};
void loop() {
// Read pin values
for (int index = 0; index < 4; index++)
{
int currentButtonState = !digitalRead(index + pinToButtonMap);
if (currentButtonState != lastButtonState[index])
{
Joystick.setButton(index, currentButtonState);
lastButtonState[index] = currentButtonState;
}
}
delay(50);
}
Newbie needing a little help getting started
-
pilotguy9853
- Posts: 6
- Joined: Sun May 11, 2025 2:23 pm
-
ahsrabrifat
- Posts: 201
- Joined: Sat Jan 18, 2025 2:31 pm
Re: Newbie needing a little help getting started
The sketch you're using was originally made for the Arduino Leonardo/Micro, which have native USB HID support. On ESP32-S3, that sketch and Joystick_ESP32S2.h won’t work out-of-the-box unless you’ve installed and configured everything correctly.
-
pilotguy9853
- Posts: 6
- Joined: Sun May 11, 2025 2:23 pm
Re: Newbie needing a little help getting started
I am at a loss for what I need to check to make sure it is installed and configured properly. I have this set under boards manager:
https://espressif.github.io/arduino-esp ... index.json
I have the library installed. What other settings do I need to check?
Thanks
https://espressif.github.io/arduino-esp ... index.json
I have the library installed. What other settings do I need to check?
Thanks
-
pilotguy9853
- Posts: 6
- Joined: Sun May 11, 2025 2:23 pm
Re: Newbie needing a little help getting started
So after much digging on the internet and trying lots of things I finally was able to get this working using the Tiny USB library.
Who is online
Users browsing this forum: Applebot, Bing [Bot], ChatGPT-User, Google [Bot], PerplexityBot, Semrush [Bot] and 11 guests