From 0b0e2a3f345115d298fcc836862c4431da8bf63f Mon Sep 17 00:00:00 2001 From: kust2708 Date: Sun, 29 Nov 2015 15:42:42 +0100 Subject: [PATCH] Onepad : Fix compilation with wx2.8 Feedback fix, when more than two gamepad are used simultaneously. Change all 'this->' by 'm_' fix on the hack sixaxis pressure Modification of the size (1000x760 -> 1000x730) --- plugins/onepad/CMakeLists.txt | 14 +- plugins/onepad/Linux/GamepadConfiguration.cpp | 162 ++++---- plugins/onepad/Linux/GamepadConfiguration.h | 16 +- .../onepad/Linux/JoystickConfiguration.cpp | 173 ++++---- plugins/onepad/Linux/JoystickConfiguration.h | 16 +- plugins/onepad/Linux/dialog.cpp | 373 ++++++++++-------- plugins/onepad/Linux/dialog.h | 20 +- 7 files changed, 414 insertions(+), 360 deletions(-) diff --git a/plugins/onepad/CMakeLists.txt b/plugins/onepad/CMakeLists.txt index c4d6156361..c7e40beafe 100644 --- a/plugins/onepad/CMakeLists.txt +++ b/plugins/onepad/CMakeLists.txt @@ -65,16 +65,16 @@ set(onepadLinuxSources ${linux_sources}/ini.cpp ${linux_sources}/dialog.cpp ${linux_sources}/linux.cpp - ${linux_sources}/opPanel.cpp - ${linux_sources}/GamepadConfiguration.cpp - ${linux_headers}/JoystickConfiguration.cpp) + ${linux_sources}/opPanel.cpp + ${linux_sources}/GamepadConfiguration.cpp + ${linux_headers}/JoystickConfiguration.cpp) # onepad Linux headers set(onepadLinuxHeaders ${linux_headers}/linux.h - ${linux_headers}/opPanel.h - ${linux_headers}/GamepadConfiguration.h - ${linux_headers}/JoystickConfiguration.h) + ${linux_headers}/opPanel.h + ${linux_headers}/GamepadConfiguration.h + ${linux_headers}/JoystickConfiguration.h) # onepad Windows sources set(onepadWindowsSources @@ -107,7 +107,7 @@ set(onepadFinalSources ${onepadHeaders} ${onepadLinuxSources} ${onepadLinuxHeaders} - ${onepadGuiResources} + ${onepadGuiResources} ) include_directories( diff --git a/plugins/onepad/Linux/GamepadConfiguration.cpp b/plugins/onepad/Linux/GamepadConfiguration.cpp index 81db299482..473fe6e189 100644 --- a/plugins/onepad/Linux/GamepadConfiguration.cpp +++ b/plugins/onepad/Linux/GamepadConfiguration.cpp @@ -25,7 +25,7 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) : wxFrame( wxID_ANY, // ID _T("Gamepad configuration"), // Title wxDefaultPosition, // Position - wxSize(400, 200), // Width + Lenght + wxSize(400, 230), // Width + Lenght // Style wxSYSTEM_MENU | wxCAPTION | @@ -34,45 +34,45 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) : wxFrame( ) { - this->pad_id = pad; - this->pan_gamepad_config = new wxPanel( + m_pad_id = pad; + m_pan_gamepad_config = new wxPanel( this, // Parent wxID_ANY, // ID wxDefaultPosition, // Prosition wxSize(300, 200) // Size ); - this->cb_rumble = new wxCheckBox( - this->pan_gamepad_config, // Parent + m_cb_rumble = new wxCheckBox( + m_pan_gamepad_config, // Parent wxID_ANY, // ID _T("&Enable rumble"), // Label wxPoint(20, 20) // Position ); - this->cb_hack_sixaxis_usb = new wxCheckBox( - this->pan_gamepad_config, // Parent + m_cb_hack_sixaxis_usb = new wxCheckBox( + m_pan_gamepad_config, // Parent wxID_ANY, // ID _T("&Hack: Sixaxis/DS3 plugged in USB"), // Label wxPoint(20, 40) // Position ); - this->cb_hack_sixaxis_pressure = new wxCheckBox( - this->pan_gamepad_config, // Parent + m_cb_hack_sixaxis_pressure = new wxCheckBox( + m_pan_gamepad_config, // Parent wxID_ANY, // ID _T("&Hack: Sixaxis/DS3 pressure"), // Label wxPoint(20, 60) // Position ); wxString txt_rumble = wxT("Rumble intensity"); - this->lbl_rumble_intensity = new wxStaticText( - this->pan_gamepad_config, // Parent + m_lbl_rumble_intensity = new wxStaticText( + m_pan_gamepad_config, // Parent wxID_ANY, // ID txt_rumble, // Text which must be displayed wxPoint(20, 90), // Position wxDefaultSize // Size ); - this->sl_rumble_intensity = new wxSlider( - this->pan_gamepad_config, // Parent + m_sl_rumble_intensity = new wxSlider( + m_pan_gamepad_config, // Parent wxID_ANY, // ID 0, // value 0, // min value 0x0000 @@ -82,16 +82,16 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) : wxFrame( ); wxString txt_joystick = wxT("Joystick sensibility"); - this->lbl_rumble_intensity = new wxStaticText( - this->pan_gamepad_config, // Parent + m_lbl_rumble_intensity = new wxStaticText( + m_pan_gamepad_config, // Parent wxID_ANY, // ID txt_joystick, // Text which must be displayed wxPoint(20, 120), // Position wxDefaultSize // Size ); - this->sl_joystick_sensibility = new wxSlider( - this->pan_gamepad_config, // Parent + m_sl_joystick_sensibility = new wxSlider( + m_pan_gamepad_config, // Parent wxID_ANY, // ID 0, // value 0, // min value @@ -100,16 +100,16 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) : wxFrame( wxSize(200, 30) // Size ); - this->bt_ok = new wxButton( - this->pan_gamepad_config, // Parent + m_bt_ok = new wxButton( + m_pan_gamepad_config, // Parent wxID_ANY, // ID _T("&OK"), // Label wxPoint(250, 160), // Position wxSize(60,25) // Size ); - this->bt_cancel = new wxButton( - this->pan_gamepad_config, // Parent + m_bt_cancel = new wxButton( + m_pan_gamepad_config, // Parent wxID_ANY, // ID _T("&Cancel"), // Label wxPoint(320, 160), // Position @@ -117,20 +117,28 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) : wxFrame( ); // Connect the buttons to the OnButtonClicked Event - this->Connect( + Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(GamepadConfiguration::OnButtonClicked) ); // Connect the sliders to the OnSliderReleased Event - this->Connect( + Connect( wxEVT_SCROLL_THUMBRELEASE, wxCommandEventHandler(GamepadConfiguration::OnSliderReleased) ); + // Connect the checkboxes to the OnCheckboxClicked Event - this->Connect( - wxEVT_CHECKBOX, - wxCommandEventHandler(GamepadConfiguration::OnCheckboxChange) - ); + #if wxMAJOR_VERSION >= 3 + Connect( + wxEVT_CHECKBOX, + wxCommandEventHandler(GamepadConfiguration::OnCheckboxChange) + ); + #else + Connect( + wxEVT_COMMAND_CHECKBOX_CLICKED, + wxCommandEventHandler(GamepadConfiguration::OnCheckboxChange) + ); + #endif } /** @@ -140,14 +148,14 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) : wxFrame( */ void GamepadConfiguration::InitGamepadConfiguration() { - this->repopulate(); // Set label and fit simulated key array + repopulate(); // Set label and fit simulated key array /* * Check if there exist at least one pad available * if the pad id is 0, you need at least 1 gamepad connected, * if the pad id is 1, you need at least 2 gamepad connected, * Prevent to use a none initialized value on s_vgamePad (core dump) */ - if(s_vgamePad.size() >= this->pad_id+1) + if(s_vgamePad.size() >= m_pad_id+1) { /* * Determine if the device can use rumble @@ -155,19 +163,19 @@ void GamepadConfiguration::InitGamepadConfiguration() * May be better to create a new function in order to check only that */ - if(!s_vgamePad[this->pad_id]->TestForce(0.001f)) + if(!s_vgamePad[m_pad_id]->TestForce(0.001f)) { - wxMessageBox("Rumble is not available for your device."); - this->cb_rumble->Disable(); // disable the rumble checkbox - this->sl_rumble_intensity->Disable(); // disable the rumble intensity slider + wxMessageBox(L"Rumble is not available for your device."); + m_cb_rumble->Disable(); // disable the rumble checkbox + m_sl_rumble_intensity->Disable(); // disable the rumble intensity slider } } else { - wxMessageBox("No gamepad detected."); - this->sl_joystick_sensibility->Disable(); // disable the joystick sensibility slider - this->cb_rumble->Disable(); // disable the rumble checkbox - this->sl_rumble_intensity->Disable(); // disable the rumble intensity slider + wxMessageBox(L"No gamepad detected."); + m_sl_joystick_sensibility->Disable(); // disable the joystick sensibility slider + m_cb_rumble->Disable(); // disable the rumble checkbox + m_sl_rumble_intensity->Disable(); // disable the rumble intensity slider } } @@ -183,14 +191,14 @@ void GamepadConfiguration::OnButtonClicked(wxCommandEvent &event) // Affichage d'un message à chaque clic sur le bouton wxButton* bt_tmp = (wxButton*)event.GetEventObject(); // get the button object int bt_id = bt_tmp->GetId(); // get the real ID - if(bt_id == this->bt_ok->GetId()) // If the button ID is equals to the Ok button ID + if(bt_id == m_bt_ok->GetId()) // If the button ID is equals to the Ok button ID { - this->Close(); // Close the window + Close(); // Close the window } - else if(bt_id == this->bt_cancel->GetId()) // If the button ID is equals to the cancel button ID + else if(bt_id == m_bt_cancel->GetId()) // If the button ID is equals to the cancel button ID { - this->reset(); // reinitialize the value of each parameters - this->Close(); // Close the window + reset(); // reinitialize the value of each parameters + Close(); // Close the window } } @@ -203,12 +211,12 @@ void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event) { wxSlider* sl_tmp = (wxSlider*)event.GetEventObject(); // get the slider object int sl_id = sl_tmp->GetId(); // slider id - if(sl_id == this->sl_rumble_intensity->GetId()) // if this is the rumble intensity slider + if(sl_id == m_sl_rumble_intensity->GetId()) // if this is the rumble intensity slider { - u32 intensity = this->sl_rumble_intensity->GetValue(); // get the new value + u32 intensity = m_sl_rumble_intensity->GetValue(); // get the new value conf->set_ff_intensity(intensity); // and set the force feedback intensity value with it // get the rumble intensity - float strength = this->sl_rumble_intensity->GetValue(); + float strength = m_sl_rumble_intensity->GetValue(); /* * convert in a float value between 0 and 1, and run rumble feedback * 1 -> 0x7FFF @@ -220,11 +228,11 @@ void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event) * 0x7FFF : maximum intensity * 1 : maximum value of the intensity for the sdl rumble test */ - s_vgamePad[this->pad_id]->TestForce(strength/0x7FFF); + s_vgamePad[m_pad_id]->TestForce(strength/0x7FFF); } - else if(sl_id == this->sl_joystick_sensibility->GetId()) + else if(sl_id == m_sl_joystick_sensibility->GetId()) { - u32 sensibility = this->sl_joystick_sensibility->GetValue(); // get the new value + u32 sensibility = m_sl_joystick_sensibility->GetValue(); // get the new value conf->set_sensibility(sensibility); // and set the joystick sensibility } } @@ -236,26 +244,26 @@ void GamepadConfiguration::OnCheckboxChange(wxCommandEvent& event) { wxCheckBox* cb_tmp = (wxCheckBox*) event.GetEventObject(); // get the slider object int cb_id = cb_tmp->GetId(); - if(cb_id == this->cb_rumble->GetId()) + if(cb_id == m_cb_rumble->GetId()) { - conf->pad_options[this->pad_id].forcefeedback = (this->cb_rumble->GetValue())?(u32)1:(u32)0; - if(this->cb_rumble->GetValue()) + conf->pad_options[m_pad_id].forcefeedback = (m_cb_rumble->GetValue())?(u32)1:(u32)0; + if(m_cb_rumble->GetValue()) { - s_vgamePad[this->pad_id]->TestForce(); - this->sl_rumble_intensity->Enable(); + s_vgamePad[m_pad_id]->TestForce(); + m_sl_rumble_intensity->Enable(); } else { - this->sl_rumble_intensity->Disable(); + m_sl_rumble_intensity->Disable(); } } - else if(cb_id == this->cb_hack_sixaxis_usb->GetId()) + else if(cb_id == m_cb_hack_sixaxis_usb->GetId()) { - conf->pad_options[this->pad_id].sixaxis_usb = (this->cb_hack_sixaxis_usb->GetValue())?(u32)1:(u32)0; + conf->pad_options[m_pad_id].sixaxis_usb = (m_cb_hack_sixaxis_usb->GetValue())?(u32)1:(u32)0; } - else if(cb_id == this->cb_hack_sixaxis_pressure->GetId()) + else if(cb_id == m_cb_hack_sixaxis_pressure->GetId()) { - conf->pad_options[this->pad_id].sixaxis_pressure = (this->cb_hack_sixaxis_pressure->GetValue())?(u32)1:(u32)0; + conf->pad_options[m_pad_id].sixaxis_pressure = (m_cb_hack_sixaxis_pressure->GetValue())?(u32)1:(u32)0; } } @@ -266,31 +274,35 @@ void GamepadConfiguration::OnCheckboxChange(wxCommandEvent& event) // Reset checkbox and slider values void GamepadConfiguration::reset() { - this->cb_rumble->SetValue(this->init_rumble); - this->cb_hack_sixaxis_usb->SetValue(this->init_hack_sixaxis); - this->sl_rumble_intensity->SetValue(this->init_rumble_intensity); - this->sl_joystick_sensibility->SetValue(this->init_joystick_sensibility); + m_cb_rumble->SetValue(m_init_rumble); + m_cb_hack_sixaxis_usb->SetValue(m_init_hack_sixaxis); + m_cb_hack_sixaxis_pressure->SetValue(m_init_hack_sixaxis_pressure); + m_sl_rumble_intensity->SetValue(m_init_rumble_intensity); + m_sl_joystick_sensibility->SetValue(m_init_joystick_sensibility); } // Set button values void GamepadConfiguration::repopulate() { - bool val = conf->pad_options[this->pad_id].forcefeedback; - this->init_rumble = val; - this->cb_rumble->SetValue(val); - val = conf->pad_options[this->pad_id].sixaxis_usb; - this->init_hack_sixaxis = val; - this->cb_hack_sixaxis_usb->SetValue(val); + bool val = conf->pad_options[m_pad_id].forcefeedback; + m_init_rumble = val; + m_cb_rumble->SetValue(val); + val = conf->pad_options[m_pad_id].sixaxis_usb; + m_init_hack_sixaxis = val; + m_cb_hack_sixaxis_usb->SetValue(val); + val = conf->pad_options[m_pad_id].sixaxis_pressure; + m_init_hack_sixaxis_pressure = val; + m_cb_hack_sixaxis_pressure->SetValue(val); int tmp = conf->get_ff_intensity(); - this->sl_rumble_intensity->SetValue(tmp); - this->init_rumble_intensity = tmp; + m_sl_rumble_intensity->SetValue(tmp); + m_init_rumble_intensity = tmp; tmp = conf->get_sensibility(); - this->sl_joystick_sensibility->SetValue(tmp); - this->init_joystick_sensibility = tmp; + m_sl_joystick_sensibility->SetValue(tmp); + m_init_joystick_sensibility = tmp; // enable rumble intensity slider if the checkbox is checked - if(this->cb_rumble->GetValue()) - this->sl_rumble_intensity->Enable(); + if(m_cb_rumble->GetValue()) + m_sl_rumble_intensity->Enable(); else // disable otherwise - this->sl_rumble_intensity->Disable(); + m_sl_rumble_intensity->Disable(); } diff --git a/plugins/onepad/Linux/GamepadConfiguration.h b/plugins/onepad/Linux/GamepadConfiguration.h index 6edd640541..b2c4331d3e 100644 --- a/plugins/onepad/Linux/GamepadConfiguration.h +++ b/plugins/onepad/Linux/GamepadConfiguration.h @@ -34,15 +34,15 @@ class GamepadConfiguration : public wxFrame { - wxPanel* pan_gamepad_config; - wxCheckBox *cb_rumble, *cb_hack_sixaxis_usb, *cb_hack_sixaxis_pressure; - wxSlider *sl_rumble_intensity, *sl_joystick_sensibility; - wxButton *bt_ok, *bt_cancel; - wxStaticText *lbl_rumble_intensity, *lbl_joystick_sensibility; + wxPanel* m_pan_gamepad_config; + wxCheckBox *m_cb_rumble, *m_cb_hack_sixaxis_usb, *m_cb_hack_sixaxis_pressure; + wxSlider *m_sl_rumble_intensity, *m_sl_joystick_sensibility; + wxButton *m_bt_ok, *m_bt_cancel; + wxStaticText *m_lbl_rumble_intensity, *m_lbl_joystick_sensibility; - int pad_id; - u32 init_rumble_intensity, init_joystick_sensibility; - bool init_rumble, init_hack_sixaxis; + int m_pad_id; + u32 m_init_rumble_intensity, m_init_joystick_sensibility; + bool m_init_rumble, m_init_hack_sixaxis, m_init_hack_sixaxis_pressure; // methods void repopulate(); diff --git a/plugins/onepad/Linux/JoystickConfiguration.cpp b/plugins/onepad/Linux/JoystickConfiguration.cpp index b0419db339..3c417a8a27 100644 --- a/plugins/onepad/Linux/JoystickConfiguration.cpp +++ b/plugins/onepad/Linux/JoystickConfiguration.cpp @@ -34,33 +34,33 @@ JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *paren ) { - this->pad_id = pad; - this->isForLeftJoystick = left; - this->pan_joystick_config = new wxPanel( + m_pad_id = pad; + m_isForLeftJoystick = left; + m_pan_joystick_config = new wxPanel( this, // Parent wxID_ANY, // ID wxDefaultPosition, // Prosition wxSize(300, 200) // Size ); - if(this->isForLeftJoystick) + if(m_isForLeftJoystick) { - this->cb_reverse_Lx = new wxCheckBox( - this->pan_joystick_config, // Parent + m_cb_reverse_Lx = new wxCheckBox( + m_pan_joystick_config, // Parent wxID_ANY, // ID _T("Reverse Lx"), // Label wxPoint(20, 20) // Position ); - this->cb_reverse_Ly = new wxCheckBox( - this->pan_joystick_config, // Parent + m_cb_reverse_Ly = new wxCheckBox( + m_pan_joystick_config, // Parent wxID_ANY, // ID _T("Reverse Ly"), // Label wxPoint(20, 40) // Position ); - this->cb_mouse_Ljoy = new wxCheckBox( - this->pan_joystick_config, // Parent + m_cb_mouse_Ljoy = new wxCheckBox( + m_pan_joystick_config, // Parent wxID_ANY, // ID _T("Use mouse for left analog joystick"), // Label wxPoint(20, 60) // Position @@ -68,38 +68,38 @@ JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *paren } else { - this->cb_reverse_Rx = new wxCheckBox( - this->pan_joystick_config, // Parent + m_cb_reverse_Rx = new wxCheckBox( + m_pan_joystick_config, // Parent wxID_ANY, // ID _T("Reverse Rx"), // Label wxPoint(20, 20) // Position ); - this->cb_reverse_Ry = new wxCheckBox( - this->pan_joystick_config, // Parent + m_cb_reverse_Ry = new wxCheckBox( + m_pan_joystick_config, // Parent wxID_ANY, // ID _T("Reverse Ry"), // Label wxPoint(20, 40) // Position ); - this->cb_mouse_Rjoy = new wxCheckBox( - this->pan_joystick_config, // Parent + m_cb_mouse_Rjoy = new wxCheckBox( + m_pan_joystick_config, // Parent wxID_ANY, // ID _T("Use mouse for right analog joystick"), // Label wxPoint(20, 60) // Position ); } - this->bt_ok = new wxButton( - this->pan_joystick_config, // Parent + m_bt_ok = new wxButton( + m_pan_joystick_config, // Parent wxID_ANY, // ID _T("&OK"), // Label wxPoint(250, 130), // Position wxSize(60,25) // Size ); - this->bt_cancel = new wxButton( - this->pan_joystick_config, // Parent + m_bt_cancel = new wxButton( + m_pan_joystick_config, // Parent wxID_ANY, // ID _T("&Cancel"), // Label wxPoint(320, 130), // Position @@ -107,16 +107,23 @@ JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *paren ); // Connect the buttons to the OnButtonClicked Event - this->Connect( + Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(JoystickConfiguration::OnButtonClicked) ); // Connect the checkboxes to the OnCheckboxClicked Event - this->Connect( - wxEVT_CHECKBOX, - wxCommandEventHandler(JoystickConfiguration::OnCheckboxChange) - ); + #if wxMAJOR_VERSION >= 3 + Connect( + wxEVT_CHECKBOX, + wxCommandEventHandler(JoystickConfiguration::OnCheckboxChange) + ); + #else + Connect( + wxEVT_COMMAND_CHECKBOX_CLICKED, + wxCommandEventHandler(JoystickConfiguration::OnCheckboxChange) + ); + #endif } /** @@ -125,26 +132,26 @@ JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *paren */ void JoystickConfiguration::InitJoystickConfiguration() { - this->repopulate(); // Set label and fit simulated key array + repopulate(); // Set label and fit simulated key array /* * Check if there exist at least one pad available * if the pad id is 0, you need at least 1 gamepad connected, * if the pad id is 1, you need at least 2 gamepad connected, * Prevent to use a none initialized value on s_vgamePad (core dump) */ - if(s_vgamePad.size() < this->pad_id+1) + if(s_vgamePad.size() < m_pad_id+1) { - wxMessageBox("No gamepad detected."); + wxMessageBox(L"No gamepad detected."); // disable all checkbox - if(this->isForLeftJoystick) + if(m_isForLeftJoystick) { - this->cb_reverse_Lx->Disable(); - this->cb_reverse_Ly->Disable(); + m_cb_reverse_Lx->Disable(); + m_cb_reverse_Ly->Disable(); } else { - this->cb_reverse_Rx->Disable(); - this->cb_reverse_Ry->Disable(); + m_cb_reverse_Rx->Disable(); + m_cb_reverse_Ry->Disable(); } } } @@ -161,14 +168,14 @@ void JoystickConfiguration::OnButtonClicked(wxCommandEvent &event) // Affichage d'un message à chaque clic sur le bouton wxButton* bt_tmp = (wxButton*)event.GetEventObject(); // get the button object int bt_id = bt_tmp->GetId(); // get the real ID - if(bt_id == this->bt_ok->GetId()) // If the button ID is equals to the Ok button ID + if(bt_id == m_bt_ok->GetId()) // If the button ID is equals to the Ok button ID { - this->Close(); // Close the window + Close(); // Close the window } - else if(bt_id == this->bt_cancel->GetId()) // If the button ID is equals to the cancel button ID + else if(bt_id == m_bt_cancel->GetId()) // If the button ID is equals to the cancel button ID { - this->reset(); // reinitialize the value of each parameters - this->Close(); // Close the window + reset(); // reinitialize the value of each parameters + Close(); // Close the window } } @@ -180,40 +187,40 @@ void JoystickConfiguration::OnCheckboxChange(wxCommandEvent& event) wxCheckBox* cb_tmp = (wxCheckBox*) event.GetEventObject(); // get the slider object int cb_id = cb_tmp->GetId(); bool val; - if(this->isForLeftJoystick) + if(m_isForLeftJoystick) { - if(cb_id == this->cb_reverse_Ly->GetId()) + if(cb_id == m_cb_reverse_Ly->GetId()) { - val = this->cb_reverse_Ly->GetValue(); - conf->pad_options[this->pad_id].reverse_ly = val; + val = m_cb_reverse_Ly->GetValue(); + conf->pad_options[m_pad_id].reverse_ly = val; } - else if(cb_id == this->cb_reverse_Lx->GetId()) + else if(cb_id == m_cb_reverse_Lx->GetId()) { - val = this->cb_reverse_Lx->GetValue(); - conf->pad_options[this->pad_id].reverse_lx = val; + val = m_cb_reverse_Lx->GetValue(); + conf->pad_options[m_pad_id].reverse_lx = val; } - else if(cb_id == this->cb_mouse_Ljoy->GetId()) + else if(cb_id == m_cb_mouse_Ljoy->GetId()) { - val = this->cb_mouse_Ljoy->GetValue(); - conf->pad_options[this->pad_id].mouse_l = val; + val = m_cb_mouse_Ljoy->GetValue(); + conf->pad_options[m_pad_id].mouse_l = val; } } else { - if(cb_id == this->cb_reverse_Ry->GetId()) + if(cb_id == m_cb_reverse_Ry->GetId()) { - val = this->cb_reverse_Ry->GetValue(); - conf->pad_options[this->pad_id].reverse_ry = val; + val = m_cb_reverse_Ry->GetValue(); + conf->pad_options[m_pad_id].reverse_ry = val; } - else if(cb_id == this->cb_reverse_Rx->GetId()) + else if(cb_id == m_cb_reverse_Rx->GetId()) { - val = this->cb_reverse_Rx->GetValue(); - conf->pad_options[this->pad_id].reverse_rx = val; + val = m_cb_reverse_Rx->GetValue(); + conf->pad_options[m_pad_id].reverse_rx = val; } - else if(cb_id == this->cb_mouse_Rjoy->GetId()) + else if(cb_id == m_cb_mouse_Rjoy->GetId()) { - val = this->cb_mouse_Rjoy->GetValue(); - conf->pad_options[this->pad_id].mouse_r = val; + val = m_cb_mouse_Rjoy->GetValue(); + conf->pad_options[m_pad_id].mouse_r = val; } } } @@ -225,17 +232,17 @@ void JoystickConfiguration::OnCheckboxChange(wxCommandEvent& event) // Reset checkbox and slider values void JoystickConfiguration::reset() { - if(this->isForLeftJoystick) + if(m_isForLeftJoystick) { - this->cb_reverse_Lx->SetValue(this->init_reverse_Lx); - this->cb_reverse_Ly->SetValue(this->init_reverse_Ly); - this->cb_mouse_Ljoy->SetValue(this->init_mouse_Ljoy); + m_cb_reverse_Lx->SetValue(m_init_reverse_Lx); + m_cb_reverse_Ly->SetValue(m_init_reverse_Ly); + m_cb_mouse_Ljoy->SetValue(m_init_mouse_Ljoy); } else { - this->cb_reverse_Rx->SetValue(this->init_reverse_Rx); - this->cb_reverse_Ry->SetValue(this->init_reverse_Ry); - this->cb_mouse_Rjoy->SetValue(this->init_mouse_Rjoy); + m_cb_reverse_Rx->SetValue(m_init_reverse_Rx); + m_cb_reverse_Ry->SetValue(m_init_reverse_Ry); + m_cb_mouse_Rjoy->SetValue(m_init_mouse_Rjoy); } } @@ -243,32 +250,32 @@ void JoystickConfiguration::reset() void JoystickConfiguration::repopulate() { bool val; - if(this->isForLeftJoystick) + if(m_isForLeftJoystick) { - val = conf->pad_options[this->pad_id].reverse_lx; - this->init_reverse_Lx = val; - this->cb_reverse_Lx->SetValue(val); + val = conf->pad_options[m_pad_id].reverse_lx; + m_init_reverse_Lx = val; + m_cb_reverse_Lx->SetValue(val); - val = conf->pad_options[this->pad_id].reverse_ly; - this->init_reverse_Ly = val; - this->cb_reverse_Ly->SetValue(val); + val = conf->pad_options[m_pad_id].reverse_ly; + m_init_reverse_Ly = val; + m_cb_reverse_Ly->SetValue(val); - val = conf->pad_options[this->pad_id].mouse_l; - this->init_mouse_Ljoy = val; - this->cb_mouse_Ljoy->SetValue(val); + val = conf->pad_options[m_pad_id].mouse_l; + m_init_mouse_Ljoy = val; + m_cb_mouse_Ljoy->SetValue(val); } else { - val = conf->pad_options[this->pad_id].reverse_rx; - this->init_reverse_Rx = val; - this->cb_reverse_Rx->SetValue(val); + val = conf->pad_options[m_pad_id].reverse_rx; + m_init_reverse_Rx = val; + m_cb_reverse_Rx->SetValue(val); - val = conf->pad_options[this->pad_id].reverse_ry; - this->init_reverse_Ry = val; - this->cb_reverse_Ry->SetValue(val); + val = conf->pad_options[m_pad_id].reverse_ry; + m_init_reverse_Ry = val; + m_cb_reverse_Ry->SetValue(val); - val = conf->pad_options[this->pad_id].mouse_r; - this->init_mouse_Rjoy = val; - this->cb_mouse_Rjoy->SetValue(val); + val = conf->pad_options[m_pad_id].mouse_r; + m_init_mouse_Rjoy = val; + m_cb_mouse_Rjoy->SetValue(val); } } diff --git a/plugins/onepad/Linux/JoystickConfiguration.h b/plugins/onepad/Linux/JoystickConfiguration.h index 229c2580e3..353829528f 100644 --- a/plugins/onepad/Linux/JoystickConfiguration.h +++ b/plugins/onepad/Linux/JoystickConfiguration.h @@ -34,16 +34,16 @@ class JoystickConfiguration : public wxFrame { - wxPanel* pan_joystick_config; - wxCheckBox *cb_reverse_Lx, *cb_reverse_Ly, *cb_reverse_Rx, *cb_reverse_Ry, - *cb_mouse_Ljoy, // Use mouse for left joystick - *cb_mouse_Rjoy; // Use mouse for right joystick - wxButton *bt_ok, *bt_cancel; + wxPanel* m_pan_joystick_config; + wxCheckBox *m_cb_reverse_Lx, *m_cb_reverse_Ly, *m_cb_reverse_Rx, *m_cb_reverse_Ry, + *m_cb_mouse_Ljoy, // Use mouse for left joystick + *m_cb_mouse_Rjoy; // Use mouse for right joystick + wxButton *m_bt_ok, *m_bt_cancel; - int pad_id; + int m_pad_id; // isForLeftJoystick -> true is for Left Joystick, false is for Right Joystick - bool init_reverse_Lx, init_reverse_Ly, init_reverse_Rx, init_reverse_Ry, - init_mouse_Ljoy, init_mouse_Rjoy, isForLeftJoystick; + bool m_init_reverse_Lx, m_init_reverse_Ly, m_init_reverse_Rx, m_init_reverse_Ry, + m_init_mouse_Ljoy, m_init_mouse_Rjoy, m_isForLeftJoystick; // methods void repopulate(); diff --git a/plugins/onepad/Linux/dialog.cpp b/plugins/onepad/Linux/dialog.cpp index f30881df3f..70cd374219 100644 --- a/plugins/onepad/Linux/dialog.cpp +++ b/plugins/onepad/Linux/dialog.cpp @@ -24,7 +24,7 @@ Dialog::Dialog() : wxFrame( NULL, // Parent wxID_ANY, // ID _T("OnePad configuration"), // Title wxDefaultPosition, // Position - wxSize(1000, 760), // Width + Lenght + wxSize(DEFAULT_WIDTH, DEFAULT_HEIGHT), // Width + Lenght // Style wxSYSTEM_MENU | wxCAPTION | @@ -235,15 +235,15 @@ Dialog::Dialog() : wxFrame( NULL, // Parent padding[Cancel][3] = 642; // Y // create a new Notebook - this->tab_gamepad = new wxNotebook(this, wxID_ANY); + m_tab_gamepad = new wxNotebook(this, wxID_ANY); for(int i=0; ipan_tabs[i] = new opPanel( - this->tab_gamepad, + m_pan_tabs[i] = new opPanel( + m_tab_gamepad, wxID_ANY, wxDefaultPosition, - wxSize(1000, 760) + wxSize(DEFAULT_WIDTH, DEFAULT_HEIGHT) ); // Add new page // Define label @@ -251,16 +251,16 @@ Dialog::Dialog() : wxFrame( NULL, // Parent std::string label = "Gamepad "; sstm << label << i; // New page creation - this->tab_gamepad->AddPage( - this->pan_tabs[i], // Parent - sstm.str() // Title + m_tab_gamepad->AddPage( + m_pan_tabs[i], // Parent + wxString(sstm.str().c_str(), wxConvUTF8) // Title ); for(int j=0; jbt_gamepad[i][j] = new wxButton( - this->pan_tabs[i], // Parent + m_bt_gamepad[i][j] = new wxButton( + m_pan_tabs[i], // Parent wxID_HIGHEST+j+1, // ID _T("Undefined"), // Label wxPoint(padding[j][2], padding[j][3]), // Position @@ -268,36 +268,36 @@ Dialog::Dialog() : wxFrame( NULL, // Parent ); } // Redefine others gui buttons label - this->bt_gamepad[i][JoyL_config]->SetLabel(_T("&Left Joystick Config")); - this->bt_gamepad[i][JoyR_config]->SetLabel(_T("&Right Joystick Config")); - this->bt_gamepad[i][Gamepad_config]->SetLabel(_T("&Gamepad Configuration")); - this->bt_gamepad[i][Set_all]->SetLabel(_T("&Set All Buttons")); - this->bt_gamepad[i][Cancel]->SetLabel(_T("&Cancel")); - this->bt_gamepad[i][Apply]->SetLabel(_T("&Apply")); - this->bt_gamepad[i][Ok]->SetLabel(_T("&Ok")); + m_bt_gamepad[i][JoyL_config]->SetLabel(_T("&Left Joystick Config")); + m_bt_gamepad[i][JoyR_config]->SetLabel(_T("&Right Joystick Config")); + m_bt_gamepad[i][Gamepad_config]->SetLabel(_T("&Gamepad Configuration")); + m_bt_gamepad[i][Set_all]->SetLabel(_T("&Set All Buttons")); + m_bt_gamepad[i][Cancel]->SetLabel(_T("&Cancel")); + m_bt_gamepad[i][Apply]->SetLabel(_T("&Apply")); + m_bt_gamepad[i][Ok]->SetLabel(_T("&Ok")); // Disable analog button (not yet supported) - this->bt_gamepad[i][Analog]->Disable(); + m_bt_gamepad[i][Analog]->Disable(); } // Connect the buttons to the OnButtonClicked Event - this->Connect( + Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Dialog::OnButtonClicked) ); - time_update_gui.SetOwner(this); - this->Connect( + m_time_update_gui.SetOwner(this); + Connect( wxEVT_TIMER, wxCommandEventHandler(Dialog::JoystickEvent) ); - time_update_gui.Start(UPDATE_TIME, wxTIMER_CONTINUOUS); + m_time_update_gui.Start(UPDATE_TIME, wxTIMER_CONTINUOUS); for(int i=0; ipressed[i][j] = false; + m_pressed[i][j] = false; } } } @@ -306,7 +306,7 @@ void Dialog::InitDialog() { GamePad::EnumerateGamePads(s_vgamePad); // activate gamepads LoadConfig(); // Load configuration from the ini file - this->repopulate(); // Set label and fit simulated key array + repopulate(); // Set label and fit simulated key array } /****************************************/ @@ -318,101 +318,101 @@ void Dialog::OnButtonClicked(wxCommandEvent &event) // Affichage d'un message à chaque clic sur le bouton wxButton* bt_tmp = (wxButton*)event.GetEventObject(); // get the button object int bt_id = bt_tmp->GetId()-wxID_HIGHEST-1; // get the real ID - int gamepad_id = this->tab_gamepad->GetSelection(); // get the tab ID (equivalent to the gamepad id) + int gamepad_id = m_tab_gamepad->GetSelection(); // get the tab ID (equivalent to the gamepad id) if(bt_id >= 0 && bt_id <= PAD_R_LEFT) // if the button ID is a gamepad button { bt_tmp->Disable(); // switch the button state to "Disable" - this->config_key(gamepad_id, bt_id); + config_key(gamepad_id, bt_id); bt_tmp->Enable(); // switch the button state to "Enable" } else if(bt_id == Gamepad_config) // If the button ID is equals to the Gamepad_config button ID { - this->frm_gamepad_config = new GamepadConfiguration(gamepad_id, this); - this->frm_gamepad_config->InitGamepadConfiguration(); - this->frm_gamepad_config->Show(true); + m_frm_gamepad_config = new GamepadConfiguration(gamepad_id, this); + m_frm_gamepad_config->InitGamepadConfiguration(); + m_frm_gamepad_config->Show(true); } else if(bt_id == JoyL_config) // If the button ID is equals to the JoyL_config button ID { - this->frm_joystick_config = new JoystickConfiguration(gamepad_id, true, this); - this->frm_joystick_config->InitJoystickConfiguration(); - this->frm_joystick_config->Show(true); + m_frm_joystick_config = new JoystickConfiguration(gamepad_id, true, this); + m_frm_joystick_config->InitJoystickConfiguration(); + m_frm_joystick_config->Show(true); } else if(bt_id == JoyR_config) // If the button ID is equals to the JoyR_config button ID { - this->frm_joystick_config = new JoystickConfiguration(gamepad_id, false, this); - this->frm_joystick_config->InitJoystickConfiguration(); - this->frm_joystick_config->Show(true); + m_frm_joystick_config = new JoystickConfiguration(gamepad_id, false, this); + m_frm_joystick_config->InitJoystickConfiguration(); + m_frm_joystick_config->Show(true); } else if(bt_id == Set_all) // If the button ID is equals to the Set_all button ID { for(int i=0; ibt_gamepad[gamepad_id][i]; + bt_tmp = m_bt_gamepad[gamepad_id][i]; switch(i) { case PAD_L_UP: // Left joystick (Up) ↑ - this->pan_tabs[gamepad_id]->ShowImg(img_l_arrow_up); + m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_up); break; case PAD_L_RIGHT: // Left joystick (Right) → - this->pan_tabs[gamepad_id]->ShowImg(img_l_arrow_right); + m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_right); break; case PAD_L_DOWN: // Left joystick (Down) ↓ - this->pan_tabs[gamepad_id]->ShowImg(img_l_arrow_bottom); + m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_bottom); break; case PAD_L_LEFT: // Left joystick (Left) ← - this->pan_tabs[gamepad_id]->ShowImg(img_l_arrow_left); + m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_left); break; case PAD_R_UP: // Right joystick (Up) ↑ - this->pan_tabs[gamepad_id]->ShowImg(img_r_arrow_up); + m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_up); break; case PAD_R_RIGHT: // Right joystick (Right) → - this->pan_tabs[gamepad_id]->ShowImg(img_r_arrow_right); + m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_right); break; case PAD_R_DOWN: // Right joystick (Down) ↓ - this->pan_tabs[gamepad_id]->ShowImg(img_r_arrow_bottom); + m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_bottom); break; case PAD_R_LEFT: // Right joystick (Left) ← - this->pan_tabs[gamepad_id]->ShowImg(img_r_arrow_left); + m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_left); break; default: - this->pan_tabs[gamepad_id]->ShowImg(i); + m_pan_tabs[gamepad_id]->ShowImg(i); break; } - this->pan_tabs[gamepad_id]->Refresh(); - this->pan_tabs[gamepad_id]->Update(); - this->config_key(gamepad_id, i); + m_pan_tabs[gamepad_id]->Refresh(); + m_pan_tabs[gamepad_id]->Update(); + config_key(gamepad_id, i); switch(i) { case PAD_L_UP: // Left joystick (Up) ↑ - this->pan_tabs[gamepad_id]->HideImg(img_l_arrow_up); + m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_up); break; case PAD_L_RIGHT: // Left joystick (Right) → - this->pan_tabs[gamepad_id]->HideImg(img_l_arrow_right); + m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_right); break; case PAD_L_DOWN: // Left joystick (Down) ↓ - this->pan_tabs[gamepad_id]->HideImg(img_l_arrow_bottom); + m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_bottom); break; case PAD_L_LEFT: // Left joystick (Left) ← - this->pan_tabs[gamepad_id]->HideImg(img_l_arrow_left); + m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_left); break; case PAD_R_UP: // Right joystick (Up) ↑ - this->pan_tabs[gamepad_id]->HideImg(img_r_arrow_up); + m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_up); break; case PAD_R_RIGHT: // Right joystick (Right) → - this->pan_tabs[gamepad_id]->HideImg(img_r_arrow_right); + m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_right); break; case PAD_R_DOWN: // Right joystick (Down) ↓ - this->pan_tabs[gamepad_id]->HideImg(img_r_arrow_bottom); + m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_bottom); break; case PAD_R_LEFT: // Right joystick (Left) ← - this->pan_tabs[gamepad_id]->HideImg(img_r_arrow_left); + m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_left); break; default: - this->pan_tabs[gamepad_id]->HideImg(i); + m_pan_tabs[gamepad_id]->HideImg(i); break; } - this->pan_tabs[gamepad_id]->Refresh(); - this->pan_tabs[gamepad_id]->Update(); + m_pan_tabs[gamepad_id]->Refresh(); + m_pan_tabs[gamepad_id]->Update(); usleep(500000); // give enough time to the user to release the button } } @@ -448,107 +448,122 @@ void Dialog::JoystickEvent(wxCommandEvent& event) case SDL_KEYUP: break; case SDL_JOYAXISMOTION: - key = axis_to_key(false, (events.jaxis.value<0), events.jaxis.axis); - it=this->map_images[events.jaxis.which].find(key); - if(it != this->map_images[events.jaxis.which].end()) + if(events.jaxis.which < GAMEPAD_NUMBER) { - map = this->map_images[events.jaxis.which][key]; - if(events.jaxis.value == 0) + key = axis_to_key(false, (events.jaxis.value<0), events.jaxis.axis); + it=m_map_images[events.jaxis.which].find(key); + if(it != m_map_images[events.jaxis.which].end()) { - if(map >= PAD_L_UP && map <= PAD_L_LEFT) - this->pan_tabs[events.jaxis.which]->HideImg(img_left_cursor); - else if(map >= PAD_R_UP && map <= PAD_R_LEFT) - this->pan_tabs[events.jaxis.which]->HideImg(img_right_cursor); + map = m_map_images[events.jaxis.which][key]; + if(events.jaxis.value == 0) + { + if(map >= PAD_L_UP && map <= PAD_L_LEFT) + m_pan_tabs[events.jaxis.which]->HideImg(img_left_cursor); + else if(map >= PAD_R_UP && map <= PAD_R_LEFT) + m_pan_tabs[events.jaxis.which]->HideImg(img_right_cursor); + else if(map < PAD_L_UP) + m_pan_tabs[events.jaxis.which]->HideImg(map); + } + else + { + if(map >= PAD_L_UP && map <= PAD_L_LEFT) + { + m_pan_tabs[events.jaxis.which]->MoveJoystick(events.jaxis.axis, events.jaxis.value); + m_pan_tabs[events.jaxis.which]->ShowImg(img_left_cursor); + } + else if(map >= PAD_R_UP && map <= PAD_R_LEFT) + { + m_pan_tabs[events.jaxis.which]->MoveJoystick(events.jaxis.axis, events.jaxis.value); + m_pan_tabs[events.jaxis.which]->ShowImg(img_right_cursor); + } + else if(map < PAD_L_UP) // if this is not a joystick + { + m_pan_tabs[events.jaxis.which]->ShowImg(map); + } + } + break; } - else + // Hack Dualshock 4 (L2, R2) + key = axis_to_key(false, (events.jaxis.value>0), events.jaxis.axis); + it2=m_map_images[events.jaxis.which].find(key); + if(it2 != m_map_images[events.jaxis.which].end()) { - if(map >= PAD_L_UP && map <= PAD_L_LEFT) + map = m_map_images[events.jaxis.which][key]; + if(map < PAD_L_UP) // if this is not a joystick { - this->pan_tabs[events.jaxis.which]->MoveJoystick(events.jaxis.axis, events.jaxis.value); - this->pan_tabs[events.jaxis.which]->ShowImg(img_left_cursor); - } - else if(map >= PAD_R_UP && map <= PAD_R_LEFT) - { - this->pan_tabs[events.jaxis.which]->MoveJoystick(events.jaxis.axis, events.jaxis.value); - this->pan_tabs[events.jaxis.which]->ShowImg(img_right_cursor); - } - else if(map < PAD_L_UP) // if this is not a joystick - { - this->pan_tabs[events.jaxis.which]->ShowImg(map); + m_pan_tabs[events.jaxis.which]->HideImg(map); } + break; } - break; - } - // Hack Dualshock 4 (L2, R2) - key = axis_to_key(false, (events.jaxis.value>0), events.jaxis.axis); - it2=this->map_images[events.jaxis.which].find(key); - if(it2 != this->map_images[events.jaxis.which].end()) - { - map = this->map_images[events.jaxis.which][key]; - if(map < PAD_L_UP) // if this is not a joystick - { - this->pan_tabs[events.jaxis.which]->HideImg(map); - } - break; } break; case SDL_JOYBUTTONDOWN: - key = button_to_key(events.jbutton.button); - it=this->map_images[events.jaxis.which].find(key); - if(it != this->map_images[events.jaxis.which].end()) + if(events.jbutton.which < GAMEPAD_NUMBER) { - map = this->map_images[events.jaxis.which][key]; - this->pan_tabs[events.jaxis.which]->ShowImg(map); + key = button_to_key(events.jbutton.button); + it=m_map_images[events.jbutton.which].find(key); + if(it != m_map_images[events.jbutton.which].end()) + { + map = m_map_images[events.jbutton.which][key]; + m_pan_tabs[events.jbutton.which]->ShowImg(map); + } } break; case SDL_JOYBUTTONUP: - key = button_to_key(events.jbutton.button); - it=this->map_images[events.jaxis.which].find(key); - if(it != this->map_images[events.jaxis.which].end()) + if(events.jbutton.which < GAMEPAD_NUMBER) { - map = this->map_images[events.jaxis.which][key]; - this->pan_tabs[events.jaxis.which]->HideImg(map); + key = button_to_key(events.jbutton.button); + it=m_map_images[events.jbutton.which].find(key); + if(it != m_map_images[events.jbutton.which].end()) + { + map = m_map_images[events.jbutton.which][key]; + m_pan_tabs[events.jbutton.which]->HideImg(map); + } } + break; case SDL_JOYHATMOTION: - switch(events.jhat.value) + if(events.jhat.which < GAMEPAD_NUMBER) { - case SDL_HAT_UP: - key = hat_to_key(events.jhat.value, events.jhat.hat); - it=this->map_images[events.jaxis.which].find(key); - if(it != this->map_images[events.jaxis.which].end()) - { - this->pan_tabs[events.jaxis.which]->ShowImg(img_dp_up); - } - break; - case SDL_HAT_DOWN: - key = hat_to_key(events.jhat.value, events.jhat.hat); - it=this->map_images[events.jaxis.which].find(key); - if(it != this->map_images[events.jaxis.which].end()) - { - this->pan_tabs[events.jaxis.which]->ShowImg(img_dp_bottom); - } - break; - case SDL_HAT_RIGHT: - key = hat_to_key(events.jhat.value, events.jhat.hat); - it=this->map_images[events.jaxis.which].find(key); - if(it != this->map_images[events.jaxis.which].end()) - { - this->pan_tabs[events.jaxis.which]->ShowImg(img_dp_right); - } - break; - case SDL_HAT_LEFT: - key = hat_to_key(events.jhat.value, events.jhat.hat); - it=this->map_images[events.jaxis.which].find(key); - if(it != this->map_images[events.jaxis.which].end()) - { - this->pan_tabs[events.jaxis.which]->ShowImg(img_dp_left); - } - break; - case SDL_HAT_CENTERED: - this->pan_tabs[events.jaxis.which]->HideImg(img_dp_up); - this->pan_tabs[events.jaxis.which]->HideImg(img_dp_bottom); - this->pan_tabs[events.jaxis.which]->HideImg(img_dp_right); - this->pan_tabs[events.jaxis.which]->HideImg(img_dp_left); + switch(events.jhat.value) + { + case SDL_HAT_UP: + key = hat_to_key(events.jhat.value, events.jhat.hat); + it=m_map_images[events.jhat.which].find(key); + if(it != m_map_images[events.jhat.which].end()) + { + m_pan_tabs[events.jhat.which]->ShowImg(img_dp_up); + } + break; + case SDL_HAT_DOWN: + key = hat_to_key(events.jhat.value, events.jhat.hat); + it=m_map_images[events.jhat.which].find(key); + if(it != m_map_images[events.jhat.which].end()) + { + m_pan_tabs[events.jhat.which]->ShowImg(img_dp_bottom); + } + break; + case SDL_HAT_RIGHT: + key = hat_to_key(events.jhat.value, events.jhat.hat); + it=m_map_images[events.jhat.which].find(key); + if(it != m_map_images[events.jhat.which].end()) + { + m_pan_tabs[events.jhat.which]->ShowImg(img_dp_right); + } + break; + case SDL_HAT_LEFT: + key = hat_to_key(events.jhat.value, events.jhat.hat); + it=m_map_images[events.jhat.which].find(key); + if(it != m_map_images[events.jhat.which].end()) + { + m_pan_tabs[events.jhat.which]->ShowImg(img_dp_left); + } + break; + case SDL_HAT_CENTERED: + m_pan_tabs[events.jhat.which]->HideImg(img_dp_up); + m_pan_tabs[events.jhat.which]->HideImg(img_dp_bottom); + m_pan_tabs[events.jhat.which]->HideImg(img_dp_right); + m_pan_tabs[events.jhat.which]->HideImg(img_dp_left); + } } break; default: @@ -578,10 +593,10 @@ void Dialog::config_key(int pad, int key) // Note: key_pressed == 0 when ESC is hit to abort the capture if (key_pressed > 0) { - this->clear_key(pad, key); + clear_key(pad, key); set_keyboad_key(pad, key_pressed, key); - this->simulatedKeys[pad][key] = key_pressed; - this->map_images[pad][key_pressed] = key; + m_simulatedKeys[pad][key] = key_pressed; + m_map_images[pad][key_pressed] = key; } captured = true; } @@ -594,40 +609,45 @@ void Dialog::config_key(int pad, int key) { if ((*itjoy)->PollButtons(key_pressed)) { - this->clear_key(pad, key); + clear_key(pad, key); set_key(pad, key, key_pressed); - this->map_images[pad][key_pressed] = key; + m_map_images[pad][key_pressed] = key; captured = true; } else if((*itjoy)->PollAxes(key_pressed)) { - - this->clear_key(pad, key); + clear_key(pad, key); set_key(pad, key, key_pressed); - this->map_images[pad][key_pressed] = key; + m_map_images[pad][key_pressed] = key; captured = true; } else if((*itjoy)->PollHats(key_pressed)) { - this->clear_key(pad, key); + clear_key(pad, key); set_key(pad, key, key_pressed); - this->map_images[pad][key_pressed] = key; + m_map_images[pad][key_pressed] = key; captured = true; } itjoy++; } } } - this->bt_gamepad[pad][key]->SetLabel( - KeyName(pad, key, this->simulatedKeys[pad][key]).c_str() - ); + #if wxMAJOR_VERSION >= 3 + m_bt_gamepad[pad][key]->SetLabel( + KeyName(pad, key, m_simulatedKeys[pad][key]).c_str() + ); + #else + m_bt_gamepad[pad][key]->SetLabel( + wxString(KeyName(pad, key, m_simulatedKeys[pad][key]).c_str(), wxConvUTF8) + ); + #endif } void Dialog::clear_key(int pad, int key) { // Erase the keyboard binded key - u32 keysim = this->simulatedKeys[pad][key]; - this->simulatedKeys[pad][key] = 0; + u32 keysim = m_simulatedKeys[pad][key]; + m_simulatedKeys[pad][key] = 0; // erase gamepad entry (keysim map) std::map::iterator it1; @@ -638,14 +658,14 @@ void Dialog::clear_key(int pad, int key) // erase gamepad entry (image map) int val = get_key(pad, key); std::map::iterator it2; - it2=this->map_images[pad].find(val); - if(it2 != this->map_images[pad].end()) + it2=m_map_images[pad].find(val); + if(it2 != m_map_images[pad].end()) { - this->map_images[pad].erase(it2); + m_map_images[pad].erase(it2); } // Erase the keyboard image map - //this->map_images[pad].erase(keysim); + //m_map_images[pad].erase(keysim); // Erase the Gamepad binded key set_key(pad, key, 0); } @@ -660,10 +680,17 @@ void Dialog::repopulate() { if (get_key(gamepad_id, key) != 0) { - this->bt_gamepad[gamepad_id][key]->SetLabel( - KeyName(gamepad_id, key).c_str() - ); - this->map_images[gamepad_id][get_key(gamepad_id, key)] = key; + #if wxMAJOR_VERSION >= 3 + m_bt_gamepad[gamepad_id][key]->SetLabel( + KeyName(gamepad_id, key).c_str() + ); + #else + m_bt_gamepad[gamepad_id][key]->SetLabel( + wxString(KeyName(gamepad_id, key).c_str(), wxConvUTF8) + ); + #endif + + m_map_images[gamepad_id][get_key(gamepad_id, key)] = key; } } @@ -674,11 +701,17 @@ void Dialog::repopulate() { int keysym = it->first; int key = it->second; - this->bt_gamepad[gamepad_id][key]->SetLabel( - KeyName(gamepad_id, key, keysym).c_str() - ); - this->simulatedKeys[gamepad_id][key] = keysym; - this->map_images[gamepad_id][keysym] = key; + #if wxMAJOR_VERSION >= 3 + m_bt_gamepad[gamepad_id][key]->SetLabel( + KeyName(gamepad_id, key, keysym).c_str() + ); + #else + m_bt_gamepad[gamepad_id][key]->SetLabel( + wxString(KeyName(gamepad_id, key, keysym).c_str(), wxConvUTF8) + ); + #endif + m_simulatedKeys[gamepad_id][key] = keysym; + m_map_images[gamepad_id][keysym] = key; } } } diff --git a/plugins/onepad/Linux/dialog.h b/plugins/onepad/Linux/dialog.h index 5c0e7ba078..0f7ab28ed2 100644 --- a/plugins/onepad/Linux/dialog.h +++ b/plugins/onepad/Linux/dialog.h @@ -61,27 +61,29 @@ enum gui_buttons { #define BUTTONS_LENGHT 32 // numbers of buttons on the gamepad #define GAMEPAD_NUMBER 2 // numbers of gamepad #define UPDATE_TIME 5 +#define DEFAULT_WIDTH 1000 +#define DEFAULT_HEIGHT 740 class Dialog : public wxFrame { // Panels - opPanel* pan_tabs[GAMEPAD_NUMBER]; // Gamepad Tabs box + opPanel* m_pan_tabs[GAMEPAD_NUMBER]; // Gamepad Tabs box // Notebooks - wxNotebook* tab_gamepad; // Joysticks Tabs + wxNotebook* m_tab_gamepad; // Joysticks Tabs // Buttons - wxButton* bt_gamepad[GAMEPAD_NUMBER][BUTTONS_LENGHT]; // Joystick button use to modify the button mapping + wxButton* m_bt_gamepad[GAMEPAD_NUMBER][BUTTONS_LENGHT]; // Joystick button use to modify the button mapping // Contain all simulated key - u32 simulatedKeys[GAMEPAD_NUMBER][MAX_KEYS]; + u32 m_simulatedKeys[GAMEPAD_NUMBER][MAX_KEYS]; // Timer - wxTimer time_update_gui; + wxTimer m_time_update_gui; // Check if the gui must display feddback image - bool pressed[GAMEPAD_NUMBER][NB_IMG]; + bool m_pressed[GAMEPAD_NUMBER][NB_IMG]; // Map the key pressed with the feedback image id - std::map map_images[GAMEPAD_NUMBER]; + std::map m_map_images[GAMEPAD_NUMBER]; // Frame - GamepadConfiguration* frm_gamepad_config; // Gamepad Configuration frame - JoystickConfiguration* frm_joystick_config; // Joystick Configuration frame + GamepadConfiguration* m_frm_gamepad_config; // Gamepad Configuration frame + JoystickConfiguration* m_frm_joystick_config; // Joystick Configuration frame // methods void config_key(int, int);