Dynamic USB HID descriptor

Hello, everyone! At the moment I am working with Arduino Leonardo and i have a such a non-standard question - is it possible in principle to implement a Dynamic USB HID device descriptor based on Arduino (for example, Leonardo)? I saw the following code on the Internet, where the HID descriptor is described as below:

    0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
    0x09, 0x30,                    //     USAGE (X)
    0x09, 0x31,                    //     USAGE (Y)
    0x09, 0x38,                    //     USAGE (Wheel)
#ifdef ABSOLUTE_MOUSE_MODE
    0x15, 0x01,                    //     LOGICAL_MINIMUM (1)       <<<< This allows us to talk to any display resolution
    0x25, 0x64,                    //     LOGICAL_MAXIMUM (100)     <<<<  as though it was 100x100 pixels
    0x75, 0x08,                    //     REPORT_SIZE (8)
    0x95, 0x03,                    //     REPORT_COUNT (3)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)      <<<< This allows us to moveTo absolute positions
#else
    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)
#endif
    0xc0,                          //   END_COLLECTION
    0xc0,                          // END_COLLECTION

, where depending on ABSOLUTE_MOUSE_MODE the descriptor will be different on each start. However, I would like to understand how from the outside you can affect this part of the code, to make a descriptor change on the next reboot of the device. The simplest solution, as for me, would be to keep track of some PIN and if it closure to a ground, depending on that, apply the condition and change the Discriptor. I would like to ask knowledgeable people whether it is possible to implement this in principle. I will also clarify that the PIN of the board may not necessarily act as a trigger, the main thing is that the user himself can set it. Thanks!

The descriptor is a data structure and as such it can be modified by the program. That doesn't necessarily need to be done at compile time.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.