Skip to content

Commit 781da9d

Browse files
MegamouseAniLeo
authored andcommitted
input: disable pad vibration after no new data was sent for 3 seconds
This is supposedly how the lib does it.
1 parent 1e6a4dc commit 781da9d

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

rpcs3/Emu/Io/PadHandler.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,22 @@ void PadHandlerBase::process()
752752

753753
pad->move_data.orientation_enabled = b_has_orientation && device->config && device->config->orientation_enabled.get();
754754

755+
// Disable pad vibration if no new data was sent for 3 seconds
756+
if (pad->m_last_rumble_time_us > 0)
757+
{
758+
std::lock_guard lock(pad::g_pad_mutex);
759+
760+
if ((get_system_time() - pad->m_last_rumble_time_us) > 3'000'000)
761+
{
762+
for (VibrateMotor& motor : pad->m_vibrateMotors)
763+
{
764+
motor.m_value = 0;
765+
}
766+
767+
pad->m_last_rumble_time_us = 0;
768+
}
769+
}
770+
755771
const connection status = update_connection(device);
756772

757773
switch (status)

rpcs3/Emu/Io/pad_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,8 @@ struct Pad
522522
s32 m_orientation_reset_button_index{-1}; // Special button index. -1 if not set.
523523
bool get_orientation_reset_button_active();
524524

525+
u64 m_last_rumble_time_us{0};
526+
525527
// Cable State: 0 - 1 plugged in ?
526528
u8 m_cable_state{0};
527529

rpcs3/Input/pad_thread.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ void pad_thread::SetRumble(const u32 pad, u8 large_motor, bool small_motor)
236236
if (pad >= m_pads.size())
237237
return;
238238

239+
m_pads[pad]->m_last_rumble_time_us = get_system_time();
239240
m_pads[pad]->m_vibrateMotors[0].m_value = large_motor;
240241
m_pads[pad]->m_vibrateMotors[1].m_value = small_motor ? 255 : 0;
241242
}

0 commit comments

Comments
 (0)