BLE HID device Gamepad button click not recognised on iOS

alkurop
Posts: 1
Joined: Sun Jun 16, 2024 2:17 pm

BLE HID device Gamepad button click not recognised on iOS

Postby alkurop » Sun Jun 16, 2024 5:57 pm

Hi. I'm working on a Gamepad device, following esp_hid_device example.
I have modified the example to run under bluedroid, modify the demo function to:

esp_hid_ble_gap_adv_init(ESP_HID_APPEARANCE_GAMEPAD, ble_hid_config.device_name);

const unsigned char mediaReportMap[] = {
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x04, // USAGE (Gamepad)
0xa1, 0x01, // COLLECTION (Application)
0x85, 0x00, // Report id 0
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x03, // USAGE_MAXIMUM (Button 3)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x95, 0x03, // REPORT_COUNT (3)
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
// padding
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x05, // REPORT_SIZE (5)
0x81, 0x03, // Input(Constant, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField)

0xc0 // END_COLLECTION
};

void esp_hidd_send_consumer_value(uint8_t key_cmd, bool key_pressed)
{
uint8_t buffer[1] = {0};
if (key_pressed)
{
buffer[0] = 1;
}

esp_err_t res = esp_hidd_dev_input_set(s_ble_hid_param.hid_dev, 0, 0x00, buffer, 1);

return;
}

The device is recognised as a Gamepade device on iOS and Android.
On Android this sample works as expected. The button clicks are recognised.
However, on iOS the pairing works but clicks are not recognised.

I have tried the same operation with a PS4 joystick. After connecting it, I go to the Switch Access setting on iOS, and add an external switch. When I click the button, it is recognised. But with my ESP32C3 device, the is no reaction to button click.
This issues is only happening on iOS, because Android does react to the button click in Switch Access.

Please help me to configure the device.

fedekrum
Posts: 3
Joined: Tue Oct 01, 2024 1:38 pm

Re: BLE HID device Gamepad button click not recognised on iOS

Postby fedekrum » Thu Oct 31, 2024 6:39 am

https://github.com/lemmingDev/ESP32-BLE ... me-ov-file
Compatible with iOS (No - not even for accessibility switch - This is not a “Made for iPhone” (MFI) compatible device)

chegewara
Posts: 2375
Joined: Wed Jun 14, 2017 9:00 pm

Re: BLE HID device Gamepad button click not recognised on iOS

Postby chegewara » Tue Nov 05, 2024 7:42 am

Hi,
i didnt check the whole descriptor, if its correct or not, but one thing you should check.
Some drivers on some OSs may have "problem" with report ID 0.
It is no against specification, but some of them may expect that HID data include report ID and some are expecting it is not included if its 0.
Lets say it is safe to set report ID to any value but 0.

Who is online

Users browsing this forum: Google [Bot] and 196 guests