mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-01 05:38:50 +00:00
Merge pull request #917 from lioncash/input
InputCommon: Rename class InputPlugin to InputConfig
This commit is contained in:
commit
24b5ce2ddc
12 changed files with 85 additions and 88 deletions
|
@ -15,20 +15,20 @@
|
|||
namespace Pad
|
||||
{
|
||||
|
||||
static InputPlugin g_plugin("GCPadNew", _trans("Pad"), "GCPad");
|
||||
InputPlugin *GetPlugin()
|
||||
static InputConfig s_config("GCPadNew", _trans("Pad"), "GCPad");
|
||||
InputConfig* GetConfig()
|
||||
{
|
||||
return &g_plugin;
|
||||
return &s_config;
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
std::vector<ControllerEmu*>::const_iterator
|
||||
i = g_plugin.controllers.begin(),
|
||||
e = g_plugin.controllers.end();
|
||||
i = s_config.controllers.begin(),
|
||||
e = s_config.controllers.end();
|
||||
for ( ; i!=e; ++i )
|
||||
delete *i;
|
||||
g_plugin.controllers.clear();
|
||||
s_config.controllers.clear();
|
||||
|
||||
g_controller_interface.Shutdown();
|
||||
}
|
||||
|
@ -38,13 +38,13 @@ void Initialize(void* const hwnd)
|
|||
{
|
||||
// add 4 gcpads
|
||||
for (unsigned int i=0; i<4; ++i)
|
||||
g_plugin.controllers.push_back(new GCPad(i));
|
||||
s_config.controllers.push_back(new GCPad(i));
|
||||
|
||||
g_controller_interface.SetHwnd(hwnd);
|
||||
g_controller_interface.Initialize();
|
||||
|
||||
// load the saved controller config
|
||||
g_plugin.LoadConfig(true);
|
||||
s_config.LoadConfig(true);
|
||||
}
|
||||
|
||||
void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus)
|
||||
|
@ -52,7 +52,7 @@ void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus)
|
|||
memset(_pPADStatus, 0, sizeof(*_pPADStatus));
|
||||
_pPADStatus->err = PAD_ERR_NONE;
|
||||
|
||||
std::unique_lock<std::recursive_mutex> lk(g_plugin.controls_lock, std::try_to_lock);
|
||||
std::unique_lock<std::recursive_mutex> lk(s_config.controls_lock, std::try_to_lock);
|
||||
|
||||
if (!lk.owns_lock())
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus)
|
|||
_last_numPAD = _numPAD;
|
||||
|
||||
// get input
|
||||
((GCPad*)g_plugin.controllers[_numPAD])->GetInput(_pPADStatus);
|
||||
((GCPad*)s_config.controllers[_numPAD])->GetInput(_pPADStatus);
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
|
@ -89,7 +89,7 @@ void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus)
|
|||
//
|
||||
void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lk(g_plugin.controls_lock, std::try_to_lock);
|
||||
std::unique_lock<std::recursive_mutex> lk(s_config.controls_lock, std::try_to_lock);
|
||||
|
||||
if (lk.owns_lock())
|
||||
{
|
||||
|
@ -97,11 +97,11 @@ void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
|
|||
// set rumble
|
||||
if (1 == _uType && _uStrength > 2)
|
||||
{
|
||||
((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(255);
|
||||
((GCPad*)s_config.controllers[ _numPAD ])->SetOutput(255);
|
||||
}
|
||||
else
|
||||
{
|
||||
((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(0);
|
||||
((GCPad*)s_config.controllers[ _numPAD ])->SetOutput(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
|
|||
//
|
||||
void Motor(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lk(g_plugin.controls_lock, std::try_to_lock);
|
||||
std::unique_lock<std::recursive_mutex> lk(s_config.controls_lock, std::try_to_lock);
|
||||
|
||||
if (lk.owns_lock())
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ void Motor(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
|
|||
// set rumble
|
||||
if (_uType == 6)
|
||||
{
|
||||
((GCPad*)g_plugin.controllers[ _numPAD ])->SetMotor(_uStrength);
|
||||
((GCPad*)s_config.controllers[ _numPAD ])->SetMotor(_uStrength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,12 +132,12 @@ void Motor(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
|
|||
bool GetMicButton(u8 pad)
|
||||
{
|
||||
|
||||
std::unique_lock<std::recursive_mutex> lk(g_plugin.controls_lock, std::try_to_lock);
|
||||
std::unique_lock<std::recursive_mutex> lk(s_config.controls_lock, std::try_to_lock);
|
||||
|
||||
if (!lk.owns_lock())
|
||||
return false;
|
||||
|
||||
return ((GCPad*)g_plugin.controllers[pad])->GetMicButton();
|
||||
return ((GCPad*)s_config.controllers[pad])->GetMicButton();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Pad
|
|||
void Shutdown();
|
||||
void Initialize(void* const hwnd);
|
||||
|
||||
InputPlugin *GetPlugin();
|
||||
InputConfig* GetConfig();
|
||||
|
||||
void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus);
|
||||
void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength);
|
||||
|
|
|
@ -16,21 +16,21 @@
|
|||
namespace Wiimote
|
||||
{
|
||||
|
||||
static InputPlugin g_plugin(WIIMOTE_INI_NAME, _trans("Wiimote"), "Wiimote");
|
||||
static InputConfig s_config(WIIMOTE_INI_NAME, _trans("Wiimote"), "Wiimote");
|
||||
static int s_last_number = 4;
|
||||
|
||||
InputPlugin *GetPlugin()
|
||||
InputConfig* GetConfig()
|
||||
{
|
||||
return &g_plugin;
|
||||
return &s_config;
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
for (const ControllerEmu* i : g_plugin.controllers)
|
||||
for (const ControllerEmu* i : s_config.controllers)
|
||||
{
|
||||
delete i;
|
||||
}
|
||||
g_plugin.controllers.clear();
|
||||
s_config.controllers.clear();
|
||||
|
||||
WiimoteReal::Stop();
|
||||
|
||||
|
@ -42,13 +42,13 @@ void Initialize(void* const hwnd, bool wait)
|
|||
{
|
||||
// add 4 wiimotes
|
||||
for (unsigned int i = WIIMOTE_CHAN_0; i<MAX_BBMOTES; ++i)
|
||||
g_plugin.controllers.push_back(new WiimoteEmu::Wiimote(i));
|
||||
s_config.controllers.push_back(new WiimoteEmu::Wiimote(i));
|
||||
|
||||
|
||||
g_controller_interface.SetHwnd(hwnd);
|
||||
g_controller_interface.Initialize();
|
||||
|
||||
g_plugin.LoadConfig(false);
|
||||
s_config.LoadConfig(false);
|
||||
|
||||
WiimoteReal::Initialize(wait);
|
||||
|
||||
|
@ -83,7 +83,7 @@ void Pause()
|
|||
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
if (WIIMOTE_SRC_HYBRID & g_wiimote_sources[_number])
|
||||
((WiimoteEmu::Wiimote*)g_plugin.controllers[_number])->ControlChannel(_channelID, _pData, _Size);
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->ControlChannel(_channelID, _pData, _Size);
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
|
@ -101,7 +101,7 @@ void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
|||
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
if (WIIMOTE_SRC_HYBRID & g_wiimote_sources[_number])
|
||||
((WiimoteEmu::Wiimote*)g_plugin.controllers[_number])->InterruptChannel(_channelID, _pData, _Size);
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->InterruptChannel(_channelID, _pData, _Size);
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
|
@ -115,7 +115,7 @@ void Update(int _number)
|
|||
//PanicAlert( "Wiimote_Update" );
|
||||
|
||||
// TODO: change this to a try_to_lock, and make it give empty input on failure
|
||||
std::lock_guard<std::recursive_mutex> lk(g_plugin.controls_lock);
|
||||
std::lock_guard<std::recursive_mutex> lk(s_config.controls_lock);
|
||||
|
||||
if (_number <= s_last_number)
|
||||
{
|
||||
|
@ -125,7 +125,7 @@ void Update(int _number)
|
|||
s_last_number = _number;
|
||||
|
||||
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
|
||||
((WiimoteEmu::Wiimote*)g_plugin.controllers[_number])->Update();
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->Update();
|
||||
else
|
||||
WiimoteReal::Update(_number);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ void DoState(u8 **ptr, PointerWrap::Mode mode)
|
|||
PointerWrap p(ptr, mode);
|
||||
p.Do(s_last_number);
|
||||
for (unsigned int i=0; i<MAX_BBMOTES; ++i)
|
||||
((WiimoteEmu::Wiimote*)g_plugin.controllers[i])->DoState(p);
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[i])->DoState(p);
|
||||
}
|
||||
|
||||
// ___________________________________________________________________________
|
||||
|
|
|
@ -42,7 +42,7 @@ void Pause();
|
|||
unsigned int GetAttached();
|
||||
void DoState(u8 **ptr, PointerWrap::Mode mode);
|
||||
void EmuStateChange(EMUSTATE_CHANGE newState);
|
||||
InputPlugin *GetPlugin();
|
||||
InputConfig* GetConfig();
|
||||
|
||||
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
|
||||
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
|
||||
|
|
|
@ -158,7 +158,7 @@ void Wiimote::InterruptChannel(const u16 channel, const void* const _data, const
|
|||
|
||||
auto const data = static_cast<const u8*>(_data);
|
||||
Report rpt(data, data + size);
|
||||
WiimoteEmu::Wiimote *const wm = (WiimoteEmu::Wiimote*)::Wiimote::GetPlugin()->controllers[index];
|
||||
WiimoteEmu::Wiimote *const wm = (WiimoteEmu::Wiimote*)::Wiimote::GetConfig()->controllers[index];
|
||||
|
||||
// Convert output DATA packets to SET_REPORT packets.
|
||||
// Nintendo Wiimotes work without this translation, but 3rd
|
||||
|
@ -347,7 +347,7 @@ void Wiimote::EmuStop()
|
|||
|
||||
void Wiimote::EmuResume()
|
||||
{
|
||||
WiimoteEmu::Wiimote *const wm = (WiimoteEmu::Wiimote*)::Wiimote::GetPlugin()->controllers[index];
|
||||
WiimoteEmu::Wiimote *const wm = (WiimoteEmu::Wiimote*)::Wiimote::GetConfig()->controllers[index];
|
||||
|
||||
m_last_input_report.clear();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue