Go Down

Topic: Problem with modifying HID report descriptor in Leonardo (Read 2570 times) previous topic - next topic

ancc

Hello

I'm using a clone of Leonardo board on 32u4 chip in Arduino 1.0 IDE.
The task is to turn Leonardo HID mouse from relative coordinates to absolute coordinates, so it can act as touchscreen controller.

I found HID descriptor in /arduino 1.0/hardware/arduino/cores/arduino/HID.cpp
Originally it looks like this:

Code: [Select]
// Mouse
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop) // 54
    0x09, 0x02,                    // USAGE (Mouse)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x09, 0x01,                    //   USAGE (Pointer)
    0xa1, 0x00,                    //   COLLECTION (Physical)
    0x85, 0x01,                    //     REPORT_ID (1)
    0x05, 0x09,                    //     USAGE_PAGE (Button)
    0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
    0x29, 0x03,                    //     USAGE_MAXIMUM (Button 3)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
    0x95, 0x03,                    //     REPORT_COUNT (3)
    0x75, 0x01,                    //     REPORT_SIZE (1)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
    0x95, 0x01,                    //     REPORT_COUNT (1)
    0x75, 0x05,                    //     REPORT_SIZE (5)
    0x81, 0x03,                    //     INPUT (Cnst,Var,Abs)
    0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
    0x09, 0x30,                    //     USAGE (X)
    0x09, 0x31,                    //     USAGE (Y)
    0x09, 0x38,                    //     USAGE (Wheel)
    0x15, 0x81,                    //     LOGICAL_MINIMUM (-127)
    0x25, 0x7F,                    //     LOGICAL_MAXIMUM (127)
    0x75, 0x08,                    //     REPORT_SIZE (8)
    0x95, 0x03,                    //     REPORT_COUNT (3)
    0x81, 0x06,                    //     INPUT (Data,Var,Rel)
    0xc0,                          //   END_COLLECTION
    0xc0,                          // END_COLLECTION


I change last line like this
Code: [Select]
    0x81, 0x02,                    //     INPUT (Data,Var,ABS)
And I got a HID mouse device with absolute coordinates from -127 to 127 and it works.
After that I change one line like this
Code: [Select]
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
After this modification I got a HID mouse device with absolute coordinates from 0 to 127 and it works.

Now I try to change line that describes LOGICAL MAXUMUM for example like this
Code: [Select]
    0x25, 0xff,              //     LOGICAL_MAXIMUM (255)
After this modification mouse.move is not working. I thing that it's because of wrong type of data somewhere.
I tried to do several modifications of data types from singned char to byte and from u8 to byte in some places that I found, for example in HID.cpp and USBAPI.h  but there was no effect. Perhaps something I do not understand. Can anybody experienced in this tell me where to fix arduino code?  I want to get LOGICAL_MAXIMUM higher than 127

gillianlcr

Hi ancc,

I'm working on the same target.
For your ask, i think you cannot overshoot 127 probably because the number of byte (2e7).
It's just a possibility, i'm beginner.

my scketch
I try just to push the cursor in the middle of the screen. Your modifications with absolute coordinates seem me OK !
But it does not work.....

Have you just changed the only last line in HID.cpp (Rel --> Abs)?

Thanks for you answer

yunowa

Thank you!!!
This source is from the computer works fine
But the absolute coordinates from an Android phone does not work.
Android relative coordinates in the source, it works well.
Is there a good way to
I'll give you favor.
I have tested Android phones Galaxy S2
Favor the development environment IDE 1.0.1.
I do not speak English well.I'm sorry.

Go Up