Reset the GC adapter rumble when stopping a game
And when loading a savestate, pausing, and starting dolphin as well (right after the libusb initialization). Intended fix for issue 9001
This commit is contained in:
parent
584ea8b320
commit
680ebfeaa8
|
@ -45,6 +45,9 @@
|
||||||
#include "Core/HW/HW.h"
|
#include "Core/HW/HW.h"
|
||||||
#include "Core/HW/Memmap.h"
|
#include "Core/HW/Memmap.h"
|
||||||
#include "Core/HW/ProcessorInterface.h"
|
#include "Core/HW/ProcessorInterface.h"
|
||||||
|
#if defined(__LIBUSB__) || defined(_WIN32)
|
||||||
|
#include "Core/HW/SI_GCAdapter.h"
|
||||||
|
#endif
|
||||||
#include "Core/HW/SystemTimers.h"
|
#include "Core/HW/SystemTimers.h"
|
||||||
#include "Core/HW/VideoInterface.h"
|
#include "Core/HW/VideoInterface.h"
|
||||||
#include "Core/HW/Wiimote.h"
|
#include "Core/HW/Wiimote.h"
|
||||||
|
@ -274,6 +277,9 @@ void Stop() // - Hammertime!
|
||||||
|
|
||||||
g_video_backend->Video_ExitLoop();
|
g_video_backend->Video_ExitLoop();
|
||||||
}
|
}
|
||||||
|
#if defined(__LIBUSB__) || defined(_WIN32)
|
||||||
|
SI_GCAdapter::ResetRumble();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclareAsCPUThread()
|
void DeclareAsCPUThread()
|
||||||
|
@ -608,6 +614,9 @@ void SetState(EState _State)
|
||||||
case CORE_PAUSE:
|
case CORE_PAUSE:
|
||||||
CPU::EnableStepping(true); // Break
|
CPU::EnableStepping(true); // Break
|
||||||
Wiimote::Pause();
|
Wiimote::Pause();
|
||||||
|
#if defined(__LIBUSB__) || defined(_WIN32)
|
||||||
|
SI_GCAdapter::ResetRumble();
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case CORE_RUN:
|
case CORE_RUN:
|
||||||
CPU::EnableStepping(false);
|
CPU::EnableStepping(false);
|
||||||
|
@ -716,6 +725,9 @@ bool PauseAndLock(bool doLock, bool unpauseOnUnlock)
|
||||||
// video has to come after CPU, because CPU thread can wait for video thread (s_efbAccessRequested).
|
// video has to come after CPU, because CPU thread can wait for video thread (s_efbAccessRequested).
|
||||||
g_video_backend->PauseAndLock(doLock, unpauseOnUnlock);
|
g_video_backend->PauseAndLock(doLock, unpauseOnUnlock);
|
||||||
|
|
||||||
|
#if defined(__LIBUSB__) || defined(_WIN32)
|
||||||
|
SI_GCAdapter::ResetRumble();
|
||||||
|
#endif
|
||||||
return wasUnpaused;
|
return wasUnpaused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <libusb.h>
|
#include <libusb.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
@ -295,6 +296,7 @@ static void AddGCAdapter(libusb_device* device)
|
||||||
s_detected = true;
|
s_detected = true;
|
||||||
if (s_detect_callback != nullptr)
|
if (s_detect_callback != nullptr)
|
||||||
s_detect_callback();
|
s_detect_callback();
|
||||||
|
ResetRumble();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown()
|
void Shutdown()
|
||||||
|
@ -398,6 +400,23 @@ void Input(int chan, GCPadStatus* pad)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResetRumble()
|
||||||
|
{
|
||||||
|
if (!SConfig::GetInstance().m_GameCubeAdapter)
|
||||||
|
return;
|
||||||
|
if (s_handle == nullptr || !s_detected)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::fill(std::begin(s_controller_rumble), std::end(s_controller_rumble), 0);
|
||||||
|
|
||||||
|
unsigned char rumble[5] = {0x11, s_controller_rumble[0], s_controller_rumble[1], s_controller_rumble[2], s_controller_rumble[3]};
|
||||||
|
|
||||||
|
int size = 0;
|
||||||
|
libusb_interrupt_transfer(s_handle, s_endpoint_out, rumble, sizeof(rumble), &size, 16);
|
||||||
|
|
||||||
|
DEBUG_LOG(SERIALINTERFACE, "Rumble state reset");
|
||||||
|
}
|
||||||
|
|
||||||
void Output(int chan, u8 rumble_command)
|
void Output(int chan, u8 rumble_command)
|
||||||
{
|
{
|
||||||
if (s_handle == nullptr || !SConfig::GetInstance().m_GameCubeAdapter || !SConfig::GetInstance().m_AdapterRumble)
|
if (s_handle == nullptr || !SConfig::GetInstance().m_GameCubeAdapter || !SConfig::GetInstance().m_AdapterRumble)
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace SI_GCAdapter
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
void ResetRumble();
|
||||||
void Setup();
|
void Setup();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
void SetAdapterCallback(std::function<void(void)> func);
|
void SetAdapterCallback(std::function<void(void)> func);
|
||||||
|
|
Loading…
Reference in New Issue