Fix indefinite rumble on emulation pause

This commit is contained in:
Kekker-git 2018-03-25 22:23:46 -04:00
parent 69addc680d
commit d40ae9f569
3 changed files with 21 additions and 9 deletions

View File

@ -244,6 +244,17 @@ bool Init(std::unique_ptr<BootParameters> boot)
return true; return true;
} }
static void ResetRumble()
{
#if defined(__LIBUSB__)
GCAdapter::ResetRumble();
#endif
#if defined(CIFACE_USE_XINPUT) || defined(CIFACE_USE_DINPUT)
for (int i = 0; i < 4; ++i)
Pad::ResetRumble(i);
#endif
}
// Called from GUI thread // Called from GUI thread
void Stop() // - Hammertime! void Stop() // - Hammertime!
{ {
@ -274,9 +285,8 @@ void Stop() // - Hammertime!
g_video_backend->Video_ExitLoop(); g_video_backend->Video_ExitLoop();
} }
#if defined(__LIBUSB__)
GCAdapter::ResetRumble(); ResetRumble();
#endif
#ifdef USE_MEMORYWATCHER #ifdef USE_MEMORYWATCHER
MemoryWatcher::Shutdown(); MemoryWatcher::Shutdown();
@ -605,9 +615,7 @@ void SetState(State state)
// stopped (including the CPU). // stopped (including the CPU).
CPU::EnableStepping(true); // Break CPU::EnableStepping(true); // Break
Wiimote::Pause(); Wiimote::Pause();
#if defined(__LIBUSB__) ResetRumble();
GCAdapter::ResetRumble();
#endif
break; break;
case State::Running: case State::Running:
CPU::EnableStepping(false); CPU::EnableStepping(false);
@ -726,9 +734,7 @@ static bool PauseAndLock(bool do_lock, bool unpause_on_unlock)
// (s_efbAccessRequested). // (s_efbAccessRequested).
Fifo::PauseAndLock(do_lock, false); Fifo::PauseAndLock(do_lock, false);
#if defined(__LIBUSB__) ResetRumble();
GCAdapter::ResetRumble();
#endif
// CPU is unlocked last because CPU::PauseAndLock contains the synchronization // CPU is unlocked last because CPU::PauseAndLock contains the synchronization
// mechanism that prevents CPU::Break from racing. // mechanism that prevents CPU::Break from racing.

View File

@ -60,6 +60,11 @@ void Rumble(const int pad_num, const ControlState strength)
static_cast<GCPad*>(s_config.GetController(pad_num))->SetOutput(strength); static_cast<GCPad*>(s_config.GetController(pad_num))->SetOutput(strength);
} }
void ResetRumble(const int pad_num)
{
static_cast<GCPad*>(s_config.GetController(pad_num))->SetOutput(0.0);
}
bool GetMicButton(const int pad_num) bool GetMicButton(const int pad_num)
{ {
return static_cast<GCPad*>(s_config.GetController(pad_num))->GetMicButton(); return static_cast<GCPad*>(s_config.GetController(pad_num))->GetMicButton();

View File

@ -27,6 +27,7 @@ InputConfig* GetConfig();
GCPadStatus GetStatus(int pad_num); GCPadStatus GetStatus(int pad_num);
ControllerEmu::ControlGroup* GetGroup(int pad_num, PadGroup group); ControllerEmu::ControlGroup* GetGroup(int pad_num, PadGroup group);
void Rumble(int pad_num, ControlState strength); void Rumble(int pad_num, ControlState strength);
void ResetRumble(int pad_num);
bool GetMicButton(int pad_num); bool GetMicButton(int pad_num);
} }