Gamepad descriptor
Posted: Sun Sep 29, 2024 9:11 am
hey guys so im making a 2 button game pad for a sequencal shifter. i have everything working, but i want to change how windows see's it, at the moment it sees it as 8 axis 2 button device, in "game Controllers", how do i get it to see it as "sequencal shifter"
i get i need to use descriptor, but no idea how to do that, iv tired diffrent methords, but nothing works, im using the latest BleGamepad and NimBLE:
i get i need to use descriptor, but no idea how to do that, iv tired diffrent methords, but nothing works, im using the latest BleGamepad and NimBLE:
Code: Select all
#include <BleGamepad.h>
#include <BleGamepadConfiguration.h>
// Pin Definitions
const int BUTTON_1_PIN = 12; // Pin for Button 1
const int BUTTON_2_PIN = 13; // Pin for Button 2
// Create a gamepad configuration
BleGamepadConfiguration config;
// Initialize the gamepad instance with the name 'Gamepad Shifter'
BleGamepad gamepad("Sequential Shifter", "Craig Jenkins", 100);
void setup() {
Serial.begin(115200);
// Setup the gamepad configuration explicitly
config.setModelNumber("Sequential Shifter");
config.setSoftwareRevision("1.0");
config.setSerialNumber("123456789");
config.setFirmwareRevision("1.0");
config.setHardwareRevision("1.0");
config.setVid(0x1234); // Set your Vendor ID
config.setPid(0x5678); // Set your Product ID
config.setGuidVersion(0x0110); // Set your GUID Version
// Only declare buttons
config.setButtonCount(2); // Set button count to 2
config.setHatSwitchCount(0); // No hat switches
gamepad.begin(&config); // Initialize with the configuration
// Setup button pins as input with pull-ups
pinMode(BUTTON_1_PIN, INPUT_PULLUP);
pinMode(BUTTON_2_PIN, INPUT_PULLUP);
}
void loop() {
static bool button1State = false;
static bool button2State = false;
bool currentButton1State = digitalRead(BUTTON_1_PIN) == LOW; // Low means pressed
bool currentButton2State = digitalRead(BUTTON_2_PIN) == LOW; // Low means pressed
// Button 1 Logic
if (currentButton1State != button1State) {
button1State = currentButton1State;
if (button1State) {
gamepad.press(1); // Press Button 1
Serial.println("Button 1 Pressed");
} else {
gamepad.release(1); // Release Button 1
Serial.println("Button 1 Released");
}
}
// Button 2 Logic
if (currentButton2State != button2State) {
button2State = currentButton2State;
if (button2State) {
gamepad.press(2); // Press Button 2
Serial.println("Button 2 Pressed");
} else {
gamepad.release(2); // Release Button 2
Serial.println("Button 2 Released");
}
}
// Send updated gamepad state
gamepad.sendReport();
// Add a delay to debounce button presses
delay(10);
}