fix: honor an explicit zero rotation origin for keys#175
Open
numachang wants to merge 1 commit into
Open
Conversation
Keys with a rotation (r != 0) whose origin rx/ry is explicitly 0 were pivoted around each key's own corner instead of the layout origin (0,0), scrambling rotated clusters on boards that rotate about the origin. `(rx || x)` collapsed a legitimate 0 back to the key's own x; switching to `(rx ?? x)` keeps an explicit 0 as 0. Fixes zmkfirmware#97 Co-Authored-By: Claude <noreply@anthropic.com>
✅ Deploy Preview for zmk-studio ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #97.
Keys with a rotation (
r != 0) whose rotation originrx/ryis explicitly0are pivoted around each key's own corner instead of the layout origin(0,0). On boards that rotate clusters about the origin this scrambles the layout, as reported in #97.The cause is in
scalePosition:rx || xtreats a legitimate0as falsy and falls back to the key's ownx, sotransformXbecomes0(pivot at the key's own corner) instead of-x * oneU(pivot at the layout origin).Fix
Use
??so an explicit0is preserved:When
rx/ryare non-zero or omitted the behavior is unchanged; only the explicit-zero case is corrected.Verification
Verified locally in Storybook with a layout containing a thumb cluster rotated about a shared origin plus a key rotated about
(0,0): rotated clusters stay connected and the zero-origin key is positioned correctly.tscandeslintare clean.🤖 Generated with Claude Code