1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-24 19:52:37 +01:00

GUI: Pad Settings dialog reworked.

This commit is contained in:
O1L 2014-04-05 18:26:45 +04:00
parent 3bcf5d1557
commit bbbe2f8916
7 changed files with 738 additions and 227 deletions

View File

@ -39,27 +39,27 @@ public:
CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE,
CELL_PAD_DEV_TYPE_STANDARD));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, static_cast<char>(Ini.PadHandlerLeft.GetValue()), CELL_PAD_CTRL_LEFT));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, static_cast<char>(Ini.PadHandlerDown.GetValue()), CELL_PAD_CTRL_DOWN));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, static_cast<char>(Ini.PadHandlerRight.GetValue()), CELL_PAD_CTRL_RIGHT));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, static_cast<char>(Ini.PadHandlerUp.GetValue()), CELL_PAD_CTRL_UP));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, WXK_RETURN, CELL_PAD_CTRL_START));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, static_cast<char>(Ini.PadHandlerR3.GetValue()), CELL_PAD_CTRL_R3));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, static_cast<char>(Ini.PadHandlerL3.GetValue()), CELL_PAD_CTRL_L3));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, WXK_SPACE, CELL_PAD_CTRL_SELECT));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerLeft.GetValue(), CELL_PAD_CTRL_LEFT));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerDown.GetValue(), CELL_PAD_CTRL_DOWN));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerRight.GetValue(), CELL_PAD_CTRL_RIGHT));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerUp.GetValue(), CELL_PAD_CTRL_UP));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerStart.GetValue(), CELL_PAD_CTRL_START));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerR3.GetValue(), CELL_PAD_CTRL_R3));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerL3.GetValue(), CELL_PAD_CTRL_L3));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerSelect.GetValue(), CELL_PAD_CTRL_SELECT));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, static_cast<char>(Ini.PadHandlerSquare.GetValue()), CELL_PAD_CTRL_SQUARE));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, static_cast<char>(Ini.PadHandlerCross.GetValue()), CELL_PAD_CTRL_CROSS));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, static_cast<char>(Ini.PadHandlerCircle.GetValue()), CELL_PAD_CTRL_CIRCLE));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, static_cast<char>(Ini.PadHandlerTriangle.GetValue()), CELL_PAD_CTRL_TRIANGLE));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, static_cast<char>(Ini.PadHandlerR1.GetValue()), CELL_PAD_CTRL_R1));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, static_cast<char>(Ini.PadHandlerL1.GetValue()), CELL_PAD_CTRL_L1));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, static_cast<char>(Ini.PadHandlerR2.GetValue()), CELL_PAD_CTRL_R2));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, static_cast<char>(Ini.PadHandlerL2.GetValue()), CELL_PAD_CTRL_L2));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerSquare.GetValue(), CELL_PAD_CTRL_SQUARE));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerCross.GetValue(), CELL_PAD_CTRL_CROSS));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerCircle.GetValue(), CELL_PAD_CTRL_CIRCLE));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerTriangle.GetValue(), CELL_PAD_CTRL_TRIANGLE));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerR1.GetValue(), CELL_PAD_CTRL_R1));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerL1.GetValue(), CELL_PAD_CTRL_L1));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerR2.GetValue(), CELL_PAD_CTRL_R2));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerL2.GetValue(), CELL_PAD_CTRL_L2));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X, WXK_LEFT, WXK_RIGHT));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y, WXK_UP, WXK_DOWN));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X, WXK_HOME, WXK_END));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y, WXK_PAGEUP, WXK_PAGEDOWN));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X, Ini.PadHandlerLStickLeft.GetValue(), Ini.PadHandlerLStickRight.GetValue()));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y, Ini.PadHandlerLStickUp.GetValue(), Ini.PadHandlerLStickDown.GetValue()));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X, Ini.PadHandlerRStickLeft.GetValue(), Ini.PadHandlerRStickRight.GetValue()));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y, Ini.PadHandlerRStickUp.GetValue(), Ini.PadHandlerRStickDown.GetValue()));
}
};

View File

@ -3,6 +3,7 @@
#include "CompilerELF.h"
#include "MemoryViewer.h"
#include "RSXDebugger.h"
#include "PADManager.h"
#include "git-version.h"
#include "Ini.h"
@ -38,26 +39,6 @@ enum IDs
id_update_dbg,
};
enum PadIDs
{
id_pad_left,
id_pad_down,
id_pad_right,
id_pad_up,
id_pad_start,
id_pad_r3,
id_pad_l3,
id_pad_select,
id_pad_square,
id_pad_cross,
id_pad_circle,
id_pad_triangle,
id_pad_r1,
id_pad_l1,
id_pad_r2,
id_pad_l2,
};
wxString GetPaneName()
{
static int pane_num = 0;
@ -574,189 +555,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
void MainFrame::ConfigPad(wxCommandEvent& WXUNUSED(event))
{
bool paused = false;
if(Emu.IsRunning())
{
Emu.Pause();
paused = true;
}
wxDialog diag(this, wxID_ANY, "PAD Settings", wxDefaultPosition);
wxBoxSizer* s_panel(new wxBoxSizer(wxHORIZONTAL));
wxBoxSizer* s_subpanel1(new wxBoxSizer(wxVERTICAL));
wxBoxSizer* s_subpanel2(new wxBoxSizer(wxVERTICAL));
wxBoxSizer* s_subpanel3(new wxBoxSizer(wxVERTICAL));
wxBoxSizer* s_subpanel4(new wxBoxSizer(wxVERTICAL));
wxBoxSizer* s_subpanel5(new wxBoxSizer(wxVERTICAL));
wxStaticBoxSizer* s_round_pad_controls( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Controls") ) );
wxStaticBoxSizer* s_round_pad_left( new wxStaticBoxSizer( wxVERTICAL, &diag, _("LEFT") ) );
wxStaticBoxSizer* s_round_pad_down( new wxStaticBoxSizer( wxVERTICAL, &diag, _("DOWN") ) );
wxStaticBoxSizer* s_round_pad_right( new wxStaticBoxSizer( wxVERTICAL, &diag, _("RIGHT") ) );
wxStaticBoxSizer* s_round_pad_up( new wxStaticBoxSizer( wxVERTICAL, &diag, _("UP") ) );
wxStaticBoxSizer* s_round_pad_shifts_l( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Shifts") ) );
wxStaticBoxSizer* s_round_pad_l1( new wxStaticBoxSizer( wxVERTICAL, &diag, _("L1") ) );
wxStaticBoxSizer* s_round_pad_l2( new wxStaticBoxSizer( wxVERTICAL, &diag, _("L2") ) );
wxStaticBoxSizer* s_round_pad_l3( new wxStaticBoxSizer( wxVERTICAL, &diag, _("L3") ) );
wxStaticBoxSizer* s_round_pad_system( new wxStaticBoxSizer( wxVERTICAL, &diag, _("System") ) );
wxStaticBoxSizer* s_round_pad_select( new wxStaticBoxSizer( wxVERTICAL, &diag, _("SELECT") ) );
wxStaticBoxSizer* s_round_pad_start( new wxStaticBoxSizer( wxVERTICAL, &diag, _("START") ) );
wxStaticBoxSizer* s_round_pad_shifts_r( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Shifts") ) );
wxStaticBoxSizer* s_round_pad_r1( new wxStaticBoxSizer( wxVERTICAL, &diag, _("R1") ) );
wxStaticBoxSizer* s_round_pad_r2( new wxStaticBoxSizer( wxVERTICAL, &diag, _("R2") ) );
wxStaticBoxSizer* s_round_pad_r3( new wxStaticBoxSizer( wxVERTICAL, &diag, _("R3") ) );
wxStaticBoxSizer* s_round_pad_buttons( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Buttons") ) );
wxStaticBoxSizer* s_round_pad_square( new wxStaticBoxSizer( wxVERTICAL, &diag, _("SQUARE") ) );
wxStaticBoxSizer* s_round_pad_cross( new wxStaticBoxSizer( wxVERTICAL, &diag, _("CROSS") ) );
wxStaticBoxSizer* s_round_pad_circle( new wxStaticBoxSizer( wxVERTICAL, &diag, _("CIRCLE") ) );
wxStaticBoxSizer* s_round_pad_triangle( new wxStaticBoxSizer( wxVERTICAL, &diag, _("TRIANGLE") ) );
wxComboBox* cbox_pad_left = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_down = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_right = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_up = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_start = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_r3 = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_l3 = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_select = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_square = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_cross = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_circle = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_triangle = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_r1 = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_l1 = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_r2 = new wxComboBox(&diag, wxID_ANY);
wxComboBox* cbox_pad_l2 = new wxComboBox(&diag, wxID_ANY);
for(int i=0; i<128; i++)
{
cbox_pad_left->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_down->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_right->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_up->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_r3->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_l3->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_square->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_cross->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_circle->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_triangle->Append(wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_r1->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_l1->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_r2->Append (wxString::Format("%c", static_cast<char>(i) ) );
cbox_pad_l2->Append (wxString::Format("%c", static_cast<char>(i) ) );
}
cbox_pad_start->Append("Enter");
cbox_pad_select->Append("Space");
cbox_pad_left->SetSelection (Ini.PadHandlerLeft.GetValue());
cbox_pad_down->SetSelection (Ini.PadHandlerDown.GetValue());
cbox_pad_right->SetSelection (Ini.PadHandlerRight.GetValue());
cbox_pad_up->SetSelection (Ini.PadHandlerUp.GetValue());
cbox_pad_start->SetSelection (Ini.PadHandlerStart.GetValue());
cbox_pad_r3->SetSelection (Ini.PadHandlerR3.GetValue());
cbox_pad_l3->SetSelection (Ini.PadHandlerL3.GetValue());
cbox_pad_select->SetSelection (Ini.PadHandlerSelect.GetValue());
cbox_pad_square->SetSelection (Ini.PadHandlerSquare.GetValue());
cbox_pad_cross->SetSelection (Ini.PadHandlerCross.GetValue());
cbox_pad_circle->SetSelection (Ini.PadHandlerCircle.GetValue());
cbox_pad_triangle->SetSelection (Ini.PadHandlerTriangle.GetValue());
cbox_pad_r1->SetSelection (Ini.PadHandlerR1.GetValue());
cbox_pad_l1->SetSelection (Ini.PadHandlerL1.GetValue());
cbox_pad_r2->SetSelection (Ini.PadHandlerR2.GetValue());
cbox_pad_l2->SetSelection (Ini.PadHandlerL2.GetValue());
s_round_pad_left->Add(cbox_pad_left, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_down->Add(cbox_pad_down, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_right->Add(cbox_pad_right, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_up->Add(cbox_pad_up, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_start->Add(cbox_pad_start, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_r3->Add(cbox_pad_r3, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_l3->Add(cbox_pad_l3, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_select->Add(cbox_pad_select, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_square->Add(cbox_pad_square, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_cross->Add(cbox_pad_cross, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_circle->Add(cbox_pad_circle, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_triangle->Add(cbox_pad_triangle, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_r1->Add(cbox_pad_r1, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_l1->Add(cbox_pad_l1, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_r2->Add(cbox_pad_r2, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_l2->Add(cbox_pad_l2, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_controls->Add(s_round_pad_left, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_controls->Add(s_round_pad_down, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_controls->Add(s_round_pad_right, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_controls->Add(s_round_pad_up, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_shifts_l->Add(s_round_pad_l1, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_shifts_l->Add(s_round_pad_l2, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_shifts_l->Add(s_round_pad_l3, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_system->Add(s_round_pad_start, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_system->Add(s_round_pad_select, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_shifts_r->Add(s_round_pad_r1, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_shifts_r->Add(s_round_pad_r2, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_shifts_r->Add(s_round_pad_r3, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_buttons->Add(s_round_pad_square, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_buttons->Add(s_round_pad_cross, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_buttons->Add(s_round_pad_circle, wxSizerFlags().Border(wxALL, 5).Expand());
s_round_pad_buttons->Add(s_round_pad_triangle, wxSizerFlags().Border(wxALL, 5).Expand());
wxBoxSizer* s_b_panel(new wxBoxSizer(wxHORIZONTAL));
s_b_panel->Add(new wxButton(&diag, wxID_OK), wxSizerFlags().Border(wxALL, 5).Center());
s_b_panel->Add(new wxButton(&diag, wxID_CANCEL), wxSizerFlags().Border(wxALL, 5).Center());
s_subpanel1->Add(s_round_pad_controls, wxSizerFlags().Border(wxALL, 5).Expand());
s_subpanel2->Add(s_round_pad_shifts_l, wxSizerFlags().Border(wxALL, 5).Expand());
s_subpanel3->Add(s_round_pad_system, wxSizerFlags().Border(wxALL, 5).Expand());
s_subpanel3->Add(s_b_panel, wxSizerFlags().Border(wxALL, 8).Expand());
s_subpanel4->Add(s_round_pad_shifts_r, wxSizerFlags().Border(wxALL, 5).Expand());
s_subpanel5->Add(s_round_pad_buttons, wxSizerFlags().Border(wxALL, 5).Expand());
s_panel->Add(s_subpanel1, wxSizerFlags().Border(wxALL, 5).Expand());
s_panel->Add(s_subpanel2, wxSizerFlags().Border(wxALL, 5).Expand());
s_panel->Add(s_subpanel3, wxSizerFlags().Border(wxALL, 5).Expand());
s_panel->Add(s_subpanel4, wxSizerFlags().Border(wxALL, 5).Expand());
s_panel->Add(s_subpanel5, wxSizerFlags().Border(wxALL, 5).Expand());
diag.SetSizerAndFit( s_panel );
if(diag.ShowModal() == wxID_OK)
{
Ini.PadHandlerLeft.SetValue(cbox_pad_left->GetSelection());
Ini.PadHandlerDown.SetValue(cbox_pad_down->GetSelection());
Ini.PadHandlerRight.SetValue(cbox_pad_right->GetSelection());
Ini.PadHandlerUp.SetValue(cbox_pad_up->GetSelection());
Ini.PadHandlerStart.SetValue(cbox_pad_start->GetSelection());
Ini.PadHandlerR3.SetValue(cbox_pad_r3->GetSelection());
Ini.PadHandlerL3.SetValue(cbox_pad_l3->GetSelection());
Ini.PadHandlerSelect.SetValue(cbox_pad_select->GetSelection());
Ini.PadHandlerSquare.SetValue(cbox_pad_square->GetSelection());
Ini.PadHandlerCross.SetValue(cbox_pad_cross->GetSelection());
Ini.PadHandlerCircle.SetValue(cbox_pad_circle->GetSelection());
Ini.PadHandlerTriangle.SetValue(cbox_pad_triangle->GetSelection());
Ini.PadHandlerR1.SetValue(cbox_pad_r1->GetSelection());
Ini.PadHandlerL1.SetValue(cbox_pad_l1->GetSelection());
Ini.PadHandlerR2.SetValue(cbox_pad_r2->GetSelection());
Ini.PadHandlerL2.SetValue(cbox_pad_l2->GetSelection());
Ini.Save();
}
if(paused) Emu.Resume();
PADManager(this).ShowModal();
}
void MainFrame::ConfigVFS(wxCommandEvent& WXUNUSED(event))

573
rpcs3/Gui/PADManager.cpp Normal file
View File

@ -0,0 +1,573 @@
#include "stdafx.h"
#include "PADManager.h"
PADManager::PADManager(wxWindow* parent)
: wxDialog(parent, wxID_ANY, "PAD Settings", wxDefaultPosition)
, m_button_id(0)
, m_key_pressed(false)
{
bool paused = false;
if(Emu.IsRunning())
{
Emu.Pause();
paused = true;
}
wxBoxSizer* s_panel(new wxBoxSizer(wxHORIZONTAL));
wxBoxSizer* s_subpanel(new wxBoxSizer(wxVERTICAL));
wxBoxSizer* s_subpanel2(new wxBoxSizer(wxVERTICAL));
// Left Analog Stick
wxStaticBoxSizer* s_round_stick_l( new wxStaticBoxSizer( wxVERTICAL, this, _("Left Analog Stick") ) );
wxBoxSizer* s_subpanel_lstick_1( new wxBoxSizer( wxVERTICAL) );
wxBoxSizer* s_subpanel_lstick_2( new wxBoxSizer( wxHORIZONTAL) );
wxBoxSizer* s_subpanel_lstick_3( new wxBoxSizer( wxVERTICAL) );
// D-Pad
wxStaticBoxSizer* s_round_pad_controls( new wxStaticBoxSizer( wxVERTICAL, this, _("D-Pad") ) );
wxBoxSizer* s_subpanel_pad_1( new wxBoxSizer( wxVERTICAL) );
wxBoxSizer* s_subpanel_pad_2( new wxBoxSizer( wxHORIZONTAL) );
wxBoxSizer* s_subpanel_pad_3( new wxBoxSizer( wxVERTICAL) );
// Left shifts
wxStaticBoxSizer* s_round_pad_shifts_l( new wxStaticBoxSizer( wxVERTICAL, this, _("Left Shifts") ) );
wxStaticBoxSizer* s_round_pad_l1( new wxStaticBoxSizer( wxVERTICAL, this, _("L1") ) );
wxStaticBoxSizer* s_round_pad_l2( new wxStaticBoxSizer( wxVERTICAL, this, _("L2") ) );
wxStaticBoxSizer* s_round_pad_l3( new wxStaticBoxSizer( wxVERTICAL, this, _("L3") ) );
// Start / Select
wxStaticBoxSizer* s_round_pad_system( new wxStaticBoxSizer( wxVERTICAL, this, _("System") ) );
wxStaticBoxSizer* s_round_pad_select( new wxStaticBoxSizer( wxVERTICAL, this, _("Select") ) );
wxStaticBoxSizer* s_round_pad_start( new wxStaticBoxSizer( wxVERTICAL, this, _("Start") ) );
// Right shifts
wxStaticBoxSizer* s_round_pad_shifts_r( new wxStaticBoxSizer( wxVERTICAL, this, _("Right Shifts") ) );
wxStaticBoxSizer* s_round_pad_r1( new wxStaticBoxSizer( wxVERTICAL, this, _("R1") ) );
wxStaticBoxSizer* s_round_pad_r2( new wxStaticBoxSizer( wxVERTICAL, this, _("R2") ) );
wxStaticBoxSizer* s_round_pad_r3( new wxStaticBoxSizer( wxVERTICAL, this, _("R3") ) );
// Action buttons
wxStaticBoxSizer* s_round_pad_buttons( new wxStaticBoxSizer( wxVERTICAL, this, _("Buttons") ) );
wxStaticBoxSizer* s_round_pad_square( new wxStaticBoxSizer( wxVERTICAL, this, _("Square") ) );
wxStaticBoxSizer* s_round_pad_cross( new wxStaticBoxSizer( wxVERTICAL, this, _("Cross") ) );
wxStaticBoxSizer* s_round_pad_circle( new wxStaticBoxSizer( wxVERTICAL, this, _("Circle") ) );
wxStaticBoxSizer* s_round_pad_triangle( new wxStaticBoxSizer( wxVERTICAL, this, _("Triangle") ) );
wxBoxSizer* s_subpanel_buttons_1( new wxBoxSizer( wxVERTICAL) );
wxBoxSizer* s_subpanel_buttons_2( new wxBoxSizer( wxHORIZONTAL) );
wxBoxSizer* s_subpanel_buttons_3( new wxBoxSizer( wxVERTICAL) );
// Right Analog Stick
wxStaticBoxSizer* s_round_stick_r( new wxStaticBoxSizer( wxVERTICAL, this, _("Right Analog Stick") ) );
wxBoxSizer* s_subpanel_rstick_1( new wxBoxSizer( wxVERTICAL) );
wxBoxSizer* s_subpanel_rstick_2( new wxBoxSizer( wxHORIZONTAL) );
wxBoxSizer* s_subpanel_rstick_3( new wxBoxSizer( wxVERTICAL) );
// Ok / Cancel
wxBoxSizer* s_b_panel(new wxBoxSizer(wxHORIZONTAL));
wxBoxSizer* s_reset_panel(new wxBoxSizer(wxHORIZONTAL));
#define ButtonParameters wxEmptyString, wxDefaultPosition, wxSize(60,-1)
#define SizerFlags wxSizerFlags().Border(wxALL, 3).Center()
// Buttons
b_up_lstick = new wxButton(this, id_pad_lstick_up, ButtonParameters);
b_down_lstick = new wxButton(this, id_pad_lstick_down, ButtonParameters);
b_left_lstick = new wxButton(this, id_pad_lstick_left, ButtonParameters);
b_right_lstick = new wxButton(this, id_pad_lstick_right, ButtonParameters);
b_up = new wxButton(this, id_pad_up, ButtonParameters);
b_down = new wxButton(this, id_pad_down, ButtonParameters);
b_left = new wxButton(this, id_pad_left, ButtonParameters);
b_right = new wxButton(this, id_pad_right, ButtonParameters);
b_shift_l1 = new wxButton(this, id_pad_l1, ButtonParameters);
b_shift_l2 = new wxButton(this, id_pad_l2, ButtonParameters);
b_shift_l3 = new wxButton(this, id_pad_l3, ButtonParameters);
b_start = new wxButton(this, id_pad_start, ButtonParameters);
b_select = new wxButton(this, id_pad_select, ButtonParameters);
b_shift_r1 = new wxButton(this, id_pad_r1, ButtonParameters);
b_shift_r2 = new wxButton(this, id_pad_r2, ButtonParameters);
b_shift_r3 = new wxButton(this, id_pad_r3, ButtonParameters);
b_square = new wxButton(this, id_pad_square, ButtonParameters);
b_cross = new wxButton(this, id_pad_cross, ButtonParameters);
b_circle = new wxButton(this, id_pad_circle, ButtonParameters);
b_triangle = new wxButton(this, id_pad_triangle, ButtonParameters);
b_up_rstick = new wxButton(this, id_pad_rstick_up, ButtonParameters);
b_down_rstick = new wxButton(this, id_pad_rstick_down, ButtonParameters);
b_left_rstick = new wxButton(this, id_pad_rstick_left, ButtonParameters);
b_right_rstick = new wxButton(this, id_pad_rstick_right, ButtonParameters);
b_ok = new wxButton(this, wxID_OK, "OK", wxDefaultPosition, wxSize(60,-1));
b_cancel = new wxButton(this, wxID_CANCEL, "Cancel", wxDefaultPosition, wxSize(60,-1));
b_reset = new wxButton(this, id_reset_parameters, "By default");
// Get button labels from .ini
UpdateLabel();
// Add buttons in subpanels
// LStick
s_subpanel_lstick_1->Add(b_up_lstick);
s_subpanel_lstick_2->Add(b_left_lstick);
s_subpanel_lstick_2->Add(b_right_lstick);
s_subpanel_lstick_3->Add(b_down_lstick);
// D-Pad
s_subpanel_pad_1->Add(b_up);
s_subpanel_pad_2->Add(b_left);
s_subpanel_pad_2->Add(b_right);
s_subpanel_pad_3->Add(b_down);
// Left shifts
s_round_pad_l1->Add(b_shift_l1);
s_round_pad_l2->Add(b_shift_l2);
s_round_pad_l3->Add(b_shift_l3);
// Start / Select
s_round_pad_select->Add(b_select);
s_round_pad_start->Add(b_start);
// Right shifts
s_round_pad_r1->Add(b_shift_r1);
s_round_pad_r2->Add(b_shift_r2);
s_round_pad_r3->Add(b_shift_r3);
// Action buttons
s_round_pad_square->Add(b_square);
s_round_pad_cross->Add(b_cross);
s_round_pad_circle->Add(b_circle);
s_round_pad_triangle->Add(b_triangle);
s_subpanel_buttons_1->Add(s_round_pad_triangle);
s_subpanel_buttons_2->Add(s_round_pad_square);
s_subpanel_buttons_2->Add(s_round_pad_circle);
s_subpanel_buttons_3->Add(s_round_pad_cross);
// RStick
s_subpanel_rstick_1->Add(b_up_rstick);
s_subpanel_rstick_2->Add(b_left_rstick);
s_subpanel_rstick_2->Add(b_right_rstick);
s_subpanel_rstick_3->Add(b_down_rstick);
// Ok / Cancel
s_b_panel->Add(b_ok);
s_b_panel->Add(b_cancel);
// Reset parameters
s_reset_panel->Add(b_reset);
s_round_stick_l->Add(s_subpanel_lstick_1, SizerFlags);
s_round_stick_l->Add(s_subpanel_lstick_2, SizerFlags);
s_round_stick_l->Add(s_subpanel_lstick_3, SizerFlags);
s_round_pad_controls->Add(s_subpanel_pad_1, SizerFlags);
s_round_pad_controls->Add(s_subpanel_pad_2, SizerFlags);
s_round_pad_controls->Add(s_subpanel_pad_3, SizerFlags);
s_round_pad_shifts_l->Add(s_round_pad_l1, SizerFlags);
s_round_pad_shifts_l->Add(s_round_pad_l2, SizerFlags);
s_round_pad_shifts_l->Add(s_round_pad_l3, SizerFlags);
s_round_pad_system->Add(s_round_pad_select, SizerFlags);
s_round_pad_system->Add(s_round_pad_start, SizerFlags);
s_round_pad_shifts_r->Add(s_round_pad_r1, SizerFlags);
s_round_pad_shifts_r->Add(s_round_pad_r2, SizerFlags);
s_round_pad_shifts_r->Add(s_round_pad_r3, SizerFlags);
s_round_pad_buttons->Add(s_subpanel_buttons_1, SizerFlags);
s_round_pad_buttons->Add(s_subpanel_buttons_2, SizerFlags);
s_round_pad_buttons->Add(s_subpanel_buttons_3, SizerFlags);
s_round_stick_r->Add(s_subpanel_rstick_1, SizerFlags);
s_round_stick_r->Add(s_subpanel_rstick_2, SizerFlags);
s_round_stick_r->Add(s_subpanel_rstick_3, SizerFlags);
s_subpanel->Add(s_round_stick_l);
s_subpanel->AddSpacer(50);
s_subpanel->Add(s_b_panel, SizerFlags);
s_subpanel2->Add(s_round_pad_controls);
s_subpanel2->AddSpacer(50);
s_subpanel2->Add(s_reset_panel, SizerFlags);
// Add subpanels in general panel
s_panel->Add(s_subpanel);
s_panel->Add(s_subpanel2);
s_panel->Add(s_round_pad_shifts_l);
s_panel->Add(s_round_pad_system);
s_panel->Add(s_round_pad_shifts_r);
s_panel->Add(s_round_pad_buttons);
s_panel->Add(s_round_stick_r);
this->SetSizerAndFit(s_panel);
// Connect buttons
m_app_connector.Connect(wxID_ANY, wxEVT_KEY_UP, wxKeyEventHandler(PADManager::OnKeyUp), (wxObject*)0, this);
m_app_connector.Connect(wxID_ANY, wxEVT_KEY_DOWN, wxKeyEventHandler(PADManager::OnKeyDown), (wxObject*)0, this);
Connect(b_up_lstick->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_down_lstick->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_left_lstick->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_right_lstick->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_up->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (PADManager::OnButtonClicked));
Connect(b_down->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_left->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_right->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_shift_l1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_shift_l2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_shift_l3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_start->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_select->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_shift_r1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_shift_r2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_shift_r3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_square->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_cross->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_circle->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_triangle->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_up_rstick->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_down_rstick->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_left_rstick->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_right_rstick->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_ok->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_reset->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_cancel->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
if(paused) Emu.Resume();
}
void PADManager::OnKeyDown(wxKeyEvent &keyEvent)
{
m_key_pressed = true;
switch (m_button_id)
{
case id_pad_lstick_left: Ini.PadHandlerLStickLeft.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_lstick_down: Ini.PadHandlerLStickDown.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_lstick_right: Ini.PadHandlerLStickRight.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_lstick_up: Ini.PadHandlerLStickUp.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_left: Ini.PadHandlerLeft.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_down: Ini.PadHandlerDown.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_right: Ini.PadHandlerRight.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_up: Ini.PadHandlerUp.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_l1: Ini.PadHandlerL1.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_l2: Ini.PadHandlerL2.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_l3: Ini.PadHandlerL3.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_start: Ini.PadHandlerStart.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_select: Ini.PadHandlerSelect.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_r1: Ini.PadHandlerR1.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_r2: Ini.PadHandlerR2.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_r3: Ini.PadHandlerR3.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_square: Ini.PadHandlerSquare.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_cross: Ini.PadHandlerCross.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_circle: Ini.PadHandlerCircle.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_triangle: Ini.PadHandlerTriangle.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_rstick_left: Ini.PadHandlerRStickLeft.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_rstick_down: Ini.PadHandlerRStickDown.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_rstick_right: Ini.PadHandlerRStickRight.SetValue(keyEvent.GetKeyCode()); break;
case id_pad_rstick_up: Ini.PadHandlerRStickUp.SetValue(keyEvent.GetKeyCode()); break;
case 0: break;
default: ConLog.Error("Unknown button ID: %d", m_button_id); break;
}
UpdateLabel();
keyEvent.Skip();
}
void PADManager::OnKeyUp(wxKeyEvent &keyEvent)
{
SwitchButtons(true); // enable all buttons
m_button_id = 0; // reset current button id
m_key_pressed = false;
keyEvent.Skip();
}
void PADManager::OnButtonClicked(wxCommandEvent &event)
{
if (event.GetId() != wxID_OK && event.GetId() != wxID_CANCEL && event.GetId() != id_reset_parameters)
{
m_button_id = event.GetId();
SwitchButtons(false); // disable all buttons, needed for using Space, Enter and other specific buttons
//RunTimer(3, event.GetId()); // TODO: Currently, timer disabled. Use by later, have some strange problems
//SwitchButtons(true); // needed, if timer enabled
UpdateLabel();
}
else
{
switch (event.GetId())
{
case id_reset_parameters: ResetParameters(); UpdateLabel(); break;
case wxID_OK: Ini.Save(); break;
case wxID_CANCEL: break;
default: ConLog.Error("Unknown button ID: %d", event.GetId()); break;
}
}
event.Skip();
}
const wxString PADManager::GetKeyName(const u32 keyCode)
{
wxString keyName;
switch(keyCode)
{
case WXK_NONE: ConLog.Error("Invalid key code"); keyName = "ERROR!"; break;
case WXK_BACK: keyName = "BackSpace"; break;
case WXK_TAB: keyName = "Tab"; break;
case WXK_RETURN: keyName = "Enter"; break;
case WXK_ESCAPE: keyName = "Esc"; break;
case WXK_SPACE: keyName = "Space"; break;
case WXK_DELETE: keyName = "Delete"; break;
case WXK_SHIFT: keyName = "Shift"; break;
case WXK_ALT: keyName = "ALT"; break;
case WXK_CONTROL: keyName = "CTRL"; break;
case WXK_PAUSE: keyName = "Pause"; break;
case WXK_CAPITAL: keyName = "CapsLock"; break;
case WXK_END: keyName = "End"; break;
case WXK_HOME: keyName = "Home"; break;
case WXK_LEFT: keyName = "Left"; break;
case WXK_UP: keyName = "Up"; break;
case WXK_RIGHT: keyName = "Right"; break;
case WXK_DOWN: keyName = "Down"; break;
case WXK_SELECT: keyName = "Select"; break;
case WXK_PRINT: keyName = "Print"; break;
case WXK_SNAPSHOT: keyName = "Snapshot"; break;
case WXK_INSERT: keyName = "Insert"; break;
case WXK_NUMPAD0: keyName = "Num0"; break;
case WXK_NUMPAD1: keyName = "Num1"; break;
case WXK_NUMPAD2: keyName = "Num2"; break;
case WXK_NUMPAD3: keyName = "Num3"; break;
case WXK_NUMPAD4: keyName = "Num4"; break;
case WXK_NUMPAD5: keyName = "Num5"; break;
case WXK_NUMPAD6: keyName = "Num6"; break;
case WXK_NUMPAD7: keyName = "Num7"; break;
case WXK_NUMPAD8: keyName = "Num8"; break;
case WXK_NUMPAD9: keyName = "Num9"; break;
case WXK_F1: keyName = "F1"; break;
case WXK_F2: keyName = "F2"; break;
case WXK_F3: keyName = "F3"; break;
case WXK_F4: keyName = "F4"; break;
case WXK_F5: keyName = "F5"; break;
case WXK_F6: keyName = "F6"; break;
case WXK_F7: keyName = "F7"; break;
case WXK_F8: keyName = "F8"; break;
case WXK_F9: keyName = "F9"; break;
case WXK_F10: keyName = "F10"; break;
case WXK_F11: keyName = "F11"; break;
case WXK_F12: keyName = "F12"; break;
case WXK_NUMLOCK: keyName = "NumLock"; break;
case WXK_SCROLL: keyName = "ScrollLock"; break;
case WXK_PAGEUP: keyName = "PgUp"; break;
case WXK_PAGEDOWN: keyName = "PgDn"; break;
case WXK_NUMPAD_SPACE: keyName = "NumSpace"; break;
case WXK_NUMPAD_TAB: keyName = "NumTab"; break;
case WXK_NUMPAD_ENTER: keyName = "NumEnter"; break;
case WXK_NUMPAD_HOME: keyName = "NumHome"; break;
case WXK_NUMPAD_LEFT: keyName = "NumLeft"; break;
case WXK_NUMPAD_UP: keyName = "NumUp"; break;
case WXK_NUMPAD_RIGHT: keyName = "NumRight"; break;
case WXK_NUMPAD_DOWN: keyName = "NumDown"; break;
case WXK_NUMPAD_PAGEUP: keyName = "NumPgUp"; break;
case WXK_NUMPAD_PAGEDOWN: keyName = "NumPgDn"; break;
case WXK_NUMPAD_END: keyName = "NumEnd"; break;
case WXK_NUMPAD_BEGIN: keyName = "NumHome"; break;
case WXK_NUMPAD_INSERT: keyName = "NumIns"; break;
case WXK_NUMPAD_DELETE: keyName = "NumDel"; break;
default: keyName = static_cast<char>(keyCode); break;
}
return keyName;
}
void PADManager::UpdateLabel()
{
// Get button labels from .ini
b_up_lstick->SetLabel(GetKeyName(Ini.PadHandlerLStickUp.GetValue()));
b_down_lstick->SetLabel(GetKeyName(Ini.PadHandlerLStickDown.GetValue()));
b_left_lstick->SetLabel(GetKeyName(Ini.PadHandlerLStickLeft.GetValue()));
b_right_lstick->SetLabel(GetKeyName(Ini.PadHandlerLStickRight.GetValue()));
b_up->SetLabel(GetKeyName(Ini.PadHandlerUp.GetValue()));
b_down->SetLabel(GetKeyName(Ini.PadHandlerDown.GetValue()));
b_left->SetLabel(GetKeyName(Ini.PadHandlerLeft.GetValue()));
b_right->SetLabel(GetKeyName(Ini.PadHandlerRight.GetValue()));
b_shift_l1->SetLabel(GetKeyName(Ini.PadHandlerL1.GetValue()));
b_shift_l2->SetLabel(GetKeyName(Ini.PadHandlerL2.GetValue()));
b_shift_l3->SetLabel(GetKeyName(Ini.PadHandlerL3.GetValue()));
b_start->SetLabel(GetKeyName(Ini.PadHandlerStart.GetValue()));
b_select->SetLabel(GetKeyName(Ini.PadHandlerSelect.GetValue()));
b_shift_r1->SetLabel(GetKeyName(Ini.PadHandlerR1.GetValue()));
b_shift_r2->SetLabel(GetKeyName(Ini.PadHandlerR2.GetValue()));
b_shift_r3->SetLabel(GetKeyName(Ini.PadHandlerR3.GetValue()));
b_square->SetLabel(GetKeyName(Ini.PadHandlerSquare.GetValue()));
b_cross->SetLabel(GetKeyName(Ini.PadHandlerCross.GetValue()));
b_circle->SetLabel(GetKeyName(Ini.PadHandlerCircle.GetValue()));
b_triangle->SetLabel(GetKeyName(Ini.PadHandlerTriangle.GetValue()));
b_up_rstick->SetLabel(GetKeyName(Ini.PadHandlerRStickUp.GetValue()));
b_down_rstick->SetLabel(GetKeyName(Ini.PadHandlerRStickDown.GetValue()));
b_left_rstick->SetLabel(GetKeyName(Ini.PadHandlerRStickLeft.GetValue()));
b_right_rstick->SetLabel(GetKeyName(Ini.PadHandlerRStickRight.GetValue()));
}
void PADManager::ResetParameters()
{
Ini.PadHandlerLStickUp.SetValue(315);
Ini.PadHandlerLStickDown.SetValue(317);
Ini.PadHandlerLStickLeft.SetValue(314);
Ini.PadHandlerLStickRight.SetValue(316);
Ini.PadHandlerUp.SetValue(static_cast<int>('W'));
Ini.PadHandlerDown.SetValue(static_cast<int>('S'));
Ini.PadHandlerLeft.SetValue(static_cast<int>('A'));
Ini.PadHandlerRight.SetValue(static_cast<int>('D'));
Ini.PadHandlerL1.SetValue(static_cast<int>('1'));
Ini.PadHandlerL2.SetValue(static_cast<int>('Q'));
Ini.PadHandlerL3.SetValue(static_cast<int>('Z'));
Ini.PadHandlerStart.SetValue(13);
Ini.PadHandlerSelect.SetValue(32);
Ini.PadHandlerR1.SetValue(static_cast<int>('3'));
Ini.PadHandlerR2.SetValue(static_cast<int>('E'));
Ini.PadHandlerR3.SetValue(static_cast<int>('C'));
Ini.PadHandlerSquare.SetValue(static_cast<int>('J'));
Ini.PadHandlerCross.SetValue(static_cast<int>('K'));
Ini.PadHandlerCircle.SetValue(static_cast<int>('L'));
Ini.PadHandlerTriangle.SetValue(static_cast<int>('I'));
Ini.PadHandlerRStickUp.SetValue(366);
Ini.PadHandlerRStickDown.SetValue(367);
Ini.PadHandlerRStickLeft.SetValue(313);
Ini.PadHandlerRStickRight.SetValue(312);
}
void PADManager::UpdateTimerLabel(const u32 id)
{
switch (id)
{
case id_pad_lstick_left: b_left_lstick->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_lstick_down: b_down_lstick->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_lstick_right: b_right_lstick->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_lstick_up: b_up_lstick->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_left: b_left->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_down: b_down->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_right: b_right->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_up: b_up->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_l1: b_shift_l1->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_l2: b_shift_l2->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_l3: b_shift_l3->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_start: b_start->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_select: b_select->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_r1: b_shift_r1->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_r2: b_shift_r2->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_r3: b_shift_r3->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_square: b_square->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_cross: b_cross->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_circle: b_circle->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_triangle: b_triangle->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_rstick_left: b_left_rstick->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_rstick_down: b_down_rstick->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_rstick_right: b_right_rstick->SetLabel(static_cast<char>(m_seconds + 47)); break;
case id_pad_rstick_up: b_up_rstick->SetLabel(static_cast<char>(m_seconds + 47)); break;
default: ConLog.Error("Unknown button ID: %d", id); break;
}
}
void PADManager::SwitchButtons(const bool IsEnabled)
{
b_up_lstick->Enable(IsEnabled);
b_down_lstick->Enable(IsEnabled);
b_left_lstick->Enable(IsEnabled);
b_right_lstick->Enable(IsEnabled);
b_up->Enable(IsEnabled);
b_down->Enable(IsEnabled);
b_left->Enable(IsEnabled);
b_right->Enable(IsEnabled);
b_shift_l1->Enable(IsEnabled);
b_shift_l2->Enable(IsEnabled);
b_shift_l3->Enable(IsEnabled);
b_start->Enable(IsEnabled);
b_select->Enable(IsEnabled);
b_shift_r1->Enable(IsEnabled);
b_shift_r2->Enable(IsEnabled);
b_shift_r3->Enable(IsEnabled);
b_square->Enable(IsEnabled);
b_cross->Enable(IsEnabled);
b_circle->Enable(IsEnabled);
b_triangle->Enable(IsEnabled);
b_up_rstick->Enable(IsEnabled);
b_down_rstick->Enable(IsEnabled);
b_left_rstick->Enable(IsEnabled);
b_right_rstick->Enable(IsEnabled);
b_ok->Enable(IsEnabled);
b_cancel->Enable(IsEnabled);
b_reset->Enable(IsEnabled);
}
void PADManager::RunTimer(const u32 seconds, const u32 id)
{
m_seconds = seconds;
clock_t t1, t2;
t1 = t2 = clock() / CLK_TCK;
while (m_seconds)
{
if (t1 / CLK_TCK + 1 <= (t2 = clock()) / CLK_TCK)
{
UpdateTimerLabel(id);
m_seconds--;
t1 = t2;
}
if(m_key_pressed)
{
m_seconds = 0;
break;
}
}
}

102
rpcs3/Gui/PADManager.h Normal file
View File

@ -0,0 +1,102 @@
#include "Ini.h"
#include <time.h>
enum ButtonIDs
{
id_pad_lstick_left = 0x777,
id_pad_lstick_down,
id_pad_lstick_right,
id_pad_lstick_up,
id_pad_left,
id_pad_down,
id_pad_right,
id_pad_up,
id_pad_l1,
id_pad_l2,
id_pad_l3,
id_pad_start,
id_pad_select,
id_pad_r1,
id_pad_r2,
id_pad_r3,
id_pad_square,
id_pad_cross,
id_pad_circle,
id_pad_triangle,
id_pad_rstick_left,
id_pad_rstick_down,
id_pad_rstick_right,
id_pad_rstick_up,
id_reset_parameters,
};
struct PadButtons
{
wxButton* b_up_lstick;
wxButton* b_down_lstick;
wxButton* b_left_lstick;
wxButton* b_right_lstick;
wxButton* b_up;
wxButton* b_down;
wxButton* b_left;
wxButton* b_right;
wxButton* b_shift_l1;
wxButton* b_shift_l2;
wxButton* b_shift_l3;
wxButton* b_start;
wxButton* b_select;
wxButton* b_shift_r1;
wxButton* b_shift_r2;
wxButton* b_shift_r3;
wxButton* b_square;
wxButton* b_cross;
wxButton* b_circle;
wxButton* b_triangle;
wxButton* b_up_rstick;
wxButton* b_down_rstick;
wxButton* b_left_rstick;
wxButton* b_right_rstick;
wxButton* b_ok;
wxButton* b_cancel;
wxButton* b_reset;
};
class PADManager : public wxDialog, PadButtons
{
private:
AppConnector m_app_connector;
u32 m_seconds;
u32 m_button_id;
bool m_key_pressed;
public:
PADManager(wxWindow* parent);
~PADManager()
{
}
void OnKeyDown(wxKeyEvent &keyEvent);
void OnKeyUp(wxKeyEvent &keyEvent);
void OnButtonClicked(wxCommandEvent &event);
void UpdateLabel();
void ResetParameters();
void UpdateTimerLabel(const u32 id);
void SwitchButtons(const bool IsEnabled);
const wxString GetKeyName(const u32 keyCode);
void RunTimer(const u32 seconds, const u32 id);
};

View File

@ -113,6 +113,10 @@ public:
IniEntry<u8> HLELogLvl;
IniEntry<u8> SysLanguage;
IniEntry<int> PadHandlerLStickLeft;
IniEntry<int> PadHandlerLStickDown;
IniEntry<int> PadHandlerLStickRight;
IniEntry<int> PadHandlerLStickUp;
IniEntry<int> PadHandlerLeft;
IniEntry<int> PadHandlerDown;
IniEntry<int> PadHandlerRight;
@ -129,6 +133,10 @@ public:
IniEntry<int> PadHandlerL1;
IniEntry<int> PadHandlerR2;
IniEntry<int> PadHandlerL2;
IniEntry<int> PadHandlerRStickLeft;
IniEntry<int> PadHandlerRStickDown;
IniEntry<int> PadHandlerRStickRight;
IniEntry<int> PadHandlerRStickUp;
public:
Inis() : DefPath("EmuSettings")
@ -154,6 +162,10 @@ public:
MouseHandlerMode.Init("MouseHandlerMode", path);
path = DefPath + "/" + "ControlSetings";
PadHandlerLStickLeft.Init("PadHandlerLStickLeft", path);
PadHandlerLStickDown.Init("PadHandlerLStickDown", path);
PadHandlerLStickRight.Init("PadHandlerLStickRight", path);
PadHandlerLStickUp.Init("PadHandlerLStickUp", path);
PadHandlerLeft.Init("PadHandlerLeft", path);
PadHandlerDown.Init("PadHandlerDown", path);
PadHandlerRight.Init("PadHandlerRight", path);
@ -170,6 +182,11 @@ public:
PadHandlerL1.Init("PadHandlerL1", path);
PadHandlerR2.Init("PadHandlerR2", path);
PadHandlerL2.Init("PadHandlerL2", path);
PadHandlerRStickLeft.Init("PadHandlerRStickLeft", path);
PadHandlerRStickDown.Init("PadHandlerRStickDown", path);
PadHandlerRStickRight.Init("PadHandlerRStickRight", path);
PadHandlerRStickUp.Init("PadHandlerRStickUp", path);
path = DefPath + "/" + "Audio";
AudioOutMode.Init("AudioOutMode", path);
@ -209,14 +226,18 @@ public:
HLELogLvl.Load(0);
SysLanguage.Load(1);
PadHandlerLStickLeft.Load(314); //WXK_LEFT
PadHandlerLStickDown.Load(317); //WXK_DOWN
PadHandlerLStickRight.Load(316); //WXK_RIGHT
PadHandlerLStickUp.Load(315); //WXK_UP
PadHandlerLeft.Load(static_cast<int>('A'));
PadHandlerDown.Load(static_cast<int>('S'));
PadHandlerRight.Load(static_cast<int>('D'));
PadHandlerUp.Load(static_cast<int>('W'));
PadHandlerStart.Load(0);
PadHandlerStart.Load(13); //WXK_RETURN
PadHandlerR3.Load(static_cast<int>('C'));
PadHandlerL3.Load(static_cast<int>('Z'));
PadHandlerSelect.Load(0);
PadHandlerSelect.Load(32); //WXK_SPACE
PadHandlerSquare.Load(static_cast<int>('J'));
PadHandlerCross.Load(static_cast<int>('K'));
PadHandlerCircle.Load(static_cast<int>('L'));
@ -225,6 +246,10 @@ public:
PadHandlerL1.Load(static_cast<int>('1'));
PadHandlerR2.Load(static_cast<int>('E'));
PadHandlerL2.Load(static_cast<int>('Q'));
PadHandlerRStickLeft.Load(313); //WXK_HOME
PadHandlerRStickDown.Load(367); //WXK_PAGEDOWN
PadHandlerRStickRight.Load(312); //WXK_END
PadHandlerRStickUp.Load(366); //WXK_PAGEUP
}
void Save()
@ -250,6 +275,10 @@ public:
HLELogLvl.Save();
SysLanguage.Save();
PadHandlerLStickLeft.Save();
PadHandlerLStickDown.Save();
PadHandlerLStickRight.Save();
PadHandlerLStickUp.Save();
PadHandlerLeft.Save();
PadHandlerDown.Save();
PadHandlerRight.Save();
@ -266,6 +295,10 @@ public:
PadHandlerL1.Save();
PadHandlerR2.Save();
PadHandlerL2.Save();
PadHandlerRStickLeft.Save();
PadHandlerRStickDown.Save();
PadHandlerRStickRight.Save();
PadHandlerRStickUp.Save();
}
};

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -331,6 +331,7 @@
<ClCompile Include="Gui\InterpreterDisAsm.cpp" />
<ClCompile Include="Gui\MainFrame.cpp" />
<ClCompile Include="Gui\MemoryViewer.cpp" />
<ClCompile Include="Gui\PADManager.cpp" />
<ClCompile Include="Gui\RSXDebugger.cpp" />
<ClCompile Include="Gui\TextInputDialog.cpp" />
<ClCompile Include="Gui\VFSManager.cpp" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Emu">
@ -364,6 +364,9 @@
<ClCompile Include="Gui\RSXDebugger.cpp">
<Filter>Gui</Filter>
</ClCompile>
<ClCompile Include="Gui\PADManager.cpp">
<Filter>Gui</Filter>
</ClCompile>
<ClCompile Include="Emu\SysCalls\Modules\cellPamf.cpp">
<Filter>Emu\SysCalls\Modules</Filter>
</ClCompile>