upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/gameinput_test.cpp
diff options
context:
space:
mode:
authorCozma <65982369+Cozmaaa@users.noreply.github.com>2026-11-22 18:09:44 +0200
committerCozma <65982369+Cozmaaa@users.noreply.github.com>2026-11-22 18:09:44 +0200
commit3ff74e8d58cb9420e4dae884378b98eb55ce62b2 (patch)
treeeed1cb4e1caa7d5aa5c42c19cafaf49da97c457c /runtime/test/gameinput_test.cpp
parent4eb6155d3ac4f9d3fadb0d095c4ce13e76783615 (diff)
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.
Diffstat (limited to 'runtime/test/gameinput_test.cpp')
-rw-r--r--runtime/test/gameinput_test.cpp27
1 files changed, 27 insertions, 0 deletions
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) {
393 } 393 }
394 check(monotonic && polls < 100 && sticks_at_rest(st), "keyboard pad: right stick decays to 0 when the mouse stops"); 394 check(monotonic && polls < 100 && sticks_at_rest(st), "keyboard pad: right stick decays to 0 when the mouse stops");
395 395
396 // LEONIDA_MOUSE_SENSITIVITY scales the axis units per count: 2 doubles, 0.5 halves; out of range clamps.
397 auto settle = [&] {
398 for (int i = 0; i < 200 && !sticks_at_rest(pad_state(input, kb)); ++i) rt::gameinput::poll();
399 };
400 set_env("LEONIDA_MOUSE_SENSITIVITY", "2");
401 rt::gameinput::reload_config();
402 g_cursor_x += 10;
403 rt::gameinput::poll();
404 check(approx(pad_state(input, kb).rightThumbstickX, 20480 / 32767.0f), "keyboard pad: mouse sensitivity 2 doubles the stick");
405 settle();
406 set_env("LEONIDA_MOUSE_SENSITIVITY", "0.5");
407 rt::gameinput::reload_config();
408 g_cursor_x -= 10;
409 rt::gameinput::poll();
410 check(approx(pad_state(input, kb).rightThumbstickX, -5120 / 32767.0f), "keyboard pad: mouse sensitivity 0.5 halves the stick");
411 settle();
412 set_env("LEONIDA_MOUSE_SENSITIVITY", "100");
413 rt::gameinput::reload_config();
414 check(rt::gameinput::config().mouse_sensitivity == 10.0f, "keyboard pad: mouse sensitivity clamps to 10");
415 set_env("LEONIDA_MOUSE_SENSITIVITY", "0");
416 rt::gameinput::reload_config();
417 check(approx(rt::gameinput::config().mouse_sensitivity, 0.1f), "keyboard pad: mouse sensitivity clamps to 0.1");
418 set_env("LEONIDA_MOUSE_SENSITIVITY", nullptr);
419 rt::gameinput::reload_config();
420 check(rt::gameinput::config().mouse_sensitivity == 1.0f && rt::gameinput::config().ds_trigger_gain == 1.0f,
421 "keyboard pad: mouse sensitivity defaults to 1 and leaves the trigger gain alone");
422
396 g_keys[VK_RBUTTON] = true; 423 g_keys[VK_RBUTTON] = true;
397 rt::gameinput::poll(); 424 rt::gameinput::poll();
398 st = pad_state(input, kb); 425 st = pad_state(input, kb);