远程控制设备的HID描述符

时间:2019-06-11 13:18:34

标签: android bluetooth hid television

我正在开发Android上的远程控制应用程序。

这是我隐藏的描述符。我能够发送以下关键事件:降低音量/提高音量,dpad中心/提高音量/降低音量/向左/右键。

private static final byte[] REPORT_MAP_REMOTE_WORKING = {
            USAGE_PAGE, 0x0c, // Usage Page (Consumer Devices)
            USAGE, 0x01, // Usage (Consumer Control)
            COLLECTION, 0x01, // Collection (Application)
            REPORT_ID, 0x01, // // Report ID
            LOGICAL_MINIMUM, 0x00, // // Logical Minimum (0)
            LOGICAL_MAXIMUM, 0x01, // // Logical Maximum (1)

            // VOLUME UP - 0 byte 0 bit - 0x01
            USAGE, (byte) 0xe9,

            // VOLUME DOWN - 0 byte 1 bit - 0x02
            USAGE, (byte) 0xea,
            REPORT_SIZE, 0x01,
            REPORT_COUNT, 0x02,
            INPUT, 0x06, // Input (Data, Variable, Relative)

            // DPAD CENTER - 0 byte 2 bit - 0x04
            USAGE, (byte) 0x41,
            REPORT_COUNT, COUNT_01,
            INPUT, 0x06, // Input (Data, Variable, Relative)

            // DPAD UP - 0 byte 3 bit - 0x08
            USAGE, (byte) 0x42,
            REPORT_COUNT, COUNT_01,
            INPUT, 0x06, // Input (Data, Variable, Relative)

            // DPAD DOWN - 0 byte 4 bit - 0x10
            USAGE, (byte) 0x43,
            REPORT_COUNT, COUNT_01,
            INPUT, 0x06, // Input (Data, Variable, Relative)

            // DPAD LEFT - 0 byte 5 bit - 0x20
            USAGE, (byte) 0x44,
            REPORT_COUNT, COUNT_01,
            INPUT, 0x06, // Input (Data, Variable, Relative)

            // DPAD RIGHT - 0 byte 6 bit - 0x40
            USAGE, (byte) 0x45,
            REPORT_COUNT, COUNT_01,
            INPUT, 0x06, // Input (Data, Variable, Relative)

            // VOLUME MUTE - 0 byte 7 bit - 0x80
            USAGE, (byte) 0xe2,
            REPORT_COUNT, COUNT_01,
            INPUT, 0x06, // Input (Data, Variable, Relative)

            END_COLLECTION, // End Collection
    };

我如何编辑此描述符以能够在任何遥控器上发送带有相应颜色按钮(红色,绿色,黄色,蓝色)的事件?

1 个答案:

答案 0 :(得分:0)

红色/绿色/蓝色/黄色按钮也是“消费者”页面上的用法。 试试这个:

//--------------------------------------------------------------------------------
// Report descriptor data in hex (length 47 bytes)
//--------------------------------------------------------------------------------


// 050C0901 A1018501 15002501 09E909EA 09410942 09430944 094509E2 0969096A
// 096B096C 7501950C 81069504 8101C0    


//--------------------------------------------------------------------------------
// 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)
85 01          (GLOBAL) REPORT_ID          0x01 (1)  
15 00          (GLOBAL) LOGICAL_MINIMUM    0x00 (0)  <-- Info: Consider replacing 15 00 with 14
25 01          (GLOBAL) LOGICAL_MAXIMUM    0x01 (1)  
09 E9          (LOCAL)  USAGE              0x000C00E9 Volume Increment (Re-trigger Control)  
09 EA          (LOCAL)  USAGE              0x000C00EA Volume Decrement (Re-trigger Control)  
09 41          (LOCAL)  USAGE              0x000C0041 Menu Pick (One Shot Control)  
09 42          (LOCAL)  USAGE              0x000C0042 Menu Up (One Shot Control)  
09 43          (LOCAL)  USAGE              0x000C0043 Menu Down (One Shot Control)  
09 44          (LOCAL)  USAGE              0x000C0044 Menu Left (One Shot Control)  
09 45          (LOCAL)  USAGE              0x000C0045 Menu Right (One Shot Control)  
09 E2          (LOCAL)  USAGE              0x000C00E2 Mute (On/Off Control)  
09 69          (LOCAL)  USAGE              0x000C0069 Red Menu Button (Momentary Control)  
09 6A          (LOCAL)  USAGE              0x000C006A Green Menu Button (Momentary Control)  
09 6B          (LOCAL)  USAGE              0x000C006B Blue Menu Button (Momentary Control)  
09 6C          (LOCAL)  USAGE              0x000C006C Yellow Menu Button (Momentary Control)  
75 01          (GLOBAL) REPORT_SIZE        0x01 (1) Number of bits per field  
95 0C          (GLOBAL) REPORT_COUNT       0x0C (12) Number of fields  
81 06          (MAIN)   INPUT              0x00000006 (12 fields x 1 bit) 0=Data 1=Variable 1=Relative 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap 
95 04          (GLOBAL) REPORT_COUNT       0x04 (4) Number of fields  
81 01          (MAIN)   INPUT              0x00000001 (4 fields x 1 bit) 1=Constant 0=Array 0=Absolute 
C0           (MAIN)   END_COLLECTION     Application 
*/

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

typedef struct
{
  uint8_t  reportId;                                 // Report ID = 0x01 (1)
                                                     // Collection: CA:ConsumerControl
  uint8_t  CD_ConsumerControlVolumeIncrement : 1;    // Usage 0x000C00E9: Volume Increment, Value = 0 to 1
  uint8_t  CD_ConsumerControlVolumeDecrement : 1;    // Usage 0x000C00EA: Volume Decrement, Value = 0 to 1
  uint8_t  CD_ConsumerControlMenuPick : 1;           // Usage 0x000C0041: Menu Pick, Value = 0 to 1
  uint8_t  CD_ConsumerControlMenuUp : 1;             // Usage 0x000C0042: Menu Up, Value = 0 to 1
  uint8_t  CD_ConsumerControlMenuDown : 1;           // Usage 0x000C0043: Menu Down, Value = 0 to 1
  uint8_t  CD_ConsumerControlMenuLeft : 1;           // Usage 0x000C0044: Menu Left, Value = 0 to 1
  uint8_t  CD_ConsumerControlMenuRight : 1;          // Usage 0x000C0045: Menu Right, Value = 0 to 1
  uint8_t  CD_ConsumerControlMute : 1;               // Usage 0x000C00E2: Mute, Value = 0 to 1
  uint8_t  CD_ConsumerControlRedMenuButton : 1;      // Usage 0x000C0069: Red Menu Button, Value = 0 to 1
  uint8_t  CD_ConsumerControlGreenMenuButton : 1;    // Usage 0x000C006A: Green Menu Button, Value = 0 to 1
  uint8_t  CD_ConsumerControlBlueMenuButton : 1;     // Usage 0x000C006B: Blue Menu Button, Value = 0 to 1
  uint8_t  CD_ConsumerControlYellowMenuButton : 1;   // Usage 0x000C006C: Yellow Menu Button, Value = 0 to 1
  uint8_t  : 1;                                      // Pad
  uint8_t  : 1;                                      // Pad
  uint8_t  : 1;                                      // Pad
  uint8_t  : 1;                                      // Pad
} inputReport01_t;