Esp32 HID descritors gamepad HELP

Hi guys so im working on a simple 2 button game pad for a shifter im making, everything works fine, but in windows and games it shows up as 8 axis 2 button device, im trying to change that so it shows Sequencal shifter, iv tired loads of diffrent examples, tried following guides etc, i must of spent over a week trying to sort this out, can anyone help? im guessing i need custom descriptors..? here is my code in the "working" state:

#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);
}

iv updated my code to this: but its still showing up as 8 axis 2 button device:

#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

// Initialize the gamepad configuration
BleGamepadConfiguration config;

// Custom HID Descriptor for the gamepad
const uint8_t customHIDDescriptor[] = {
    0x05, 0x01,        // USAGE_PAGE (Generic Desktop)
    0x09, 0x05,        // USAGE (Game Pad)
    0xa1, 0x01,        // COLLECTION (Application)
    
    // Button section
    0x15, 0x00,        // LOGICAL_MINIMUM (0)
    0x25, 0x01,        // LOGICAL_MAXIMUM (1)
    0x05, 0x09,        // USAGE_PAGE (Button)
    0x19, 0x01,        // USAGE_MINIMUM (Button 1)
    0x29, 0x02,        // USAGE_MAXIMUM (Button 2)
    0x95, 0x02,        // REPORT_COUNT (2)
    0x75, 0x01,        // REPORT_SIZE (1)
    0x81, 0x02,        // INPUT (Data, Var, Abs) 
    
    // End Collection
    0xc0,              // END_COLLECTION
};

// Initialize the gamepad instance
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);
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.