cellGem: implement cellGemSetRumble

This commit is contained in:
Megamouse 2024-12-20 00:44:31 +01:00
parent c6a76eb9af
commit cc50049bca
2 changed files with 24 additions and 6 deletions

View File

@ -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;
}

View File

@ -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)