Skip to content

joystick: use 0..1 domain for game controller triggers#906

Merged
jcelerier merged 1 commit into
masterfrom
1854-gamepad-wrong-min-value-for-triggers
Jun 26, 2026
Merged

joystick: use 0..1 domain for game controller triggers#906
jcelerier merged 1 commit into
masterfrom
1854-gamepad-wrong-min-value-for-triggers

Conversation

@edumeneses

Copy link
Copy Markdown
Contributor

Summary

Game controller triggers (SDL_CONTROLLER_AXIS_TRIGGERLEFT / TRIGGERRIGHT) range from 0 to 1, but the axis loop in game_controller_protocol::set_device gave every axis the same -1..1 domain. 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..1 for the two trigger axes, -1..1 for the sticks.

Relates to ossia/score#1854

🤖 Generated with Claude Code

@jcelerier

Copy link
Copy Markdown
Member

Hmm I need to double-check this, IIRC SDL gave me -1/1 for my xbox triggers

@edumeneses

Copy link
Copy Markdown
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

@edumeneses

Copy link
Copy Markdown
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>
@jcelerier jcelerier force-pushed the 1854-gamepad-wrong-min-value-for-triggers branch from 2514648 to 64178d6 Compare June 26, 2026 10:16
@jcelerier jcelerier temporarily deployed to Apple Certificate June 26, 2026 10:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 26, 2026 10:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 26, 2026 10:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 26, 2026 10:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 26, 2026 10:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 26, 2026 10:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 26, 2026 10:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 26, 2026 10:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 26, 2026 10:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 26, 2026 10:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 26, 2026 10:16 — with GitHub Actions Inactive
@jcelerier

Copy link
Copy Markdown
Member

indeed for game controller api it's 0..1! i'll rebase after merge passes

@jcelerier jcelerier merged commit ccb4120 into master Jun 26, 2026
36 of 37 checks passed
@jcelerier jcelerier deleted the 1854-gamepad-wrong-min-value-for-triggers branch June 26, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants