(cleanup) Delete an awful global variable (g_plugin in ConfigDiag). Rename the Plugin class in InputConfig to InputPlugin, which is better but not ideal.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5663 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2010-06-12 18:45:39 +00:00
parent 393aa36fc2
commit caab5f62ad
7 changed files with 89 additions and 84 deletions

View File

@ -17,7 +17,7 @@
#include "InputConfig.h" #include "InputConfig.h"
Plugin::Plugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name ) InputPlugin::InputPlugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name )
: ini_name(_ini_name) : ini_name(_ini_name)
, gui_name(_gui_name) , gui_name(_gui_name)
, profile_name(_profile_name) , profile_name(_profile_name)
@ -30,7 +30,7 @@ Plugin::Plugin( const char* const _ini_name, const char* const _gui_name, const
// controllers.push_back( new Wiimote( i ) ); // controllers.push_back( new Wiimote( i ) );
}; };
Plugin::~Plugin() InputPlugin::~InputPlugin()
{ {
// delete pads // delete pads
std::vector<ControllerEmu*>::const_iterator i = controllers.begin(), std::vector<ControllerEmu*>::const_iterator i = controllers.begin(),
@ -39,7 +39,7 @@ Plugin::~Plugin()
delete *i; delete *i;
} }
bool Plugin::LoadConfig() bool InputPlugin::LoadConfig()
{ {
IniFile inifile; IniFile inifile;
if (false == inifile.Load(std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini")) if (false == inifile.Load(std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini"))
@ -51,9 +51,10 @@ bool Plugin::LoadConfig()
for ( ; i!=e; ++i ) { for ( ; i!=e; ++i ) {
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str())); (*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
} }
return true;
} }
void Plugin::SaveConfig() void InputPlugin::SaveConfig()
{ {
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini" ); std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini" );

View File

@ -30,12 +30,14 @@
#include <map> #include <map>
#include <sstream> #include <sstream>
class Plugin // InputPlugin isn't a very good name anymore since it's also used for GCPad which
// will soon not even be a plugin anymore.
class InputPlugin
{ {
public: public:
Plugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name ); InputPlugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name );
~Plugin(); ~InputPlugin();
bool LoadConfig(); bool LoadConfig();
void SaveConfig(); void SaveConfig();

View File

@ -19,8 +19,6 @@
#define _connect_macro_( b, f, c, s ) (b)->Connect( wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s ) #define _connect_macro_( b, f, c, s ) (b)->Connect( wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s )
static Plugin* g_plugin;
void GamepadPage::ConfigExtension( wxCommandEvent& event ) void GamepadPage::ConfigExtension( wxCommandEvent& event )
{ {
ControllerEmu::Extension* const ex = ((ExtensionButton*)event.GetEventObject())->extension; ControllerEmu::Extension* const ex = ((ExtensionButton*)event.GetEventObject())->extension;
@ -102,8 +100,9 @@ void PadSettingChoice::UpdateValue()
value = float(GetValue()) / 100; value = float(GetValue()) / 100;
} }
ControlDialog::ControlDialog( wxWindow* const parent, ControllerInterface::ControlReference* const ref, const std::vector<ControllerInterface::Device*>& devs ) ControlDialog::ControlDialog( wxWindow* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref, const std::vector<ControllerInterface::Device*>& devs )
:wxDialog( parent, -1, wxT("Configure Control"), wxDefaultPosition ) :wxDialog( parent, -1, wxT("Configure Control"), wxDefaultPosition )
,m_plugin(plugin)
,control_reference(ref) ,control_reference(ref)
{ {
@ -144,10 +143,11 @@ ControlButton::ControlButton( wxWindow* const parent, ControllerInterface::Contr
SetLabel( wxString::FromAscii( label.c_str() ) ); SetLabel( wxString::FromAscii( label.c_str() ) );
} }
void ConfigDialog::UpdateProfileComboBox() void InputConfigDialog::UpdateProfileComboBox()
{ {
std::string pname( File::GetUserPath(D_CONFIG_IDX) ); std::string pname( File::GetUserPath(D_CONFIG_IDX) );
pname += PROFILES_PATH; pname += g_plugin->profile_name; pname += PROFILES_PATH;
pname += m_plugin.profile_name;
CFileSearch::XStringVector exts; CFileSearch::XStringVector exts;
exts.push_back("*.ini"); exts.push_back("*.ini");
@ -174,17 +174,17 @@ void ConfigDialog::UpdateProfileComboBox()
} }
} }
void ConfigDialog::UpdateControlReferences() void InputConfigDialog::UpdateControlReferences()
{ {
std::vector< GamepadPage* >::iterator i = m_padpages.begin(), std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
e = m_padpages.end(); e = m_padpages.end();
for ( ; i != e; ++i ) for ( ; i != e; ++i )
(*i)->controller->UpdateReferences( g_plugin->controller_interface ); (*i)->controller->UpdateReferences( m_plugin.controller_interface );
} }
void ConfigDialog::ClickSave( wxCommandEvent& event ) void InputConfigDialog::ClickSave( wxCommandEvent& event )
{ {
g_plugin->SaveConfig(); m_plugin.SaveConfig();
Close(); Close();
} }
@ -279,7 +279,7 @@ void GamepadPage::UpdateGUI()
void GamepadPage::ClearAll( wxCommandEvent& event ) void GamepadPage::ClearAll( wxCommandEvent& event )
{ {
g_plugin->controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
// just load an empty ini section to clear everything :P // just load an empty ini section to clear everything :P
IniFile::Section section; IniFile::Section section;
@ -291,7 +291,7 @@ void GamepadPage::ClearAll( wxCommandEvent& event )
UpdateGUI(); UpdateGUI();
g_plugin->controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
} }
void ControlDialog::SetControl( wxCommandEvent& event ) void ControlDialog::SetControl( wxCommandEvent& event )
@ -299,9 +299,9 @@ void ControlDialog::SetControl( wxCommandEvent& event )
control_reference->control_qualifier.name = control_reference->control_qualifier.name =
std::string( control_chooser->textctrl->GetValue().ToAscii() ); std::string( control_chooser->textctrl->GetValue().ToAscii() );
g_plugin->controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
control_reference->UpdateControls(); control_reference->UpdateControls();
g_plugin->controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
control_chooser->UpdateListSelection(); control_chooser->UpdateListSelection();
} }
@ -317,9 +317,9 @@ void GamepadPage::SetDevice( wxCommandEvent& event )
controller->UpdateDefaultDevice(); controller->UpdateDefaultDevice();
// update references // update references
g_plugin->controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
controller->UpdateReferences( g_plugin->controller_interface ); controller->UpdateReferences( m_plugin.controller_interface );
g_plugin->controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
} }
void ControlDialog::SetDevice( wxCommandEvent& event ) void ControlDialog::SetDevice( wxCommandEvent& event )
@ -330,9 +330,9 @@ void ControlDialog::SetDevice( wxCommandEvent& event )
device_cbox->SetValue( wxString::FromAscii( control_reference->device_qualifier.ToString().c_str() ) ); device_cbox->SetValue( wxString::FromAscii( control_reference->device_qualifier.ToString().c_str() ) );
// update references // update references
g_plugin->controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
g_plugin->controller_interface.UpdateReference( control_reference ); m_plugin.controller_interface.UpdateReference( control_reference );
g_plugin->controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
// update gui // update gui
control_chooser->UpdateListContents(); control_chooser->UpdateListContents();
@ -342,26 +342,26 @@ void ControlDialog::ClearControl( wxCommandEvent& event )
{ {
control_reference->control_qualifier.name.clear(); control_reference->control_qualifier.name.clear();
g_plugin->controls_crit.Leave(); // enter m_plugin.controls_crit.Leave(); // enter
control_reference->UpdateControls(); control_reference->UpdateControls();
g_plugin->controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
control_chooser->UpdateListSelection(); control_chooser->UpdateListSelection();
} }
void GamepadPage::AdjustSetting( wxCommandEvent& event ) void GamepadPage::AdjustSetting( wxCommandEvent& event )
{ {
g_plugin->controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
// updates the setting value from the GUI control // updates the setting value from the GUI control
(dynamic_cast<PadSetting*>(event.GetEventObject()))->UpdateValue(); (dynamic_cast<PadSetting*>(event.GetEventObject()))->UpdateValue();
g_plugin->controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
} }
void GamepadPage::AdjustControlOption( wxCommandEvent& event ) void GamepadPage::AdjustControlOption( wxCommandEvent& event )
{ {
g_plugin->controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
m_control_dialog->control_reference->range = ControlState( m_control_dialog->control_chooser->range_slider->GetValue() ) / SLIDER_TICK_COUNT; m_control_dialog->control_reference->range = ControlState( m_control_dialog->control_chooser->range_slider->GetValue() ) / SLIDER_TICK_COUNT;
@ -369,12 +369,12 @@ void GamepadPage::AdjustControlOption( wxCommandEvent& event )
((ControllerInterface::InputReference*)m_control_dialog->control_reference)->mode = ((ControllerInterface::InputReference*)m_control_dialog->control_reference)->mode =
m_control_dialog->control_chooser->mode_cbox->GetSelection(); m_control_dialog->control_chooser->mode_cbox->GetSelection();
g_plugin->controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
} }
void GamepadPage::ConfigControl( wxCommandEvent& event ) void GamepadPage::ConfigControl( wxCommandEvent& event )
{ {
m_control_dialog = new ControlDialog( this, ((ControlButton*)event.GetEventObject())->control_reference, g_plugin->controller_interface.Devices() ); m_control_dialog = new ControlDialog( this, m_plugin, ((ControlButton*)event.GetEventObject())->control_reference, m_plugin.controller_interface.Devices() );
m_control_dialog->ShowModal(); m_control_dialog->ShowModal();
m_control_dialog->Destroy(); m_control_dialog->Destroy();
@ -388,11 +388,11 @@ void GamepadPage::ClearControl( wxCommandEvent& event )
btn->control_reference->control_qualifier.name.clear(); btn->control_reference->control_qualifier.name.clear();
btn->control_reference->device_qualifier = controller->default_device; btn->control_reference->device_qualifier = controller->default_device;
g_plugin->controls_crit.Enter(); m_plugin.controls_crit.Enter();
if (btn->control_reference->is_input) if (btn->control_reference->is_input)
((ControllerInterface::InputReference*)btn->control_reference)->mode = 0; ((ControllerInterface::InputReference*)btn->control_reference)->mode = 0;
controller->UpdateReferences( g_plugin->controller_interface ); controller->UpdateReferences( m_plugin.controller_interface );
g_plugin->controls_crit.Leave(); m_plugin.controls_crit.Leave();
// update changes // update changes
UpdateGUI(); UpdateGUI();
@ -416,10 +416,10 @@ void ControlDialog::DetectControl( wxCommandEvent& event )
btn->SetLabel(wxT("w")); btn->SetLabel(wxT("w"));
} }
g_plugin->controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
if ( control_reference->Detect( DETECT_WAIT_TIME + (num - 1) * 500, num ) ) // if we got input, update gui if ( control_reference->Detect( DETECT_WAIT_TIME + (num - 1) * 500, num ) ) // if we got input, update gui
control_chooser->UpdateListSelection(); control_chooser->UpdateListSelection();
g_plugin->controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
btn->SetLabel(lbl); btn->SetLabel(lbl);
} }
@ -430,9 +430,9 @@ void GamepadPage::DetectControl( wxCommandEvent& event )
btn->SetLabel(wxT("[ waiting ]")); btn->SetLabel(wxT("[ waiting ]"));
g_plugin->controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
btn->control_reference->Detect( DETECT_WAIT_TIME ); btn->control_reference->Detect( DETECT_WAIT_TIME );
g_plugin->controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
btn->SetLabel(wxString::FromAscii(btn->control_reference->control_qualifier.name.c_str())); btn->SetLabel(wxString::FromAscii(btn->control_reference->control_qualifier.name.c_str()));
} }
@ -463,9 +463,9 @@ void ControlDialog::SelectControl( wxCommandEvent& event )
control_reference->control_qualifier.name = control_reference->control_qualifier.name =
std::string( final_label.ToAscii() ); std::string( final_label.ToAscii() );
g_plugin->controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
control_reference->UpdateControls(); control_reference->UpdateControls();
g_plugin->controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
control_chooser->UpdateGUI(); control_chooser->UpdateGUI();
} }
@ -549,10 +549,10 @@ void GamepadPage::LoadProfile( wxCommandEvent& event )
if ( profile_cbox->GetValue().empty() ) if ( profile_cbox->GetValue().empty() )
return; return;
g_plugin->controls_crit.Enter(); m_plugin.controls_crit.Enter();
std::string fname( File::GetUserPath(D_CONFIG_IDX) ); std::string fname( File::GetUserPath(D_CONFIG_IDX) );
fname += PROFILES_PATH; fname += g_plugin->profile_name; fname += '/'; fname += PROFILES_PATH; fname += m_plugin.profile_name; fname += '/';
fname += profile_cbox->GetValue().ToAscii(); fname += ".ini"; fname += profile_cbox->GetValue().ToAscii(); fname += ".ini";
if ( false == File::Exists( fname.c_str() ) ) if ( false == File::Exists( fname.c_str() ) )
@ -561,9 +561,9 @@ void GamepadPage::LoadProfile( wxCommandEvent& event )
IniFile inifile; IniFile inifile;
inifile.Load(fname); inifile.Load(fname);
controller->LoadConfig( inifile.GetOrCreateSection("Profile")); controller->LoadConfig( inifile.GetOrCreateSection("Profile"));
controller->UpdateReferences( g_plugin->controller_interface ); controller->UpdateReferences( m_plugin.controller_interface );
g_plugin->controls_crit.Leave(); m_plugin.controls_crit.Leave();
UpdateGUI(); UpdateGUI();
} }
@ -574,7 +574,7 @@ void GamepadPage::SaveProfile( wxCommandEvent& event )
return; return;
std::string fname( File::GetUserPath(D_CONFIG_IDX) ); std::string fname( File::GetUserPath(D_CONFIG_IDX) );
fname += PROFILES_PATH; fname += g_plugin->profile_name; fname += '/'; fname += PROFILES_PATH; fname += m_plugin.profile_name; fname += '/';
if ( false == File::Exists( fname.c_str() ) ) if ( false == File::Exists( fname.c_str() ) )
File::CreateFullPath( fname.c_str() ); File::CreateFullPath( fname.c_str() );
fname += profile_cbox->GetValue().ToAscii(); fname += ".ini"; fname += profile_cbox->GetValue().ToAscii(); fname += ".ini";
@ -596,7 +596,7 @@ void GamepadPage::DeleteProfile( wxCommandEvent& event )
// don't need lock // don't need lock
std::string fname( File::GetUserPath(D_CONFIG_IDX) ); std::string fname( File::GetUserPath(D_CONFIG_IDX) );
fname += PROFILES_PATH; fname += g_plugin->profile_name; fname += '/'; fname += PROFILES_PATH; fname += m_plugin.profile_name; fname += '/';
fname += profile_cbox->GetValue().ToAscii(); fname += ".ini"; fname += profile_cbox->GetValue().ToAscii(); fname += ".ini";
if ( File::Exists( fname.c_str() ) ) if ( File::Exists( fname.c_str() ) )
File::Delete( fname.c_str() ); File::Delete( fname.c_str() );
@ -604,7 +604,7 @@ void GamepadPage::DeleteProfile( wxCommandEvent& event )
m_config_dialog->UpdateProfileComboBox(); m_config_dialog->UpdateProfileComboBox();
} }
void ConfigDialog::UpdateDeviceComboBox() void InputConfigDialog::UpdateDeviceComboBox()
{ {
std::vector< GamepadPage* >::iterator i = m_padpages.begin(), std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
e = m_padpages.end(); e = m_padpages.end();
@ -612,8 +612,8 @@ void ConfigDialog::UpdateDeviceComboBox()
for ( ; i != e; ++i ) for ( ; i != e; ++i )
{ {
(*i)->device_cbox->Clear(); (*i)->device_cbox->Clear();
std::vector<ControllerInterface::Device*>::const_iterator di = g_plugin->controller_interface.Devices().begin(), std::vector<ControllerInterface::Device*>::const_iterator di = m_plugin.controller_interface.Devices().begin(),
de = g_plugin->controller_interface.Devices().end(); de = m_plugin.controller_interface.Devices().end();
for ( ; di!=de; ++di ) for ( ; di!=de; ++di )
{ {
dq.FromDevice( *di ); dq.FromDevice( *di );
@ -625,12 +625,12 @@ void ConfigDialog::UpdateDeviceComboBox()
void GamepadPage::RefreshDevices( wxCommandEvent& event ) void GamepadPage::RefreshDevices( wxCommandEvent& event )
{ {
g_plugin->controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
// refresh devices // refresh devices
// TODO: remove hackery of not deinting SDL // TODO: remove hackery of not deinting SDL
g_plugin->controller_interface.DeInit(true); m_plugin.controller_interface.DeInit(true);
g_plugin->controller_interface.Init(); m_plugin.controller_interface.Init();
// update all control references // update all control references
m_config_dialog->UpdateControlReferences(); m_config_dialog->UpdateControlReferences();
@ -638,7 +638,7 @@ void GamepadPage::RefreshDevices( wxCommandEvent& event )
// update device cbox // update device cbox
m_config_dialog->UpdateDeviceComboBox(); m_config_dialog->UpdateDeviceComboBox();
g_plugin->controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
} }
ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWindow* const parent, wxWindow* const eventsink ) ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWindow* const parent, wxWindow* const eventsink )
@ -843,13 +843,14 @@ ControlGroupsSizer::ControlGroupsSizer( ControllerEmu* const controller, wxWindo
} }
GamepadPage::GamepadPage( wxWindow* parent, const unsigned int pad_num, ConfigDialog* const config_dialog ) GamepadPage::GamepadPage( wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog )
: wxNotebookPage( parent, -1 , wxDefaultPosition, wxDefaultSize ) : wxNotebookPage( parent, -1 , wxDefaultPosition, wxDefaultSize )
,controller(g_plugin->controllers[pad_num]) ,m_plugin(plugin)
,controller(plugin.controllers[pad_num])
,m_config_dialog(config_dialog) ,m_config_dialog(config_dialog)
{ {
wxBoxSizer* control_group_sizer = new ControlGroupsSizer( g_plugin->controllers[pad_num], this, this, &control_groups ); wxBoxSizer* control_group_sizer = new ControlGroupsSizer( m_plugin.controllers[pad_num], this, this, &control_groups );
wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, wxT("Profile") ); wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, wxT("Profile") );
@ -905,32 +906,26 @@ GamepadPage::GamepadPage( wxWindow* parent, const unsigned int pad_num, ConfigDi
Layout(); Layout();
}; };
ConfigDialog::~ConfigDialog()
{
m_update_timer->Stop();
}
ConfigDialog::ConfigDialog( wxWindow* const parent, Plugin& plugin, const std::string& name, const bool _is_game_running ) InputConfigDialog::InputConfigDialog( wxWindow* const parent, InputPlugin& plugin, const std::string& name, const bool _is_game_running )
: wxDialog( parent, wxID_ANY, wxString::FromAscii(name.c_str()), wxPoint(128,-1), wxDefaultSize ) : wxDialog( parent, wxID_ANY, wxString::FromAscii(name.c_str()), wxPoint(128,-1), wxDefaultSize )
, is_game_running(_is_game_running) , is_game_running(_is_game_running)
, m_plugin(plugin) , m_plugin(plugin)
{ {
g_plugin = &plugin;
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 < plugin.controllers.size(); ++i ) for ( unsigned int i = 0; i < plugin.controllers.size(); ++i )
{ {
GamepadPage* gp = new GamepadPage( m_pad_notebook, i, this ); GamepadPage* gp = new GamepadPage( m_pad_notebook, m_plugin, i, this );
m_padpages.push_back( gp ); m_padpages.push_back( gp );
m_pad_notebook->AddPage( gp, wxString::FromAscii( g_plugin->gui_name ) + wxT(' ') + wxChar('1'+i) ); m_pad_notebook->AddPage( gp, wxString::FromAscii( m_plugin.gui_name ) + wxT(' ') + wxChar('1'+i) );
} }
UpdateDeviceComboBox(); UpdateDeviceComboBox();
UpdateProfileComboBox(); UpdateProfileComboBox();
wxButton* const close_button = new wxButton( this, -1, wxT("Save")); wxButton* const close_button = new wxButton( this, -1, wxT("Save"));
_connect_macro_(close_button, ConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this); _connect_macro_(close_button, InputConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this);
_connect_macro_(close_button, ConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this); _connect_macro_(close_button, InputConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxBoxSizer* btns = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* btns = new wxBoxSizer( wxHORIZONTAL );
//btns->Add( new wxStaticText( this, -1, wxString::FromAscii(ver.c_str())), 0, wxLEFT|wxTOP, 5 ); //btns->Add( new wxStaticText( this, -1, wxString::FromAscii(ver.c_str())), 0, wxLEFT|wxTOP, 5 );
@ -950,8 +945,13 @@ ConfigDialog::ConfigDialog( wxWindow* const parent, Plugin& plugin, const std::s
// live preview update timer // live preview update timer
m_update_timer = new wxTimer( this, -1 ); m_update_timer = new wxTimer( this, -1 );
Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( ConfigDialog::UpdateBitmaps ), (wxObject*)0, this ); Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( InputConfigDialog::UpdateBitmaps ), (wxObject*)0, this );
m_update_timer->Start( PREVIEW_UPDATE_TIME, wxTIMER_CONTINUOUS); m_update_timer->Start( PREVIEW_UPDATE_TIME, wxTIMER_CONTINUOUS);
} }
InputConfigDialog::~InputConfigDialog()
{
m_update_timer->Stop();
}

View File

@ -121,7 +121,7 @@ private:
class ControlDialog : public wxDialog class ControlDialog : public wxDialog
{ {
public: public:
ControlDialog( wxWindow* const parent, ControllerInterface::ControlReference* const ref, const std::vector<ControllerInterface::Device*>& devs ); ControlDialog( wxWindow* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref, const std::vector<ControllerInterface::Device*>& devs );
void SelectControl( wxCommandEvent& event ); void SelectControl( wxCommandEvent& event );
void DetectControl( wxCommandEvent& event ); void DetectControl( wxCommandEvent& event );
@ -130,6 +130,7 @@ public:
void SetDevice( wxCommandEvent& event ); void SetDevice( wxCommandEvent& event );
ControllerInterface::ControlReference* const control_reference; ControllerInterface::ControlReference* const control_reference;
InputPlugin& m_plugin;
wxComboBox* device_cbox; wxComboBox* device_cbox;
ControlChooser* control_chooser; ControlChooser* control_chooser;
}; };
@ -172,14 +173,14 @@ public:
}; };
class ConfigDialog; class InputConfigDialog;
class GamepadPage : public wxNotebookPage class GamepadPage : public wxNotebookPage
{ {
friend class ConfigDialog; friend class InputConfigDialog;
public: public:
GamepadPage( wxWindow* parent, const unsigned int pad_num, ConfigDialog* const config_dialog ); GamepadPage( wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog );
void UpdateGUI(); void UpdateGUI();
@ -214,15 +215,16 @@ protected:
private: private:
ControlDialog* m_control_dialog; ControlDialog* m_control_dialog;
ConfigDialog* const m_config_dialog; InputConfigDialog* const m_config_dialog;
InputPlugin &m_plugin;
}; };
class ConfigDialog : public wxDialog class InputConfigDialog : public wxDialog
{ {
public: public:
ConfigDialog( wxWindow* const parent, Plugin& plugin, const std::string& name, const bool _is_game_running ); InputConfigDialog( wxWindow* const parent, InputPlugin& plugin, const std::string& name, const bool _is_game_running );
~ConfigDialog(); ~InputConfigDialog();
void ClickSave( wxCommandEvent& event ); void ClickSave( wxCommandEvent& event );
@ -238,7 +240,7 @@ private:
wxNotebook* m_pad_notebook; wxNotebook* m_pad_notebook;
std::vector<GamepadPage*> m_padpages; std::vector<GamepadPage*> m_padpages;
Plugin& m_plugin; InputPlugin& m_plugin;
wxTimer* m_update_timer; wxTimer* m_update_timer;
}; };

View File

@ -17,7 +17,7 @@
#include "ConfigDiag.h" #include "ConfigDiag.h"
void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event)) void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
{ {
GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage( m_pad_notebook->GetSelection() ); GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage( m_pad_notebook->GetSelection() );

View File

@ -44,7 +44,7 @@
#endif #endif
// plugin globals // plugin globals
static Plugin g_plugin( "GCPadNew", "Pad", "GCPad" ); static InputPlugin g_plugin( "GCPadNew", "Pad", "GCPad" );
SPADInitialize *g_PADInitialize = NULL; SPADInitialize *g_PADInitialize = NULL;
#ifdef _WIN32 #ifdef _WIN32
@ -276,7 +276,7 @@ void DllConfig(HWND _hParent)
// copied from GCPad // copied from GCPad
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
wxWindow *frame = GetParentedWxWindow(_hParent); wxWindow *frame = GetParentedWxWindow(_hParent);
ConfigDialog* m_ConfigFrame = new ConfigDialog( frame, g_plugin, PLUGIN_FULL_NAME, was_init ); InputConfigDialog* m_ConfigFrame = new InputConfigDialog( frame, g_plugin, PLUGIN_FULL_NAME, was_init );
#ifdef _WIN32 #ifdef _WIN32
frame->Disable(); frame->Disable();

View File

@ -32,7 +32,7 @@
#endif #endif
// plugin globals // plugin globals
static Plugin g_plugin( "WiimoteNew", "Wiimote", "Wiimote" ); static InputPlugin g_plugin( "WiimoteNew", "Wiimote", "Wiimote" );
SWiimoteInitialize g_WiimoteInitialize; SWiimoteInitialize g_WiimoteInitialize;
#ifdef _WIN32 #ifdef _WIN32
@ -257,7 +257,7 @@ void DllConfig(HWND _hParent)
// copied from GCPad // copied from GCPad
wxWindow *frame = GetParentedWxWindow(_hParent); wxWindow *frame = GetParentedWxWindow(_hParent);
ConfigDialog* m_ConfigFrame = new ConfigDialog( frame, g_plugin, PLUGIN_FULL_NAME, was_init ); InputConfigDialog* m_ConfigFrame = new InputConfigDialog( frame, g_plugin, PLUGIN_FULL_NAME, was_init );
#ifdef _WIN32 #ifdef _WIN32
frame->Disable(); frame->Disable();