From cc50049bca08d5b27000ced573ed5d213063de71 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 20 Dec 2024 00:44:31 +0100 Subject: [PATCH] cellGem: implement cellGemSetRumble --- rpcs3/Emu/Cell/Modules/cellGem.cpp | 21 ++++++++++++++++++++- rpcs3/Input/ps_move_handler.cpp | 9 ++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellGem.cpp b/rpcs3/Emu/Cell/Modules/cellGem.cpp index cb26b5d4b9..f4f5599afc 100644 --- a/rpcs3/Emu/Cell/Modules/cellGem.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGem.cpp @@ -888,7 +888,7 @@ public: std::lock_guard lock(pad::g_pad_mutex); const auto handler = pad::get_current_handler(); auto& handlers = handler->get_handlers(); - if (auto it = handlers.find(pad_handler::move); it != handlers.end()) + if (auto it = handlers.find(pad_handler::move); it != handlers.end() && it->second) { for (auto& binding : it->second->bindings()) { @@ -2789,6 +2789,25 @@ error_code cellGemSetRumble(u32 gem_num, u8 rumble) gem.controllers[gem_num].rumble = rumble; + // Set actual device rumble + if (g_cfg.io.move == move_handler::real) + { + std::lock_guard pad_lock(pad::g_pad_mutex); + const auto handler = pad::get_current_handler(); + auto& handlers = handler->get_handlers(); + if (auto it = handlers.find(pad_handler::move); it != handlers.end() && it->second) + { + const u32 pad_index = pad_num(gem_num); + for (const auto& binding : it->second->bindings()) + { + if (!binding.device || binding.device->player_id != pad_index) continue; + + handler->SetRumble(pad_index, rumble, rumble > 0); + break; + } + } + } + return CELL_OK; } diff --git a/rpcs3/Input/ps_move_handler.cpp b/rpcs3/Input/ps_move_handler.cpp index 07c379a9ee..80742f0dc8 100644 --- a/rpcs3/Input/ps_move_handler.cpp +++ b/rpcs3/Input/ps_move_handler.cpp @@ -817,11 +817,9 @@ int ps_move_handler::send_output_report(ps_move_device* device) const auto elapsed = now - device->last_output_report_time; // Update LED at an interval or it will be disabled automatically - if (elapsed >= 4000ms) - { - device->new_output_data = true; - } - else + device->new_output_data |= elapsed >= 4000ms; + + if (!device->new_output_data) { // Use LED update rate of 120ms if (elapsed < 120ms) @@ -858,6 +856,7 @@ void ps_move_handler::apply_pad_data(const pad_ensemble& binding) const u8 speed_large = config->enable_vibration_motor_large ? pad->m_vibrateMotors[idx_l].m_value : 0; + dev->new_output_data |= dev->large_motor != speed_large; dev->large_motor = speed_large; if (send_output_report(dev) >= 0)