Started working on the look of the padsimple config dialog

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@641 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2008-09-23 16:14:12 +00:00
parent 0400d044ec
commit da4a384b11
6 changed files with 420 additions and 1281 deletions

View file

@ -1,254 +1,263 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "ConfigDlg.h"
#include "../PadSimple.h"
//#include "../DirectInputBase.h"
BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
EVT_CLOSE(ConfigDialog::OnClose)
EVT_BUTTON(ID_CLOSE,ConfigDialog::OnCloseClick)
EVT_CHECKBOX(ID_ATTACHED,ConfigDialog::AttachedCheck)
EVT_CHECKBOX(ID_DISABLE,ConfigDialog::DisableCheck)
EVT_CHECKBOX(ID_RUMBLE,ConfigDialog::RumbleCheck)
EVT_BUTTON(CTL_A,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_B,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_X,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_Y,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_Z,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_START,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_TRIGGER_L,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_L,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_TRIGGER_R,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_R,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_MAINUP,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_MAINDOWN,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_MAINLEFT,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_MAINRIGHT,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_HALFMAIN,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_SUBUP,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_SUBDOWN,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_SUBLEFT,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_SUBRIGHT,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_HALFSUB,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_DPADUP,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_DPADDOWN,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_DPADLEFT,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_DPADRIGHT,ConfigDialog::OnButtonClick)
END_EVENT_TABLE()
ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
clickedButton = NULL;
CreateGUIControls();
}
ConfigDialog::~ConfigDialog()
{
}
void ConfigDialog::CreateGUIControls()
{
// Notebook
m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize);
// Controller pages
m_Controller[0] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE1, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Controller[0], wxT("Controller 1"));
m_Controller[1] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE2, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Controller[1], wxT("Controller 2"));
m_Controller[2] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE3, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Controller[2], wxT("Controller 3"));
m_Controller[3] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE4, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Controller[3], wxT("Controller 4"));
// Standard buttons
m_Close = new wxButton(this, ID_CLOSE, wxT("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// Put notebook and standard buttons in sizers
wxBoxSizer* sSButtons;
sSButtons = new wxBoxSizer(wxHORIZONTAL);
sSButtons->Add(0, 0, 1, wxEXPAND, 5);
sSButtons->Add(m_Close, 0, wxALL, 5);
wxBoxSizer* sMain;
sMain = new wxBoxSizer(wxVERTICAL);
sMain->Add(m_Notebook, 1, wxEXPAND|wxALL, 5);
sMain->Add(sSButtons, 0, wxEXPAND, 5);
this->SetSizer(sMain);
this->Layout();
wxArrayString arrayStringFor_DeviceName;
for(int i = 0; i < 4; i++)
{
sDevice[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Controller:"));
sDeviceTop[i] = new wxBoxSizer(wxHORIZONTAL);
sDeviceBottom[i] = new wxBoxSizer(wxHORIZONTAL);
m_DeviceName[i] = new wxChoice(m_Controller[i], ID_DEVICENAME, wxDefaultPosition, wxDefaultSize, arrayStringFor_DeviceName, 0, wxDefaultValidator);
m_Attached[i] = new wxCheckBox(m_Controller[i], ID_ATTACHED, wxT("Controller attached"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Disable[i] = new wxCheckBox(m_Controller[i], ID_DISABLE, wxT("Disable when window looses focus"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Rumble[i] = new wxCheckBox(m_Controller[i], ID_RUMBLE, wxT("Enable rumble"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Attached[i]->SetValue(pad[i].attached);
m_Disable[i]->SetValue(pad[i].disable);
m_Rumble[i]->SetValue(pad[i].rumble);
m_Rumble[i]->Show(pad[i].type);
sDeviceTop[i]->Add(m_DeviceName[i], 1, wxEXPAND|wxALL, 1);
sDeviceTop[i]->Add(m_Attached[i], 0, wxEXPAND|wxALL, 1);
sDeviceBottom[i]->AddStretchSpacer(1);
sDeviceBottom[i]->Add(m_Disable[i], 0, wxEXPAND|wxALL, 1);
sDeviceBottom[i]->Add(m_Rumble[i], 0, wxEXPAND|wxALL, 1);
sDeviceBottom[i]->AddStretchSpacer(1);
sDevice[i]->Add(sDeviceTop[i], 0, wxEXPAND|wxALL, 1);
sDevice[i]->Add(sDeviceBottom[i], 0, wxEXPAND|wxALL, 1);
sButtons[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Buttons:"));
m_ButtonA[i] = new wxButton(m_Controller[i], CTL_A, wxT("A: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonB[i] = new wxButton(m_Controller[i], CTL_B, wxT("B: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonX[i] = new wxButton(m_Controller[i], CTL_X, wxT("X: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonY[i] = new wxButton(m_Controller[i], CTL_Y, wxT("Y: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonZ[i] = new wxButton(m_Controller[i], CTL_Z, wxT("Z: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonStart[i] = new wxButton(m_Controller[i], CTL_START, wxT("Start: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
sButtons[i]->Add(m_ButtonA[i], 0, wxEXPAND|wxALL);
sButtons[i]->Add(m_ButtonB[i], 0, wxEXPAND|wxALL);
sButtons[i]->Add(m_ButtonX[i], 0, wxEXPAND|wxALL);
sButtons[i]->Add(m_ButtonY[i], 0, wxEXPAND|wxALL);
sButtons[i]->Add(m_ButtonZ[i], 0, wxEXPAND|wxALL);
sButtons[i]->Add(m_ButtonStart[i], 0, wxEXPAND|wxALL);
sTriggerL[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("L Trigger:"));
m_TriggerL[i] = new wxButton(m_Controller[i], CTL_TRIGGER_L, wxT("Analog: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonL[i] = new wxButton(m_Controller[i], CTL_L, wxT("Click: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
sTriggerR[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("R Trigger:"));
m_TriggerR[i] = new wxButton(m_Controller[i], CTL_TRIGGER_R, wxT("Analog: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonR[i] = new wxButton(m_Controller[i], CTL_R, wxT("Click: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
sTriggerL[i]->Add(m_TriggerL[i], 0, wxEXPAND|wxALL);
sTriggerL[i]->Add(m_ButtonL[i], 0, wxEXPAND|wxALL);
sTriggerR[i]->Add(m_TriggerR[i], 0, wxEXPAND|wxALL);
sTriggerR[i]->Add(m_ButtonR[i], 0, wxEXPAND|wxALL);
sStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Main Stick:"));
m_StickUp[i] = new wxButton(m_Controller[i], CTL_MAINUP, wxT("Up: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_StickDown[i] = new wxButton(m_Controller[i], CTL_MAINDOWN, wxT("Down: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_StickLeft[i] = new wxButton(m_Controller[i], CTL_MAINLEFT, wxT("Left: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_StickRight[i] = new wxButton(m_Controller[i], CTL_MAINRIGHT, wxT("Right: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
sStick[i]->Add(m_StickUp[i], 0, wxEXPAND|wxALL);
sStick[i]->Add(m_StickDown[i], 0, wxEXPAND|wxALL);
sStick[i]->Add(m_StickLeft[i], 0, wxEXPAND|wxALL);
sStick[i]->Add(m_StickRight[i], 0, wxEXPAND|wxALL);
sDPad[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("D-Pad:"));
m_DPadUp[i] = new wxButton(m_Controller[i], CTL_DPADUP, wxT("Up: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_DPadDown[i] = new wxButton(m_Controller[i], CTL_DPADDOWN, wxT("Down: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_DPadLeft[i] = new wxButton(m_Controller[i], CTL_DPADLEFT, wxT("Left: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_DPadRight[i] = new wxButton(m_Controller[i], CTL_DPADRIGHT, wxT("Right: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
sDPad[i]->Add(m_DPadUp[i], 0, wxEXPAND|wxALL);
sDPad[i]->Add(m_DPadDown[i], 0, wxEXPAND|wxALL);
sDPad[i]->Add(m_DPadLeft[i], 0, wxEXPAND|wxALL);
sDPad[i]->Add(m_DPadRight[i], 0, wxEXPAND|wxALL);
sCStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("C-Stick:"));
m_CStickUp[i] = new wxButton(m_Controller[i], CTL_SUBUP, wxT("Up: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_CStickDown[i] = new wxButton(m_Controller[i], CTL_SUBDOWN, wxT("Down: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_CStickLeft[i] = new wxButton(m_Controller[i], CTL_SUBLEFT, wxT("Left: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_CStickRight[i] = new wxButton(m_Controller[i], CTL_SUBRIGHT, wxT("Right: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
sCStick[i]->Add(m_CStickUp[i], 0, wxEXPAND|wxALL);
sCStick[i]->Add(m_CStickDown[i], 0, wxEXPAND|wxALL);
sCStick[i]->Add(m_CStickLeft[i], 0, wxEXPAND|wxALL);
sCStick[i]->Add(m_CStickRight[i], 0, wxEXPAND|wxALL);
sPage[i] = new wxGridBagSizer(0, 0);
sPage[i]->SetFlexibleDirection(wxBOTH);
sPage[i]->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
sPage[i]->Add(sDevice[i], wxGBPosition(0, 0), wxGBSpan(1, 5), wxEXPAND|wxALL, 1);
sPage[i]->Add(sButtons[i], wxGBPosition(1, 0), wxGBSpan(3, 1), wxALL, 1);
sPage[i]->Add(sTriggerL[i], wxGBPosition(1, 1), wxGBSpan(1, 1), wxALL, 1);
sPage[i]->Add(sTriggerR[i], wxGBPosition(2, 1), wxGBSpan(1, 1), wxALL, 1);
sPage[i]->Add(sStick[i], wxGBPosition(1, 2), wxGBSpan(2, 1), wxALL, 1);
sPage[i]->Add(sDPad[i], wxGBPosition(1, 3), wxGBSpan(2, 1), wxALL, 1);
sPage[i]->Add(sCStick[i], wxGBPosition(1, 4), wxGBSpan(2, 1), wxALL, 1);
m_Controller[i]->SetSizer(sPage[i]);
sPage[i]->Layout();
}
//TODO get keyboard input after clicking a wxButton
//clickedButton->Connect(wxID_ANY, wxEVT_KEY_DOWN, wxKeyEventHandler(ConfigDialog::OnKeyDown), (wxObject*)NULL, this);
SetIcon(wxNullIcon);
Fit();
}
void ConfigDialog::OnClose(wxCloseEvent& event)
{
EndModal(0);
}
void ConfigDialog::OnKeyDown(wxKeyEvent& event)
{
if(clickedButton != NULL)
{
int page = m_Notebook->GetSelection();
pad[page].keyForControl[clickedButton->GetId()] = event.GetKeyCode();
clickedButton->SetLabel(wxString::Format(wxT("%i"), event.GetKeyCode()));
}
//this is here to see if the event gets processed at all...so far, it doesn't
m_ButtonA[0]->SetLabel(wxString::Format(wxT("%i"), event.GetKeyCode()));
//clickedButton = NULL;
event.Skip();
}
void ConfigDialog::OnCloseClick(wxCommandEvent& event)
{
Close();
}
void ConfigDialog::AttachedCheck(wxCommandEvent& event)
{
int page = m_Notebook->GetSelection();
pad[page].attached = m_Attached[page]->GetValue();
}
void ConfigDialog::DisableCheck(wxCommandEvent& event)
{
int page = m_Notebook->GetSelection();
pad[page].disable = m_Disable[page]->GetValue();
}
void ConfigDialog::RumbleCheck(wxCommandEvent& event)
{
int page = m_Notebook->GetSelection();
pad[page].rumble = m_Rumble[page]->GetValue();
}
void ConfigDialog::OnButtonClick(wxCommandEvent& event)
{
clickedButton = (wxButton *)event.GetEventObject();
//wxString oldLabel = clickedButton->GetLabel();
clickedButton->SetLabel(wxString::FromAscii("Press Key"));
//clickedButton->SetLabel(wxString::Format(wxT("%i"), keyPress));
//clickedButton->SetLabel(wxString::Format(wxT("%s %i"), oldLabel, keyPress));
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "ConfigDlg.h"
#include "../PadSimple.h"
//#include "../DirectInputBase.h"
BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
EVT_CLOSE(ConfigDialog::OnClose)
EVT_BUTTON(ID_CLOSE,ConfigDialog::OnCloseClick)
EVT_CHECKBOX(ID_ATTACHED,ConfigDialog::AttachedCheck)
EVT_CHECKBOX(ID_DISABLE,ConfigDialog::DisableCheck)
EVT_CHECKBOX(ID_RUMBLE,ConfigDialog::RumbleCheck)
EVT_BUTTON(CTL_A,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_B,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_X,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_Y,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_Z,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_START,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_TRIGGER_L,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_L,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_TRIGGER_R,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_R,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_MAINUP,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_MAINDOWN,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_MAINLEFT,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_MAINRIGHT,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_HALFMAIN,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_SUBUP,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_SUBDOWN,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_SUBLEFT,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_SUBRIGHT,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_HALFSUB,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_DPADUP,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_DPADDOWN,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_DPADLEFT,ConfigDialog::OnButtonClick)
EVT_BUTTON(CTL_DPADRIGHT,ConfigDialog::OnButtonClick)
END_EVENT_TABLE()
ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
clickedButton = NULL;
CreateGUIControls();
}
ConfigDialog::~ConfigDialog()
{
}
void ConfigDialog::CreateGUIControls()
{
// Notebook
m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize);
// Controller pages
m_Controller[0] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE1, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Controller[0], wxT("Controller 1"));
m_Controller[1] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE2, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Controller[1], wxT("Controller 2"));
m_Controller[2] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE3, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Controller[2], wxT("Controller 3"));
m_Controller[3] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE4, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Controller[3], wxT("Controller 4"));
// Standard buttons
m_Close = new wxButton(this, ID_CLOSE, wxT("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// Put notebook and standard buttons in sizers
wxBoxSizer* sSButtons;
sSButtons = new wxBoxSizer(wxHORIZONTAL);
sSButtons->Add(0, 0, 1, wxEXPAND, 5);
sSButtons->Add(m_Close, 0, wxALL, 5);
wxBoxSizer* sMain;
sMain = new wxBoxSizer(wxVERTICAL);
sMain->Add(m_Notebook, 1, wxEXPAND|wxALL, 5);
sMain->Add(sSButtons, 0, wxEXPAND, 5);
this->SetSizer(sMain);
this->Layout();
wxArrayString arrayStringFor_DeviceName;
for(int i = 0; i < 4; i++)
{
sDevice[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Controller:"));
sDeviceTop[i] = new wxBoxSizer(wxHORIZONTAL);
sDeviceBottom[i] = new wxBoxSizer(wxHORIZONTAL);
m_DeviceName[i] = new wxChoice(m_Controller[i], ID_DEVICENAME, wxDefaultPosition, wxDefaultSize, arrayStringFor_DeviceName, 0, wxDefaultValidator);
m_Attached[i] = new wxCheckBox(m_Controller[i], ID_ATTACHED, wxT("Controller attached"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Disable[i] = new wxCheckBox(m_Controller[i], ID_DISABLE, wxT("Disable when window looses focus"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Rumble[i] = new wxCheckBox(m_Controller[i], ID_RUMBLE, wxT("Enable rumble"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Attached[i]->SetValue(pad[i].attached);
m_Disable[i]->SetValue(pad[i].disable);
m_Rumble[i]->SetValue(pad[i].rumble);
m_Rumble[i]->Show(pad[i].type);
sDeviceTop[i]->Add(m_DeviceName[i], 1, wxEXPAND|wxALL, 1);
sDeviceTop[i]->Add(m_Attached[i], 0, wxEXPAND|wxALL, 1);
sDeviceBottom[i]->AddStretchSpacer(1);
sDeviceBottom[i]->Add(m_Disable[i], 0, wxEXPAND|wxALL, 1);
sDeviceBottom[i]->Add(m_Rumble[i], 0, wxEXPAND|wxALL, 1);
sDeviceBottom[i]->AddStretchSpacer(1);
sDevice[i]->Add(sDeviceTop[i], 0, wxEXPAND|wxALL, 1);
sDevice[i]->Add(sDeviceBottom[i], 0, wxEXPAND|wxALL, 1);
sButtons[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Buttons:"));
hButtons[i][0] = new wxBoxSizer(wxHORIZONTAL);
hButtons[i][0]->Add(new wxStaticText(m_Controller[i], 0, wxT("A:"), wxDefaultPosition, wxDefaultSize), 0,
wxALIGN_CENTER_VERTICAL|wxALL);
m_ButtonA[i] = new wxButton(m_Controller[i], CTL_A, wxT(""), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonB[i] = new wxButton(m_Controller[i], CTL_B, wxT("B: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonX[i] = new wxButton(m_Controller[i], CTL_X, wxT("X: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonY[i] = new wxButton(m_Controller[i], CTL_Y, wxT("Y: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonZ[i] = new wxButton(m_Controller[i], CTL_Z, wxT("Z: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonStart[i] = new wxButton(m_Controller[i], CTL_START, wxT("Start: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
hButtons[i][0]->Add(m_ButtonA[i], 0, wxEXPAND|wxALL);
sButtons[i]->Add(hButtons[i][0]);
sButtons[i]->Add(m_ButtonB[i], 0, wxEXPAND|wxALL);
sButtons[i]->Add(m_ButtonX[i], 0, wxEXPAND|wxALL);
sButtons[i]->Add(m_ButtonY[i], 0, wxEXPAND|wxALL);
sButtons[i]->Add(m_ButtonZ[i], 0, wxEXPAND|wxALL);
sButtons[i]->Add(m_ButtonStart[i], 0, wxEXPAND|wxALL);
sTriggerL[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("L Trigger"));
m_TriggerL[i] = new wxButton(m_Controller[i], CTL_TRIGGER_L, wxT("Analog: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonL[i] = new wxButton(m_Controller[i], CTL_L, wxT("Click: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
sTriggerR[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("R Trigger"));
m_TriggerR[i] = new wxButton(m_Controller[i], CTL_TRIGGER_R, wxT("Analog: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_ButtonR[i] = new wxButton(m_Controller[i], CTL_R, wxT("Click: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
sTriggerL[i]->Add(m_TriggerL[i], 0, wxEXPAND|wxALL);
sTriggerL[i]->Add(m_ButtonL[i], 0, wxEXPAND|wxALL);
sTriggerR[i]->Add(m_TriggerR[i], 0, wxEXPAND|wxALL);
sTriggerR[i]->Add(m_ButtonR[i], 0, wxEXPAND|wxALL);
sStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Main Stick"));
m_StickUp[i] = new wxButton(m_Controller[i], CTL_MAINUP, wxT("Up: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_StickDown[i] = new wxButton(m_Controller[i], CTL_MAINDOWN, wxT("Down: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_StickLeft[i] = new wxButton(m_Controller[i], CTL_MAINLEFT, wxT("Left: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_StickRight[i] = new wxButton(m_Controller[i], CTL_MAINRIGHT, wxT("Right: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
sStick[i]->Add(m_StickUp[i], 0, wxEXPAND|wxALL);
sStick[i]->Add(m_StickDown[i], 0, wxEXPAND|wxALL);
sStick[i]->Add(m_StickLeft[i], 0, wxEXPAND|wxALL);
sStick[i]->Add(m_StickRight[i], 0, wxEXPAND|wxALL);
sDPad[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("D-Pad"));
m_DPadUp[i] = new wxButton(m_Controller[i], CTL_DPADUP, wxT("Up: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_DPadDown[i] = new wxButton(m_Controller[i], CTL_DPADDOWN, wxT("Down: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_DPadLeft[i] = new wxButton(m_Controller[i], CTL_DPADLEFT, wxT("Left: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_DPadRight[i] = new wxButton(m_Controller[i], CTL_DPADRIGHT, wxT("Right: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
sDPad[i]->Add(m_DPadUp[i], 0, wxEXPAND|wxALL);
sDPad[i]->Add(m_DPadDown[i], 0, wxEXPAND|wxALL);
sDPad[i]->Add(m_DPadLeft[i], 0, wxEXPAND|wxALL);
sDPad[i]->Add(m_DPadRight[i], 0, wxEXPAND|wxALL);
sCStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("C-Stick"));
m_CStickUp[i] = new wxButton(m_Controller[i], CTL_SUBUP, wxT("Up: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_CStickDown[i] = new wxButton(m_Controller[i], CTL_SUBDOWN, wxT("Down: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_CStickLeft[i] = new wxButton(m_Controller[i], CTL_SUBLEFT, wxT("Left: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_CStickRight[i] = new wxButton(m_Controller[i], CTL_SUBRIGHT, wxT("Right: "), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
sCStick[i]->Add(m_CStickUp[i], 0, wxEXPAND|wxALL);
sCStick[i]->Add(m_CStickDown[i], 0, wxEXPAND|wxALL);
sCStick[i]->Add(m_CStickLeft[i], 0, wxEXPAND|wxALL);
sCStick[i]->Add(m_CStickRight[i], 0, wxEXPAND|wxALL);
sPage[i] = new wxGridBagSizer(0, 0);
sPage[i]->SetFlexibleDirection(wxBOTH);
sPage[i]->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
sPage[i]->Add(sDevice[i], wxGBPosition(0, 0), wxGBSpan(1, 5), wxEXPAND|wxALL, 1);
sPage[i]->Add(sButtons[i], wxGBPosition(1, 0), wxGBSpan(3, 1), wxALL, 1);
sPage[i]->Add(sTriggerL[i], wxGBPosition(1, 1), wxGBSpan(1, 1), wxALL, 1);
sPage[i]->Add(sTriggerR[i], wxGBPosition(2, 1), wxGBSpan(1, 1), wxALL, 1);
sPage[i]->Add(sStick[i], wxGBPosition(1, 2), wxGBSpan(2, 1), wxALL, 1);
sPage[i]->Add(sDPad[i], wxGBPosition(1, 3), wxGBSpan(2, 1), wxALL, 1);
sPage[i]->Add(sCStick[i], wxGBPosition(1, 4), wxGBSpan(2, 1), wxALL, 1);
m_Controller[i]->SetSizer(sPage[i]);
sPage[i]->Layout();
}
SetIcon(wxNullIcon);
Fit();
}
void ConfigDialog::OnClose(wxCloseEvent& event)
{
EndModal(0);
}
void ConfigDialog::OnKeyDown(wxKeyEvent& event)
{
if(clickedButton != NULL)
{
int page = m_Notebook->GetSelection();
pad[page].keyForControl[clickedButton->GetId()] = event.GetKeyCode();
clickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode()));
clickedButton->Disconnect();
}
clickedButton = NULL;
event.Skip();
}
void ConfigDialog::OnCloseClick(wxCommandEvent& event)
{
Close();
}
void ConfigDialog::AttachedCheck(wxCommandEvent& event)
{
int page = m_Notebook->GetSelection();
pad[page].attached = m_Attached[page]->GetValue();
}
void ConfigDialog::DisableCheck(wxCommandEvent& event)
{
int page = m_Notebook->GetSelection();
pad[page].disable = m_Disable[page]->GetValue();
}
void ConfigDialog::RumbleCheck(wxCommandEvent& event)
{
int page = m_Notebook->GetSelection();
pad[page].rumble = m_Rumble[page]->GetValue();
}
void ConfigDialog::OnButtonClick(wxCommandEvent& event)
{
if(clickedButton) {
clickedButton->SetLabel(oldLabel);
}
clickedButton = (wxButton *)event.GetEventObject();
oldLabel = clickedButton->GetLabel();
clickedButton->SetLabel(wxString::FromAscii("Press Key"));
clickedButton->Connect(wxID_ANY, wxEVT_KEY_DOWN,
wxKeyEventHandler(ConfigDialog::OnKeyDown),
(wxObject*)NULL, this);
//clickedButton->SetLabel(wxString::Format(wxT("%i"), keyPress));
//clickedButton->SetLabel(wxString::Format(wxT("%s %i"), oldLabel, keyPress));
}

View file

@ -1,125 +1,124 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef __CONFIGDIALOG_h__
#define __CONFIGDIALOG_h__
#include <wx/wx.h>
#include <wx/dialog.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/stattext.h>
#include <wx/combobox.h>
#include <wx/checkbox.h>
#include <wx/notebook.h>
#include <wx/panel.h>
#include <wx/gbsizer.h>
#undef CONFIGDIALOG_STYLE
#define CONFIGDIALOG_STYLE wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxCLOSE_BOX
class ConfigDialog : public wxDialog
{
private:
DECLARE_EVENT_TABLE();
public:
ConfigDialog(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("Pad Configuration"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = CONFIGDIALOG_STYLE);
virtual ~ConfigDialog();
private:
wxNotebook *m_Notebook;
wxPanel *m_Controller[4];
wxButton *m_Close;
wxStaticBoxSizer *sDevice[4];
wxBoxSizer *sDeviceTop[4];
wxBoxSizer *sDeviceBottom[4];
wxGridBagSizer* sPage[4];
wxStaticBoxSizer *sButtons[4];
wxStaticBoxSizer *sTriggerL[4];
wxStaticBoxSizer *sTriggerR[4];
wxStaticBoxSizer *sStick[4];
wxStaticBoxSizer *sCStick[4];
wxStaticBoxSizer *sDPad[4];
wxChoice *m_DeviceName[4];
wxCheckBox *m_Attached[4];
wxCheckBox *m_Disable[4];
wxCheckBox *m_Rumble[4];
wxButton *m_ButtonA[4];
wxButton *m_ButtonB[4];
wxButton *m_ButtonX[4];
wxButton *m_ButtonY[4];
wxButton *m_ButtonZ[4];
wxButton *m_ButtonStart[4];
wxButton *m_TriggerL[4];
wxButton *m_ButtonL[4];
wxButton *m_TriggerR[4];
wxButton *m_ButtonR[4];
wxButton *m_StickUp[4];
wxButton *m_StickDown[4];
wxButton *m_StickLeft[4];
wxButton *m_StickRight[4];
wxButton *m_CStickUp[4];
wxButton *m_CStickDown[4];
wxButton *m_CStickLeft[4];
wxButton *m_CStickRight[4];
wxButton *m_DPadUp[4];
wxButton *m_DPadDown[4];
wxButton *m_DPadLeft[4];
wxButton *m_DPadRight[4];
private:
enum
{
////GUI Enum Control ID Start
ID_CLOSE = 1000,
ID_NOTEBOOK,
ID_CONTROLLERPAGE1,
ID_CONTROLLERPAGE2,
ID_CONTROLLERPAGE3,
ID_CONTROLLERPAGE4,
ID_DEVICENAME,
ID_ATTACHED,
ID_DISABLE,
ID_RUMBLE,
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
};
private:
void OnClose(wxCloseEvent& event);
void CreateGUIControls();
void OnCloseClick(wxCommandEvent& event);
void OnKeyDown(wxKeyEvent& event);
void AttachedCheck(wxCommandEvent& event);
void DisableCheck(wxCommandEvent& event);
void RumbleCheck(wxCommandEvent& event);
void OnButtonClick(wxCommandEvent& event);
int keyPress;
wxButton *clickedButton;
/*DInput m_dinput;*/
};
#endif
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef __CONFIGDLG_H__
#define __CONFIGDLG_H__
#include <wx/wx.h>
#include <wx/dialog.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/stattext.h>
#include <wx/combobox.h>
#include <wx/checkbox.h>
#include <wx/notebook.h>
#include <wx/panel.h>
#include <wx/gbsizer.h>
#undef CONFIGDIALOG_STYLE
#define CONFIGDIALOG_STYLE wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxCLOSE_BOX
class ConfigDialog : public wxDialog
{
public:
ConfigDialog(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("Pad Configuration"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = CONFIGDIALOG_STYLE);
virtual ~ConfigDialog();
private:
DECLARE_EVENT_TABLE();
wxNotebook *m_Notebook;
wxPanel *m_Controller[4];
wxButton *m_Close;
wxStaticBoxSizer *sDevice[4];
wxBoxSizer *sDeviceTop[4];
wxBoxSizer *sDeviceBottom[4];
wxGridBagSizer* sPage[4];
wxStaticBoxSizer *sButtons[4];
wxBoxSizer *hButtons[4][2];
wxStaticBoxSizer *sTriggerL[4];
wxStaticBoxSizer *sTriggerR[4];
wxStaticBoxSizer *sStick[4];
wxStaticBoxSizer *sCStick[4];
wxStaticBoxSizer *sDPad[4];
wxChoice *m_DeviceName[4];
wxCheckBox *m_Attached[4];
wxCheckBox *m_Disable[4];
wxCheckBox *m_Rumble[4];
wxButton *m_ButtonA[4];
wxButton *m_ButtonB[4];
wxButton *m_ButtonX[4];
wxButton *m_ButtonY[4];
wxButton *m_ButtonZ[4];
wxButton *m_ButtonStart[4];
wxButton *m_TriggerL[4];
wxButton *m_ButtonL[4];
wxButton *m_TriggerR[4];
wxButton *m_ButtonR[4];
wxButton *m_StickUp[4];
wxButton *m_StickDown[4];
wxButton *m_StickLeft[4];
wxButton *m_StickRight[4];
wxButton *m_CStickUp[4];
wxButton *m_CStickDown[4];
wxButton *m_CStickLeft[4];
wxButton *m_CStickRight[4];
wxButton *m_DPadUp[4];
wxButton *m_DPadDown[4];
wxButton *m_DPadLeft[4];
wxButton *m_DPadRight[4];
enum
{
////GUI Enum Control ID Start
ID_CLOSE = 1000,
ID_NOTEBOOK,
ID_CONTROLLERPAGE1,
ID_CONTROLLERPAGE2,
ID_CONTROLLERPAGE3,
ID_CONTROLLERPAGE4,
ID_DEVICENAME,
ID_ATTACHED,
ID_DISABLE,
ID_RUMBLE,
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
};
void OnClose(wxCloseEvent& event);
void CreateGUIControls();
void OnCloseClick(wxCommandEvent& event);
void OnKeyDown(wxKeyEvent& event);
void AttachedCheck(wxCommandEvent& event);
void DisableCheck(wxCommandEvent& event);
void RumbleCheck(wxCommandEvent& event);
void OnButtonClick(wxCommandEvent& event);
int keyPress;
wxButton *clickedButton;
wxString oldLabel;
/*DInput m_dinput;*/
};
#endif

View file

@ -16,6 +16,8 @@
// http://code.google.com/p/dolphin-emu/
// controls
#ifndef __PADSIMPLE_H__
#define __PADSIMPLE_H__
enum
{
CTL_A = 0,
@ -74,6 +76,35 @@ static const char* controlNames[] =
"D-Pad_right",
};
// control human readable
static const char* userControlNames[] =
{
"A",
"B",
"X",
"Y",
"Z",
"Start",
"Analog", // Don't use
"L",
"Analog", // Don't use
"R",
"Up",
"Down",
"Left",
"Right",
"Soft_main_switch", // Don't use
"Up",
"Down",
"Left",
"Right",
"Soft_sub_switch", // Don't use
"Up",
"Down",
"Left",
"Right",
};
struct SPads {
bool type; //keyboard = 0, xpad = 1
int XPad; //player# of the xpad
@ -87,3 +118,5 @@ extern SPads pad[];
void LoadConfig();
void SaveConfig();
#endif

View file

@ -1,726 +0,0 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifdef _WIN32
#define XINPUT_ENABLE
#endif
#include <stdio.h>
#include <math.h>
#include "Common.h"
#ifdef XINPUT_ENABLE
#include "XInput.h"
#endif
#include "pluginspecs_pad.h"
#include "IniFile.h"
#ifdef _WIN32
#include "DirectInputBase.h"
#include "resource.h"
#include "AboutDlg.h"
#include "ConfigDlg.h"
DInput dinput;
#else
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
Display* GXdsp;
bool KeyStatus[23];
#endif
void __Log(int, const char *fmt, ...)
{
//DebugLog(fmt);
}
// controls
enum
{
CTL_MAINLEFT = 0,
CTL_MAINUP,
CTL_MAINRIGHT,
CTL_MAINDOWN,
CTL_SUBLEFT,
CTL_SUBUP,
CTL_SUBRIGHT,
CTL_SUBDOWN,
CTL_DPADLEFT,
CTL_DPADUP,
CTL_DPADRIGHT,
CTL_DPADDOWN,
CTL_A,
CTL_B,
CTL_X,
CTL_Y,
CTL_Z,
CTL_L,
CTL_R,
CTL_START,
CTL_HALFMAIN,
CTL_HALFSUB,
CTL_HALFTRIGGER,
NUMCONTROLS
};
// control names
static const char* controlNames[] =
{
"Main_stick_left",
"Main_stick_up",
"Main_stick_right",
"Main_stick_down",
"Sub_stick_left",
"Sub_stick_up",
"Sub_stick_right",
"Sub_stick_down",
"D-Pad_left",
"D-Pad_up",
"D-Pad_right",
"D-Pad_down",
"A_button",
"B_button",
"X_button",
"Y_button",
"Z_trigger",
"L_button",
"R_button",
"Start",
"Soft_main_switch",
"Soft_sub_switch",
"Soft_triggers_switch",
};
unsigned int keyForControl[NUMCONTROLS];
HINSTANCE g_hInstance = NULL;
SPADInitialize g_PADInitialize;
bool g_rumbleEnable = true;
void LoadConfig();
void SaveConfig();
#define RECORD_SIZE (1024 * 128)
SPADStatus recordBuffer[RECORD_SIZE];
int count = 0;
// #define RECORD_STORE
// #define RECORD_REPLAY
void RecordInput(const SPADStatus& _rPADStatus)
{
if (count >= RECORD_SIZE)
{
return;
}
recordBuffer[count++] = _rPADStatus;
}
const SPADStatus& PlayRecord()
{
if (count >= RECORD_SIZE){return(recordBuffer[0]);}
return(recordBuffer[count++]);
}
void LoadRecord()
{
FILE* pStream = fopen("c:\\pad-record.bin", "rb");
if (pStream != NULL)
{
fread(recordBuffer, 1, RECORD_SIZE * sizeof(SPADStatus), pStream);
fclose(pStream);
}
}
void SaveRecord()
{
FILE* pStream = fopen("c:\\pad-record.bin", "wb");
if (pStream != NULL)
{
fwrite(recordBuffer, 1, RECORD_SIZE * sizeof(SPADStatus), pStream);
fclose(pStream);
}
}
#ifdef _WIN32
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
DWORD dwReason, // reason called
LPVOID lpvReserved) // reserved
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
default:
break;
}
g_hInstance = hinstDLL;
return(TRUE);
}
#endif
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
{
_PluginInfo->Version = 0x0100;
_PluginInfo->Type = PLUGIN_TYPE_PAD;
#ifdef DEBUGFAST
sprintf(_PluginInfo->Name, "Dolphin KB/X360pad (DebugFast)");
#else
#ifndef _DEBUG
sprintf(_PluginInfo->Name, "Dolphin KB/X360pad ");
#else
sprintf(_PluginInfo->Name, "Dolphin KB/X360pad (Debug)");
#endif
#endif
}
void DllAbout(HWND _hParent)
{
#ifdef _WIN32
CAboutDlg aboutDlg;
aboutDlg.DoModal(_hParent);
#endif
}
void DllConfig(HWND _hParent)
{
#ifdef _WIN32
LoadConfig();
CConfigDlg configDlg;
configDlg.DoModal(_hParent);
SaveConfig();
#endif
}
void PAD_Initialize(SPADInitialize _PADInitialize)
{
#ifdef RECORD_REPLAY
LoadRecord();
#endif
g_PADInitialize = _PADInitialize;
#ifdef _WIN32
dinput.Init((HWND)g_PADInitialize.hWnd);
#else
GXdsp = (Display*)g_PADInitialize.hWnd;
#endif
LoadConfig();
}
void PAD_Shutdown()
{
#ifdef RECORD_STORE
SaveRecord();
#endif
#ifdef _WIN32
dinput.Free();
#endif
SaveConfig();
}
const float kDeadZone = 0.1f;
// Implement circular deadzone
void ScaleStickValues(unsigned char* outx,
unsigned char* outy,
short inx, short iny)
{
float x = ((float)inx + 0.5f) / 32767.5f;
float y = ((float)iny + 0.5f) / 32767.5f;
if ((x == 0.0f) && (y == 0.0f)) // to be safe
{
*outx = 0;
*outy = 0;
return;
}
float magnitude = sqrtf(x * x + y * y);
float nx = x / magnitude;
float ny = y / magnitude;
if (magnitude < kDeadZone){magnitude = kDeadZone;}
magnitude = (magnitude - kDeadZone) / (1.0f - kDeadZone);
magnitude *= magnitude; // another power may be more appropriate
nx *= magnitude;
ny *= magnitude;
int ix = (int)(nx * 100);
int iy = (int)(ny * 100);
*outx = 0x80 + ix;
*outy = 0x80 + iy;
}
#ifdef _WIN32
void DInput_Read(int _numPad, SPADStatus* _pPADStatus)
{
if (_numPad != 0)
{
return;
}
dinput.Read();
int mainvalue = (dinput.diks[keyForControl[CTL_HALFMAIN]] & 0xFF) ? 40 : 100;
int subvalue = (dinput.diks[keyForControl[CTL_HALFSUB]] & 0xFF) ? 40 : 100;
int triggervalue = (dinput.diks[keyForControl[CTL_HALFTRIGGER]] & 0xFF) ? 100 : 255;
// get the new keys
if (dinput.diks[keyForControl[CTL_MAINLEFT]] & 0xFF){_pPADStatus->stickX -= mainvalue;}
if (dinput.diks[keyForControl[CTL_MAINRIGHT]] & 0xFF){_pPADStatus->stickX += mainvalue;}
if (dinput.diks[keyForControl[CTL_MAINDOWN]] & 0xFF){_pPADStatus->stickY -= mainvalue;}
if (dinput.diks[keyForControl[CTL_MAINUP]] & 0xFF){_pPADStatus->stickY += mainvalue;}
if (dinput.diks[keyForControl[CTL_SUBLEFT]] & 0xFF){_pPADStatus->substickX -= subvalue;}
if (dinput.diks[keyForControl[CTL_SUBRIGHT]] & 0xFF){_pPADStatus->substickX += subvalue;}
if (dinput.diks[keyForControl[CTL_SUBDOWN]] & 0xFF){_pPADStatus->substickY -= subvalue;}
if (dinput.diks[keyForControl[CTL_SUBUP]] & 0xFF){_pPADStatus->substickY += subvalue;}
if (dinput.diks[keyForControl[CTL_L]] & 0xFF)
{
_pPADStatus->button |= PAD_TRIGGER_L;
_pPADStatus->triggerLeft = triggervalue;
}
if (dinput.diks[keyForControl[CTL_R]] & 0xFF)
{
_pPADStatus->button |= PAD_TRIGGER_R;
_pPADStatus->triggerRight = triggervalue;
}
if (dinput.diks[keyForControl[CTL_A]] & 0xFF)
{
_pPADStatus->button |= PAD_BUTTON_A;
_pPADStatus->analogA = 255;
}
if (dinput.diks[keyForControl[CTL_B]] & 0xFF)
{
_pPADStatus->button |= PAD_BUTTON_B;
_pPADStatus->analogB = 255;
}
if (dinput.diks[keyForControl[CTL_X]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_X;}
if (dinput.diks[keyForControl[CTL_Y]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_Y;}
if (dinput.diks[keyForControl[CTL_Z]] & 0xFF){_pPADStatus->button |= PAD_TRIGGER_Z;}
if (dinput.diks[keyForControl[CTL_DPADUP]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_UP;}
if (dinput.diks[keyForControl[CTL_DPADDOWN]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_DOWN;}
if (dinput.diks[keyForControl[CTL_DPADLEFT]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_LEFT;}
if (dinput.diks[keyForControl[CTL_DPADRIGHT]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_RIGHT;}
if (dinput.diks[keyForControl[CTL_START]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_START;}
}
void XInput_Read(int _numPAD, SPADStatus* _pPADStatus)
{
#ifdef XINPUT_ENABLE
const int base = 0x80;
XINPUT_STATE xstate;
DWORD xresult = XInputGetState(_numPAD, &xstate);
if ((xresult != ERROR_SUCCESS) && (_numPAD != 0))
{
return;
}
// In addition, let's .. yes, let's use XINPUT!
if (xresult == ERROR_SUCCESS)
{
const XINPUT_GAMEPAD& pad = xstate.Gamepad;
if ((_pPADStatus->stickX == base) && (_pPADStatus->stickY == base))
{
ScaleStickValues(
&_pPADStatus->stickX,
&_pPADStatus->stickY,
pad.sThumbLX,
pad.sThumbLY);
}
if ((_pPADStatus->substickX == base) && (_pPADStatus->substickY == base))
{
ScaleStickValues(
&_pPADStatus->substickX,
&_pPADStatus->substickY,
pad.sThumbRX,
pad.sThumbRY);
}
_pPADStatus->triggerLeft = pad.bLeftTrigger;
_pPADStatus->triggerRight = pad.bRightTrigger;
if (pad.bLeftTrigger > 20){_pPADStatus->button |= PAD_TRIGGER_L;}
if (pad.bRightTrigger > 20){_pPADStatus->button |= PAD_TRIGGER_R;}
if (pad.wButtons & XINPUT_GAMEPAD_A){_pPADStatus->button |= PAD_BUTTON_A;}
if (pad.wButtons & XINPUT_GAMEPAD_X){_pPADStatus->button |= PAD_BUTTON_B;}
if (pad.wButtons & XINPUT_GAMEPAD_B){_pPADStatus->button |= PAD_BUTTON_X;}
if (pad.wButtons & XINPUT_GAMEPAD_Y){_pPADStatus->button |= PAD_BUTTON_Y;}
if (pad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER){_pPADStatus->button |= PAD_TRIGGER_Z;}
if (pad.wButtons & XINPUT_GAMEPAD_START){_pPADStatus->button |= PAD_BUTTON_START;}
if (pad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT){_pPADStatus->button |= PAD_BUTTON_LEFT;}
if (pad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT){_pPADStatus->button |= PAD_BUTTON_RIGHT;}
if (pad.wButtons & XINPUT_GAMEPAD_DPAD_UP){_pPADStatus->button |= PAD_BUTTON_UP;}
if (pad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN){_pPADStatus->button |= PAD_BUTTON_DOWN;}
}
#endif
}
#endif
#if defined(__linux__)
// The graphics plugin in the PCSX2 design leaves a lot of the window processing to the pad plugin, weirdly enough.
void X11_Read(int _numPAD, SPADStatus* _pPADStatus)
{
// Do all the stuff we need to do once per frame here
if (_numPAD != 0)
{
return;
}
int i;
// This code is from Zerofrog's pcsx2 pad plugin
XEvent E;
//int keyPress=0, keyRelease=0;
KeySym key;
// keyboard input
while (XPending(GXdsp) > 0)
{
XNextEvent(GXdsp, &E);
switch (E.type)
{
case KeyPress:
//_KeyPress(pad, XLookupKeysym((XKeyEvent *)&E, 0)); break;
key = XLookupKeysym((XKeyEvent*)&E, 0);
for (i = 0; i < NUMCONTROLS; i++) {
if (key == keyForControl[i]) {
KeyStatus[i] = true;
break;
}
}
break;
case KeyRelease:
key = XLookupKeysym((XKeyEvent*)&E, 0);
//_KeyRelease(pad, XLookupKeysym((XKeyEvent *)&E, 0));
for (i = 0; i < NUMCONTROLS; i++) {
if (key == keyForControl[i]) {
KeyStatus[i] = false;
break;
}
}
break;
case FocusIn:
XAutoRepeatOff(GXdsp);
break;
case FocusOut:
XAutoRepeatOn(GXdsp);
break;
}
}
int mainvalue = (KeyStatus[20]) ? 40 : 100;
int subvalue = (KeyStatus[21]) ? 40 : 100;
int triggervalue = (KeyStatus[23]) ? 100 : 255;
if (KeyStatus[0]){_pPADStatus->stickX -= mainvalue;}
if (KeyStatus[1]){_pPADStatus->stickY += mainvalue;}
if (KeyStatus[2]){_pPADStatus->stickX += mainvalue;}
if (KeyStatus[3]){_pPADStatus->stickY -= mainvalue;}
if (KeyStatus[4]){_pPADStatus->substickX -= subvalue;}
if (KeyStatus[5]){_pPADStatus->substickY += subvalue;}
if (KeyStatus[6]){_pPADStatus->substickX += subvalue;}
if (KeyStatus[7]){_pPADStatus->substickY -= subvalue;}
if (KeyStatus[8]){_pPADStatus->button |= PAD_BUTTON_LEFT;}
if (KeyStatus[9]){_pPADStatus->button |= PAD_BUTTON_UP;}
if (KeyStatus[10]){_pPADStatus->button |= PAD_BUTTON_RIGHT;}
if (KeyStatus[11]){_pPADStatus->button |= PAD_BUTTON_DOWN;}
if (KeyStatus[12])
{
_pPADStatus->button |= PAD_BUTTON_A;
_pPADStatus->analogA = 255;
}
if (KeyStatus[13])
{
_pPADStatus->button |= PAD_BUTTON_B;
_pPADStatus->analogB = 255;
}
if (KeyStatus[14]){_pPADStatus->button |= PAD_BUTTON_X;}
if (KeyStatus[15]){_pPADStatus->button |= PAD_BUTTON_Y;}
if (KeyStatus[16]){_pPADStatus->button |= PAD_TRIGGER_Z;}
if (KeyStatus[17])
{
_pPADStatus->button |= PAD_TRIGGER_L;
_pPADStatus->triggerLeft = triggervalue;
}
if (KeyStatus[18])
{
_pPADStatus->button |= PAD_TRIGGER_R;
_pPADStatus->triggerRight = triggervalue;
}
if (KeyStatus[19]){_pPADStatus->button |= PAD_BUTTON_START;}
}
#endif
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
{
// check if all is okay
if ((_pPADStatus == NULL))
{
return;
}
#ifdef RECORD_REPLAY
*_pPADStatus = PlayRecord();
return;
#endif
const int base = 0x80;
// clear pad
memset(_pPADStatus, 0, sizeof(SPADStatus));
_pPADStatus->stickY = base;
_pPADStatus->stickX = base;
_pPADStatus->substickX = base;
_pPADStatus->substickY = base;
_pPADStatus->button |= PAD_USE_ORIGIN;
#ifdef _WIN32
// just update pad on focus
//if (g_PADInitialize.hWnd != ::GetForegroundWindow())
// return;
#endif
_pPADStatus->err = PAD_ERR_NONE;
// keyboard is hardwired to player 1.
#ifdef _WIN32
DInput_Read(_numPAD, _pPADStatus);
XInput_Read(_numPAD, _pPADStatus);
#elif defined(__linux__)
X11_Read(_numPAD, _pPADStatus);
#endif
#ifdef RECORD_STORE
RecordInput(*_pPADStatus);
#endif
}
// Rough approximation of GC behaviour - needs improvement.
void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
{
#ifdef _WIN32
static int a = 0;
if ((_uType == 0) || (_uType == 2))
{
a = 0;
}
else if (_uType == 1)
{
a = _uStrength > 2 ? 8000 : 0;
}
a = int ((float)a * 0.96f);
if (!g_rumbleEnable)
{
a = 0;
}
#ifdef XINPUT_ENABLE
XINPUT_VIBRATION vib;
vib.wLeftMotorSpeed = a; //_uStrength*100;
vib.wRightMotorSpeed = a; //_uStrength*100;
XInputSetState(_numPAD, &vib);
#endif
#endif
}
unsigned int PAD_GetAttachedPads()
{
return 1;
}
unsigned int SaveLoadState(char* _ptr, BOOL _bSave)
{
return(0);
}
void LoadConfig()
{
// Initialize pad 1 to standard controls
#ifdef _WIN32
const int defaultKeyForControl[NUMCONTROLS] =
{
DIK_LEFT, //mainstick
DIK_UP,
DIK_RIGHT,
DIK_DOWN,
DIK_J, //substick
DIK_I,
DIK_L,
DIK_K,
DIK_F, //dpad
DIK_T,
DIK_H,
DIK_G,
DIK_X, //buttons
DIK_Z,
DIK_S,
DIK_C,
DIK_D,
DIK_Q,
DIK_W,
DIK_RETURN,
DIK_LSHIFT,
DIK_LSHIFT,
DIK_LCONTROL
};
#else
const int defaultKeyForControl[NUMCONTROLS] =
{
XK_Left, //mainstick
XK_Up,
XK_Right,
XK_Down,
XK_j, //substick
XK_i,
XK_l,
XK_k,
XK_f, //dpad
XK_t,
XK_h,
XK_g,
XK_x, //buttons
XK_z,
XK_s,
XK_c,
XK_d,
XK_q,
XK_w,
XK_Return,
XK_Shift_L,
XK_Shift_L,
XK_Control_L
};
#endif
IniFile file;
file.Load("pad.ini");
for (int i = 0; i < NUMCONTROLS; i++)
{
file.Get("Bindings", controlNames[i], &keyForControl[i], defaultKeyForControl[i]);
}
file.Get("XPad1", "Rumble", &g_rumbleEnable, true);
}
void SaveConfig()
{
IniFile file;
file.Load("pad.ini");
for (int i = 0; i < NUMCONTROLS; i++)
{
file.Set("Bindings", controlNames[i], keyForControl[i]);
}
file.Set("XPad1", "Rumble", g_rumbleEnable);
file.Save("pad.ini");
}

View file

@ -1,39 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by resource.rc
//
#define IDD_PADCONFIG 101
#define IDD_ABOUTPAD 104
#define IDC_SETSTART 1003
#define IDC_SETA 1004
#define IDC_SETB 1005
#define IDC_SETX 1006
#define IDC_SETY 1007
#define IDC_SETZ 1008
#define IDC_SETSUBUP 1009
#define IDC_SETSUBLEFT 1010
#define IDC_SETSUBRIGHT 1011
#define IDC_SETSUBDOWN 1012
#define IDC_SETDPADUP 1013
#define IDC_SETDPADLEFT 1014
#define IDC_SETDPADRIGHT 1015
#define IDC_SETDPADDOWN 1016
#define IDC_SETMAINUP 1017
#define IDC_SETMAINLEFT 1018
#define IDC_SETMAINDOWN 1019
#define IDC_SETMAINRIGHT 1020
#define IDC_SETL 1021
#define IDC_SETR 1022
#define IDC_RUMBLE 1023
#define IDC_RUMBLE1 1023
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1024
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -1,137 +0,0 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_PADCONFIG DIALOGEX 0, 0, 344, 236
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Pad configuration"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Close",IDOK,287,215,50,14
PUSHBUTTON "start",IDC_SETSTART,147,103,40,14
PUSHBUTTON "a",IDC_SETA,249,83,40,14
PUSHBUTTON "b",IDC_SETB,221,99,40,14
PUSHBUTTON "x",IDC_SETX,206,72,40,14
PUSHBUTTON "y",IDC_SETY,292,90,40,14
PUSHBUTTON "z",IDC_SETZ,247,36,40,14
PUSHBUTTON " ",IDC_SETSUBUP,241,129,40,14
PUSHBUTTON " ",IDC_SETSUBLEFT,199,148,40,14
PUSHBUTTON " ",IDC_SETSUBRIGHT,281,147,40,14
PUSHBUTTON " ",IDC_SETSUBDOWN,242,168,40,14
PUSHBUTTON " ",IDC_SETDPADUP,72,130,40,14
PUSHBUTTON " ",IDC_SETDPADLEFT,29,146,40,14
PUSHBUTTON " ",IDC_SETDPADRIGHT,118,146,40,14
PUSHBUTTON " ",IDC_SETDPADDOWN,73,167,40,14
PUSHBUTTON " ",IDC_SETMAINUP,47,48,40,14
PUSHBUTTON " ",IDC_SETMAINLEFT,13,67,40,14
PUSHBUTTON " ",IDC_SETMAINDOWN,47,87,40,14
PUSHBUTTON " ",IDC_SETMAINRIGHT,85,67,40,14
PUSHBUTTON "l",IDC_SETL,97,17,40,14
PUSHBUTTON "r",IDC_SETR,222,17,40,14
GROUPBOX "Keyboard",IDC_STATIC,7,7,330,185
GROUPBOX "XBox 360 Pad",IDC_STATIC,7,196,107,33
CONTROL "Enable Rumble",IDC_RUMBLE1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,210,76,10
END
IDD_ABOUTPAD DIALOGEX 0, 0, 184, 76
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About Dolphin Simple Pad Plugin"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,127,55,50,14
LTEXT "Coded by F|RES and ector",IDC_STATIC,7,30,104,14
LTEXT "Keyboard and XInput simple pad plugin",IDC_STATIC,7,6,126,13
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_PADCONFIG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 337
TOPMARGIN, 7
BOTTOMMARGIN, 229
END
IDD_ABOUTPAD, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 177
TOPMARGIN, 6
BOTTOMMARGIN, 69
END
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED