1

我正在尝试使用 Arduino 创建单键蓝牙键盘并努力构建有效的 HID 描述符。我已经能够使用默认的通用桌面键盘 HID 描述符将按键事件发送到我的 iOS 设备,但是一旦我尝试使用以下 HID 描述符,我在发送时无法触发主页按钮事件(AC Home:0x0223) HID 报告将位 0 ​​从 0 → 1 → 0 切换:

0x05, 0x0c,       // USAGE_PAGE (Consumer Devices)
 0x09, 0x01,      // USAGE (Consumer Control)
 0xa1, 0x01,      // COLLECTION (Application)
 0x15, 0x00,      // LOGICAL_MINIMUM (0)
 0x25, 0x01,      // LOGICAL_MAXIMUM (1)
 0x75, 0x01,      // REPORT_SIZE (1)
 0x95, 0x01,      // REPORT_COUNT (1)
 0x0c, 0x02, 0x23 // USAGE (AC Home)
 0x81, 0x06,      // INPUT (Data,Var,Rel)
 0x95, 0x07,      // REPORT_COUNT (7 bytes of padding)
 0x81, 0x03,      // INPUT (Cnst,Var,Abs)
 0xc0             // END_COLLECTION

我在构建 HID 描述符时遗漏了什么?AC Home 不是 iOS 中主页按钮的正确使用 ID 吗?

任何帮助将不胜感激!

4

1 回答 1

0

是的,您的描述符中有一个小错误:

0x0c, 0x02, 0x23 // USAGE (AC Home)

应该:

0x0a, 0x23, 0x02 // USAGE (AC Home)

您当前的描述符解码为:

//--------------------------------------------------------------------------------
// Decoded Application Collection
//--------------------------------------------------------------------------------

/*
05 0C        (GLOBAL) USAGE_PAGE         0x000C Consumer Device Page 
09 01        (LOCAL)  USAGE              0x000C0001 Consumer Control (Application Collection)  
A1 01        (MAIN)   COLLECTION         0x01 Application (Usage=0x000C0001: Page=Consumer Device Page, Usage=Consumer Control, Type=Application Collection)
15 00          (GLOBAL) LOGICAL_MINIMUM    0x00 (0)  <-- Info: Consider replacing 15 00 with 14
25 01          (GLOBAL) LOGICAL_MAXIMUM    0x01 (1)  
75 01          (GLOBAL) REPORT_SIZE        0x01 (1) Number of bits per field  
95 01          (GLOBAL) REPORT_COUNT       0x01 (1) Number of fields  
0C             (ERROR)                     <-- Error: Item (0C) is not a MAIN, GLOBAL or LOCAL item
02 2381        (MAIN)                      <-- Error: Item (02) is not a MAIN item. Expected INPUT(8x) OUTPUT(9x) FEATURE(Bx) COLLECTION(Ax) or END_COLLECTION(Cx) (where x = 0,1,2,3).
06 9507        (GLOBAL) USAGE_PAGE         0x0795 Reserved 
81 03          (MAIN)   INPUT              0x00000003 (1 field x 1 bit) 1=Constant 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap 
C0           (MAIN)   END_COLLECTION     Application 
*/

//--------------------------------------------------------------------------------
// Reserved inputReport (Device --> Host)
//--------------------------------------------------------------------------------

typedef struct
{
                                                     // No REPORT ID byte
                                                     // Collection: CA:ConsumerControl
  uint8_t  : 1;                                      // Pad
} inputReport_t;

实施上述更改后,它看起来更好:

//--------------------------------------------------------------------------------
// Decoded Application Collection
//--------------------------------------------------------------------------------

/*
05 0C        (GLOBAL) USAGE_PAGE         0x000C Consumer Device Page 
09 01        (LOCAL)  USAGE              0x000C0001 Consumer Control (Application Collection)  
A1 01        (MAIN)   COLLECTION         0x01 Application (Usage=0x000C0001: Page=Consumer Device Page, Usage=Consumer Control, Type=Application Collection)
15 00          (GLOBAL) LOGICAL_MINIMUM    0x00 (0)  <-- Info: Consider replacing 15 00 with 14
25 01          (GLOBAL) LOGICAL_MAXIMUM    0x01 (1)  
75 01          (GLOBAL) REPORT_SIZE        0x01 (1) Number of bits per field  
95 01          (GLOBAL) REPORT_COUNT       0x01 (1) Number of fields  
0A 2302        (LOCAL)  USAGE              0x000C0223 AC Home (Selector)  
81 06          (MAIN)   INPUT              0x00000006 (1 field x 1 bit) 0=Data 1=Variable 1=Relative 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap 
95 07          (GLOBAL) REPORT_COUNT       0x07 (7) Number of fields  
81 03          (MAIN)   INPUT              0x00000003 (7 fields x 1 bit) 1=Constant 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap 
C0           (MAIN)   END_COLLECTION     Application 
*/

//--------------------------------------------------------------------------------
// Consumer Device Page inputReport (Device --> Host)
//--------------------------------------------------------------------------------

typedef struct
{
                                                     // No REPORT ID byte
                                                     // Collection: CA:ConsumerControl
  uint8_t  CD_ConsumerControlAcHome : 1;             // Usage 0x000C0223: AC Home, Value = 0 to 1
  uint8_t  : 1;                                      // Pad
  uint8_t  : 1;                                      // Pad
  uint8_t  : 1;                                      // Pad
  uint8_t  : 1;                                      // Pad
  uint8_t  : 1;                                      // Pad
  uint8_t  : 1;                                      // Pad
  uint8_t  : 1;                                      // Pad
} inputReport_t;

... HID 描述符是用来自githubsourceforge的 hidrdd(免费软件)解码的

于 2020-02-29T03:16:24.590 回答