Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ajmirsky opened this issue Jan 21, 2023 · 1 comment
Open

Comments

@ajmirsky
Copy link

ajmirsky commented Jan 21, 2023

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
Copy link
Owner

nipo commented Jan 22, 2023

Some thoughts:

  • If you have a Named Array (NAry) with 8 entries, 3 bits per report should be enough,
  • I'm pretty sure Physical min/max makes no sense with named arrays,
  • I'm not certain Named Arrays apply for what you are trying to declare.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants