diff options
| author | néo Luigi <85024393+neoluigi4123@users.noreply.github.com> | 2026-11-01 03:04:13 +0100 |
|---|---|---|
| committer | néo Luigi <85024393+neoluigi4123@users.noreply.github.com> | 2026-11-01 03:04:13 +0100 |
| commit | 2b413a46a2820f0a646baaa8dbd683009f096f32 (patch) | |
| tree | a89b1a40f53c7ada3f698041c598dadd9a21274f | |
| parent | feff94e8bb60bae13995b30dcb3abe717cfaaff3 (diff) | |
Vibration fix for ns2 games | Assisted by claude (code)
| -rw-r--r-- | src/core/hle/service/hid/hid_server.cpp | 39 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid_server.h | 2 |
2 files changed, 36 insertions, 5 deletions
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp index 04b4663bc2..9d5f5f91d2 100644 --- a/src/core/hle/service/hid/hid_server.cpp +++ b/src/core/hle/service/hid/hid_server.cpp @@ -132,7 +132,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r {210, C<&IHidServer::EndPermitVibrationSession>, "EndPermitVibrationSession"}, {211, C<&IHidServer::IsVibrationDeviceMounted>, "IsVibrationDeviceMounted"}, {212, C<&IHidServer::SendVibrationValueInBool>, "SendVibrationValueInBool"}, - {214, C<&IHidServer::SendNx2VibrationValues>, "SendNx2VibrationValues (guessed)"}, + {214, &IHidServer::SendNx2VibrationValues, "SendNx2VibrationValues (guessed)"}, {300, C<&IHidServer::ActivateConsoleSixAxisSensor>, "ActivateConsoleSixAxisSensor"}, {301, C<&IHidServer::StartConsoleSixAxisSensor>, "StartConsoleSixAxisSensor"}, {302, C<&IHidServer::StopConsoleSixAxisSensor>, "StopConsoleSixAxisSensor"}, @@ -1070,9 +1070,40 @@ Result IHidServer::IsVibrationDeviceMounted( R_SUCCEED(); } -Result IHidServer::SendNx2VibrationValues() { - LOG_DEBUG(Service_HID, "(STUBBED) called"); - R_SUCCEED(); +// TEMPORARY local diagnostic for #103: dumps the request layout of 214 when it changes. +void IHidServer::SendNx2VibrationValues(HLERequestContext& ctx) { + static std::string last_dump; + static u64 call_count = 0; + ++call_count; + + std::string dump = fmt::format("words(payload@{}):", ctx.GetDataPayloadOffset()); + const u32* cmd_buf = ctx.CommandBuffer(); + for (u32 i = 0; i < 16; ++i) { + dump += fmt::format(" {:08x}", cmd_buf[i]); + } + dump += fmt::format(" | X={} A={} B={} C={}", ctx.BufferDescriptorX().size(), + ctx.BufferDescriptorA().size(), ctx.BufferDescriptorB().size(), + ctx.BufferDescriptorC().size()); + const auto dump_buffer = [&dump](char kind, std::size_t index, std::span<const u8> data) { + dump += fmt::format(" | {}{} size={}:", kind, index, data.size()); + for (std::size_t i = 0; i < std::min<std::size_t>(data.size(), 96); ++i) { + dump += fmt::format("{}{:02x}", i % 4 == 0 ? " " : "", data[i]); + } + }; + for (std::size_t i = 0; i < ctx.BufferDescriptorX().size(); ++i) { + dump_buffer('X', i, ctx.ReadBufferX(i)); + } + for (std::size_t i = 0; i < ctx.BufferDescriptorA().size(); ++i) { + dump_buffer('A', i, ctx.ReadBufferA(i)); + } + + if (dump != last_dump) { + LOG_INFO(Service_HID, "214 #{}: {}", call_count, dump); + last_dump = std::move(dump); + } + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); } Result IHidServer::SendVibrationValueInBool( diff --git a/src/core/hle/service/hid/hid_server.h b/src/core/hle/service/hid/hid_server.h index 574d54c415..beeb5ba17f 100644 --- a/src/core/hle/service/hid/hid_server.h +++ b/src/core/hle/service/hid/hid_server.h @@ -191,7 +191,7 @@ private: ClientAppletResourceUserId aruid); // Switch 2 sends vibration every frame with 214 (pointer buffers of device handles and // values, like 206); Eden doesn't emulate vibration, so accept and drop it. - Result SendNx2VibrationValues(); + void SendNx2VibrationValues(HLERequestContext& ctx); Result ActivateConsoleSixAxisSensor(ClientAppletResourceUserId aruid); Result StartConsoleSixAxisSensor(Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle, ClientAppletResourceUserId aruid); |
