InputCommon: Rename class InputPlugin to InputConfig
This commit is contained in:
parent
ea7eee1f58
commit
1a3ebbb831
|
@ -15,20 +15,20 @@
|
||||||
namespace Pad
|
namespace Pad
|
||||||
{
|
{
|
||||||
|
|
||||||
static InputPlugin g_plugin("GCPadNew", _trans("Pad"), "GCPad");
|
static InputConfig s_config("GCPadNew", _trans("Pad"), "GCPad");
|
||||||
InputPlugin *GetPlugin()
|
InputConfig* GetConfig()
|
||||||
{
|
{
|
||||||
return &g_plugin;
|
return &s_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown()
|
void Shutdown()
|
||||||
{
|
{
|
||||||
std::vector<ControllerEmu*>::const_iterator
|
std::vector<ControllerEmu*>::const_iterator
|
||||||
i = g_plugin.controllers.begin(),
|
i = s_config.controllers.begin(),
|
||||||
e = g_plugin.controllers.end();
|
e = s_config.controllers.end();
|
||||||
for ( ; i!=e; ++i )
|
for ( ; i!=e; ++i )
|
||||||
delete *i;
|
delete *i;
|
||||||
g_plugin.controllers.clear();
|
s_config.controllers.clear();
|
||||||
|
|
||||||
g_controller_interface.Shutdown();
|
g_controller_interface.Shutdown();
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,13 @@ void Initialize(void* const hwnd)
|
||||||
{
|
{
|
||||||
// add 4 gcpads
|
// add 4 gcpads
|
||||||
for (unsigned int i=0; i<4; ++i)
|
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.SetHwnd(hwnd);
|
||||||
g_controller_interface.Initialize();
|
g_controller_interface.Initialize();
|
||||||
|
|
||||||
// load the saved controller config
|
// load the saved controller config
|
||||||
g_plugin.LoadConfig(true);
|
s_config.LoadConfig(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus)
|
void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus)
|
||||||
|
@ -52,7 +52,7 @@ void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus)
|
||||||
memset(_pPADStatus, 0, sizeof(*_pPADStatus));
|
memset(_pPADStatus, 0, sizeof(*_pPADStatus));
|
||||||
_pPADStatus->err = PAD_ERR_NONE;
|
_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())
|
if (!lk.owns_lock())
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus)
|
||||||
_last_numPAD = _numPAD;
|
_last_numPAD = _numPAD;
|
||||||
|
|
||||||
// get input
|
// 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)
|
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())
|
if (lk.owns_lock())
|
||||||
{
|
{
|
||||||
|
@ -97,11 +97,11 @@ void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
|
||||||
// set rumble
|
// set rumble
|
||||||
if (1 == _uType && _uStrength > 2)
|
if (1 == _uType && _uStrength > 2)
|
||||||
{
|
{
|
||||||
((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(255);
|
((GCPad*)s_config.controllers[ _numPAD ])->SetOutput(255);
|
||||||
}
|
}
|
||||||
else
|
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)
|
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())
|
if (lk.owns_lock())
|
||||||
{
|
{
|
||||||
|
@ -124,7 +124,7 @@ void Motor(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
|
||||||
// set rumble
|
// set rumble
|
||||||
if (_uType == 6)
|
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)
|
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())
|
if (!lk.owns_lock())
|
||||||
return false;
|
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 Shutdown();
|
||||||
void Initialize(void* const hwnd);
|
void Initialize(void* const hwnd);
|
||||||
|
|
||||||
InputPlugin *GetPlugin();
|
InputConfig* GetConfig();
|
||||||
|
|
||||||
void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus);
|
void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus);
|
||||||
void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength);
|
void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength);
|
||||||
|
|
|
@ -16,21 +16,21 @@
|
||||||
namespace Wiimote
|
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;
|
static int s_last_number = 4;
|
||||||
|
|
||||||
InputPlugin *GetPlugin()
|
InputConfig* GetConfig()
|
||||||
{
|
{
|
||||||
return &g_plugin;
|
return &s_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown()
|
void Shutdown()
|
||||||
{
|
{
|
||||||
for (const ControllerEmu* i : g_plugin.controllers)
|
for (const ControllerEmu* i : s_config.controllers)
|
||||||
{
|
{
|
||||||
delete i;
|
delete i;
|
||||||
}
|
}
|
||||||
g_plugin.controllers.clear();
|
s_config.controllers.clear();
|
||||||
|
|
||||||
WiimoteReal::Stop();
|
WiimoteReal::Stop();
|
||||||
|
|
||||||
|
@ -42,13 +42,13 @@ void Initialize(void* const hwnd, bool wait)
|
||||||
{
|
{
|
||||||
// add 4 wiimotes
|
// add 4 wiimotes
|
||||||
for (unsigned int i = WIIMOTE_CHAN_0; i<MAX_BBMOTES; ++i)
|
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.SetHwnd(hwnd);
|
||||||
g_controller_interface.Initialize();
|
g_controller_interface.Initialize();
|
||||||
|
|
||||||
g_plugin.LoadConfig(false);
|
s_config.LoadConfig(false);
|
||||||
|
|
||||||
WiimoteReal::Initialize(wait);
|
WiimoteReal::Initialize(wait);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ void Pause()
|
||||||
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||||
{
|
{
|
||||||
if (WIIMOTE_SRC_HYBRID & g_wiimote_sources[_number])
|
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)
|
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||||
{
|
{
|
||||||
if (WIIMOTE_SRC_HYBRID & g_wiimote_sources[_number])
|
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" );
|
//PanicAlert( "Wiimote_Update" );
|
||||||
|
|
||||||
// TODO: change this to a try_to_lock, and make it give empty input on failure
|
// 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)
|
if (_number <= s_last_number)
|
||||||
{
|
{
|
||||||
|
@ -125,7 +125,7 @@ void Update(int _number)
|
||||||
s_last_number = _number;
|
s_last_number = _number;
|
||||||
|
|
||||||
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
|
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
|
||||||
((WiimoteEmu::Wiimote*)g_plugin.controllers[_number])->Update();
|
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->Update();
|
||||||
else
|
else
|
||||||
WiimoteReal::Update(_number);
|
WiimoteReal::Update(_number);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ void DoState(u8 **ptr, PointerWrap::Mode mode)
|
||||||
PointerWrap p(ptr, mode);
|
PointerWrap p(ptr, mode);
|
||||||
p.Do(s_last_number);
|
p.Do(s_last_number);
|
||||||
for (unsigned int i=0; i<MAX_BBMOTES; ++i)
|
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();
|
unsigned int GetAttached();
|
||||||
void DoState(u8 **ptr, PointerWrap::Mode mode);
|
void DoState(u8 **ptr, PointerWrap::Mode mode);
|
||||||
void EmuStateChange(EMUSTATE_CHANGE newState);
|
void EmuStateChange(EMUSTATE_CHANGE newState);
|
||||||
InputPlugin *GetPlugin();
|
InputConfig* GetConfig();
|
||||||
|
|
||||||
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
|
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
|
||||||
void InterruptChannel(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);
|
auto const data = static_cast<const u8*>(_data);
|
||||||
Report rpt(data, data + size);
|
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.
|
// Convert output DATA packets to SET_REPORT packets.
|
||||||
// Nintendo Wiimotes work without this translation, but 3rd
|
// Nintendo Wiimotes work without this translation, but 3rd
|
||||||
|
@ -347,7 +347,7 @@ void Wiimote::EmuStop()
|
||||||
|
|
||||||
void Wiimote::EmuResume()
|
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();
|
m_last_input_report.clear();
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ extern "C" {
|
||||||
#include "DolphinWX/resources/Dolphin.c" // NOLINT: Dolphin icon
|
#include "DolphinWX/resources/Dolphin.c" // NOLINT: Dolphin icon
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputPlugin;
|
class InputConfig;
|
||||||
class wxFrame;
|
class wxFrame;
|
||||||
|
|
||||||
// Create menu items
|
// Create menu items
|
||||||
|
@ -1222,7 +1222,7 @@ void CFrame::OnConfigDSP(wxCommandEvent& WXUNUSED (event))
|
||||||
|
|
||||||
void CFrame::OnConfigPAD(wxCommandEvent& WXUNUSED (event))
|
void CFrame::OnConfigPAD(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
InputPlugin *const pad_plugin = Pad::GetPlugin();
|
InputConfig* const pad_plugin = Pad::GetConfig();
|
||||||
bool was_init = false;
|
bool was_init = false;
|
||||||
if (g_controller_interface.IsInit()) // check if game is running
|
if (g_controller_interface.IsInit()) // check if game is running
|
||||||
{
|
{
|
||||||
|
@ -1250,7 +1250,7 @@ void CFrame::OnConfigPAD(wxCommandEvent& WXUNUSED (event))
|
||||||
|
|
||||||
void CFrame::OnConfigWiimote(wxCommandEvent& WXUNUSED (event))
|
void CFrame::OnConfigWiimote(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
InputPlugin *const wiimote_plugin = Wiimote::GetPlugin();
|
InputConfig* const wiimote_plugin = Wiimote::GetConfig();
|
||||||
bool was_init = false;
|
bool was_init = false;
|
||||||
if (g_controller_interface.IsInit()) // check if game is running
|
if (g_controller_interface.IsInit()) // check if game is running
|
||||||
{
|
{
|
||||||
|
|
|
@ -133,10 +133,10 @@ void PadSettingSpin::UpdateValue()
|
||||||
setting->SetValue(float(((wxSpinCtrl*)wxcontrol)->GetValue()) / 100);
|
setting->SetValue(float(((wxSpinCtrl*)wxcontrol)->GetValue()) / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlDialog::ControlDialog(GamepadPage* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref)
|
ControlDialog::ControlDialog(GamepadPage* const parent, InputConfig& config, ControllerInterface::ControlReference* const ref)
|
||||||
: wxDialog(parent, -1, _("Configure Control"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
: wxDialog(parent, -1, _("Configure Control"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||||
, control_reference(ref)
|
, control_reference(ref)
|
||||||
, m_plugin(plugin)
|
, m_config(config)
|
||||||
, m_parent(parent)
|
, m_parent(parent)
|
||||||
{
|
{
|
||||||
m_devq = m_parent->controller->default_device;
|
m_devq = m_parent->controller->default_device;
|
||||||
|
@ -177,7 +177,7 @@ void InputConfigDialog::UpdateProfileComboBox()
|
||||||
{
|
{
|
||||||
std::string pname(File::GetUserPath(D_CONFIG_IDX));
|
std::string pname(File::GetUserPath(D_CONFIG_IDX));
|
||||||
pname += PROFILES_PATH;
|
pname += PROFILES_PATH;
|
||||||
pname += m_plugin.profile_name;
|
pname += m_config.profile_name;
|
||||||
|
|
||||||
CFileSearch::XStringVector exts;
|
CFileSearch::XStringVector exts;
|
||||||
exts.push_back("*.ini");
|
exts.push_back("*.ini");
|
||||||
|
@ -210,7 +210,7 @@ void InputConfigDialog::UpdateControlReferences()
|
||||||
|
|
||||||
void InputConfigDialog::ClickSave(wxCommandEvent& event)
|
void InputConfigDialog::ClickSave(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
m_plugin.SaveConfig();
|
m_config.SaveConfig();
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ void GamepadPage::ClearAll(wxCommandEvent&)
|
||||||
// no point in using the real ControllerInterface i guess
|
// no point in using the real ControllerInterface i guess
|
||||||
ControllerInterface face;
|
ControllerInterface face;
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
controller->UpdateReferences(face);
|
controller->UpdateReferences(face);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -308,7 +308,7 @@ void GamepadPage::LoadDefaults(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
controller->LoadDefaults(g_controller_interface);
|
controller->LoadDefaults(g_controller_interface);
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
controller->UpdateReferences(g_controller_interface);
|
controller->UpdateReferences(g_controller_interface);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -318,7 +318,7 @@ bool ControlDialog::Validate()
|
||||||
{
|
{
|
||||||
control_reference->expression = WxStrToStr(textctrl->GetValue());
|
control_reference->expression = WxStrToStr(textctrl->GetValue());
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -337,7 +337,7 @@ void GamepadPage::SetDevice(wxCommandEvent&)
|
||||||
controller->UpdateDefaultDevice();
|
controller->UpdateDefaultDevice();
|
||||||
|
|
||||||
// update references
|
// update references
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
controller->UpdateReferences(g_controller_interface);
|
controller->UpdateReferences(g_controller_interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ void ControlDialog::ClearControl(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
control_reference->expression.clear();
|
control_reference->expression.clear();
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -418,7 +418,7 @@ void ControlDialog::SetSelectedControl(wxCommandEvent&)
|
||||||
textctrl->WriteText(expr);
|
textctrl->WriteText(expr);
|
||||||
control_reference->expression = textctrl->GetValue();
|
control_reference->expression = textctrl->GetValue();
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -453,7 +453,7 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
|
||||||
textctrl->WriteText(expr);
|
textctrl->WriteText(expr);
|
||||||
control_reference->expression = textctrl->GetValue();
|
control_reference->expression = textctrl->GetValue();
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -461,19 +461,19 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
|
||||||
|
|
||||||
void GamepadPage::AdjustSetting(wxCommandEvent& event)
|
void GamepadPage::AdjustSetting(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
((PadSetting*)((wxControl*)event.GetEventObject())->GetClientData())->UpdateValue();
|
((PadSetting*)((wxControl*)event.GetEventObject())->GetClientData())->UpdateValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GamepadPage::AdjustControlOption(wxCommandEvent&)
|
void GamepadPage::AdjustControlOption(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
m_control_dialog->control_reference->range = (ControlState)(m_control_dialog->range_slider->GetValue()) / SLIDER_TICK_COUNT;
|
m_control_dialog->control_reference->range = (ControlState)(m_control_dialog->range_slider->GetValue()) / SLIDER_TICK_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GamepadPage::ConfigControl(wxEvent& event)
|
void GamepadPage::ConfigControl(wxEvent& event)
|
||||||
{
|
{
|
||||||
m_control_dialog = new ControlDialog(this, m_plugin, ((ControlButton*)event.GetEventObject())->control_reference);
|
m_control_dialog = new ControlDialog(this, m_config, ((ControlButton*)event.GetEventObject())->control_reference);
|
||||||
m_control_dialog->ShowModal();
|
m_control_dialog->ShowModal();
|
||||||
m_control_dialog->Destroy();
|
m_control_dialog->Destroy();
|
||||||
|
|
||||||
|
@ -487,7 +487,7 @@ void GamepadPage::ClearControl(wxEvent& event)
|
||||||
btn->control_reference->expression.clear();
|
btn->control_reference->expression.clear();
|
||||||
btn->control_reference->range = 1.0f;
|
btn->control_reference->range = 1.0f;
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
controller->UpdateReferences(g_controller_interface);
|
controller->UpdateReferences(g_controller_interface);
|
||||||
|
|
||||||
// update changes
|
// update changes
|
||||||
|
@ -507,7 +507,7 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
|
||||||
// This makes the "waiting" text work on Linux. true (only if needed) prevents crash on Windows
|
// This makes the "waiting" text work on Linux. true (only if needed) prevents crash on Windows
|
||||||
wxTheApp->Yield(true);
|
wxTheApp->Yield(true);
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev);
|
Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev);
|
||||||
|
|
||||||
// if we got input, select it in the list
|
// if we got input, select it in the list
|
||||||
|
@ -531,7 +531,7 @@ void GamepadPage::DetectControl(wxCommandEvent& event)
|
||||||
// This makes the "waiting" text work on Linux. true (only if needed) prevents crash on Windows
|
// This makes the "waiting" text work on Linux. true (only if needed) prevents crash on Windows
|
||||||
wxTheApp->Yield(true);
|
wxTheApp->Yield(true);
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);
|
Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);
|
||||||
|
|
||||||
// if we got input, update expression and reference
|
// if we got input, update expression and reference
|
||||||
|
@ -635,7 +635,7 @@ void GamepadPage::GetProfilePath(std::string& path)
|
||||||
|
|
||||||
path = File::GetUserPath(D_CONFIG_IDX);
|
path = File::GetUserPath(D_CONFIG_IDX);
|
||||||
path += PROFILES_PATH;
|
path += PROFILES_PATH;
|
||||||
path += m_plugin.profile_name;
|
path += m_config.profile_name;
|
||||||
path += '/';
|
path += '/';
|
||||||
path += WxStrToStr(profile_cbox->GetValue());
|
path += WxStrToStr(profile_cbox->GetValue());
|
||||||
path += ".ini";
|
path += ".ini";
|
||||||
|
@ -653,7 +653,7 @@ void GamepadPage::LoadProfile(wxCommandEvent&)
|
||||||
IniFile inifile;
|
IniFile inifile;
|
||||||
inifile.Load(fname);
|
inifile.Load(fname);
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
controller->LoadConfig(inifile.GetOrCreateSection("Profile"));
|
controller->LoadConfig(inifile.GetOrCreateSection("Profile"));
|
||||||
controller->UpdateReferences(g_controller_interface);
|
controller->UpdateReferences(g_controller_interface);
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ void InputConfigDialog::UpdateDeviceComboBox()
|
||||||
|
|
||||||
void GamepadPage::RefreshDevices(wxCommandEvent&)
|
void GamepadPage::RefreshDevices(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||||
|
|
||||||
// refresh devices
|
// refresh devices
|
||||||
g_controller_interface.Shutdown();
|
g_controller_interface.Shutdown();
|
||||||
|
@ -932,14 +932,14 @@ ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow
|
||||||
Add(stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5);
|
Add(stacked_groups, 0, /*wxEXPAND|*/wxBOTTOM|wxRIGHT, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
GamepadPage::GamepadPage(wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog)
|
GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const unsigned int pad_num, InputConfigDialog* const config_dialog)
|
||||||
: wxPanel(parent, wxID_ANY)
|
: wxPanel(parent, wxID_ANY)
|
||||||
,controller(plugin.controllers[pad_num])
|
,controller(config.controllers[pad_num])
|
||||||
, m_config_dialog(config_dialog)
|
, m_config_dialog(config_dialog)
|
||||||
, m_plugin(plugin)
|
, m_config(config)
|
||||||
{
|
{
|
||||||
|
|
||||||
wxBoxSizer* control_group_sizer = new ControlGroupsSizer(m_plugin.controllers[pad_num], this, this, &control_groups);
|
wxBoxSizer* control_group_sizer = new ControlGroupsSizer(m_config.controllers[pad_num], this, this, &control_groups);
|
||||||
|
|
||||||
wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Profile"));
|
wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Profile"));
|
||||||
|
|
||||||
|
@ -1001,16 +1001,16 @@ GamepadPage::GamepadPage(wxWindow* parent, InputPlugin& plugin, const unsigned i
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputPlugin& plugin, const std::string& name, const int tab_num)
|
InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputConfig& config, const std::string& name, const int tab_num)
|
||||||
: wxDialog(parent, wxID_ANY, wxGetTranslation(StrToWxStr(name)), wxPoint(128,-1))
|
: wxDialog(parent, wxID_ANY, wxGetTranslation(StrToWxStr(name)), wxPoint(128,-1))
|
||||||
, m_plugin(plugin)
|
, m_config(config)
|
||||||
{
|
{
|
||||||
m_pad_notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT);
|
m_pad_notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT);
|
||||||
for (unsigned int i = 0; i < std::min(plugin.controllers.size(), (size_t)MAX_WIIMOTES); ++i)
|
for (unsigned int i = 0; i < std::min(config.controllers.size(), (size_t)MAX_WIIMOTES); ++i)
|
||||||
{
|
{
|
||||||
GamepadPage* gp = new GamepadPage(m_pad_notebook, m_plugin, i, this);
|
GamepadPage* gp = new GamepadPage(m_pad_notebook, m_config, i, this);
|
||||||
m_padpages.push_back(gp);
|
m_padpages.push_back(gp);
|
||||||
m_pad_notebook->AddPage(gp, wxString::Format("%s %u", wxGetTranslation(StrToWxStr(m_plugin.gui_name)), 1+i));
|
m_pad_notebook->AddPage(gp, wxString::Format("%s %u", wxGetTranslation(StrToWxStr(m_config.gui_name)), 1+i));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pad_notebook->SetSelection(tab_num);
|
m_pad_notebook->SetSelection(tab_num);
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||||
#include "InputCommon/ControllerInterface/Device.h"
|
#include "InputCommon/ControllerInterface/Device.h"
|
||||||
|
|
||||||
class InputPlugin;
|
class InputConfig;
|
||||||
class wxComboBox;
|
class wxComboBox;
|
||||||
class wxCommandEvent;
|
class wxCommandEvent;
|
||||||
class wxEvent;
|
class wxEvent;
|
||||||
|
@ -95,7 +95,7 @@ class GamepadPage;
|
||||||
class ControlDialog : public wxDialog
|
class ControlDialog : public wxDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ControlDialog(GamepadPage* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref);
|
ControlDialog(GamepadPage* const parent, InputConfig& config, ControllerInterface::ControlReference* const ref);
|
||||||
|
|
||||||
wxStaticBoxSizer* CreateControlChooser(GamepadPage* const parent);
|
wxStaticBoxSizer* CreateControlChooser(GamepadPage* const parent);
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public:
|
||||||
void AppendControl(wxCommandEvent& event);
|
void AppendControl(wxCommandEvent& event);
|
||||||
|
|
||||||
ControllerInterface::ControlReference* const control_reference;
|
ControllerInterface::ControlReference* const control_reference;
|
||||||
InputPlugin& m_plugin;
|
InputConfig& m_config;
|
||||||
wxComboBox* device_cbox;
|
wxComboBox* device_cbox;
|
||||||
|
|
||||||
wxTextCtrl* textctrl;
|
wxTextCtrl* textctrl;
|
||||||
|
@ -173,7 +173,7 @@ class GamepadPage : public wxPanel
|
||||||
friend class ControlDialog;
|
friend class ControlDialog;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GamepadPage(wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog);
|
GamepadPage(wxWindow* parent, InputConfig& config, const unsigned int pad_num, InputConfigDialog* const config_dialog);
|
||||||
|
|
||||||
void UpdateGUI();
|
void UpdateGUI();
|
||||||
|
|
||||||
|
@ -212,13 +212,13 @@ private:
|
||||||
|
|
||||||
ControlDialog* m_control_dialog;
|
ControlDialog* m_control_dialog;
|
||||||
InputConfigDialog* const m_config_dialog;
|
InputConfigDialog* const m_config_dialog;
|
||||||
InputPlugin &m_plugin;
|
InputConfig& m_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputConfigDialog : public wxDialog
|
class InputConfigDialog : public wxDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputConfigDialog(wxWindow* const parent, InputPlugin& plugin, const std::string& name, const int tab_num = 0);
|
InputConfigDialog(wxWindow* const parent, InputConfig& config, const std::string& name, const int tab_num = 0);
|
||||||
//~InputConfigDialog();
|
//~InputConfigDialog();
|
||||||
|
|
||||||
bool Destroy() override;
|
bool Destroy() override;
|
||||||
|
@ -235,6 +235,6 @@ private:
|
||||||
|
|
||||||
wxNotebook* m_pad_notebook;
|
wxNotebook* m_pad_notebook;
|
||||||
std::vector<GamepadPage*> m_padpages;
|
std::vector<GamepadPage*> m_padpages;
|
||||||
InputPlugin& m_plugin;
|
InputConfig& m_config;
|
||||||
wxTimer* m_update_timer;
|
wxTimer* m_update_timer;
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,11 +28,11 @@
|
||||||
#include "DolphinWX/InputConfigDiag.h"
|
#include "DolphinWX/InputConfigDiag.h"
|
||||||
#include "DolphinWX/WiimoteConfigDiag.h"
|
#include "DolphinWX/WiimoteConfigDiag.h"
|
||||||
|
|
||||||
class InputPlugin;
|
class InputConfig;
|
||||||
|
|
||||||
WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin)
|
WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputConfig& config)
|
||||||
: wxDialog(parent, -1, _("Dolphin Wiimote Configuration"))
|
: wxDialog(parent, -1, _("Dolphin Wiimote Configuration"))
|
||||||
, m_plugin(plugin)
|
, m_config(config)
|
||||||
{
|
{
|
||||||
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin
|
||||||
|
|
||||||
void WiimoteConfigDiag::ConfigEmulatedWiimote(wxCommandEvent& ev)
|
void WiimoteConfigDiag::ConfigEmulatedWiimote(wxCommandEvent& ev)
|
||||||
{
|
{
|
||||||
InputConfigDialog* const m_emu_config_diag = new InputConfigDialog(this, m_plugin, _trans("Dolphin Emulated Wiimote Configuration"), m_wiimote_index_from_conf_bt_id[ev.GetId()]);
|
InputConfigDialog* const m_emu_config_diag = new InputConfigDialog(this, m_config, _trans("Dolphin Emulated Wiimote Configuration"), m_wiimote_index_from_conf_bt_id[ev.GetId()]);
|
||||||
m_emu_config_diag->ShowModal();
|
m_emu_config_diag->ShowModal();
|
||||||
m_emu_config_diag->Destroy();
|
m_emu_config_diag->Destroy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,14 @@
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/HW/Wiimote.h"
|
#include "Core/HW/Wiimote.h"
|
||||||
|
|
||||||
class InputPlugin;
|
class InputConfig;
|
||||||
class wxButton;
|
class wxButton;
|
||||||
class wxWindow;
|
class wxWindow;
|
||||||
|
|
||||||
class WiimoteConfigDiag : public wxDialog
|
class WiimoteConfigDiag : public wxDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin);
|
WiimoteConfigDiag(wxWindow* const parent, InputConfig& config);
|
||||||
|
|
||||||
void RefreshRealWiimotes(wxCommandEvent& event);
|
void RefreshRealWiimotes(wxCommandEvent& event);
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void Cancel(wxCommandEvent& event);
|
void Cancel(wxCommandEvent& event);
|
||||||
|
|
||||||
InputPlugin& m_plugin;
|
InputConfig& m_config;
|
||||||
|
|
||||||
std::map<wxWindowID, unsigned int> m_wiimote_index_from_ctrl_id;
|
std::map<wxWindowID, unsigned int> m_wiimote_index_from_ctrl_id;
|
||||||
unsigned int m_orig_wiimote_sources[MAX_BBMOTES];
|
unsigned int m_orig_wiimote_sources[MAX_BBMOTES];
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
#include "Core/HW/Wiimote.h"
|
#include "Core/HW/Wiimote.h"
|
||||||
#include "InputCommon/InputConfig.h"
|
#include "InputCommon/InputConfig.h"
|
||||||
|
|
||||||
InputPlugin::~InputPlugin()
|
InputConfig::~InputConfig()
|
||||||
{
|
{
|
||||||
// delete pads
|
// delete pads
|
||||||
for (ControllerEmu* pad : controllers)
|
for (ControllerEmu* pad : controllers)
|
||||||
delete pad;
|
delete pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputPlugin::LoadConfig(bool isGC)
|
bool InputConfig::LoadConfig(bool isGC)
|
||||||
{
|
{
|
||||||
IniFile inifile;
|
IniFile inifile;
|
||||||
IniFile game_ini;
|
IniFile game_ini;
|
||||||
|
@ -94,7 +94,7 @@ bool InputPlugin::LoadConfig(bool isGC)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputPlugin::SaveConfig()
|
void InputConfig::SaveConfig()
|
||||||
{
|
{
|
||||||
std::string ini_filename = File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini";
|
std::string ini_filename = File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini";
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,14 @@
|
||||||
#include "InputCommon/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu.h"
|
||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||||
|
|
||||||
// InputPlugin isn't a very good name anymore since it's used by GCPad/Wiimote
|
class InputConfig
|
||||||
// which are not even plugins anymore.
|
|
||||||
class InputPlugin
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
InputConfig(const char* const _ini_name, const char* const _gui_name,
|
||||||
InputPlugin(const char* const _ini_name, const char* const _gui_name,
|
|
||||||
const char* const _profile_name)
|
const char* const _profile_name)
|
||||||
: ini_name(_ini_name), gui_name(_gui_name), profile_name(_profile_name) {}
|
: ini_name(_ini_name), gui_name(_gui_name), profile_name(_profile_name) {}
|
||||||
|
|
||||||
~InputPlugin();
|
~InputConfig();
|
||||||
|
|
||||||
bool LoadConfig(bool isGC);
|
bool LoadConfig(bool isGC);
|
||||||
void SaveConfig();
|
void SaveConfig();
|
||||||
|
|
Loading…
Reference in New Issue