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.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp
index 7217dc37b..3e6b4b309 100644
--- a/runtime/test/gameinput_test.cpp
+++ b/runtime/test/gameinput_test.cpp
@@ -1599,6 +1599,27 @@ void test_haptic_motors(IGameInput* input) {
1599 rt::gameinput::poll(); 1599 rt::gameinput::poll();
1600 check(xbox.left == 0, "haptics: releasing both leaves the trigger silent"); 1600 check(xbox.left == 0, "haptics: releasing both leaves the trigger silent");
1601 1601
1602 // A request too long for a uint64 microsecond deadline plays until it is set again: the end time saturates
1603 // instead of wrapping into the past (never plays) or into the near future (stops early).
1604 p.intensity = 1.0f;
1605 p.playCount = 1;
1606 p.duration = UINT64_MAX;
1607 p.repeatDelay = 0;
1608 check(dev->SetHapticMotorState(0, &p) == S_OK, "haptics: a duration of UINT64_MAX is accepted");
1609 rt::gameinput::poll();
1610 check(xbox.left == 65535, "haptics: and plays (its end time does not wrap into the past)");
1611 p.duration = (1ull << 63) + 50'000; // times 2 wraps to 100 ms
1612 p.playCount = 2;
1613 check(dev->SetHapticMotorState(1, &p) == S_OK, "haptics: duration * playCount past UINT64_MAX is accepted");
1614 rt::gameinput::poll();
1615 Sleep(130);
1616 rt::gameinput::poll();
1617 check(xbox.right == 65535, "haptics: and keeps playing (the product does not wrap to a short request)");
1618 dev->SetHapticMotorState(0, nullptr);
1619 dev->SetHapticMotorState(1, nullptr);
1620 rt::gameinput::poll();
1621 check(xbox.left == 0 && xbox.right == 0, "haptics: both long requests stop when the state is cleared");
1622
1602 detach(xbox); 1623 detach(xbox);
1603 rt::gameinput::poll(); 1624 rt::gameinput::poll();
1604 check(rt::gameinput::connected_count() == 0, "haptics: detached"); 1625 check(rt::gameinput::connected_count() == 0, "haptics: detached");