Forked from ESP32-BLE-Gamepad by lemmingDev to provide support support for composite human interface devices.
This library will let your ESP32 microcontroller behave as a bluetooth mouse, keyboard, gamepad (XInput or generic), or a combination of any of these devices.
Published under the MIT license. Please see license.txt.
- Nimble-Arduino. Actual version support Nimble-Arduino-2.1.2
- Callback. Available from the Arduino library manager or here.
- Keypad
- Bounce2
- Identify as a 40 cell 8 Dot braille display
- Receive data from the device in an output report
- Compatible with VoiceOver
- Compatible with NVDA
- Compatible with TalkBack
- Properly read and interpret the data
- All buttons and joystick axes available
- XBox One S and XBox Series X controller support
- Linux XInput support (Kernel version < 6.5 only supports the XBox One S controller)
- Haptic feedback callbacks for strong and weak motor rumble support
- LED support (pull requests welcome)
- Button press (128 buttons)
- Button release (128 buttons)
- Axes movement (6 axes (configurable resolution up to 16 bit) (x, y, z, rZ, rX, rY) --> (Left Thumb X, Left Thumb Y, Right Thumb X, Right Thumb Y, Left Trigger, Right Trigger))
- 2 Sliders (configurable resolution up to 16 bit) (Slider 1 and Slider 2)
- 4 point of view hats (ie. d-pad plus 3 other hat switches)
- Simulation controls (rudder, throttle, accelerator, brake, steering)
- Special buttons (start, select, menu, home, back, volume up, volume down, volume mute) all disabled by default
- Configurable button count
- X and Y axes
- Configurable axes
- Supports most USB HID scancodes
- Media key support
- LED callbacks for caps/num/scroll lock keys
- Configurable HID descriptors per device
- Configurable VID and PID values
- Configurable BLE characteristics (name, manufacturer, model number, software revision, serial number, firmware revision, hardware revision)
- Report optional battery level to host
- Uses efficient NimBLE bluetooth library
- Compatible with Windows
- Compatible with Android (Android OS maps default buttons / axes / hats slightly differently than Windows)
- Compatible with Linux (limited testing)
- Compatible with MacOS X (limited testing)
- Compatible with iOS (No - not even for accessibility switch - This is not a “Made for iPhone” (MFI) compatible device)
- (Make sure your IDE of choice has support for ESP32 boards available. Instructions can be found here.)
- Download the zip version of this library from Github using either the "Code" -> "Download Zip" button or by cloning this repository to your Arduino library folder. If using the downloaded zip method, in the Arduino IDE go to "Sketch" -> "Include Library" -> "Add .ZIP Library..." and select the file you just downloaded.
- Repeat the previous step but for the NimBLE library
- If you are using the Arduino IDE, you can use the included NimBLE library installed from the library manager
- Using the Arduino IDE Library manager, download the "Callback" library by Tom Stewart.
- In the Arduino IDE, you can now go to "File" -> "Examples" -> "ESP32-BLE-CompositeHID" and select an example to get started.
#include <Arduino.h>
#include <BrailleDevice.h>
#include <BleCompositeHID.h>
BleCompositeHID compositeHID("HID", "hid", 100);
BrailleDevice* braille;
void setup()
{
Serial.begin(115200);
braille = new BrailleDevice();
compositeHID.addDevice(braille);
compositeHID.begin();
Serial.println("Waiting for connection");
delay(3000);
}
void loop()
{
// do nothing
}
Credit goes to lemmingDev for his work on ESP32-BLE-Gamepad which most of the gamepad portion of this library was based upon.
USB HID codes for keyboards created by MightyPork, 2016 (see KeyboardHIDCodes.h)
Credits to T-vK as this library is based on his ESP32-BLE-Mouse library (https://github.com/T-vK/ESP32-BLE-Mouse) that he provided.
Credits to chegewara as the ESP32-BLE-Mouse library is based on this piece of code that he provided.
Credits to wakwak-koba for the NimBLE code that he provided.
You might also be interested in:
or the NimBLE versions at