CircuitPython_JoystickXL icon indicating copy to clipboard operation
CircuitPython_JoystickXL copied to clipboard

Issue #12: Converted joystick_xl to send 16-bits per axis

Open jamesra opened this issue 1 year ago • 1 comments

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.

jamesra avatar Mar 28 '23 16:03 jamesra

FYI ... 8-bit axis have ubiquitous support ... every OS and every embedded OS I've tries supports an 8-bit axis. I don't think the same is true for 16-bit axis. On smaller microcontrollers, every byte of the descriptor matters ... some boards have a smaller upper limit on total descriptor size. If a project is already pushing the limit, this could also cause a break on upgrade.

Therefore, I would like to suggest a slightly different approach, to minimize risk of breaking existing projects:

Opt-In to 16-bit axis support.

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.

henrygab avatar Sep 22 '23 05:09 henrygab