diff options
| author | alexandersato0830 <66799221+alexandersato0830@users.noreply.github.com> | 2026-11-25 13:46:10 -0600 |
|---|---|---|
| committer | alexandersato0830 <66799221+alexandersato0830@users.noreply.github.com> | 2026-11-25 13:46:10 -0600 |
| commit | 8b3db052e4068ef7097af39a07dfff70ca1cac42 (patch) | |
| tree | cd63ca0f57f9de820a683dc6c85347b137709d42 /runtime/test/gameinput_test.cpp | |
| parent | 5da72d19f0bec96b716cad601d1af9c920976af7 (diff) | |
Keep virtual gamepad mouse deltas in range
Diffstat (limited to 'runtime/test/gameinput_test.cpp')
| -rw-r--r-- | runtime/test/gameinput_test.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp index b6658f51c..c4e2491eb 100644 --- a/runtime/test/gameinput_test.cpp +++ b/runtime/test/gameinput_test.cpp | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <cstdio> | 19 | #include <cstdio> |
| 20 | #include <cstring> | 20 | #include <cstring> |
| 21 | #include <deque> | 21 | #include <deque> |
| 22 | #include <limits> | ||
| 22 | #include <string> | 23 | #include <string> |
| 23 | #include <thread> | 24 | #include <thread> |
| 24 | #include <vector> | 25 | #include <vector> |
| @@ -777,6 +778,27 @@ void test_keyboard_pad_sticks(IGameInput* input, IGameInputDevice* kb) { | |||
| 777 | check(rt::gameinput::config().mouse_sensitivity == 1.0f && rt::gameinput::config().ds_trigger_gain == 1.0f, | 778 | check(rt::gameinput::config().mouse_sensitivity == 1.0f && rt::gameinput::config().ds_trigger_gain == 1.0f, |
| 778 | "keyboard pad: mouse sensitivity defaults to 1 and leaves the trigger gain alone"); | 779 | "keyboard pad: mouse sensitivity defaults to 1 and leaves the trigger gain alone"); |
| 779 | 780 | ||
| 781 | g_cursor_x += 3'000'000; | ||
| 782 | rt::gameinput::poll(); | ||
| 783 | check(approx(pad_state(input, kb).rightThumbstickX, 1), | ||
| 784 | "keyboard pad: a positive jump beyond LONG_MAX axis units stays full right"); | ||
| 785 | g_cursor_x -= 3'000'000; | ||
| 786 | rt::gameinput::poll(); | ||
| 787 | check(approx(pad_state(input, kb).rightThumbstickX, -1), | ||
| 788 | "keyboard pad: a negative jump beyond LONG_MIN axis units stays full left"); | ||
| 789 | |||
| 790 | const int prior_x = g_cursor_x; | ||
| 791 | g_cursor_x = std::numeric_limits<int>::max() - 1; | ||
| 792 | rt::gameinput::poll(); | ||
| 793 | settle(); | ||
| 794 | g_cursor_x = std::numeric_limits<int>::min() + 2; | ||
| 795 | rt::gameinput::poll(); | ||
| 796 | check(approx(pad_state(input, kb).rightThumbstickX, 4096 / 32767.0f), | ||
| 797 | "keyboard pad: the raw cursor counter wrap moves four counts right"); | ||
| 798 | g_cursor_x = prior_x; | ||
| 799 | rt::gameinput::poll(); | ||
| 800 | settle(); | ||
| 801 | |||
| 780 | g_keys[VK_RBUTTON] = true; | 802 | g_keys[VK_RBUTTON] = true; |
| 781 | rt::gameinput::poll(); | 803 | rt::gameinput::poll(); |
| 782 | st = pad_state(input, kb); | 804 | st = pad_state(input, kb); |