diff options
Diffstat (limited to 'runtime/test/gameinput_probe.cpp')
| -rw-r--r-- | runtime/test/gameinput_probe.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/runtime/test/gameinput_probe.cpp b/runtime/test/gameinput_probe.cpp index a56132ed5..510194f1d 100644 --- a/runtime/test/gameinput_probe.cpp +++ b/runtime/test/gameinput_probe.cpp | |||
| @@ -2,7 +2,8 @@ | |||
| 2 | // | 2 | // |
| 3 | // gameinput_probe [--seconds N] [--rumble] | 3 | // gameinput_probe [--seconds N] [--rumble] |
| 4 | // | 4 | // |
| 5 | // Lists the gamepads the shim sees, then prints the live gamepad reading of each for N seconds (default 10). With | 5 | // Lists the gamepads the shim sees, with the raw HID report tables of each pad opened through HID, then prints the |
| 6 | // live gamepad reading (and its newest raw input report, when there is one) for N seconds (default 10). With | ||
| 6 | // --rumble it first plays, on every pad: the low-frequency motor, the high-frequency motor, the left and the right | 7 | // --rumble it first plays, on every pad: the low-frequency motor, the high-frequency motor, the left and the right |
| 7 | // impulse trigger, one second each. On a DualSense the trigger steps run in the LEONIDA_DS_TRIGGERS mode (rumble by | 8 | // impulse trigger, one second each. On a DualSense the trigger steps run in the LEONIDA_DS_TRIGGERS mode (rumble by |
| 8 | // default; set it to resistance to feel that one). Everything goes through GameInputCreate from the shim registry, | 9 | // default; set it to resistance to feel that one). Everything goes through GameInputCreate from the shim registry, |
| @@ -30,6 +31,22 @@ void CALLBACK on_device(GameInputCallbackToken, void*, IGameInputDevice* device, | |||
| 30 | (current & GameInputDeviceConnected) ? "connected " : "disconnected", | 31 | (current & GameInputDeviceConnected) ? "connected " : "disconnected", |
| 31 | i->displayName ? i->displayName->data : "?", i->vendorId, i->productId, i->supportedRumbleMotors, | 32 | i->displayName ? i->displayName->data : "?", i->vendorId, i->productId, i->supportedRumbleMotors, |
| 32 | i->forceFeedbackMotorCount, i->hapticFeedbackMotorCount); | 33 | i->forceFeedbackMotorCount, i->hapticFeedbackMotorCount); |
| 34 | // Raw HID (RT-175): the report tables read from the pad's HID report descriptor, or why there are none. | ||
| 35 | if (current & GameInputDeviceConnected) { | ||
| 36 | if (!(current & GameInputDeviceRawIoEnabled)) { | ||
| 37 | std::printf("raw hid: no raw I/O (no HID device the backend could open, or no readable descriptor)\n"); | ||
| 38 | } else { | ||
| 39 | const auto list = [](const char* kind, uint32_t n, const void* p) { | ||
| 40 | const auto* r = static_cast<const GameInputRawDeviceReportInfo*>(p); | ||
| 41 | std::printf("raw hid: %u %s report(s):", n, kind); | ||
| 42 | for (uint32_t k = 0; k < n; ++k) std::printf(" id %u = %u bytes;", r[k].id, r[k].size); | ||
| 43 | std::printf("\n"); | ||
| 44 | }; | ||
| 45 | list("input", i->inputReportCount, i->inputReportInfo); | ||
| 46 | list("output", i->outputReportCount, i->outputReportInfo); | ||
| 47 | list("feature", i->featureReportCount, i->featureReportInfo); | ||
| 48 | } | ||
| 49 | } | ||
| 33 | if ((current & GameInputDeviceConnected) && !(previous & GameInputDeviceConnected)) { | 50 | if ((current & GameInputDeviceConnected) && !(previous & GameInputDeviceConnected)) { |
| 34 | device->AddRef(); | 51 | device->AddRef(); |
| 35 | g_devices.push_back(device); | 52 | g_devices.push_back(device); |
| @@ -98,6 +115,16 @@ int main(int argc, char** argv) { | |||
| 98 | if (motion) // fractions of motionInfo's maxima: accel includes gravity, so a resting pad shows ~0.5 g | 115 | if (motion) // fractions of motionInfo's maxima: accel includes gravity, so a resting pad shows ~0.5 g |
| 99 | std::printf("\n[a]=(%+.2f,%+.2f,%+.2f) [w]=(%+.2f,%+.2f,%+.2f) ", m.accelerationX, m.accelerationY, | 116 | std::printf("\n[a]=(%+.2f,%+.2f,%+.2f) [w]=(%+.2f,%+.2f,%+.2f) ", m.accelerationX, m.accelerationY, |
| 100 | m.accelerationZ, m.angularVelocityX, m.angularVelocityY, m.angularVelocityZ); | 117 | m.accelerationZ, m.angularVelocityX, m.angularVelocityY, m.angularVelocityZ); |
| 118 | void* raw = nullptr; | ||
| 119 | if (r->GetRawReport(&raw) && raw) { // the newest raw input report: id and its first 16 bytes | ||
| 120 | auto* rr = static_cast<IGameInputRawDeviceReport*>(raw); | ||
| 121 | unsigned char b[16] = {}; | ||
| 122 | const size_t n = rr->GetRawData(sizeof b, b); | ||
| 123 | std::printf("\nraw id %u (%zu bytes):", rr->GetReportInfo()->id, rr->GetRawDataSize()); | ||
| 124 | for (size_t k = 0; k < n; ++k) std::printf(" %02x", b[k]); | ||
| 125 | std::printf(" "); | ||
| 126 | rr->Release(); | ||
| 127 | } | ||
| 101 | std::fflush(stdout); | 128 | std::fflush(stdout); |
| 102 | r->Release(); | 129 | r->Release(); |
| 103 | } | 130 | } |