Follow up for fixing axis convention#51
Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
10_custom_config_unity.py, the hard-coded VID/PID and axis mappings are specific to one device model; consider either deriving from an existingget_device_specs()entry or adding a short comment warning users to adjust these values to match their own device to avoid confusing misconfigurations. - The internal titles like
Example 2:/Example 3:in the new example scripts can easily drift from the numbered filenames (09/10); it may be clearer to remove the embedded example numbers or derive them from__file__so they stay in sync with the docs and filenames.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `10_custom_config_unity.py`, the hard-coded VID/PID and axis mappings are specific to one device model; consider either deriving from an existing `get_device_specs()` entry or adding a short comment warning users to adjust these values to match their own device to avoid confusing misconfigurations.
- The internal titles like `Example 2:` / `Example 3:` in the new example scripts can easily drift from the numbered filenames (09/10); it may be clearer to remove the embedded example numbers or derive them from `__file__` so they stay in sync with the docs and filenames.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@nickswalker if you have time for a quick review here too, I would appreciate it :) |
There was a problem hiding this comment.
The use case for allowing users to write their own device specs makes sense (future/custom hardware), but I think you'd want users to not need to use this low level interface for changing the axis convention. It would be easy to mess up incidentally e.g. having an incorrect digit for a byte offset someplace. In that spirit, would simply have this example show how a user could've added SpaceMouseWirelessNew themselves (with the same info from device.toml).
The Unity convention is a reasonable use case though, so it would make sense to support it natively, but it'd require the modify_device_info() method to have the ability to remap axes altogether.
There was a problem hiding this comment.
Another thought: it may actually be desirable to "require" devices to be specified in the HID convention, that way the library knows how to remap the axes.
There was a problem hiding this comment.
Currently they are all specified in "LEGACY" convention, so we already know how to remap axes to a given convention, right? We could change everything to be HID in the TOML, as long as we still offer LEGACY as an option.
There was a problem hiding this comment.
Changing the TOML may break existing uses, as the specs data is part of the public API (pyspacemouse.get_device_specs()["SpaceNavigator"]). I think the TOML should definitely change over to HID in the next major release.
nickswalker
left a comment
There was a problem hiding this comment.
I think the new example 10 actually suggests some further API changes/enhancements. The bulk of the changes look good to me otherwise.
- use HID_Z_UP convention everywhere it is sensible - rework the last two examples showing how custom configs and axes inversion works - update docs to avoid copy pasting
b446b08 to
c8978ed
Compare
Source: https://docs.unity3d.com/6000.3/Documentation/Manual/QuaternionAndEulerRotationsInUnity.html > Unity uses a left-handed coordinate system: the positive x-axis points to the right, the positive y-axis points up, and the positive z-axis points forward. Unity’s left-handed coordinate system means that the direction of rotation from the positive x-axis to the positive y-axis is counterclockwise when looking along the positive z-axis.
Summary by Sourcery
Align examples and documentation with the HID_Z_UP axis convention and improve guidance on custom device configurations.
New Features:
Enhancements:
Documentation: