From b39f0240cb1f6a770f2db86e721bcc7ff18982d3 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 24 Sep 2008 22:20:37 +0000 Subject: [PATCH] padsimple config should get keycodes in windows now. replaced wxT("") with wxEmptyString. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@676 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_PadSimple/Src/GUI/ConfigDlg.cpp | 43 ++++++++++++----- .../Plugin_PadSimple/Src/GUI/ConfigDlg.h | 2 +- .../Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp | 46 +++++++++---------- 3 files changed, 56 insertions(+), 35 deletions(-) diff --git a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp index f53023af4e..a2d7e0a944 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp @@ -18,7 +18,12 @@ #include "ConfigDlg.h" #include "../PadSimple.h" -//#include "../DirectInputBase.h" + +#ifdef _WIN32 +#include "../DirectInputBase.h" + +DInput m_dinput; +#endif BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) EVT_CLOSE(ConfigDialog::OnClose) @@ -55,6 +60,9 @@ END_EVENT_TABLE() ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style) : wxDialog(parent, id, title, position, size, style) { +#ifdef _WIN32 + m_dinput.Init((HWND)parent); +#endif clickedButton = NULL; CreateGUIControls(); } @@ -70,7 +78,7 @@ inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer, hButton->Add(new wxStaticText(pan, 0, wxString::FromAscii(name), wxDefaultPosition, wxDefaultSize), 0, wxALIGN_CENTER_VERTICAL|wxALL); - *button = new wxButton(pan, ctl, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxBU_LEFT); + *button = new wxButton(pan, ctl, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); hButton->Add(*button, 0, wxEXPAND|wxALL); @@ -193,6 +201,9 @@ void ConfigDialog::CreateGUIControls() void ConfigDialog::OnClose(wxCloseEvent& event) { +#ifdef _WIN32 + m_dinput.Free(); +#endif EndModal(0); } void ConfigDialog::OnKeyDown(wxKeyEvent& event) @@ -200,7 +211,19 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event) if(clickedButton != NULL) { int page = m_Notebook->GetSelection(); + +#ifdef _WIN32 + m_dinput.Read(); + for(int i = 0; i < 255; i++) + { + if(m_dinput.diks[i]) + { + pad[page].keyForControl[clickedButton->GetId()] = i; + } + } +#else pad[page].keyForControl[clickedButton->GetId()] = event.GetKeyCode(); +#endif clickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode())); clickedButton->Disconnect(); } @@ -233,20 +256,18 @@ void ConfigDialog::RumbleCheck(wxCommandEvent& event) void ConfigDialog::OnButtonClick(wxCommandEvent& event) { - if(clickedButton) { - clickedButton->SetLabel(oldLabel); - } + if(clickedButton) + { + clickedButton->SetLabel(oldLabel); + } clickedButton = (wxButton *)event.GetEventObject(); oldLabel = clickedButton->GetLabel(); clickedButton->SetLabel(wxString::FromAscii("Press Key")); - - clickedButton->Connect(wxID_ANY, wxEVT_KEY_DOWN, - wxKeyEventHandler(ConfigDialog::OnKeyDown), - (wxObject*)NULL, this); + clickedButton->Connect(wxID_ANY, wxEVT_KEY_DOWN, + wxKeyEventHandler(ConfigDialog::OnKeyDown), + (wxObject*)NULL, this); //clickedButton->SetLabel(wxString::Format(wxT("%i"), keyPress)); - //clickedButton->SetLabel(wxString::Format(wxT("%s %i"), oldLabel, keyPress)); - } diff --git a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h index 4f057db916..7b9264b0fc 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h +++ b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h @@ -53,7 +53,7 @@ class ConfigDialog : public wxDialog wxBoxSizer *sDeviceBottom[4]; wxGridBagSizer* sPage[4]; wxStaticBoxSizer *sButtons[4]; - wxBoxSizer *hButtons[4][2]; + wxBoxSizer *hButtons[4][2]; wxStaticBoxSizer *sTriggerL[4]; wxStaticBoxSizer *sTriggerR[4]; wxStaticBoxSizer *sStick[4]; diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp index ab3b8d8e8d..5317f32116 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp @@ -161,18 +161,18 @@ void ConfigBox::CreateGUIControls() #ifdef _WIN32 m_Joyattach[i] = new wxCheckBox(m_Controller[i], IDC_JOYATTACH, wxT("Controller attached"), wxPoint(495, 26), wxSize(109, 25), 0, wxDefaultValidator, wxT("Controller attached")); - m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, wxT(""), wxPoint(12, 29), wxSize(476, 21), arrayStringFor_Joyname, 0, wxDefaultValidator, wxT("m_Joyname")); + m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, wxEmptyString, wxPoint(12, 29), wxSize(476, 21), arrayStringFor_Joyname, 0, wxDefaultValidator, wxT("m_Joyname")); m_gExtrasettings[i] = new wxStaticBox(m_Controller[i], IDG_EXTRASETTINGS, wxT("Extra settings:"), wxPoint(104, 385), wxSize(155, 69)); - m_Deadzone[i] = new wxComboBox(m_Controller[i], IDC_DEADZONE, wxT(""), wxPoint(167, 400), wxSize(59, 21), arrayStringFor_Deadzone, 0, wxDefaultValidator, wxT("m_Deadzone")); + m_Deadzone[i] = new wxComboBox(m_Controller[i], IDC_DEADZONE, wxEmptyString, wxPoint(167, 400), wxSize(59, 21), arrayStringFor_Deadzone, 0, wxDefaultValidator, wxT("m_Deadzone")); m_gControllertype[i] = new wxStaticBox(m_Controller[i], IDG_CONTROLLERTYPE, wxT("Controller type:"), wxPoint(359, 383), wxSize(143, 44)); - m_Controltype[i] = new wxComboBox(m_Controller[i], IDC_CONTROLTYPE, wxT(""), wxPoint(366, 401), wxSize(131, 21), arrayStringFor_Controltype, 0, wxDefaultValidator, wxT("m_Controltype")); + m_Controltype[i] = new wxComboBox(m_Controller[i], IDC_CONTROLTYPE, wxEmptyString, wxPoint(366, 401), wxSize(131, 21), arrayStringFor_Controltype, 0, wxDefaultValidator, wxT("m_Controltype")); #else m_Joyattach[i] = new wxCheckBox(m_Controller[i], IDC_JOYATTACH, wxT("Controller attached"), wxPoint(470, 26), wxSize(140, 25), 0, wxDefaultValidator, wxT("Controller attached")); - m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, wxT(""), wxPoint(10, 25), wxSize(450, 25), arrayStringFor_Joyname, 0, wxDefaultValidator, wxT("m_Joyname")); + m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, wxEmptyString, wxPoint(10, 25), wxSize(450, 25), arrayStringFor_Joyname, 0, wxDefaultValidator, wxT("m_Joyname")); m_gExtrasettings[i] = new wxStaticBox(m_Controller[i], IDG_EXTRASETTINGS, wxT("Extra settings:"), wxPoint(100, 385), wxSize(155, 65)); - m_Deadzone[i] = new wxComboBox(m_Controller[i], IDC_DEADZONE, wxT(""), wxPoint(167, 398), wxSize(80, 25), arrayStringFor_Deadzone, 0, wxDefaultValidator, wxT("m_Deadzone")); + m_Deadzone[i] = new wxComboBox(m_Controller[i], IDC_DEADZONE, wxEmptyString, wxPoint(167, 398), wxSize(80, 25), arrayStringFor_Deadzone, 0, wxDefaultValidator, wxT("m_Deadzone")); m_gControllertype[i] = new wxStaticBox(m_Controller[i], IDG_CONTROLLERTYPE, wxT("Controller type:"), wxPoint(359, 383), wxSize(160, 44)); - m_Controltype[i] = new wxComboBox(m_Controller[i], IDC_CONTROLTYPE, wxT(""), wxPoint(364, 396), wxSize(150, 25), arrayStringFor_Controltype, 0, wxDefaultValidator, wxT("m_Controltype")); + m_Controltype[i] = new wxComboBox(m_Controller[i], IDC_CONTROLTYPE, wxEmptyString, wxPoint(364, 396), wxSize(150, 25), arrayStringFor_Controltype, 0, wxDefaultValidator, wxT("m_Controltype")); #endif // GUI left side buttons @@ -190,13 +190,13 @@ void ConfigBox::CreateGUIControls() m_JoyDpadLeft[i]->Enable(false); m_JoyDpadRight[i] = new wxTextCtrl(m_Controller[i], ID_DPAD_RIGHT, wxT("0"), wxPoint(6, 406), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0")); m_JoyDpadRight[i]->Enable(false); - m_bJoyShoulderL[i] = new wxButton(m_Controller[i], IDB_SHOULDER_L, wxT(""), wxPoint(70, 82), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyAnalogMainX[i] = new wxButton(m_Controller[i], IDB_ANALOG_MAIN_X, wxT(""), wxPoint(70, 220), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyAnalogMainY[i] = new wxButton(m_Controller[i], IDB_ANALOG_MAIN_Y, wxT(""), wxPoint(70, 257), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyDpadUp[i] = new wxButton(m_Controller[i], IDB_DPAD_UP, wxT(""), wxPoint(70, 298), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyDpadDown[i] = new wxButton(m_Controller[i], IDB_DPAD_DOWN, wxT(""), wxPoint(70, 335), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyDpadLeft[i] = new wxButton(m_Controller[i], IDB_DPAD_LEFT, wxT(""), wxPoint(70, 371), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyDpadRight[i] = new wxButton(m_Controller[i], IDB_DPAD_RIGHT, wxT(""), wxPoint(70, 408), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); + m_bJoyShoulderL[i] = new wxButton(m_Controller[i], IDB_SHOULDER_L, wxEmptyString, wxPoint(70, 82), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyAnalogMainX[i] = new wxButton(m_Controller[i], IDB_ANALOG_MAIN_X, wxEmptyString, wxPoint(70, 220), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyAnalogMainY[i] = new wxButton(m_Controller[i], IDB_ANALOG_MAIN_Y, wxEmptyString, wxPoint(70, 257), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyDpadUp[i] = new wxButton(m_Controller[i], IDB_DPAD_UP, wxEmptyString, wxPoint(70, 298), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyDpadDown[i] = new wxButton(m_Controller[i], IDB_DPAD_DOWN, wxEmptyString, wxPoint(70, 335), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyDpadLeft[i] = new wxButton(m_Controller[i], IDB_DPAD_LEFT, wxEmptyString, wxPoint(70, 371), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyDpadRight[i] = new wxButton(m_Controller[i], IDB_DPAD_RIGHT, wxEmptyString, wxPoint(70, 408), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); m_textMainX[i] = new wxStaticText(m_Controller[i], IDT_ANALOG_MAIN_X, wxT("X-axis"), wxPoint(6, 204), wxDefaultSize, 0, wxT("X-axis")); m_textMainY[i] = new wxStaticText(m_Controller[i], IDT_ANALOG_MAIN_Y, wxT("Y-axis"), wxPoint(6, 241), wxDefaultSize, 0, wxT("Y-axis")); @@ -222,14 +222,14 @@ void ConfigBox::CreateGUIControls() m_JoyAnalogSubX[i]->Enable(false); m_JoyAnalogSubY[i] = new wxTextCtrl(m_Controller[i], ID_ANALOG_SUB_Y, wxT("0"), wxPoint(552, 388), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0")); m_JoyAnalogSubY[i]->Enable(false); - m_bJoyShoulderR[i] = new wxButton(m_Controller[i], IDB_SHOULDER_R, wxT(""), wxPoint(526, 108), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyButtonA[i] = new wxButton(m_Controller[i], IDB_BUTTON_A, wxT(""), wxPoint(526, 282), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyButtonB[i] = new wxButton(m_Controller[i], IDB_BUTTON_B, wxT(""), wxPoint(526, 82), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyButtonX[i] = new wxButton(m_Controller[i], IDB_BUTTON_X, wxT(""), wxPoint(526, 244), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyButtonY[i] = new wxButton(m_Controller[i], IDB_BUTTON_Y, wxT(""), wxPoint(526, 173), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyButtonZ[i] = new wxButton(m_Controller[i], IDB_BUTTON_Z, wxT(""), wxPoint(526, 147), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyAnalogSubX[i] = new wxButton(m_Controller[i], IDB_ANALOG_SUB_X, wxT(""), wxPoint(526, 353), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyAnalogSubY[i] = new wxButton(m_Controller[i], IDB_ANALOG_SUB_Y, wxT(""), wxPoint(526, 390), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); + m_bJoyShoulderR[i] = new wxButton(m_Controller[i], IDB_SHOULDER_R, wxEmptyString, wxPoint(526, 108), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyButtonA[i] = new wxButton(m_Controller[i], IDB_BUTTON_A, wxEmptyString, wxPoint(526, 282), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyButtonB[i] = new wxButton(m_Controller[i], IDB_BUTTON_B, wxEmptyString, wxPoint(526, 82), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyButtonX[i] = new wxButton(m_Controller[i], IDB_BUTTON_X, wxEmptyString, wxPoint(526, 244), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyButtonY[i] = new wxButton(m_Controller[i], IDB_BUTTON_Y, wxEmptyString, wxPoint(526, 173), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyButtonZ[i] = new wxButton(m_Controller[i], IDB_BUTTON_Z, wxEmptyString, wxPoint(526, 147), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyAnalogSubX[i] = new wxButton(m_Controller[i], IDB_ANALOG_SUB_X, wxEmptyString, wxPoint(526, 353), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyAnalogSubY[i] = new wxButton(m_Controller[i], IDB_ANALOG_SUB_Y, wxEmptyString, wxPoint(526, 390), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); m_textSubX[i] = new wxStaticText(m_Controller[i], IDT_ANALOG_SUB_X, wxT("X-axis"), wxPoint(552, 336), wxDefaultSize, 0, wxT("X-axis")); m_textSubY[i] = new wxStaticText(m_Controller[i], IDT_ANALOG_SUB_Y, wxT("Y-axis"), wxPoint(552, 373), wxDefaultSize, 0, wxT("Y-axis")); @@ -239,8 +239,8 @@ void ConfigBox::CreateGUIControls() m_JoyButtonStart[i]->Enable(false); m_JoyButtonHalfpress[i] = new wxTextCtrl(m_Controller[i], ID_BUTTONHALFPRESS, wxT("0"), wxPoint(167, 424), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0")); m_JoyButtonHalfpress[i]->Enable(false); - m_bJoyButtonStart[i] = new wxButton(m_Controller[i], IDB_BUTTONSTART, wxT(""), wxPoint(297, 385), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); - m_bJoyButtonHalfpress[i] = new wxButton(m_Controller[i], IDB_BUTTONHALFPRESS, wxT(""), wxPoint(231, 426), wxSize(21, 14), 0, wxDefaultValidator, wxT("")); + m_bJoyButtonStart[i] = new wxButton(m_Controller[i], IDB_BUTTONSTART, wxEmptyString, wxPoint(297, 385), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); + m_bJoyButtonHalfpress[i] = new wxButton(m_Controller[i], IDB_BUTTONHALFPRESS, wxEmptyString, wxPoint(231, 426), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString); #ifdef _WIN32 m_textDeadzone[i] = new wxStaticText(m_Controller[i], IDT_DEADZONE, wxT("Deadzone"), wxPoint(116, 404), wxDefaultSize, 0, wxT("Deadzone"));