diff options
Diffstat (limited to 'runtime/test/gameinput_probe.cpp')
| -rw-r--r-- | runtime/test/gameinput_probe.cpp | 20 |
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. |
| 68 | void constant_force() { | 68 | void 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); |