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:
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);