GCPad/WiimoteNew: Hopefully fixed a problem where devices with extended ascii characters in their names didn't work.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5718 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak 2010-06-16 02:57:50 +00:00
parent b0dff28539
commit cefc0b2c6f
5 changed files with 35 additions and 41 deletions

View File

@ -956,10 +956,10 @@ void CFrame::OnPluginPAD(wxCommandEvent& WXUNUSED (event))
GCPad_Init(GetHandle()); GCPad_Init(GetHandle());
#endif #endif
} }
InputConfigDialog* m_ConfigFrame = new InputConfigDialog(this, *pad_plugin, "GCPadNew", was_init ); InputConfigDialog* m_ConfigFrame = new InputConfigDialog(this, *pad_plugin, "Dolphin GCPad Configuration");
m_ConfigFrame->ShowModal(); m_ConfigFrame->ShowModal();
m_ConfigFrame->Destroy(); m_ConfigFrame->Destroy();
if ( !was_init ) // if game is running if (!was_init) // if game isn't running
{ {
GCPad_Deinit(); GCPad_Deinit();
} }

View File

@ -125,13 +125,13 @@ LCleanup:
std::string TStringToString( const std::basic_string<TCHAR>& in ) std::string TStringToString( const std::basic_string<TCHAR>& in )
{ {
const int size = WideCharToMultiByte( CP_UTF8, 0, in.data(), int(in.length()), NULL, 0, NULL, NULL ); const int size = WideCharToMultiByte(CP_ACP, 0, in.data(), int(in.length()), NULL, 0, NULL, NULL);
if ( 0 == size ) if ( 0 == size )
return ""; return "";
char* const data = new char[size]; char* const data = new char[size];
WideCharToMultiByte( CP_UTF8, 0, in.data(), int(in.length()), data, size, NULL, NULL ); WideCharToMultiByte(CP_ACP, 0, in.data(), int(in.length()), data, size, NULL, NULL);
const std::string out( data, size ); const std::string out( data, size );
delete[] data; delete[] data;
return out; return out;

View File

@ -17,7 +17,9 @@
#include "ConfigDiag.h" #include "ConfigDiag.h"
#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)
#define WXSTR_FROM_STR(s) (wxString::FromAscii((s).c_str()))
#define STR_FROM_WXSTR(w) (std::string((w).To8BitData()))
void GamepadPage::ConfigExtension( wxCommandEvent& event ) void GamepadPage::ConfigExtension( wxCommandEvent& event )
{ {
@ -100,26 +102,17 @@ void PadSettingChoice::UpdateValue()
value = float(GetValue()) / 100; value = float(GetValue()) / 100;
} }
ControlDialog::ControlDialog( wxWindow* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref, const std::vector<ControllerInterface::Device*>& devs ) ControlDialog::ControlDialog(GamepadPage* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref)
:wxDialog( parent, -1, wxT("Configure Control"), wxDefaultPosition ) :wxDialog( parent, -1, wxT("Configure Control"), wxDefaultPosition )
,control_reference(ref) ,control_reference(ref)
,m_plugin(plugin) ,m_plugin(plugin)
{ {
// GetStrings() sounds slow :/
device_cbox = new wxComboBox( this, -1, wxString::FromAscii( ref->device_qualifier.ToString().c_str() ), wxDefaultPosition, wxSize(256,-1), wxArrayString(), wxTE_PROCESS_ENTER ); device_cbox = new wxComboBox( this, -1, wxString::FromAscii( ref->device_qualifier.ToString().c_str() ), wxDefaultPosition, wxSize(256,-1), parent->device_cbox->GetStrings(), wxTE_PROCESS_ENTER );
_connect_macro_( device_cbox, ControlDialog::SetDevice, wxEVT_COMMAND_COMBOBOX_SELECTED, this ); _connect_macro_( device_cbox, ControlDialog::SetDevice, wxEVT_COMMAND_COMBOBOX_SELECTED, this );
_connect_macro_( device_cbox, ControlDialog::SetDevice, wxEVT_COMMAND_TEXT_ENTER, this ); _connect_macro_( device_cbox, ControlDialog::SetDevice, wxEVT_COMMAND_TEXT_ENTER, this );
std::vector< ControllerInterface::Device* >::const_iterator i = devs.begin(),
e = devs.end();
ControllerInterface::DeviceQualifier dq;
for ( ; i!=e; ++i )
{
dq.FromDevice( *i );
device_cbox->Append( wxString::FromAscii( dq.ToString().c_str() ) );
}
control_chooser = new ControlChooser( this, ref, parent ); control_chooser = new ControlChooser( this, ref, parent );
wxStaticBoxSizer* const d_szr = new wxStaticBoxSizer( wxVERTICAL, this, wxT("Device") ); wxStaticBoxSizer* const d_szr = new wxStaticBoxSizer( wxVERTICAL, this, wxT("Device") );
@ -252,7 +245,7 @@ void ControlChooser::UpdateGUI()
std::ostringstream ss; std::ostringstream ss;
ss << "Bound Controls: "; ss << "Bound Controls: ";
if ( bound ) ss << bound; else ss << "None"; if ( bound ) ss << bound; else ss << "None";
m_bound_label->SetLabel( wxString::FromAscii(ss.str().c_str()) ); m_bound_label->SetLabel(WXSTR_FROM_STR(ss.str()));
}; };
void GamepadPage::UpdateGUI() void GamepadPage::UpdateGUI()
@ -267,7 +260,7 @@ void GamepadPage::UpdateGUI()
std::vector<ControlButton*>::const_iterator i = (*g)->control_buttons.begin() std::vector<ControlButton*>::const_iterator i = (*g)->control_buttons.begin()
, e = (*g)->control_buttons.end(); , e = (*g)->control_buttons.end();
for ( ; i!=e; ++i ) for ( ; i!=e; ++i )
(*i)->SetLabel( wxString::FromAscii( (*i)->control_reference->control_qualifier.name.c_str() ) ); (*i)->SetLabel(WXSTR_FROM_STR((*i)->control_reference->control_qualifier.name));
// cboxes // cboxes
std::vector<PadSetting*>::const_iterator si = (*g)->options.begin() std::vector<PadSetting*>::const_iterator si = (*g)->options.begin()
@ -297,7 +290,7 @@ void GamepadPage::ClearAll( wxCommandEvent& event )
void ControlDialog::SetControl( wxCommandEvent& event ) void ControlDialog::SetControl( wxCommandEvent& event )
{ {
control_reference->control_qualifier.name = control_reference->control_qualifier.name =
std::string( control_chooser->textctrl->GetValue().ToAscii() ); STR_FROM_WXSTR(control_chooser->textctrl->GetValue());
m_plugin.controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
control_reference->UpdateControls(); control_reference->UpdateControls();
@ -308,30 +301,30 @@ void ControlDialog::SetControl( wxCommandEvent& event )
void GamepadPage::SetDevice( wxCommandEvent& event ) void GamepadPage::SetDevice( wxCommandEvent& event )
{ {
controller->default_device.FromString( std::string( device_cbox->GetValue().ToAscii() ) ); controller->default_device.FromString(STR_FROM_WXSTR(device_cbox->GetValue()));
// show user what it was validated as // show user what it was validated as
device_cbox->SetValue( wxString::FromAscii( controller->default_device.ToString().c_str() ) ); device_cbox->SetValue(WXSTR_FROM_STR(controller->default_device.ToString()));
// this will set all the controls to this default device // this will set all the controls to this default device
controller->UpdateDefaultDevice(); controller->UpdateDefaultDevice();
// update references // update references
m_plugin.controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
controller->UpdateReferences( m_plugin.controller_interface ); controller->UpdateReferences(m_plugin.controller_interface);
m_plugin.controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
} }
void ControlDialog::SetDevice( wxCommandEvent& event ) void ControlDialog::SetDevice( wxCommandEvent& event )
{ {
control_reference->device_qualifier.FromString( std::string( device_cbox->GetValue().ToAscii() ) ); control_reference->device_qualifier.FromString(STR_FROM_WXSTR(device_cbox->GetValue()));
// show user what it was validated as // show user what it was validated as
device_cbox->SetValue( wxString::FromAscii( control_reference->device_qualifier.ToString().c_str() ) ); device_cbox->SetValue(WXSTR_FROM_STR(control_reference->device_qualifier.ToString()));
// update references // update references
m_plugin.controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
m_plugin.controller_interface.UpdateReference( control_reference ); m_plugin.controller_interface.UpdateReference(control_reference);
m_plugin.controls_crit.Leave(); // leave m_plugin.controls_crit.Leave(); // leave
// update gui // update gui
@ -374,7 +367,7 @@ void GamepadPage::AdjustControlOption( wxCommandEvent& event )
void GamepadPage::ConfigControl( wxCommandEvent& event ) void GamepadPage::ConfigControl( wxCommandEvent& event )
{ {
m_control_dialog = new ControlDialog( this, m_plugin, ((ControlButton*)event.GetEventObject())->control_reference, m_plugin.controller_interface.Devices() ); m_control_dialog = new ControlDialog(this, m_plugin, ((ControlButton*)event.GetEventObject())->control_reference);
m_control_dialog->ShowModal(); m_control_dialog->ShowModal();
m_control_dialog->Destroy(); m_control_dialog->Destroy();
@ -434,7 +427,7 @@ void GamepadPage::DetectControl( wxCommandEvent& event )
btn->control_reference->Detect( DETECT_WAIT_TIME ); btn->control_reference->Detect( DETECT_WAIT_TIME );
m_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(WXSTR_FROM_STR(btn->control_reference->control_qualifier.name));
} }
void ControlDialog::SelectControl( wxCommandEvent& event ) void ControlDialog::SelectControl( wxCommandEvent& event )
@ -606,20 +599,22 @@ void GamepadPage::DeleteProfile( wxCommandEvent& event )
void InputConfigDialog::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();
ControllerInterface::DeviceQualifier dq; ControllerInterface::DeviceQualifier dq;
for ( ; i != e; ++i ) for ( ; i != e; ++i )
{ {
(*i)->device_cbox->Clear(); (*i)->device_cbox->Clear();
std::vector<ControllerInterface::Device*>::const_iterator di = m_plugin.controller_interface.Devices().begin(), std::vector<ControllerInterface::Device*>::const_iterator
di = m_plugin.controller_interface.Devices().begin(),
de = m_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);
(*i)->device_cbox->Append( wxString::FromAscii( dq.ToString().c_str() ) ); (*i)->device_cbox->Append(WXSTR_FROM_STR(dq.ToString()));
} }
(*i)->device_cbox->SetValue( wxString::FromAscii( (*i)->controller->default_device.ToString().c_str() ) ); (*i)->device_cbox->SetValue(WXSTR_FROM_STR((*i)->controller->default_device.ToString()));
} }
} }
@ -907,9 +902,8 @@ GamepadPage::GamepadPage( wxWindow* parent, InputPlugin& plugin, const unsigned
}; };
InputConfigDialog::InputConfigDialog( wxWindow* const parent, InputPlugin& plugin, const std::string& name, const bool _is_game_running ) InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputPlugin& plugin, const std::string& name)
: 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)
, m_plugin(plugin) , m_plugin(plugin)
{ {
m_pad_notebook = new wxNotebook( this, -1, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT ); m_pad_notebook = new wxNotebook( this, -1, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT );

View File

@ -118,10 +118,12 @@ private:
ControlChooser* const m_control_chooser; ControlChooser* const m_control_chooser;
}; };
class GamepadPage;
class ControlDialog : public wxDialog class ControlDialog : public wxDialog
{ {
public: public:
ControlDialog( wxWindow* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref, const std::vector<ControllerInterface::Device*>& devs ); ControlDialog(GamepadPage* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref);
void SelectControl( wxCommandEvent& event ); void SelectControl( wxCommandEvent& event );
void DetectControl( wxCommandEvent& event ); void DetectControl( wxCommandEvent& event );
@ -223,7 +225,7 @@ class InputConfigDialog : public wxDialog
{ {
public: public:
InputConfigDialog( wxWindow* const parent, InputPlugin& plugin, const std::string& name, const bool _is_game_running ); InputConfigDialog(wxWindow* const parent, InputPlugin& plugin, const std::string& name);
bool Destroy(); bool Destroy();
void ClickSave( wxCommandEvent& event ); void ClickSave( wxCommandEvent& event );
@ -234,8 +236,6 @@ public:
void UpdateControlReferences(); void UpdateControlReferences();
void UpdateBitmaps(wxTimerEvent&); void UpdateBitmaps(wxTimerEvent&);
const bool is_game_running;
private: private:
wxNotebook* m_pad_notebook; wxNotebook* m_pad_notebook;

View File

@ -257,7 +257,7 @@ void DllConfig(HWND _hParent)
// copied from GCPad // copied from GCPad
wxWindow *frame = GetParentedWxWindow(_hParent); wxWindow *frame = GetParentedWxWindow(_hParent);
InputConfigDialog* m_ConfigFrame = new InputConfigDialog( frame, g_plugin, PLUGIN_FULL_NAME, was_init ); InputConfigDialog* m_ConfigFrame = new InputConfigDialog(frame, g_plugin, PLUGIN_FULL_NAME);
#ifdef _WIN32 #ifdef _WIN32
frame->Disable(); frame->Disable();