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:
authorMoonEyes <ducoinbenjamin@yahoo.fr>2026-11-28 19:12:09 +0100
committerGitHub <noreply@github.com>2026-11-28 19:12:09 +0100
commit423521c111b416ea1cb9e3341105348e08c6c2b3 (patch)
tree62de3282dc2a8aec8c06ff5ce0d32c31601ab52a /runtime/test/gameinput_test.cpp
parentdc93dd3c188ded377b3b96f8753f6eb23a058839 (diff)
parent361c3abe61c8e76c281688ce351bbfc9d74d6928 (diff)
Merge pull request #2086 from alexandersato0830/codex/gameinput-cursor-source
Reset the mouse baseline when the cursor source changes (RT-KEYBOARD-PAD-CURSOR-SOURCE)
Diffstat (limited to 'runtime/test/gameinput_test.cpp')
-rw-r--r--runtime/test/gameinput_test.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp
index 314d9293e..7bf48f233 100644
--- a/runtime/test/gameinput_test.cpp
+++ b/runtime/test/gameinput_test.cpp
@@ -235,6 +235,11 @@ bool fake_cursor(int* x, int* y) {
235 *y = g_cursor_y; 235 *y = g_cursor_y;
236 return true; 236 return true;
237} 237}
238bool fake_cursor_with_offset(int* x, int* y) {
239 *x = g_cursor_x + 4096;
240 *y = g_cursor_y;
241 return true;
242}
238 243
239GameInputGamepadState pad_state(IGameInput* input, IGameInputDevice* dev, uint32_t* ui = nullptr) { 244GameInputGamepadState pad_state(IGameInput* input, IGameInputDevice* dev, uint32_t* ui = nullptr) {
240 GameInputGamepadState st{}; 245 GameInputGamepadState st{};
@@ -827,6 +832,19 @@ void test_keyboard_pad_sticks(IGameInput* input, IGameInputDevice* kb) {
827 g_focus = true; 832 g_focus = true;
828 rt::gameinput::poll(); 833 rt::gameinput::poll();
829 check(sticks_at_rest(pad_state(input, kb)), "keyboard pad: no mouse jump when focus returns"); 834 check(sticks_at_rest(pad_state(input, kb)), "keyboard pad: no mouse jump when focus returns");
835
836 rt::gameinput::set_cursor_source(fake_cursor_with_offset);
837 rt::gameinput::poll();
838 check(sticks_at_rest(pad_state(input, kb)), "keyboard pad: a new cursor source sets a baseline");
839 g_cursor_x += 4;
840 rt::gameinput::poll();
841 check(approx(pad_state(input, kb).rightThumbstickX, 4096 / 32767.0f),
842 "keyboard pad: motion from the new cursor source reaches the stick");
843 rt::gameinput::set_cursor_source(fake_cursor);
844 rt::gameinput::poll();
845 check(approx(pad_state(input, kb).rightThumbstickX, 3584 / 32767.0f),
846 "keyboard pad: changing cursor source lets previous motion decay without a jump");
847 settle();
830} 848}
831 849
832// Runs with no other pad connected and the device callback from main still registered. 850// Runs with no other pad connected and the device callback from main still registered.