joystick: use 0..1 domain for game controller triggers#906
Merged
Conversation
Member
|
Hmm I need to double-check this, IIRC SDL gave me -1/1 for my xbox triggers |
Contributor
Author
|
We can wait for you to test this IRL. What you are describing looks like the behavior from the old API: XBox triggers should range from -32768 to 32767 there. The GameController API should normalize everything either -1 to 1 (analog sticks) or 0 to 1 (triggers). Testing now, I get this expected behavior from the PS4 controller on my desk (range from -1 to 1 from analog and 0 to 1 from triggers). But the min value is hard-coded wrong |
Contributor
Author
|
Worst case, we can have another if-else specifically for the XBox controller |
Game controller triggers (TRIGGERLEFT/TRIGGERRIGHT) range from 0 to 1, not -1 to 1 like the sticks. They were all given the same -1..1 domain, which broke automatic ranging (e.g. mapping a trigger to a 0..200 Hz parameter started at -200). The raw SDL value is already normalized to 0..1 for triggers in push_axis, so only the declared domain needed fixing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2514648 to
64178d6
Compare
Member
|
indeed for game controller api it's 0..1! i'll rebase after merge passes |
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.
Summary
Game controller triggers (
SDL_CONTROLLER_AXIS_TRIGGERLEFT/TRIGGERRIGHT) range from 0 to 1, but the axis loop ingame_controller_protocol::set_devicegave every axis the same-1..1domain. This broke automatic ranging — e.g. mapping a trigger (intended 0..1) onto a 0..200 Hz parameter started at -200 Hz.The raw SDL value is already normalized to 0..1 for triggers in
push_axis((ev.value + .5f) / (0x7FFF + .5f)with trigger raw values in 0..32767), so only the declared domain was wrong.Fix
Pick the domain per-axis:
0..1for the two trigger axes,-1..1for the sticks.Relates to ossia/score#1854
🤖 Generated with Claude Code