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:
authoralexandersato0830 <66799221+alexandersato0830@users.noreply.github.com>2026-11-25 13:50:42 -0600
committeralexandersato0830 <66799221+alexandersato0830@users.noreply.github.com>2026-11-25 13:51:01 -0600
commit361c3abe61c8e76c281688ce351bbfc9d74d6928 (patch)
treec497f356fd49785755778bcda0977148ccc7a957 /runtime/test/gameinput_test.cpp
parent0afcf9b5980e040192644bbd78fa054a635f5237 (diff)
Reset mouse delta baseline when the cursor source changes
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 b6658f51c..65050be12 100644
--- a/runtime/test/gameinput_test.cpp
+++ b/runtime/test/gameinput_test.cpp
@@ -234,6 +234,11 @@ bool fake_cursor(int* x, int* y) {
234 *y = g_cursor_y; 234 *y = g_cursor_y;
235 return true; 235 return true;
236} 236}
237bool fake_cursor_with_offset(int* x, int* y) {
238 *x = g_cursor_x + 4096;
239 *y = g_cursor_y;
240 return true;
241}
237 242
238GameInputGamepadState pad_state(IGameInput* input, IGameInputDevice* dev, uint32_t* ui = nullptr) { 243GameInputGamepadState pad_state(IGameInput* input, IGameInputDevice* dev, uint32_t* ui = nullptr) {
239 GameInputGamepadState st{}; 244 GameInputGamepadState st{};
@@ -805,6 +810,19 @@ void test_keyboard_pad_sticks(IGameInput* input, IGameInputDevice* kb) {
805 g_focus = true; 810 g_focus = true;
806 rt::gameinput::poll(); 811 rt::gameinput::poll();
807 check(sticks_at_rest(pad_state(input, kb)), "keyboard pad: no mouse jump when focus returns"); 812 check(sticks_at_rest(pad_state(input, kb)), "keyboard pad: no mouse jump when focus returns");
813
814 rt::gameinput::set_cursor_source(fake_cursor_with_offset);
815 rt::gameinput::poll();
816 check(sticks_at_rest(pad_state(input, kb)), "keyboard pad: a new cursor source sets a baseline");
817 g_cursor_x += 4;
818 rt::gameinput::poll();
819 check(approx(pad_state(input, kb).rightThumbstickX, 4096 / 32767.0f),
820 "keyboard pad: motion from the new cursor source reaches the stick");
821 rt::gameinput::set_cursor_source(fake_cursor);
822 rt::gameinput::poll();
823 check(approx(pad_state(input, kb).rightThumbstickX, 3584 / 32767.0f),
824 "keyboard pad: changing cursor source lets previous motion decay without a jump");
825 settle();
808} 826}
809 827
810// Runs with no other pad connected and the device callback from main still registered. 828// Runs with no other pad connected and the device callback from main still registered.