fix: 更新消费者控制报告以支持播放/暂停功能

- 修改 HID 报告定义,将播放按钮的 ID 更新为播放/暂停
- 更新消费者报告映射,添加播放/暂停的使用情况
- 调整逻辑以确保播放/暂停功能正确映射到新的报告 ID
This commit is contained in:
2026-07-02 22:30:06 +08:00
parent 8254bc7d50
commit ab6fcefea0
+6 -5
View File
@@ -27,9 +27,9 @@ static const char *TAG = "ble_hid";
#define HID_CC_RPT_VOLUME_UP 0x40
#define HID_CC_RPT_VOLUME_DOWN 0x80
#define HID_CC_RPT_MUTE 1
#define HID_CC_RPT_PLAY 5
#define HID_CC_RPT_SCAN_NEXT_TRK 10
#define HID_CC_RPT_SCAN_PREV_TRK 11
#define HID_CC_RPT_PLAY_PAUSE 13
#define HID_CC_RPT_SCAN_NEXT_TRK 10
#define HID_CC_RPT_SCAN_PREV_TRK 11
/*
* Keyboard (Report ID 1) + Consumer Control (Report ID 2, mediaReportMap2).
@@ -113,8 +113,9 @@ static const unsigned char s_hid_report_map[] = {
0x09, 0xB5, // Usage (Scan Next Track)
0x09, 0xB6, // Usage (Scan Previous Track)
0x09, 0xB7, // Usage (Stop)
0x09, 0xCD, // Usage (Play/Pause)
0x15, 0x01, // Logical Minimum (1)
0x25, 0x0C, // Logical Maximum (12)
0x25, 0x0D, // Logical Maximum (13)
0x75, 0x04, // Report Size (4)
0x95, 0x01, // Report Count (1)
0x81, 0x00, // Input (Data, Array, Absolute)
@@ -187,7 +188,7 @@ static bool ble_hid_encode_consumer_report(uint16_t usage, uint8_t buffer[HID_CO
ble_hid_cc_set_button(buffer, HID_CC_RPT_MUTE);
return true;
case HID_CONSUMER_PLAY_PAUSE:
ble_hid_cc_set_button(buffer, HID_CC_RPT_PLAY);
ble_hid_cc_set_button(buffer, HID_CC_RPT_PLAY_PAUSE);
return true;
case HID_CONSUMER_SCAN_NEXT:
ble_hid_cc_set_button(buffer, HID_CC_RPT_SCAN_NEXT_TRK);