Issue #12: Converted joystick_xl to send 16-bits per axis#15
Issue #12: Converted joystick_xl to send 16-bits per axis#15jamesra wants to merge 2 commits intofasteddy516:mainfrom
Conversation
| 0x15, 0x00, # : LOGICAL_MINIMUM (0) | ||
| 0x26, 0xFF, 0x00, # : LOGICAL_MAXIMUM (255) | ||
| 0x75, 0x08, # : REPORT_SIZE (8) | ||
| 0x27, 0xFF, 0xFF, 0x00, 0x00, # : LOGICAL_MAXIMUM (1 << 16) |
There was a problem hiding this comment.
off-by-one in the comments?
LOGICAL_MAXIMUM ((1 << 16) - 1)
| 0x75, 0x08, # : REPORT_SIZE (8) | ||
| 0x27, 0xFF, 0xFF, 0x00, 0x00, # : LOGICAL_MAXIMUM (1 << 16) | ||
| 0x35, 0x00, # : PHYSICAL_MINIMUM (0) | ||
| 0x47, 0xFF, 0xFF, 0x00, 0x00, # : PHYSICAL_MAXIMUM (1 << 16) |
There was a problem hiding this comment.
off-by-one in the comments?
PHYSICAL_MAXIMUM ((1 << 16) - 1)****
| new_value = self._db_range // 2 | ||
|
|
||
| # calculate scaled joystick-compatible value and clamp to 0-255 | ||
| self._value = min(new_value * 256 // self._db_range, 255) |
There was a problem hiding this comment.
Is it correct that scaling is not supported?
I note that physical and logical maximums are equal, so scaling shouldn't do anything. Just making sure...
|
FYI ... 8-bit axis have ubiquitous support ... every OS and every embedded OS I've tries supports an 8-bit axis. Therefore, I would like to suggest a slightly different approach, to minimize risk of breaking existing projects:
For example, modify the constructor to handle a new type, such as: # in boot.py
create_joystick(axes_16bit=2, axes=4, buttons=10, hats=1)
# ... and later in main.py ....
joystick = Joystick()
joystick.add_input( ..., Axis_16bit(...), ...)In this way, the risk of breaking existing projects can be minimized. |
This is my 16-bit axis resolution change. I made some changes to the deadzone code that I hope match the original intention. In particular input.py#247
self._value = min(new_value * 256 // self._db_range, 255)was causing the problems when I tried to port it to 16-bit and I decided to keep what I ended up with.