Calibrate stick centre and travel per controller - #3
Open
JoeGeC wants to merge 2 commits into
Open
Conversation
The raw 12-bit sticks only travel about +-1250 LSB and rest off-centre, and both vary per unit and per axis (left Joy-Con x 2080 / y 2157, right x 2014 / y 2022). Mapping them as (v - 2048) * 32767 / 2048 left full deflection at 56-66% of HID range with a permanent 4-5% drift at rest, so the analog stick moved characters slower than the d-pad's digital hat. StickCalibrator learns each axis' centre from the first still window after connect and scales each direction by its own span. It runs where packets are parsed, so the live display, HID reports, and DSU all see corrected values instead of each re-deriving the same wrong assumption. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Normalising each axis against its own travel means a full diagonal reaches 1 on both, which a square mapping draws at 1.41x the ring radius. The stick's gate is round, so clamp the magnitude rather than each axis, and draw within the ring instead of centring the dot on it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Fixes the reported "left joystick input seems to be half of the input that D-pad gets".
The bug
ReportMapper.mapStickmapped raw sticks as(v - 2048) * 32767 / 2048, assuming the raw 12-bit value swings the full0..4095about a 2048 centre. Neither holds. Measured on hardware:Three separate errors fell out of that:
The same 2048 assumption was duplicated in
DsuPacketEncoder,StickCard,SidewaysMapperand theCENTERdefaults, so DSU output and the on-screen stick were short by the same margin.The fix
StickCalibratornormalises raw sticks onto a true 2048-centred0..4095space where packets are parsed, so every consumer is corrected by one change rather than each fixing its own copy.Second commit clamps the live display's dot inside its ring: now that each axis reaches its own rails, a full diagonal computes to 1.41× the radius on a square mapping. The gate is round, so the magnitude clamps rather than each axis.
Verified
StickCalibratorTestcases;./gradlew build :konsist:testgreen.Notes
0x013040) remains the proper source and would remove the connect-time learning entirely. Left as follow-up — runtime calibration is needed regardless for the Pro Controller, which we cannot hardware-test.🤖 Generated with Claude Code