From 64178d6eb2a8fc769d140fd07f0c42bd574f4880 Mon Sep 17 00:00:00 2001 From: Edu Meneses Date: Tue, 23 Jun 2026 09:33:58 -0400 Subject: [PATCH] joystick: use 0..1 domain for game controller triggers 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) --- src/ossia/protocols/joystick/game_controller_protocol.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ossia/protocols/joystick/game_controller_protocol.cpp b/src/ossia/protocols/joystick/game_controller_protocol.cpp index 29670ab2a26..cd11442ca1e 100644 --- a/src/ossia/protocols/joystick/game_controller_protocol.cpp +++ b/src/ossia/protocols/joystick/game_controller_protocol.cpp @@ -107,9 +107,12 @@ void game_controller_protocol::set_device(ossia::net::device_base& dev) if(SDL_GameControllerHasAxis(m_joystick, static_cast(i)) == SDL_TRUE) { + // Triggers range from 0 to 1, while sticks range from -1 to 1. + const bool is_trigger = (i == SDL_CONTROLLER_AXIS_TRIGGERLEFT + || i == SDL_CONTROLLER_AXIS_TRIGGERRIGHT); m_axis_parameters[i] = device_parameter::create_device_parameter( root, axes[i], 0.0, val_type::FLOAT, bounding_mode::CLIP, access_mode::GET, - make_domain(-1.0f, 1.0f)); + is_trigger ? make_domain(0.0f, 1.0f) : make_domain(-1.0f, 1.0f)); } }