Quantcast
Channel: Objective Development Forums
Viewing all articles
Browse latest Browse all 4524

Re: usbHidReportDescriptor type of confilct

$
0
0
I'm really confused by your report here and what you are expecting?

Your descriptor shows it needs 10 bytes( 2 analogs and 8 buttons), BTW buttons are normally done with one report ( 8 bits: a bit mask), I'm guessing you know that.
EDIT!!!
0x95, 0x04, // REPORT_COUNT (2) <--- ahhh... see never do this, always adjust the comments!!! Your thew me off a bit there but i'll leave what I wrote not seeing this.
EDIT!!!

reportBuffer[0] = x ( 0 to ff )
reportBuffer[1] = y ( 0 to ff )
reportBuffer[2] button 1 (0 or 1)
reportBuffer[3] button 2 (0 or 1)
reportBuffer[4] button 3 (0 or 1)
reportBuffer[5] button 4 (0 or 1)
reportBuffer[6] button 5 (0 or 1)
reportBuffer[7] button 6 (0 or 1)
reportBuffer[8] button 7 (0 or 1)
reportBuffer[9] button 8 (0 or 1)

So yes your fist code will work as its 5 bytes long, and it just doubles that equaling 10. The second code is 7 bytes and that is not dividable by 10 so it stops reporting.

It looks like you are trying to stuff 4 bytes to X and Y of the report? ( my thinking before I saw your comment typeo)
reportBuffer[0] = 500 / 0x100; // quotient = 0x01 (500 = 0x01f4, form 2 bytes, 0x01, 0xf4)
reportBuffer[1] = 500 % 0x100; // remainder = 0xf4
reportBuffer[2] = 1000 / 0x100; // 1000 = 0x03e8
reportBuffer[3] = 1000 % 0x100;

report 2 and 3 are only 1 bit in length, so clearly you are going about this with a misunderstanding. Explain the data sizes you are trying to pass in. If you need to pass in more then 255 for X or Y then your report needs to be split up.


If my guess is right you want this?
reportBuffer[0] = Little Endian of X
reportBuffer[1] = Big Endian of X
reportBuffer[2] = Little Endian of Y
reportBuffer[3] = Bittle Endian of Y
reportBuffer[4] = buttons (0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80)
reportBuffer[5] = padding.
reportBuffer[6] = padding.
reportBuffer[7] = padding.

If so try this ( check your Endianess)
    PROGMEM const char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = {   
        0x05, 0x01,        // USAGE_PAGE (Generic Desktop = 01)
       0x09, 0x05,        // USAGE (Game Pad = 05)
       0xa1, 0x01,        // COLLECTION (Application)
       0x09, 0x01,        //   USAGE (Pointer)
       0xa1, 0x00,        //   COLLECTION (Physical)
       0x09, 0x30,        //     USAGE (X)
       0x09, 0x30,        //     USAGE (X)
       0x09, 0x30,        //     USAGE (Y)
       0x09, 0x30,        //     USAGE (Y)
       0x15, 0x00,        //   LOGICAL_MINIMUM (0)
       0x26, 0xff, 0x00,  //     LOGICAL_MAXIMUM (255)
       0x75, 0x08,        //   REPORT_SIZE (8bits)
       0x95, 0x04,        //   REPORT_COUNT (4)
       0x81, 0x02,        //   INPUT (Data,Var,Abs)
       0xc0,              // END_COLLECTION
       
       0x05, 0x09,        // USAGE_PAGE (Button)
       0x19, 0x01,        //   USAGE_MINIMUM (Button 1)
       0x29, 0x08,        //   USAGE_MAXIMUM (Button 8)
       0x15, 0x00,        //   LOGICAL_MINIMUM (0)
       0x25, 0x01,        //   LOGICAL_MAXIMUM (1)
       0x75, 0x08,        // REPORT_SIZE (8)
       0x95, 0x01,        // REPORT_COUNT (1)
       0x81, 0x02,        // INPUT (Data,Var,Abs)
       0xc0               // END_COLLECTION
    };


also depending on the supplication this is not always allowed.
0x09, 0x30, // USAGE (X)
0x09, 0x30, // USAGE (X)
0x09, 0x30, // USAGE (Y)
0x09, 0x30, // USAGE (Y)
try this if the above gives you troubles.
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (X)
0x09, 0x32, // USAGE (Y)
0x09, 0x33, // USAGE (Y)

Viewing all articles
Browse latest Browse all 4524

Trending Articles