• AVR Freaks

USB-Mouse HID Descriptor

Page: 12 > Showing page 1 of 2
Author
bergenrov
New Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2009/03/27 01:52:33
  • Location: 0
  • Status: offline
2009/03/27 02:12:36 (permalink)
0

USB-Mouse HID Descriptor


Im working on a project where im trying adapt the USB-Mouse HID example the Microchip provided for the PIC18f4550 to work with a resistive touch screen. The problem im having is that I modified it to send absolute coordinates but descriptor only transfer two bytes of signed data for each axis (x,y). And this gives a very low accuracy if used with lager resolutions displays. When I try to modify it to send 4 bytes the entire protocol stops working.
Could some one please point out what im doing wrong?
 
 
rom struct{byte report[52];}hid_rpt01={

0x05, 0x01, /* Usage Page (Generic Desktop) */


0x09, 0x02, /* Usage (Mouse) */
0xA1, 0x01, /* Collection (Application) */

0x09, 0x01, /* Usage (Pointer) */
0xA1, 0x00, /* Collection (Physical) */

0x05, 0x09, /* Usage Page (Buttons) */
0x19, 0x01, /* Usage Minimum (01) */
0x29, 0x03, /* Usage Maximum (03) */
0x15, 0x00, /* Logical Minimum (0) */
0x95, 0x03, /* Report Count (3) */
0x75, 0x01, /* Report Size (1) */
0x25, 0x01, /* Logical Maximum (0) */
0x81, 0x02, /* Input (Data, Variable, Absolute) */
0x95, 0x01, /* Report Count (1) */
0x75, 0x05, /* Report Size (5) */
0x81, 0x01, /* Input (Constant) ;5 bit padding */
0x05, 0x01, /* Usage Page (Generic Desktop) */
0x09, 0x30, /* Usage (X) */
0x09, 0x31, /* Usage (Y) */

0x15, 0x81, 0x00, // USAGE_MINIMUM
0x25, 0x7F, 0x00, // USAGE_MAXIMUM

0x75, 0x10, /* Report Size (16) */
0x95, 0x02, /* Report Count (2) */
0x81, 0x02, /* Input (Data, Variable, Absolute) */


0xC0, 0xC0};/* End Collection,End Collection */
#1

23 Replies Related Threads

    friesen
    Super Member
    • Total Posts : 2125
    • Reward points : 0
    • Joined: 2008/05/08 05:23:35
    • Location: Indiana, USA
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/03/27 04:57:38 (permalink)
    0
    You need to give us more information.  What did you change?

    Erik Friesen
    #2
    bergenrov
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2009/03/27 01:52:33
    • Location: 0
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/03/27 05:32:34 (permalink)
    0
    Hi erik,
     
    I added one byte 0x00 to the USAGE_MINIMUM and MAX (ex 0x15, 0x81, //MIN to 0x15, 0x81, 0x00, //MIN)
    Increased the report size for the X,Y part from 8 to 16 and also increased the rom struct from 50 to 52.
    #3
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/03/27 06:39:34 (permalink)
    0
    0x15, 0x81, 0x00, // USAGE_MINIMUM
    0x25, 0x7F, 0x00, // USAGE_MAXIMUM

    The last 2 bits (bSize field) of the item prefix (the first byte of each line) shows the number of bytes after this prefix (*1)

    bSize bytes
    00 0
    01 1
    10 2
    11 4

    Above lines are revised as follows.
    0x16, 0x81, 0x00, // Logical_MINIMUM (2 bytes)
    0x26, 0x7F, 0x00, // Logical_MAXIMUM (2 bytes)


    For absolute value, unsigned number may be better

    0x15, 0x00, // Logical Minimum (0)
    0x26, 0xFF, 0x00, // Logical Maximum (255)


    Use HID Descriptor Tool to make up valid report descriptors.

    "HID Descriptor Tool" from USB.org
    http://www.usb.org/developers/hidpage/dt2_4.zip

    [Reference]
    (*1) See this page of the USB HID spec
    6.2.2.2 Short Items (HID1_11.pdf p26)
    http://www.usb.org/developers/devclass_docs/HID1_11.pdf

    Tsuneo
    #4
    bergenrov
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2009/03/27 01:52:33
    • Location: 0
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/01 00:43:51 (permalink)
    0
    Thank you for your help.
    I have noticed that the problem is that my HID only transfers 3 bytes of data while I need it to transfer 5 bytes but I cant find were in the code the payload size is defined. In what descriptor should I look for it. I only one Configuration, Interface, HID Class, Endpoint.
     
     
    /* Device Descriptor */
    rom USB_DEV_DSC device_dsc=
    {   
        sizeof(USB_DEV_DSC),    // bLength     // Size of this descriptor in bytes
        DSC_DEV,                // bDescriptorType   // DEVICE descriptor type
        0x0200,                 // bcdUSB    // USB Spec Release Number in BCD format
        0x00,                   // bDeviceClass   // Class Code
        0x00,                   // bDeviceSubClass  // Subclass code
        0x00,                   // bDeviceProtocol  // Protocol code
        EP0_BUFF_SIZE,          // bMaxPacketSize  // Max packet size for EP0, see usbcfg.h
        0x04D8,                 // idVendor    // Vendor ID
        0x0000,                 // idProduct   // Product ID: Mouse in a circle fw demo
        0x0001,                 // bcdDevice   // Device release number in BCD format
        0x01,                   // iManufacturer  // Manufacturer string index
        0x02,                   // iProduct    // Product string index
        0x00,                   // iSerialNumber  // Device serial number string index
        0x01                    // bNumConfigurations // Number of possible configurations
    };
    /* Configuration 1 Descriptor */
    CFG01={
        /* Configuration Descriptor */
        sizeof(USB_CFG_DSC),    // bLength     // Size of this descriptor in bytes
        DSC_CFG,                // bDescriptorType   // CONFIGURATION descriptor type
        sizeof(cfg01),          // wTotalLength   // Total length of data for this cfg
        1,                      // bNumInterfaces   // Number of interfaces in this cfg
        1,                      // bConfigurationValue  // Index value of this configuration
        0,                      // iConfiguration   // Configuration string index
        _DEFAULT|_RWU,          // bmAttributes   // Attributes, see usbdefs_std_dsc.h
        50,                     // bMaxPower    // Max power consumption (2X mA)
        /* Interface Descriptor */
        sizeof(USB_INTF_DSC),   // bLength     // Size of this descriptor in bytes
        DSC_INTF,               // bDescriptorType   // INTERFACE descriptor type
        0,                      // bInterfaceNumber  // Interface Number
        0,                      // bAlternateSetting  // Alternate Setting Number
        1,                      // bNumEndpoints   // Number of endpoints in this intf
        HID_INTF,               // bInterfaceClass   // Class code
        BOOT_INTF_SUBCLASS,     // bInterfaceSubClass  // Subclass code
        HID_PROTOCOL_MOUSE,     // bInterfaceProtocol  // Protocol code
        0,                      // iInterface    // Interface string index
       
        /* HID Class-Specific Descriptor */
        sizeof(USB_HID_DSC),    // Size of this descriptor in bytes
        DSC_HID,                // HID descriptor type
        0x0101,                 // HID Spec Release Number in BCD format
        0x00,                   // Country Code (0x00 for Not supported)
        HID_NUM_OF_DSC,         // Number of class descriptors, see usbcfg.h
        DSC_RPT,                // Report descriptor type
        sizeof(hid_rpt01),      // Size of the report descriptor
        /* Endpoint Descriptor */
        sizeof(USB_EP_DSC),  // bLength
        DSC_EP,     // bDescriptorType
        _EP01_IN,    // bEndpointAddress
        _INT,     // bmAttributes
        HID_INT_IN_EP_SIZE,  // wMaxPacketSize
        0x0A     // bInterval
    };
    #5
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/02 21:50:00 (permalink)
    0
    I have noticed that the problem is that my HID only transfers 3 bytes of data while I need it to transfer 5 bytes but I cant find were in the code the payload size is defined.


    Sorry for my late response.

    Maybe the problem is caused by the value for wMaxPacketSize of the Endpoint Descriptor.

    /* Endpoint Descriptor */
    ...
    HID_INT_IN_EP_SIZE, // wMaxPacketSize


    What is HID_INT_IN_EP_SIZE value?
    When you want to send 5 bytes report at a time, this value should be greater than or equal to 5.


    Another points for the descriptors,

    a) VID/PID of Device Descriptor

    0x04D8, // idVendor // Vendor ID - Microchip
    0x0000, // idProduct // Product ID: Mouse in a circle fw demo

    This VID/PID will cause conflict with other devices of the same VID/PID.
    Microchip sublicense unique PIDs under their VID for sale promotion. Get unique PIDs from Microchip.
    http://www.microchip.com/stellent/groups/sitecomm_sg/documents/market_communication/en025058.pdf

    b) Serial number (serial number index on Device Descriptor)
    Without serial number, Windows claim new hardware installation for every USB port, to which the device is attached. For HID device which applies the default INF, installation is done automatically. The pain of users caused by the new hardware installation is not so much, as they see just some pop-ups every time when the device is plugged in to a new USB port.
    Every new installation results new device record on the registry. For average user, 10 or so at most.

    The problem caused by no serial number is not so significant in this case.
    It's up to you, if you assign unique serial number to every device or not.

    c) Boot mouse support

    /* Interface Descriptor */
    ...
    BOOT_INTF_SUBCLASS, // bInterfaceSubClass // Subclass code
    HID_PROTOCOL_MOUSE, // bInterfaceProtocol // Protocol code

    I have doubt if the boot setting is required or not, in your case. The requirement of mouse for the BIOS stage is not so much. I think you can do without boot mouse support, unless you have a plan to run it for DOS.

    When the boot setting is enabled, your touch screen will work for BIOS, too.
    But it means you have to add these additional process to your firmware.
    - Support of Set_Protocol / Get_protocol request
    - Depending on the protocol set by Set_Protocol, the firmware sends different report to the interrupt IN endpoint.
    - - While boot protocol, standard mouse report
    - - While report protocol, your custom report

    To delete the boot setting, put 0 to both of bInterfaceSubClass and bInterfaceProtocol.


    d) HID spec version
    Current spec version is 1.11
    You didn't specify the compiler. Confirm that your compiler puts the two byte constant in low-byte-first format. Microchip C18 does.

    /* HID Class-Specific Descriptor */
    ...
    0x0101, <--- 0x0111 // HID Spec Release Number in BCD format


    Tsuneo
    #6
    bergenrov
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2009/03/27 01:52:33
    • Location: 0
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/02 22:34:24 (permalink)
    0
    Thanks for you response.
    I was finally able to solve it. It appears that I had not changed the in put package size.
    But now I encountered yet another problem, when I try to add a Out put report (Windows to HID) in the same way the communication stops working after "setup" meaning that after it has sent the HID descriptors it halts. Is there anything else that is needed to in order to assign a Output to the HID report? I have assigned it in the descriptor, defined the total report size and the output report size. Dose the out put report need to be defined in a separate endpoint or something like that?
    #7
    lbodnar
    Super Member
    • Total Posts : 1148
    • Reward points : 0
    • Joined: 2005/12/18 06:06:09
    • Location: UK
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/02 23:29:33 (permalink)
    0
    Should not this device use digitiser HID page?

    Leo
    #8
    bergenrov
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2009/03/27 01:52:33
    • Location: 0
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/03 00:52:28 (permalink)
    0
    Can you please elaborate?
    #9
    lbodnar
    Super Member
    • Total Posts : 1148
    • Reward points : 0
    • Joined: 2005/12/18 06:06:09
    • Location: UK
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/03 04:13:10 (permalink)
    0
    ORIGINAL: bergenrov
    Can you please elaborate?

    http://www.usb.org/developers/devclass_docs/Hut1_11.pdf
    Have a look at pages 102 and 128.
    If you have seen a drawing tablet with pen it is a digitiser device.

    Leo
    #10
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/03 06:19:52 (permalink)
    0
    Should not this device use digitiser HID page?

    It's a fair opinion, when you see just the device configuration.
    I also agree with you, for this device, digitizer is more suitable than mouse.

    The problem lies in the PC device driver side.
    When this device exposes a mouse top-level collection, built-in HID device driver and OS handle the rest - it works like mouse for any application on the PC.

    When it exposes a digitizer top-level collection, however, there is no built-in device driver for HID side on Windows. On the USB side, the device will be recognized as a HID device and enumerated successfully. But it doesn't go any further. A custom mini-driver is required to make it work as a digitizer.

    If you follow this digitizer way,
    a) An example of report descriptor for digitizer is included in HID descriptor tool- digit.hid

    "HID Descriptor Tool" from USB.org
    http://www.usb.org/developers/hidpage/dt2_4.zip

    b) WDK provides "Wacom Digitizer Driver Sample" in src\input\hiddigi
    Unfortunately, this driver is designed for legacy serial (RS232) connection.
    Further work is required to fit it to USB.

    Tsuneo
    #11
    bergenrov
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2009/03/27 01:52:33
    • Location: 0
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/03 08:41:36 (permalink)
    0
    Thank you, it was very helpful.

    The thing is that i dont see how the Digitizer and the Mouse differs other then that i need to develop drivers for the Digitizer. The reason for wanting to use the Mouse instead is that i want to avoid being forced to develop drivers for the device. I currently have more or less a mouse up and running as a touch screen controller meaning that it send absolute coordinates (2byte for each axis X, Y) to windows and the mouse cursor moves accordingly. And now i need to be able to send data used for calibration back to the hid. What would be the easiest way to archive this? I was thinking of just adding a simple output report to the mouse and create a simple software that send the info to it because this is more or less only needed the first time the touch screen is inserted.
    #12
    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/03 16:38:52 (permalink)
    0
    Probably a feature report (using control transfer) would be easier. Then you do not need to add an OUT endpoint.

    Jan Axelson has nice examples here:
    http://www.lvr.com/hidpage.htm

      USB_Links and libusb
    #13
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/03 17:11:40 (permalink)
    0
    And now i need to be able to send data used for calibration back to the hid.

    With Physical Minimum and Physical Maximum on the report descriptor, PC converts the mouse output range. If the touch screen is built in to a display, and the calibration value is fixed, it'll work well.

    For the details of Physical Minimum/Maximum, see 6.2.2.7 Global Items - Remarks (p36) of the HID spec.

    HID spec 1.11
    http://www.usb.org/developers/devclass_docs/HID1_11.pdf

    Tsuneo
    #14
    bergenrov
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2009/03/27 01:52:33
    • Location: 0
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/16 06:49:20 (permalink)
    0
    Thanks for clarifying. Sorry for my late answer I have been out of town.
    How do I implement the feature report "(using control transfer)" so that I can send small pieces of data to the PIC from Windows?
    #15
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/16 11:09:16 (permalink)
    0
    You'll find an impressive thread here, starting from this post.
    http://www.techtalkz.com/microsoft-device-drivers/275937-hclint-cant-find-any-hid-mouse-windows-xp-sp2-x64-environment.html#post1092230

    Here is the extracts from the thread.


    by Robert Marquardt (we'll miss you, Robert)

    You can enumerate HID mice and keyboards with the SetupDi functions at
    least for Win XP (*1). Feature reports are possible. The trick is the
    CreateFile call for the device (*2).
    Do *not* use "GENERIC_READ | GENERIC_WRITE". Use "0". This opens a mouse
    or keyboard, but you cannot read or write. DeviceIoControl calls will
    succeed nevertheless. They are documented to work. All HID function
    calls are DeviceIoCalls to the HID drivers (*3). We have a HID keyboard which
    can be programmed that way just fine.


    by EliotChang

    Hi Rebert,

    Thanks very much,
    Your solution is work fine for Windows Vista (32bit/64bit), 2003(32bit)
    and WXP-SP2(32bit).
    But the bad news is "It doesn't work for Windows XP SP2(64bit),
    2003(64bit) and Media PC (64bit)".
    I do like to implement the filter driver. It is the only way to solve
    this profblem?


    by Doron Holan [MS]

    search on the mouse device interface instead, get the enumerator property
    string, and if it is "HID", treat it like you would a HID device


    by Robert Marquardt

    Why has it been removed from the HID enumeration then? It makes no sense
    if you can still enumerate it.


    by Doron Holan [MS]

    it's an ordering issue. clients listening on the HID interface were
    notified before the RIT could open the device and for a HID keyboard and
    mouse, the upper level device interface is NOT HID, it is
    KEYBOARD/MOUSE_INPUT_DATA


    (*1) He means, Get HID GUID by HidD_GetHidGuid() and pass it to SetupDiGetClassDevs().
    You'll find a typical implementation in Jan's HID examples, "The HID Page - My Example Code - Host Applications"
    http://www.lvr.com/hidpage.htm

    (*2)

    CreateFile (
    lp_device_path_of_mouse, // lpFileName
    0, // dwDesiredAccess
    FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode
    NULL, // lpSecurityAttributes
    OPEN_EXISTING, // dwCreationDisposition
    0, // or FILE_FLAG_OVERLAPPED // dwFlagsAndAttributes
    NULL // hTemplateFile
    );


    (*3) HidD_SetFeature() is a thin wrapper of DeviceIoControl call.

    Tsuneo
    post edited by chinzei - 2009/04/16 11:37:59
    #16
    pk_volt
    Super Member
    • Total Posts : 354
    • Reward points : 0
    • Joined: 2007/04/27 19:35:47
    • Location: 0
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/16 12:27:59 (permalink)
    0
    a little off topic, but does anyone know if there is some kind of HID report descriptor builder tool?  I know there is one that "compiles" your hid report, but none specifically that builds based on drop down menus and text boxes etc etc
    #17
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/17 21:31:20 (permalink)
    0
    a little off topic, but does anyone know if there is some kind of HID report descriptor builder tool?  I know there is one that "compiles" your hid report, but none specifically that builds based on drop down menus and text boxes etc etc

    HID Descriptor Tool is the standard one. Download it on the HID Information ( http://www.usb.org/developers/hidpage/ ) page of USB.org

    HID Descriptor Tool
    http://www.usb.org/developers/hidpage/dt2_4.zip

    Using GUI, this tool helps you to make up report descriptors.
    - Also, it parses the created report descriptor for errors.
    - Select "Header File" or "Asm File" in "Save as" menu, to export the created descriptor to your code.
    - If you can't find required Usage(s), edit ".upg" files in the tool's folder and add new entries for the Usages.

    Tsuneo
    #18
    sweinhar2006
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2009/04/19 00:26:00
    • Location: 0
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/19 02:04:41 (permalink)
    0
    Hi all. I apologize for being a newby. Im a novice c++ programmer and know very little about usb. However Im studying and researching as best I can. Im working with the PIC32MX trying to develop a custom usb controller for a flight sim. I have been studying the files in the PIC32 solutions especially the HID mouse demo as it is probably the closest to what I need. Most of the files seem to be generic enough from what I can tell that you could simply insert your own code to get what you need out of it. The problem I see that I dont understand is when I edit the mouse_report.h file, the device does not enumerate or my computer says that it recognizes an HID device but it cant be started. This is the original code.



    #include "usb/hidreport.h"
    /**************************************************************************
    * HID Report for a mouse
    **************************************************************************/
    // note need to place in RAM
    BYTE HIDReport[] =
    {
    mHIDMakeShortPrefix(TAG_USAGE_PAGE, SIZE_1), UP_GENERIC_DESKTOP,
    mHIDMakeShortPrefix(TAG_USAGE, SIZE_1), MOUSE,
    mHIDMakeShortPrefix(TAG_COLLECTION, SIZE_1), APPLICATION,
    mHIDMakeShortPrefix(TAG_USAGE, SIZE_1), POINTER,
    mHIDMakeShortPrefix(TAG_COLLECTION, SIZE_1), PHYSICAL,
    mHIDMakeShortPrefix(TAG_USAGE_PAGE, SIZE_1), UP_BUTTON,
    mHIDMakeShortPrefix(TAG_USAGE_MIN, SIZE_1), 1,
    mHIDMakeShortPrefix(TAG_USAGE_MAX, SIZE_1), 3,
    mHIDMakeShortPrefix(TAG_LOGICAL_MIN, SIZE_1), 0,
    mHIDMakeShortPrefix(TAG_LOGICAL_MAX, SIZE_1), 1,
    mHIDMakeShortPrefix(TAG_REPORT_COUNT, SIZE_1), 3,
    mHIDMakeShortPrefix(TAG_REPORT_SIZE, SIZE_1), 1,
    mHIDMakeShortPrefix(TAG_INPUT, SIZE_1), (DATA | VARIABLE | ABSOLUTE),
    mHIDMakeShortPrefix(TAG_REPORT_COUNT, SIZE_1), 1,
    mHIDMakeShortPrefix(TAG_REPORT_SIZE, SIZE_1), 5,
    mHIDMakeShortPrefix(TAG_INPUT, SIZE_1), (CONSTANT),
    mHIDMakeShortPrefix(TAG_USAGE_PAGE, SIZE_1), UP_GENERIC_DESKTOP,
    mHIDMakeShortPrefix(TAG_USAGE, SIZE_1), X_DV,
    mHIDMakeShortPrefix(TAG_USAGE, SIZE_1), Y_DV,
    mHIDMakeShortPrefix(TAG_LOGICAL_MIN, SIZE_1), 0x81,
    mHIDMakeShortPrefix(TAG_LOGICAL_MAX, SIZE_1), 0x7F,
    mHIDMakeShortPrefix(TAG_REPORT_SIZE, SIZE_1), 8,
    mHIDMakeShortPrefix(TAG_REPORT_COUNT, SIZE_1), 2,
    mHIDMakeShortPrefix(TAG_INPUT, SIZE_1), (DATA | VARIABLE | RELATIVE),
    mHIDMakeShortPrefix(TAG_END_COLLECTION, SIZE_0),
    mHIDMakeShortPrefix(TAG_END_COLLECTION, SIZE_0),
    };


    const UINT HIDReportSize = (sizeof(HIDReport) / sizeof(BYTE));


    If I change nothing other than the first usage tag to be anything besides "MOUSE" it wont enumerate properly. My understanding is that windows reads this and would associate the proper driver. For instance if I change the usage tag to "GAME_PAD", it should enumerate as an HID gaming device. Now if I understand it correctly, the HID spec has certain minimums for different devices e.g. a joystick has to have minimum x,y axis and 3 buttons. I am still in the experimental stage and therefore the following code is not what I need for the end result but simply an experiment Im trying to understand USB HID enumeration and how windows classifies it.


    [code][/code]
    #include "usb/hidreport.h"

    /**************************************************************************
    * HID Report for a gamepad
    **************************************************************************/
    // note need to place in RAM
    BYTE HIDReport[] =
    {
    mHIDMakeShortPrefix(TAG_USAGE_PAGE, SIZE_1), UP_GENERIC_DESKTOP,
    mHIDMakeShortPrefix(TAG_USAGE, SIZE_1), GAME_PAD,
    mHIDMakeShortPrefix(TAG_COLLECTION, SIZE_1), APPLICATION,
    mHIDMakeShortPrefix(TAG_USAGE, SIZE_1), POINTER,
    mHIDMakeShortPrefix(TAG_COLLECTION, SIZE_1), PHYSICAL,
    mHIDMakeShortPrefix(TAG_USAGE, SIZE_1), X_DV,
    mHIDMakeShortPrefix(TAG_USAGE, SIZE_1), Y_DV,
    mHIDMakeShortPrefix(TAG_LOGICAL_MIN, SIZE_1), 0,
    mHIDMakeShortPrefix(TAG_LOGICAL_MAX, SIZE_1), 3,
    mHIDMakeShortPrefix(TAG_REPORT_COUNT, SIZE_1), 2,
    mHIDMakeShortPrefix(TAG_REPORT_SIZE, SIZE_1), 2,
    mHIDMakeShortPrefix(TAG_INPUT, SIZE_1), (DATA | VARIABLE | ABSOLUTE),
    mHIDMakeShortPrefix(TAG_REPORT_COUNT, SIZE_1), 4,
    mHIDMakeShortPrefix(TAG_REPORT_SIZE, SIZE_1), 1,
    mHIDMakeShortPrefix(TAG_INPUT, SIZE_1), (CONSTANT | VARIABLE | ABSOLUTE),
    mHIDMakeShortPrefix(TAG_USAGE_PAGE, SIZE_1), UP_BUTTON,
    mHIDMakeShortPrefix(TAG_USAGE_MIN, SIZE_1), 1,
    mHIDMakeShortPrefix(TAG_USAGE_MAX, SIZE_1), 6,
    mHIDMakeShortPrefix(TAG_LOGICAL_MIN, SIZE_1), 0,
    mHIDMakeShortPrefix(TAG_LOGICAL_MAX, SIZE_1), 1,
    mHIDMakeShortPrefix(TAG_REPORT_COUNT, SIZE_1), 6,
    mHIDMakeShortPrefix(TAG_REPORT_SIZE, SIZE_1), 1,
    mHIDMakeShortPrefix(TAG_INPUT, SIZE_1), (DATA | VARIABLE | ABSOLUTE),
    mHIDMakeShortPrefix(TAG_REPORT_COUNT, SIZE_1), 2,
    mHIDMakeShortPrefix(TAG_INPUT, SIZE_1), (CONSTANT | VARIABLE | ABSOLUTE),
    mHIDMakeShortPrefix(TAG_END_COLLECTION, SIZE_0),
    mHIDMakeShortPrefix(TAG_END_COLLECTION, SIZE_0),

    };



    const UINT HIDReportSize = (sizeof(HIDReport) / sizeof(BYTE));

    This code does not enumerate as a gaming device or at all for that matters except as an HID device that windows cant start. What am I doing wrong? I will worry about the implementation of this code in the main program once it enumerates but I cant seem to get that far. Any help pls would be appreciated.

    This is the message in control panel for it.
    USB Human Interface Device
    This device cannot start. (Code 10)

    Click 'Check for solutions' to send data about this device to Microsoft and to see if there is a solution available.


    --------------------------------------------------------------------------------


    #19
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: USB-Mouse HID Descriptor 2009/04/19 06:27:51 (permalink)
    0
    sweinhar2006:

    For instance if I change the usage tag to "GAME_PAD", it should enumerate as an HID gaming device.


    Select Joystick instead of Gamepad.
    Gamepad doesn't support the X, Y physical pointer, which come from the mouse report descriptor. Instead, Gamepad equips Up, Down, Right and Left switches.

    Confirm the supposed device on the HID Usage Tables. Don't rely on your assumption.

    HID Usage Tables 1.12
    http://www.usb.org/developers/devclass_docs/Hut1_12.pdf

    4.1 Application Usages (Hut1_12.pdf p28)

    Joystick
    CA – A manual control or cursor device. A joystick minimally consists of
    two variable axes (X and Y) and two buttons. A joystick is typically a
    rotational motion sensor. However, for legacy reasons, it is defined using
    linear axes....

    Game Pad
    CA – A manual control or cursor device. A game pad minimally consists of a
    thumb-activated rocker switch that controls two axes (X and Y) and has four
    buttons. The rocker switch consists of four contact closures for up, down,
    right, and left.


    An example report descriptor for Joystick is included in above "HID Descriptor Tool" download.

    Tsuneo
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5