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 32ddf5d91..297ca16db 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, |
| @@ -28,6 +29,22 @@ void CALLBACK on_device(GameInputCallbackToken, void*, IGameInputDevice* device, | |||
| 28 | const GameInputDeviceInfo* i = device->GetDeviceInfo(); | 29 | const GameInputDeviceInfo* i = device->GetDeviceInfo(); |
| 29 | std::printf("\n%s %s (%04x:%04x) motors=0x%x\n", (current & GameInputDeviceConnected) ? "connected " : "disconnected", | 30 | std::printf("\n%s %s (%04x:%04x) motors=0x%x\n", (current & GameInputDeviceConnected) ? "connected " : "disconnected", |
| 30 | i->displayName ? i->displayName->data : "?", i->vendorId, i->productId, i->supportedRumbleMotors); | 31 | i->displayName ? i->displayName->data : "?", i->vendorId, i->productId, i->supportedRumbleMotors); |
| 32 | // Raw HID (RT-175): the report tables read from the pad's HID report descriptor, or why there are none. | ||
| 33 | if (current & GameInputDeviceConnected) { | ||
| 34 | if (!(current & GameInputDeviceRawIoEnabled)) { | ||
| 35 | std::printf("raw hid: no raw I/O (no HID device the backend could open, or no readable descriptor)\n"); | ||
| 36 | } else { | ||
| 37 | const auto list = [](const char* kind, uint32_t n, const void* p) { | ||
| 38 | const auto* r = static_cast<const GameInputRawDeviceReportInfo*>(p); | ||
| 39 | std::printf("raw hid: %u %s report(s):", n, kind); | ||
| 40 | for (uint32_t k = 0; k < n; ++k) std::printf(" id %u = %u bytes;", r[k].id, r[k].size); | ||
| 41 | std::printf("\n"); | ||
| 42 | }; | ||
| 43 | list("input", i->inputReportCount, i->inputReportInfo); | ||
| 44 | list("output", i->outputReportCount, i->outputReportInfo); | ||
| 45 | list("feature", i->featureReportCount, i->featureReportInfo); | ||
| 46 | } | ||
| 47 | } | ||
| 31 | if ((current & GameInputDeviceConnected) && !(previous & GameInputDeviceConnected)) { | 48 | if ((current & GameInputDeviceConnected) && !(previous & GameInputDeviceConnected)) { |
| 32 | device->AddRef(); | 49 | device->AddRef(); |
| 33 | g_devices.push_back(device); | 50 | g_devices.push_back(device); |
| @@ -96,6 +113,16 @@ int main(int argc, char** argv) { | |||
| 96 | if (motion) // fractions of motionInfo's maxima: accel includes gravity, so a resting pad shows ~0.5 g | 113 | if (motion) // fractions of motionInfo's maxima: accel includes gravity, so a resting pad shows ~0.5 g |
| 97 | std::printf("\n[a]=(%+.2f,%+.2f,%+.2f) [w]=(%+.2f,%+.2f,%+.2f) ", m.accelerationX, m.accelerationY, | 114 | std::printf("\n[a]=(%+.2f,%+.2f,%+.2f) [w]=(%+.2f,%+.2f,%+.2f) ", m.accelerationX, m.accelerationY, |
| 98 | m.accelerationZ, m.angularVelocityX, m.angularVelocityY, m.angularVelocityZ); | 115 | m.accelerationZ, m.angularVelocityX, m.angularVelocityY, m.angularVelocityZ); |
| 116 | void* raw = nullptr; | ||
| 117 | if (r->GetRawReport(&raw) && raw) { // the newest raw input report: id and its first 16 bytes | ||
| 118 | auto* rr = static_cast<IGameInputRawDeviceReport*>(raw); | ||
| 119 | unsigned char b[16] = {}; | ||
| 120 | const size_t n = rr->GetRawData(sizeof b, b); | ||
| 121 | std::printf("\nraw id %u (%zu bytes):", rr->GetReportInfo()->id, rr->GetRawDataSize()); | ||
| 122 | for (size_t k = 0; k < n; ++k) std::printf(" %02x", b[k]); | ||
| 123 | std::printf(" "); | ||
| 124 | rr->Release(); | ||
| 125 | } | ||
| 99 | std::fflush(stdout); | 126 | std::fflush(stdout); |
| 100 | r->Release(); | 127 | r->Release(); |
| 101 | } | 128 | } |