nipo / hrdc

HID Report Descriptor Compiler
MIT License
19 stars 5 forks source link

named arrays cause incorrect logical maximum, missing physical range #8

Open ajmirsky opened 1 year ago

ajmirsky commented 1 year ago
from hrdc.usage import *
from hrdc.descriptor import *

leds = (
    led.Player1,
    led.Player2,
    led.Player3,
    led.Player4,
    led.Player5,
    led.Player6,
    led.Player7,
    led.Player8,
)

descriptor = Collection(Collection.Application, game.Player,
                        Collection(Collection.Physical, game.PinballDevice,
                                   Report(1,
                                          Value(Value.Input,
                                                led.PlayerIndicator,
                                                16,
                                                count=8,
                                                logicalMin=0, logicalMax=6500,
                                                physicalMin=-7500, physicalMax=7500,
                                                namedArray=leds
                                                )
                                          )
                                   ))

compile_main(descriptor)

creates:

> python test.py --output=code
     0x05, 0x05,                    // UsagePage (game)
     0x09, 0x2f,                    // Usage (Player)
     0xa1, 0x01,                    // Collection (Application)
     0x09, 0x02,                    //     Usage (PinballDevice)
     0xa1, 0x00,                    //     Collection (Physical)
     0x85, 0x01,                    //         ReportID (1)
     0x05, 0x08,                    //         UsagePage (led)
     0x09, 0x4e,                    //         Usage (PlayerIndicator)
     0xa1, 0x02,                    //         Collection (Logical)
     0x15, 0x00,                    //             LogicalMinimum (0)
     0x25, 0x07,                    //             LogicalMaximum (7)       <--- logical max should 6500
                                                                                                     <--- physical min and max are missing
     0x75, 0x08,                    //             ReportSize (16)
     0x95, 0x08,                    //             ReportCount (8)
     0x19, 0x4f,                    //             UsageMinimum (Player1)
     0x29, 0x56,                    //             UsageMaximum (Player8)
     0x81, 0x02,                    //             Input (Variable)
     0xc0,                          //         EndCollection
     0xc0,                          //     EndCollection
     0xc0,                          // EndCollection
nipo commented 1 year ago

Some thoughts:

Could you please explain what you are trying to achieve in terms of reports ?