From 3ff74e8d58cb9420e4dae884378b98eb55ce62b2 Mon Sep 17 00:00:00 2001 From: Cozma <65982369+Cozmaaa@users.noreply.github.com> Date: Sun, 22 Nov 2026 18:09:44 +0200 Subject: gameinput: the keyboard pad's right stick reads raw mouse input and keeps the cursor in the window GetCursorPos deltas stop at the screen edge and include pointer acceleration. A message-only window on its own thread now registers for raw mouse input (RIDEV_INPUTSINK) and sums the relative counts; the poll takes the difference of that total. Absolute reports are ignored, and GetCursorPos stays as the fallback if registration fails. With raw input on and a window of this process in the foreground, the cursor is clipped to that window's client area (re-applied every 100 ms), and released on focus loss or when the pad is turned off. LEONIDA_MOUSE_SENSITIVITY (0.1..10, default 1) scales the axis units per count. --- runtime/test/gameinput_test.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'runtime/test/gameinput_test.cpp') diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp index d1923ceaf..d57b5a0d7 100644 --- a/runtime/test/gameinput_test.cpp +++ b/runtime/test/gameinput_test.cpp @@ -393,6 +393,33 @@ void test_keyboard_pad_sticks(IGameInput* input, IGameInputDevice* kb) { } check(monotonic && polls < 100 && sticks_at_rest(st), "keyboard pad: right stick decays to 0 when the mouse stops"); + // LEONIDA_MOUSE_SENSITIVITY scales the axis units per count: 2 doubles, 0.5 halves; out of range clamps. + auto settle = [&] { + for (int i = 0; i < 200 && !sticks_at_rest(pad_state(input, kb)); ++i) rt::gameinput::poll(); + }; + set_env("LEONIDA_MOUSE_SENSITIVITY", "2"); + rt::gameinput::reload_config(); + g_cursor_x += 10; + rt::gameinput::poll(); + check(approx(pad_state(input, kb).rightThumbstickX, 20480 / 32767.0f), "keyboard pad: mouse sensitivity 2 doubles the stick"); + settle(); + set_env("LEONIDA_MOUSE_SENSITIVITY", "0.5"); + rt::gameinput::reload_config(); + g_cursor_x -= 10; + rt::gameinput::poll(); + check(approx(pad_state(input, kb).rightThumbstickX, -5120 / 32767.0f), "keyboard pad: mouse sensitivity 0.5 halves the stick"); + settle(); + set_env("LEONIDA_MOUSE_SENSITIVITY", "100"); + rt::gameinput::reload_config(); + check(rt::gameinput::config().mouse_sensitivity == 10.0f, "keyboard pad: mouse sensitivity clamps to 10"); + set_env("LEONIDA_MOUSE_SENSITIVITY", "0"); + rt::gameinput::reload_config(); + check(approx(rt::gameinput::config().mouse_sensitivity, 0.1f), "keyboard pad: mouse sensitivity clamps to 0.1"); + set_env("LEONIDA_MOUSE_SENSITIVITY", nullptr); + rt::gameinput::reload_config(); + check(rt::gameinput::config().mouse_sensitivity == 1.0f && rt::gameinput::config().ds_trigger_gain == 1.0f, + "keyboard pad: mouse sensitivity defaults to 1 and leaves the trigger gain alone"); + g_keys[VK_RBUTTON] = true; rt::gameinput::poll(); st = pad_state(input, kb); -- cgit v1.2.3