• AVR Freaks

Hot!Something wrong with the HID descriptors

Author
zkl1097
New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2014/03/07 05:57:28
  • Location: 0
  • Status: offline
2014/03/07 06:41:04 (permalink)
0

Something wrong with the HID descriptors

SmileSmileSmileSmileSmile
Hi,
   I am a new comer , and I feel lucky that I can find such fantastic website, besides, the man here seems very nice!
   Now ,I am working on a project about HID keyboard , but not everything works well, except the Play/Pause and AL Consumer Control Configuration .
   Is there any one who can help me ? Below is my report ,thanks !!!Smile
   0x05, 0x0C,     // Usage Page (Consumer Devices)  
  0x09, 0x01,     // Usage (Consumer Control)  
  0xA1, 0x01,     // Collection (Application)   
  0x85, 0x03,     //  Report ID=3      
  0x05, 0x0C,     //  Usage Page (Consumer Devices)  
  0x15, 0x00,     //  Logical Minimum (0)     
  0x25, 0x01,     //  Logical Maximum (1)     
  0x75, 0x01,     //  Report Size (1)      
  0x95, 0x08,     //  Report Count (8)     
  0x09, 0xCD,                     //  Usage (Play / Pause) bit 1         
  0x0A, 0x83, 0x01,            //      Usage (AL Consumer Control Configuration) bit2    
  0x0A, 0xAA, 0x01,            //      Uasge (AL Desktop)     bit3
  0x0A, 0x04, 0x02,            //      Usage (AC Exit)   bit4
  0x09, 0xB7,                     //  Usage (Stop)   bit5   
  0x09, 0x94,                     //  Usage (Quit)   bit6   
  0x09, 0xB3,                    //  Usage (Fast Forward) bit7
  0x09, 0xB4,                    //  Usage (Rewind)   bit8
  0x81, 0x02,                    //  Input (Data, Variable, Absolute)      
  0xC0                              // End Collection 
#1

3 Replies Related Threads

    Alan_O
    Super Member
    • Total Posts : 268
    • Reward points : 0
    • Joined: 2013/09/23 13:16:02
    • Location: Orlando, FL United States of America
    • Status: offline
    Re:Something wrong with the HID descriptors 2014/03/07 08:20:58 (permalink)
    0
    You need to use a 16-bit item for that one:

      0x0A, 0xCD, 0x00                    //  Usage (Play / Pause) bit 1      

     
    It's because data in a report descriptor is signed, making 0xCD a negative number (because the sign bit it set). If it's 16-bit, the sign bit is moved out of the way.
     
    Alan.
     
    #2
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    Re:Something wrong with the HID descriptors 2014/03/07 13:43:04 (permalink)
    0
    You have to be aware of Usage Types.
    Depending on Usage Type, Logical min/max and Input flags alters.
    As of the details of Usage Types, refer to "3.4.1 Usage Types (Controls)" section in "HID Usage Tables 1.12" on USB.org
    http://www.usb.org/develo...ass_docs/Hut1_12v2.pdf

    a) One Shot Control (OSC)
    These Usages are assigned to OSC.
    - Play/Pause
    - Stop
    - Quit

    For this Usage Type,
    - Logical min/max (0/1)
    - Input flags (Relative, Preferred State)

    On/Off Control (OOC)
    These Usages are assigned to OOC.
    - Fast Forward
    - Rewind

    There are three options for this type
    1. two buttons (On and Off)
    - Logical min/max (-1/1)
    - Input flags (Relative, No Preferred)
    2. one push button, which toggles state at every push
    - Logical min/max (0/1)
    - Input flags (Relative, Preferred State)
    3. one push button, momentary switch
    - Logical min/max (0/1)
    - Input flags (Absolute, No Preferred)
    The third option fits to above Usages

    Selector (Sel)
    These Usages are Selectors, which belong to "Application Launch Buttons" (Usage: 0x0180)
    - AL Consumer Control Configuration
    - AL Desktop
    This Usage is also a Selector, which belongs to "Generic GUI Application Controls" (Usage:  0x0200)
    - AC Exit
    Selectors are defined in a separate Named Array collection.
    Refer to "A.4 Named Array Field" section of Hut1_12v2.pdf


    char ReportDescriptor[68] = {
        0x05, 0x0c,                    // USAGE_PAGE (Consumer Devices)
        0x09, 0x01,                    // USAGE (Consumer Control)
        0xa1, 0x01,                    // COLLECTION (Application)
                                 // OSC usages
        0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
        0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
        0x75, 0x01,                    //   REPORT_SIZE (1)
        0x95, 0x03,                    //   REPORT_COUNT (3)
        0x09, 0xcd,                    //   USAGE (Play/Pause)
        0x09, 0xb7,                    //   USAGE (Stop)
        0x09, 0x94,                    //   USAGE (Quit)
        0x81, 0x06,                    //   INPUT (Data,Var,Rel)
                                 // OOC usages
        0x95, 0x02,                    //   REPORT_COUNT (2)
        0x09, 0xb3,                    //   USAGE (Fast Forward)
        0x09, 0xb4,                    //   USAGE (Rewind)
        0x81, 0x22,                    //   INPUT (Data,Var,Abs,NPrf)
                                 // Sel usages 1
        0x0a, 0x80, 0x01,              //   USAGE (Application Launch Buttons)
        0xa1, 0x02,                    //   COLLECTION (Logical)
        0x15, 0x01,                    //     LOGICAL_MINIMUM (1)
        0x25, 0x02,                    //     LOGICAL_MAXIMUM (2)
        0x75, 0x02,                    //     REPORT_SIZE (2)
        0x95, 0x01,                    //     REPORT_COUNT (1)
        0x0a, 0x83, 0x01,              //     USAGE (AL Consumer Control Configuration) - index 1
        0x0a, 0xaa, 0x01,              //     USAGE (AL Desktop)                        - index 2
        0x81, 0x00,                    //     INPUT (Data,Ary,Abs)    - index 0 means none of above is selected
        0xc0,                          //     END_COLLECTION
                                 // Sel usages 2
        0x0a, 0x00, 0x02,              //   USAGE (Generic GUI Application Controls)
        0xa1, 0x02,                    //   COLLECTION (Logical)
        0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
        0x75, 0x01,                    //     REPORT_SIZE (1)
        0x0a, 0x04, 0x02,              //     USAGE (AC Exit)               - index 1
        0x81, 0x00,                    //     INPUT (Data,Ary,Abs)
        0xc0,                          //     END_COLLECTION
        0xc0                           // END_COLLECTION
    };


    Tsuneo
    #3
    odon
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/11/23 02:04:36
    • Location: 0
    • Status: offline
    Re:Something wrong with the HID descriptors 2021/01/19 03:50:58 (permalink)
    +1 (1)
    chinzei

    char ReportDescriptor[68] = {
       0x05, 0x0c,                    // USAGE_PAGE (Consumer Devices)
       0x09, 0x01,                    // USAGE (Consumer Control)
       0xa1, 0x01,                    // COLLECTION (Application)
                                // OSC usages
       0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
       0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
       0x75, 0x01,                    //   REPORT_SIZE (1)
       0x95, 0x03,                    //   REPORT_COUNT (3)
       0x09, 0xcd,                    //   USAGE (Play/Pause)
       0x09, 0xb7,                    //   USAGE (Stop)
       0x09, 0x94,                    //   USAGE (Quit)
       0x81, 0x06,                    //   INPUT (Data,Var,Rel)
                                // OOC usages
       0x95, 0x02,                    //   REPORT_COUNT (2)
       0x09, 0xb3,                    //   USAGE (Fast Forward)
       0x09, 0xb4,                    //   USAGE (Rewind)
       0x81, 0x22,                    //   INPUT (Data,Var,Abs,NPrf)
                                // Sel usages 1
       0x0a, 0x80, 0x01,              //   USAGE (Application Launch Buttons)
       0xa1, 0x02,                    //   COLLECTION (Logical)
       0x15, 0x01,                    //     LOGICAL_MINIMUM (1)
       0x25, 0x02,                    //     LOGICAL_MAXIMUM (2)
       0x75, 0x02,                    //     REPORT_SIZE (2)
       0x95, 0x01,                    //     REPORT_COUNT (1)
       0x0a, 0x83, 0x01,              //     USAGE (AL Consumer Control Configuration) - index 1
       0x0a, 0xaa, 0x01,              //     USAGE (AL Desktop)                        - index 2
       0x81, 0x00,                    //     INPUT (Data,Ary,Abs)    - index 0 means none of above is selected
       0xc0,                          //     END_COLLECTION
                                // Sel usages 2
       0x0a, 0x00, 0x02,              //   USAGE (Generic GUI Application Controls)
       0xa1, 0x02,                    //   COLLECTION (Logical)
       0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
       0x75, 0x01,                    //     REPORT_SIZE (1)
       0x0a, 0x04, 0x02,              //     USAGE (AC Exit)               - index 1
       0x81, 0x00,                    //     INPUT (Data,Ary,Abs)
       0xc0,                          //     END_COLLECTION
       0xc0                           // END_COLLECTION
    };

    I have a question regarding this structure of report descriptor. Why the usages commented by "sel usages X" are wrapped with sub-collection. Shouldn't the OOC and OSC collection also be wrapped, or none collections (logical) removed from sel usages 1 and 2?
     
    What is data format for a report is it cotinous sequence of bits:
    PlayPause/Stop/Quit/FF/Reverse/control/desktop/ac exit?
    #4
    Jump to:
    © 2021 APG vNext Commercial Version 4.5