upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/gameinput_probe.cpp
diff options
context:
space:
mode:
authorLeonida local test <local-test@localhost>2026-11-22 23:15:09 +0100
committerLeonida local test <local-test@localhost>2026-11-22 23:15:09 +0100
commitdc01a173970ceccfefefc9e70e6cd31b1eeec43a (patch)
tree6c64d024783afb6e06647f1c43779f9b20fe3f86 /runtime/test/gameinput_probe.cpp
parent59aa22ff0ca967db25c0ff8116c52484b7773b5e (diff)
gameinput: report SDL's effect result from gameinput_probe (RT-160)
`--force-feedback` now reads the shim's output state once the poll thread has picked the effect up, and says whether SDL created it and is running it, or why it did not, so a wheel owner can tell a silent drop from a real run. The shim records SDL_CreateHapticEffect's id, SDL_RunHapticEffect's result and SDL's error text per device; gameinput_test asserts the success and the refusal. AI-assisted
Diffstat (limited to 'runtime/test/gameinput_probe.cpp')
-rw-r--r--runtime/test/gameinput_probe.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/runtime/test/gameinput_probe.cpp b/runtime/test/gameinput_probe.cpp
index 58a6a1010..1d3202cb5 100644
--- a/runtime/test/gameinput_probe.cpp
+++ b/runtime/test/gameinput_probe.cpp
@@ -66,7 +66,9 @@ void play(const char* what, GameInputRumbleParams p) {
66// A constant force at full magnitude on the pad's first motor, held for a second: the effect a wheel feels as a 66// A constant force at full magnitude on the pad's first motor, held for a second: the effect a wheel feels as a
67// steady pull. A pad SDL did not open as a haptic device reports no motor, and the step says so and moves on. 67// steady pull. A pad SDL did not open as a haptic device reports no motor, and the step says so and moves on.
68void constant_force() { 68void constant_force() {
69 for (IGameInputDevice* d : g_devices) { 69 // g_devices is in connection order, which is what output_state indexes; the SDL outcome is read back per pad.
70 for (size_t n = 0; n < g_devices.size(); ++n) {
71 IGameInputDevice* d = g_devices[n];
70 const GameInputDeviceInfo* i = d->GetDeviceInfo(); 72 const GameInputDeviceInfo* i = d->GetDeviceInfo();
71 if (i->forceFeedbackMotorCount == 0) { 73 if (i->forceFeedbackMotorCount == 0) {
72 std::printf("force feedback: %s reports no force-feedback motor; skipped\n", 74 std::printf("force feedback: %s reports no force-feedback motor; skipped\n",
@@ -88,7 +90,21 @@ void constant_force() {
88 } 90 }
89 std::printf("force feedback: constant linearX 1.0 on motor 0, 1 s\n"); 91 std::printf("force feedback: constant linearX 1.0 on motor 0, 1 s\n");
90 e->SetState(GameInputFeedbackRunning); 92 e->SetState(GameInputFeedbackRunning);
91 Sleep(1000); 93 Sleep(1000); // the poll thread creates and runs the effect
94 char seen[256] = "no output state";
95 rt::gameinput::OutputState out{};
96 if (rt::gameinput::output_state(static_cast<int>(n), &out)) {
97 if (out.effect_id < 0) {
98 std::snprintf(seen, sizeof seen, "SDL did not create the effect (%s)",
99 out.effect_error[0] ? out.effect_error : "no error text");
100 } else if (!out.effect_ran) {
101 std::snprintf(seen, sizeof seen, "SDL created effect %d but did not run it (%s)", out.effect_id,
102 out.effect_error[0] ? out.effect_error : "no error text");
103 } else {
104 std::snprintf(seen, sizeof seen, "SDL created effect %d and is running it", out.effect_id);
105 }
106 }
107 std::printf("force feedback: %s\n", seen);
92 e->SetState(GameInputFeedbackStopped); 108 e->SetState(GameInputFeedbackStopped);
93 e->Release(); // the poll thread destroys the SDL effect 109 e->Release(); // the poll thread destroys the SDL effect
94 Sleep(300); 110 Sleep(300);