mirror of https://github.com/PCSX2/pcsx2.git
Pad: Don't `Destroy()` modals
On macOS it prevents the parent window from regaining focus Also remove OK/Cancel buttons JoystickConfiguration, they already obey the Cancel/Apply/OK of the parent
This commit is contained in:
parent
1470315356
commit
4890a26ae0
|
@ -49,9 +49,6 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow* parent)
|
|||
gamepad_box->Add(rumble_box, wxSizerFlags().Expand().Border(wxALL, 5));
|
||||
gamepad_box->Add(joy_box, wxSizerFlags().Expand().Border(wxALL, 5));
|
||||
|
||||
gamepad_box->Add(CreateSeparatedButtonSizer(wxOK), wxSizerFlags().Right().Border(wxALL, 5));
|
||||
|
||||
Bind(wxEVT_BUTTON, &GamepadConfiguration::OnOk, this, wxID_OK);
|
||||
Bind(wxEVT_SCROLL_THUMBRELEASE, &GamepadConfiguration::OnSliderReleased, this);
|
||||
Bind(wxEVT_CHECKBOX, &GamepadConfiguration::OnCheckboxChange, this);
|
||||
Bind(wxEVT_CHOICE, &GamepadConfiguration::OnChoiceChange, this);
|
||||
|
@ -99,11 +96,6 @@ void GamepadConfiguration::InitGamepadConfiguration()
|
|||
}
|
||||
}
|
||||
|
||||
void GamepadConfiguration::OnOk(wxCommandEvent& event)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Slider event, called when the use release the slider button
|
||||
* @FIXME The current solution can't change the joystick sensibility and the rumble intensity
|
||||
|
|
|
@ -40,7 +40,6 @@ class GamepadConfiguration : public wxDialog
|
|||
void repopulate();
|
||||
|
||||
// Events
|
||||
void OnOk(wxCommandEvent&);
|
||||
void OnSliderReleased(wxCommandEvent&);
|
||||
void OnCheckboxChange(wxCommandEvent&);
|
||||
void OnChoiceChange(wxCommandEvent&);
|
||||
|
|
|
@ -15,15 +15,15 @@
|
|||
|
||||
#include "JoystickConfiguration.h"
|
||||
|
||||
static const s32 x_check_id = wxID_HIGHEST + 100 + 1;
|
||||
static const s32 y_check_id = wxID_HIGHEST + 100 + 2;
|
||||
static const s32 joy_check_id = wxID_HIGHEST + 100 + 3;
|
||||
|
||||
// Constructor of JoystickConfiguration
|
||||
JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow* parent)
|
||||
: wxDialog(parent, wxID_ANY, _T("Joystick configuration"), wxDefaultPosition, wxDefaultSize,
|
||||
wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
|
||||
{
|
||||
m_init_reverse_Lx = m_init_reverse_Ly =
|
||||
m_init_reverse_Rx = m_init_reverse_Ry =
|
||||
m_init_mouse_Ljoy = m_init_mouse_Rjoy = false;
|
||||
|
||||
m_pad_id = pad;
|
||||
m_isForLeftJoystick = left;
|
||||
|
||||
|
@ -31,33 +31,21 @@ JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow* paren
|
|||
|
||||
if (m_isForLeftJoystick)
|
||||
{
|
||||
m_cb_reverse_Lx = new wxCheckBox(this, Lx_check_id, _T("Reverse Lx"));
|
||||
m_cb_reverse_Ly = new wxCheckBox(this, Ly_check_id, _T("Reverse Ly"));
|
||||
m_cb_mouse_Ljoy = new wxCheckBox(this, Ljoy_check_id, _T("Use mouse for left analog joystick"));
|
||||
|
||||
joy_conf_box->Add(m_cb_reverse_Lx, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||
joy_conf_box->Add(m_cb_reverse_Ly, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||
joy_conf_box->Add(m_cb_mouse_Ljoy, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||
|
||||
m_cb_reverse_Rx = m_cb_reverse_Ry = m_cb_mouse_Rjoy = nullptr;
|
||||
m_cb_reverse_x = new wxCheckBox(this, x_check_id, _T("Reverse Lx"));
|
||||
m_cb_reverse_y = new wxCheckBox(this, y_check_id, _T("Reverse Ly"));
|
||||
m_cb_mouse_joy = new wxCheckBox(this, joy_check_id, _T("Use mouse for left analog joystick"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cb_reverse_Rx = new wxCheckBox(this, Rx_check_id, _T("Reverse Rx"));
|
||||
m_cb_reverse_Ry = new wxCheckBox(this, Ry_check_id, _T("Reverse Ry"));
|
||||
m_cb_mouse_Rjoy = new wxCheckBox(this, Rjoy_check_id, _T("Use mouse for right analog joystick"));
|
||||
|
||||
joy_conf_box->Add(m_cb_reverse_Rx, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||
joy_conf_box->Add(m_cb_reverse_Ry, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||
joy_conf_box->Add(m_cb_mouse_Rjoy, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||
|
||||
m_cb_reverse_Lx = m_cb_reverse_Ly = m_cb_mouse_Ljoy = nullptr;
|
||||
m_cb_reverse_x = new wxCheckBox(this, x_check_id, _T("Reverse Rx"));
|
||||
m_cb_reverse_y = new wxCheckBox(this, y_check_id, _T("Reverse Ry"));
|
||||
m_cb_mouse_joy = new wxCheckBox(this, joy_check_id, _T("Use mouse for right analog joystick"));
|
||||
}
|
||||
|
||||
joy_conf_box->Add(CreateSeparatedButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Border(wxALL, 5).Right());
|
||||
joy_conf_box->Add(m_cb_reverse_x, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||
joy_conf_box->Add(m_cb_reverse_y, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||
joy_conf_box->Add(m_cb_mouse_joy, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||
|
||||
Bind(wxEVT_BUTTON, &JoystickConfiguration::OnOk, this, wxID_OK);
|
||||
Bind(wxEVT_BUTTON, &JoystickConfiguration::OnCancel, this, wxID_CANCEL);
|
||||
Bind(wxEVT_CHECKBOX, &JoystickConfiguration::OnCheckboxChange, this);
|
||||
|
||||
SetSizerAndFit(joy_conf_box);
|
||||
|
@ -84,30 +72,11 @@ void JoystickConfiguration::InitJoystickConfiguration()
|
|||
wxMessageBox(L"No second gamepad detected.");
|
||||
|
||||
// disable all checkboxes
|
||||
if (m_isForLeftJoystick)
|
||||
{
|
||||
m_cb_reverse_Lx->Disable();
|
||||
m_cb_reverse_Ly->Disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cb_reverse_Rx->Disable();
|
||||
m_cb_reverse_Ry->Disable();
|
||||
}
|
||||
m_cb_reverse_y->Disable();
|
||||
m_cb_reverse_x->Disable();
|
||||
}
|
||||
}
|
||||
|
||||
void JoystickConfiguration::OnOk(wxCommandEvent& event)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void JoystickConfiguration::OnCancel(wxCommandEvent& event)
|
||||
{
|
||||
reset();
|
||||
Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkbox event, called when the value of the checkbox change
|
||||
*/
|
||||
|
@ -120,16 +89,16 @@ void JoystickConfiguration::OnCheckboxChange(wxCommandEvent& event)
|
|||
{
|
||||
switch (cb_id)
|
||||
{
|
||||
case Lx_check_id:
|
||||
g_conf.pad_options[m_pad_id].reverse_lx = m_cb_reverse_Lx->GetValue();
|
||||
case x_check_id:
|
||||
g_conf.pad_options[m_pad_id].reverse_lx = m_cb_reverse_x->GetValue();
|
||||
break;
|
||||
|
||||
case Ly_check_id:
|
||||
g_conf.pad_options[m_pad_id].reverse_ly = m_cb_reverse_Ly->GetValue();
|
||||
case y_check_id:
|
||||
g_conf.pad_options[m_pad_id].reverse_ly = m_cb_reverse_y->GetValue();
|
||||
break;
|
||||
|
||||
case Ljoy_check_id:
|
||||
g_conf.pad_options[m_pad_id].mouse_l = m_cb_mouse_Ljoy->GetValue();
|
||||
case joy_check_id:
|
||||
g_conf.pad_options[m_pad_id].mouse_l = m_cb_mouse_joy->GetValue();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -140,16 +109,16 @@ void JoystickConfiguration::OnCheckboxChange(wxCommandEvent& event)
|
|||
{
|
||||
switch (cb_id)
|
||||
{
|
||||
case Rx_check_id:
|
||||
g_conf.pad_options[m_pad_id].reverse_rx = m_cb_reverse_Rx->GetValue();
|
||||
case x_check_id:
|
||||
g_conf.pad_options[m_pad_id].reverse_rx = m_cb_reverse_x->GetValue();
|
||||
break;
|
||||
|
||||
case Ry_check_id:
|
||||
g_conf.pad_options[m_pad_id].reverse_ry = m_cb_reverse_Ry->GetValue();
|
||||
case y_check_id:
|
||||
g_conf.pad_options[m_pad_id].reverse_ry = m_cb_reverse_y->GetValue();
|
||||
break;
|
||||
|
||||
case Rjoy_check_id:
|
||||
g_conf.pad_options[m_pad_id].mouse_r = m_cb_mouse_Rjoy->GetValue();
|
||||
case joy_check_id:
|
||||
g_conf.pad_options[m_pad_id].mouse_r = m_cb_mouse_joy->GetValue();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -162,46 +131,19 @@ void JoystickConfiguration::OnCheckboxChange(wxCommandEvent& event)
|
|||
/*********** Methods functions **********/
|
||||
/****************************************/
|
||||
|
||||
// Reset checkbox and slider values
|
||||
void JoystickConfiguration::reset()
|
||||
{
|
||||
if (m_isForLeftJoystick)
|
||||
{
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Set button values
|
||||
void JoystickConfiguration::repopulate()
|
||||
{
|
||||
if (m_isForLeftJoystick)
|
||||
{
|
||||
m_init_reverse_Lx = g_conf.pad_options[m_pad_id].reverse_lx;
|
||||
m_cb_reverse_Lx->SetValue(m_init_reverse_Lx);
|
||||
|
||||
m_init_reverse_Ly = g_conf.pad_options[m_pad_id].reverse_ly;
|
||||
m_cb_reverse_Ly->SetValue(m_init_reverse_Ly);
|
||||
|
||||
m_init_mouse_Ljoy = g_conf.pad_options[m_pad_id].mouse_l;
|
||||
m_cb_mouse_Ljoy->SetValue(m_init_mouse_Ljoy);
|
||||
m_cb_reverse_x->SetValue(g_conf.pad_options[m_pad_id].reverse_lx);
|
||||
m_cb_reverse_y->SetValue(g_conf.pad_options[m_pad_id].reverse_ly);
|
||||
m_cb_mouse_joy->SetValue(g_conf.pad_options[m_pad_id].mouse_l);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_init_reverse_Rx = g_conf.pad_options[m_pad_id].reverse_rx;
|
||||
m_cb_reverse_Rx->SetValue(m_init_reverse_Rx);
|
||||
|
||||
m_init_reverse_Ry = g_conf.pad_options[m_pad_id].reverse_ry;
|
||||
m_cb_reverse_Ry->SetValue(m_init_reverse_Ry);
|
||||
|
||||
m_init_mouse_Rjoy = g_conf.pad_options[m_pad_id].mouse_r;
|
||||
m_cb_mouse_Rjoy->SetValue(m_init_mouse_Rjoy);
|
||||
m_cb_reverse_x->SetValue(g_conf.pad_options[m_pad_id].reverse_rx);
|
||||
m_cb_reverse_y->SetValue(g_conf.pad_options[m_pad_id].reverse_ry);
|
||||
m_cb_mouse_joy->SetValue(g_conf.pad_options[m_pad_id].mouse_r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,33 +24,20 @@
|
|||
#include "../keyboard.h"
|
||||
#include "../PAD.h"
|
||||
|
||||
static const s32 Lx_check_id = wxID_HIGHEST + 100 + 1;
|
||||
static const s32 Ly_check_id = wxID_HIGHEST + 100 + 2;
|
||||
static const s32 Ljoy_check_id = wxID_HIGHEST + 100 + 3;
|
||||
|
||||
static const s32 Rx_check_id = wxID_HIGHEST + 100 + 4;
|
||||
static const s32 Ry_check_id = wxID_HIGHEST + 100 + 5;
|
||||
static const s32 Rjoy_check_id = wxID_HIGHEST + 100 + 6;
|
||||
|
||||
class JoystickConfiguration : public wxDialog
|
||||
{
|
||||
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
|
||||
wxCheckBox *m_cb_reverse_x, *m_cb_reverse_y,
|
||||
*m_cb_mouse_joy; // Use mouse for joystick
|
||||
|
||||
u32 m_pad_id;
|
||||
// isForLeftJoystick -> true is for Left Joystick, false is for Right Joystick
|
||||
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;
|
||||
bool m_isForLeftJoystick;
|
||||
|
||||
// Methods
|
||||
void repopulate();
|
||||
void reset();
|
||||
|
||||
// Events
|
||||
void OnCheckboxChange(wxCommandEvent&);
|
||||
void OnOk(wxCommandEvent&);
|
||||
void OnCancel(wxCommandEvent&);
|
||||
|
||||
public:
|
||||
JoystickConfiguration(int, bool, wxWindow*);
|
||||
|
|
Loading…
Reference in New Issue