Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HW: Fix infinite rumble on emulation pause #6477

Merged
merged 1 commit into from Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 15 additions & 9 deletions Source/Core/Core/Core.cpp
Expand Up @@ -244,6 +244,17 @@ bool Init(std::unique_ptr<BootParameters> boot)
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
void Stop() // - Hammertime!
{
Expand Down Expand Up @@ -274,9 +285,8 @@ void Stop() // - Hammertime!

g_video_backend->Video_ExitLoop();
}
#if defined(__LIBUSB__)
GCAdapter::ResetRumble();
#endif

ResetRumble();

#ifdef USE_MEMORYWATCHER
MemoryWatcher::Shutdown();
Expand Down Expand Up @@ -605,9 +615,7 @@ void SetState(State state)
// stopped (including the CPU).
CPU::EnableStepping(true); // Break
Wiimote::Pause();
#if defined(__LIBUSB__)
GCAdapter::ResetRumble();
#endif
ResetRumble();
break;
case State::Running:
CPU::EnableStepping(false);
Expand Down Expand Up @@ -726,9 +734,7 @@ static bool PauseAndLock(bool do_lock, bool unpause_on_unlock)
// (s_efbAccessRequested).
Fifo::PauseAndLock(do_lock, false);

#if defined(__LIBUSB__)
GCAdapter::ResetRumble();
#endif
ResetRumble();

// CPU is unlocked last because CPU::PauseAndLock contains the synchronization
// mechanism that prevents CPU::Break from racing.
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Core/HW/GCPad.cpp
Expand Up @@ -60,6 +60,11 @@ void Rumble(const int pad_num, const ControlState 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)
{
return static_cast<GCPad*>(s_config.GetController(pad_num))->GetMicButton();
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/HW/GCPad.h
Expand Up @@ -27,6 +27,7 @@ InputConfig* GetConfig();
GCPadStatus GetStatus(int pad_num);
ControllerEmu::ControlGroup* GetGroup(int pad_num, PadGroup group);
void Rumble(int pad_num, ControlState strength);
void ResetRumble(int pad_num);

bool GetMicButton(int pad_num);
}