This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UsageMin/UsageMax

In all of Keil's USBHID examples, there are two items in the Report Descriptor called UsageMin and UsageMax.
Thy are set to 1 and 3. I have reviewed the USB Usage Spec and several other examples and I still don't understand the need for these two items of range.
I can find no other example of these two items. In MSDN2, I find the HIDP_Value_CAPS structure that includes the RANGE.UsageMin and RANGE.UsageMax that tells about the bounds but what is their use?
In Keil's HIDClient code, I see no place where the two items are used. Of course when I comment out the two lines of code, the code fails. Probably I'm breaking an array count somewhere when I comment out the code.
I'm hoping that someone like Tsuneo can educate me on the two items. I have sent a query to Keil Support but it will be awhile before I expect an answer.
Al Bradford

Parents
  • You'll see a good example in the report descriptor for USB keyboard.

    "Device Class Definition for HID 1.11"
    www.usb.org/.../HID1_11.pdf
    E.6 Report Descriptor (Keyboard) (HID1_11.pdf p69)

    This excerpt shows the definition of modifier keys (CTRL, ALT, SHIFT and GUI)

    // ------- Input for the Modifier byte -----------
    05 07   Usage Page (Key Codes)   -- usage is defined in the Keyboard page (0x07)
    19 E0   Usage Minimum (224)      -- the first item is "Keyboard LeftControl"
    29 E7   Usage Maximum (231)      -- the last item is "Keyboard Right GUI"
    15 00   Logical Minimum (0)      -- the value is 0 or 1
    25 01   Logical Maximum (1)
    75 01   Report Size (1)          -- each item has a bit
    95 08   Report Count (8)         -- 8 bits, as a whole
    81 02   Input (Data, Variable, Absolute) -- the modifier byte
    

    - First, looking at the "Usage Page", you'll know the "Usage" is defined in the Keyboard page (0x07).
    - Then, you'll open the "HID Usage Tables" and look into the long table on
    "10 Keyboard/Keypad Page (0x07)" chapter.

    "HID Usage Tables 1.12"
    www.usb.org/.../Hut1_12.pdf

    At the end of the table, you'll see these values.

    Table 12: Keyboard/Keypad Page (Hut1_12.pdf p60)
    
    224 E0   Keyboard LeftControl  -- Usage Minimum
    225 E1   Keyboard LeftShift
    226 E2   Keyboard LeftAlt
    227 E3   Keyboard Left GUI
    228 E4   Keyboard RightControl
    229 E5   Keyboard RightShift
    230 E6   Keyboard RightAlt
    231 E7   Keyboard Right GUI    -- Usage Maximum
    

    This pair of Usage Minimum/ Maximum specifies eight "Usages", from "Keyboard LeftControl" to "Keyboard Right GUI". It gives the "name" (or attribute) to each bit.

    Bit    Key
     0   LEFT CTRL
     1   LEFT SHIFT
     2   LEFT ALT
     3   LEFT GUI
     4   RIGHT CTRL
     5   RIGHT SHIFT
     6   RIGHT ALT
     7   RIGHT GUI
    

    .

    This kind of detailed HID "grammar" is useful when you make up an established HID, like keyboard or mouse. When you handle a vendor-specific HID, you can do without such a detail :-)

    For example, this report descriptor shows a vender-specific HID with IN and OUT endpoints. 64 bytes Input and Output report are defined, respectively.

        0x06, 0x00, 0xff,       // USAGE_PAGE (Vendor Defined Page 1)
        0x09, 0x01,             // USAGE (Vendor Usage 1)
        0xa1, 0x01,             // COLLECTION (Application)
        0x15, 0x00,             //  LOGICAL_MINIMUM (0)
        0x26, 0xff, 0x00,       //  LOGICAL_MAXIMUM (255)
        0x75, 0x08,             //  REPORT_SIZE  (8)    - bits
        0x95, 0x40,             //  REPORT_COUNT (64)   - Bytes
        0x09, 0x01,             //  USAGE (Vendor Usage 1)
        0x81, 0x02,             //  INPUT (Data,Var,Abs)
        0x09, 0x01,             //  USAGE (Vendor Usage 1)
        0x91, 0x02,             //  OUTPUT (Data,Var,Abs)
        0xc0                    // END_COLLECTION
    

    This one is the same one that I've advised to fix the bug of the report descriptor of ULINK2, in this post.

    "ULINK2 slow performance on USB 2.0"
    http://www.keil.com/forum/docs/thread11783.asp

    That is, a vendor-specific HID like ULINK2, this simple report descriptor is enough. You don't need to define the usage of each items precisely.

    Tsuneo

Reply
  • You'll see a good example in the report descriptor for USB keyboard.

    "Device Class Definition for HID 1.11"
    www.usb.org/.../HID1_11.pdf
    E.6 Report Descriptor (Keyboard) (HID1_11.pdf p69)

    This excerpt shows the definition of modifier keys (CTRL, ALT, SHIFT and GUI)

    // ------- Input for the Modifier byte -----------
    05 07   Usage Page (Key Codes)   -- usage is defined in the Keyboard page (0x07)
    19 E0   Usage Minimum (224)      -- the first item is "Keyboard LeftControl"
    29 E7   Usage Maximum (231)      -- the last item is "Keyboard Right GUI"
    15 00   Logical Minimum (0)      -- the value is 0 or 1
    25 01   Logical Maximum (1)
    75 01   Report Size (1)          -- each item has a bit
    95 08   Report Count (8)         -- 8 bits, as a whole
    81 02   Input (Data, Variable, Absolute) -- the modifier byte
    

    - First, looking at the "Usage Page", you'll know the "Usage" is defined in the Keyboard page (0x07).
    - Then, you'll open the "HID Usage Tables" and look into the long table on
    "10 Keyboard/Keypad Page (0x07)" chapter.

    "HID Usage Tables 1.12"
    www.usb.org/.../Hut1_12.pdf

    At the end of the table, you'll see these values.

    Table 12: Keyboard/Keypad Page (Hut1_12.pdf p60)
    
    224 E0   Keyboard LeftControl  -- Usage Minimum
    225 E1   Keyboard LeftShift
    226 E2   Keyboard LeftAlt
    227 E3   Keyboard Left GUI
    228 E4   Keyboard RightControl
    229 E5   Keyboard RightShift
    230 E6   Keyboard RightAlt
    231 E7   Keyboard Right GUI    -- Usage Maximum
    

    This pair of Usage Minimum/ Maximum specifies eight "Usages", from "Keyboard LeftControl" to "Keyboard Right GUI". It gives the "name" (or attribute) to each bit.

    Bit    Key
     0   LEFT CTRL
     1   LEFT SHIFT
     2   LEFT ALT
     3   LEFT GUI
     4   RIGHT CTRL
     5   RIGHT SHIFT
     6   RIGHT ALT
     7   RIGHT GUI
    

    .

    This kind of detailed HID "grammar" is useful when you make up an established HID, like keyboard or mouse. When you handle a vendor-specific HID, you can do without such a detail :-)

    For example, this report descriptor shows a vender-specific HID with IN and OUT endpoints. 64 bytes Input and Output report are defined, respectively.

        0x06, 0x00, 0xff,       // USAGE_PAGE (Vendor Defined Page 1)
        0x09, 0x01,             // USAGE (Vendor Usage 1)
        0xa1, 0x01,             // COLLECTION (Application)
        0x15, 0x00,             //  LOGICAL_MINIMUM (0)
        0x26, 0xff, 0x00,       //  LOGICAL_MAXIMUM (255)
        0x75, 0x08,             //  REPORT_SIZE  (8)    - bits
        0x95, 0x40,             //  REPORT_COUNT (64)   - Bytes
        0x09, 0x01,             //  USAGE (Vendor Usage 1)
        0x81, 0x02,             //  INPUT (Data,Var,Abs)
        0x09, 0x01,             //  USAGE (Vendor Usage 1)
        0x91, 0x02,             //  OUTPUT (Data,Var,Abs)
        0xc0                    // END_COLLECTION
    

    This one is the same one that I've advised to fix the bug of the report descriptor of ULINK2, in this post.

    "ULINK2 slow performance on USB 2.0"
    http://www.keil.com/forum/docs/thread11783.asp

    That is, a vendor-specific HID like ULINK2, this simple report descriptor is enough. You don't need to define the usage of each items precisely.

    Tsuneo

Children