Patch from the.emeralddragonfly which adds functionality to PadSimple:

- Adjustable partial press for the main stick, C-stick, and triggers
(separate keys + adjustable values for semi-L, semi-R, semi-main, semi-C)
- Escape key to clear a keybinding (especially useful now)
- A whole bunch of cleanuppy/consistency stuff.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4572 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
bztdlinux 2009-11-14 20:19:06 +00:00
parent b531c3a04d
commit 2814438e79
4 changed files with 569 additions and 404 deletions

View File

@ -15,6 +15,8 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include <sstream>
#include "Common.h"
#include "ConfigDlg.h"
#include "../PadSimple.h"
@ -38,33 +40,39 @@ BEGIN_EVENT_TABLE(PADConfigDialogSimple,wxDialog)
EVT_CHECKBOX(ID_DISABLE,PADConfigDialogSimple::ControllerSettingsChanged)
// Input recording
#ifdef RERECORDING
EVT_CHECKBOX(ID_RECORDING,PADConfigDialogSimple::ControllerSettingsChanged)
EVT_CHECKBOX(ID_PLAYBACK,PADConfigDialogSimple::ControllerSettingsChanged)
EVT_BUTTON(ID_SAVE_RECORDING,PADConfigDialogSimple::ControllerSettingsChanged)
#endif
#ifdef RERECORDING
EVT_CHECKBOX(ID_RECORDING,PADConfigDialogSimple::ControllerSettingsChanged)
EVT_CHECKBOX(ID_PLAYBACK,PADConfigDialogSimple::ControllerSettingsChanged)
EVT_BUTTON(ID_SAVE_RECORDING,PADConfigDialogSimple::ControllerSettingsChanged)
#endif
EVT_BUTTON(CTL_A,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_B,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_X,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_Y,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_Z,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_START,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_L,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_R,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAINUP,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAINDOWN,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAINLEFT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAINRIGHT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_SUBUP,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_SUBDOWN,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_SUBLEFT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_SUBRIGHT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADUP,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADDOWN,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADLEFT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADRIGHT,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_HALFPRESS,PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_A, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_B, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_X, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_Y, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_Z, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_START, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_L, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_R, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_L_SEMI, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_R_SEMI, PADConfigDialogSimple::OnButtonClick)
EVT_SLIDER(ID_TRIGGER_SEMIVALUE, PADConfigDialogSimple::ControllerSettingsChanged)
EVT_BUTTON(CTL_MAINUP, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAINDOWN, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAINLEFT, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAINRIGHT, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_MAIN_SEMI, PADConfigDialogSimple::OnButtonClick)
EVT_SLIDER(ID_MAIN_SEMIVALUE, PADConfigDialogSimple::ControllerSettingsChanged)
EVT_BUTTON(CTL_SUBUP, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_SUBDOWN, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_SUBLEFT, PADConfigDialogSimple::OnButtonClick)
EVT_SLIDER(ID_SUB_SEMIVALUE, PADConfigDialogSimple::ControllerSettingsChanged)
EVT_BUTTON(CTL_SUBRIGHT, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_SUB_SEMI, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADUP, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADDOWN, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADLEFT, PADConfigDialogSimple::OnButtonClick)
EVT_BUTTON(CTL_DPADRIGHT, PADConfigDialogSimple::OnButtonClick)
END_EVENT_TABLE()
PADConfigDialogSimple::PADConfigDialogSimple(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
@ -86,16 +94,16 @@ PADConfigDialogSimple::~PADConfigDialogSimple()
// Create input button controls
// -------------------
inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer,
const char *name, int ctl, int controller)
inline void AddControl(wxPanel *pan, wxButton **button,
wxStaticBoxSizer *sizer, const char *name, int ctl, int controller)
{
wxBoxSizer *hButton = new wxBoxSizer(wxHORIZONTAL);
char keyStr[10] = {0};
// Add the label
hButton->Add(new wxStaticText(pan, 0, wxString::FromAscii(name),
wxDefaultPosition, wxDefaultSize), 0,
wxALIGN_CENTER_VERTICAL|wxALL);
wxDefaultPosition, wxDefaultSize), 0,
wxALIGN_CENTER_VERTICAL|wxALL);
// Give it the mapped key name
#ifdef _WIN32
@ -106,12 +114,75 @@ inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer,
// Add the button to its sizer
*button = new wxButton(pan, ctl, wxString::FromAscii(keyStr),
wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
hButton->Add(*button, 0, wxALIGN_RIGHT|wxALL);
sizer->Add(hButton, 0, wxALIGN_RIGHT|wxALL);
}
// Create input slider controls
// -------------------
inline void PADConfigDialogSimple::AddSlider(wxPanel *pan, wxSlider **slider,
wxStaticBoxSizer *sizer, const char *name, int ctl, int controller)
{
wxBoxSizer *hSlider = new wxBoxSizer(wxHORIZONTAL);
int semivalue, maxvalue;
std::stringstream ss;
// Add the label
hSlider->Add(new wxStaticText(pan, 0, wxString::FromAscii(name),
wxDefaultPosition, wxDefaultSize), 0,
wxALIGN_CENTER_VERTICAL|wxALL);
// Do everything else
switch (ctl)
{
case ID_TRIGGER_SEMIVALUE:
semivalue = pad[controller].Trigger_semivalue;
maxvalue = TRIGGER_FULL;
// Add the slider to its sizer
*slider = new wxSlider(pan, ctl, semivalue, 0, maxvalue, wxDefaultPosition, wxSize(100,-1));
(**slider).SetPageSize(32);
hSlider->Add(*slider, 0, wxALIGN_RIGHT|wxALL);
sizer->Add(hSlider, 0, wxALIGN_RIGHT|wxALL);
// Add numeric value label to sizer
ss << pad[controller].Trigger_semivalue;
m_Trigger_SemiValue_Label[controller] = new wxStaticText(pan, 0,
wxString::FromAscii( ss.str().c_str() ), wxDefaultPosition, wxSize(25, -1));
hSlider->Add(m_Trigger_SemiValue_Label[controller],
0, wxALIGN_CENTER_VERTICAL|wxALL);
break;
case ID_MAIN_SEMIVALUE:
semivalue = pad[controller].Main_stick_semivalue;
maxvalue = STICK_FULL;
// Add the slider to its sizer
*slider = new wxSlider(pan, ctl, semivalue, 0, maxvalue, wxDefaultPosition, wxSize(100, -1));
(**slider).SetPageSize(10);
hSlider->Add(*slider, 0, wxALIGN_RIGHT|wxALL);
sizer->Add(hSlider, 0, wxALIGN_RIGHT|wxALL);
// Add numeric value label to sizer
ss << pad[controller].Main_stick_semivalue;
m_Stick_SemiValue_Label[controller] = new wxStaticText(pan, 0,
wxString::FromAscii( ss.str().c_str() ), wxDefaultPosition, wxSize(25, -1));
hSlider->Add(m_Stick_SemiValue_Label[controller],
0, wxALIGN_CENTER_VERTICAL|wxALL);
break;
case ID_SUB_SEMIVALUE:
semivalue = pad[controller].Sub_stick_semivalue;
maxvalue = STICK_FULL;
// Add the slider to its sizer
*slider = new wxSlider(pan, ctl, semivalue, 0, maxvalue, wxDefaultPosition, wxSize(100,-1));
(**slider).SetPageSize(10);
hSlider->Add(*slider, 0, wxALIGN_RIGHT|wxALL);
sizer->Add(hSlider, 0, wxALIGN_RIGHT|wxALL);
// Add numeric value label to sizer
ss << pad[controller].Sub_stick_semivalue;
m_CStick_SemiValue_Label[controller] = new wxStaticText(pan, 0,
wxString::FromAscii( ss.str().c_str() ), wxDefaultPosition, wxSize(25, -1));
hSlider->Add(m_CStick_SemiValue_Label[controller],
0, wxALIGN_CENTER_VERTICAL|wxALL);
break;
}
}
void PADConfigDialogSimple::CreateGUIControls()
{
@ -219,7 +290,7 @@ void PADConfigDialogSimple::CreateGUIControls()
// Rerecording
// ---------
#ifdef RERECORDING
#ifdef RERECORDING
// Create controls
m_SizeRecording[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Input Recording"));
m_CheckRecording[i] = new wxCheckBox(m_Controller[i], ID_RECORDING, wxT("Record input"));
@ -252,7 +323,7 @@ void PADConfigDialogSimple::CreateGUIControls()
m_CheckPlayback[0]->SetValue(pad[0].bPlayback);
//DEBUG_LOG(CONSOLE, "m_CheckRecording: %i\n", pad[0].bRecording, pad[0].bPlayback);
#endif
#endif
@ -270,12 +341,11 @@ void PADConfigDialogSimple::CreateGUIControls()
sTriggers[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Triggers"));
AddControl(m_Controller[i], &(m_ButtonL[i]), sTriggers[i], " L: ", CTL_L, i);
AddControl(m_Controller[i], &(m_ButtonR[i]), sTriggers[i], " R: ", CTL_R, i);
sModifiers[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Modifiers"));
AddControl(m_Controller[i], &(m_HalfPress[i]), sModifiers[i], "1/2 Press: ", CTL_HALFPRESS, i);
AddControl(m_Controller[i], &(m_ButtonL[i]), sTriggers[i], "L: ", CTL_L, i);
AddControl(m_Controller[i], &(m_ButtonR[i]), sTriggers[i], "R: ", CTL_R, i);
AddControl(m_Controller[i], &(m_ButtonL_Semi[i]), sTriggers[i], "Semi-L: ", CTL_L_SEMI, i);
AddControl(m_Controller[i], &(m_ButtonR_Semi[i]), sTriggers[i], "Semi-R: ", CTL_R_SEMI, i);
AddSlider(m_Controller[i], &(m_Trigger_SemiValue[i]), sTriggers[i], "Semi: ", ID_TRIGGER_SEMIVALUE, i);
sStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Main Stick"));
@ -283,6 +353,8 @@ void PADConfigDialogSimple::CreateGUIControls()
AddControl(m_Controller[i], &(m_StickDown[i]), sStick[i], "Down: ", CTL_MAINDOWN, i);
AddControl(m_Controller[i], &(m_StickLeft[i]), sStick[i], "Left: ", CTL_MAINLEFT, i);
AddControl(m_Controller[i], &(m_StickRight[i]), sStick[i], "Right: ", CTL_MAINRIGHT, i);
AddControl(m_Controller[i], &(m_Stick_Semi[i]), sStick[i], "Semi-press: ", CTL_MAIN_SEMI, i);
AddSlider(m_Controller[i], &(m_Stick_SemiValue[i]), sStick[i], "Semi: ", ID_MAIN_SEMIVALUE, i);
sDPad[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("D-Pad"));
@ -297,6 +369,8 @@ void PADConfigDialogSimple::CreateGUIControls()
AddControl(m_Controller[i], &(m_CStickDown[i]), sCStick[i], "Down: ", CTL_SUBDOWN, i);
AddControl(m_Controller[i], &(m_CStickLeft[i]), sCStick[i], "Left: ", CTL_SUBLEFT, i);
AddControl(m_Controller[i], &(m_CStickRight[i]), sCStick[i], "Right: ", CTL_SUBRIGHT, i);
AddControl(m_Controller[i], &(m_CStick_Semi[i]), sCStick[i], "Semi-press: ", CTL_SUB_SEMI, i);
AddSlider(m_Controller[i], &(m_CStick_SemiValue[i]), sCStick[i], "Semi: ", ID_SUB_SEMIVALUE, i);
// --------------------------------------------------------------------
// Sizers
@ -307,7 +381,6 @@ void PADConfigDialogSimple::CreateGUIControls()
sPage[i]->Add(sDevice[i], wxGBPosition(0, 0), wxGBSpan(1, 5), wxEXPAND|wxALL, 1);
sPage[i]->Add(sButtons[i], wxGBPosition(1, 0), wxGBSpan(2, 1), wxALL, 1);
sPage[i]->Add(sTriggers[i], wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 1);
sPage[i]->Add(sModifiers[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);
@ -324,6 +397,11 @@ void PADConfigDialogSimple::OnClose(wxCloseEvent& event)
EndModal(0);
}
void PADConfigDialogSimple::OnCloseClick(wxCommandEvent& event)
{
Close();
}
void PADConfigDialogSimple::OnShow(wxShowEvent& event)
{
#ifdef _WIN32
@ -334,30 +412,46 @@ void PADConfigDialogSimple::OnShow(wxShowEvent& event)
void PADConfigDialogSimple::OnKeyDown(wxKeyEvent& event)
{
char keyStr[10] = {0};
if(ClickedButton != NULL)
if(ClickedButton)
{
// Get the selected notebook page
int page = m_Notebook->GetSelection();
#ifdef _WIN32
m_dinput.Read();
for(int i = 0; i < 255; i++)
if (m_dinput.diks[DIK_ESCAPE])
{
if(m_dinput.diks[i])
pad[page].keyForControl[ClickedButton->GetId()] = 0x00;
ClickedButton->SetLabel(wxString::FromAscii(""));
}
else
{
for(int i = 0; i < 255; i++)
{
// Save the mapped key, the wxButtons have the Id 0 to 21
pad[page].keyForControl[ClickedButton->GetId()] = i;
// Get the key name
DInput::DIKToString(i, keyStr);
ClickedButton->SetLabel(wxString::FromAscii(keyStr));
break;
if(m_dinput.diks[i])
{
// Save the mapped key
pad[page].keyForControl[ClickedButton->GetId()] = i;
// Get the key name
DInput::DIKToString(i, keyStr);
ClickedButton->SetLabel(wxString::FromAscii(keyStr));
break;
}
}
}
#elif defined(HAVE_X11) && HAVE_X11
pad[page].keyForControl[ClickedButton->GetId()] = InputCommon::wxCharCodeWXToX(event.GetKeyCode());
InputCommon::XKeyToString(pad[page].keyForControl[ClickedButton->GetId()], keyStr);
ClickedButton->SetLabel(wxString::FromAscii(keyStr));
#elif defined(HAVE_X11) && HAVE_X11
if (event.GetKeyCode() == (XK_Escape & 0xFF))
{
pad[page].keyForControl[ClickedButton->GetId()] = InputCommon::wxCharCodeWXToX(0x00);
ClickedButton->SetLabel(wxString::FromAscii(""));
}
else
{
pad[page].keyForControl[ClickedButton->GetId()] = InputCommon::wxCharCodeWXToX(event.GetKeyCode());
InputCommon::XKeyToString(pad[page].keyForControl[ClickedButton->GetId()], keyStr);
ClickedButton->SetLabel(wxString::FromAscii(keyStr));
}
#endif
ClickedButton->Disconnect();
}
@ -370,9 +464,9 @@ void PADConfigDialogSimple::OnKeyDown(wxKeyEvent& event)
void PADConfigDialogSimple::OnButtonClick(wxCommandEvent& event)
{
// Check if the Space key was set, to solve the problem that the Space key calls this function
#ifdef _WIN32
if (m_dinput.diks[DIK_SPACE]) { m_dinput.diks[DIK_SPACE] = 0; return; }
#endif
#ifdef _WIN32
if (m_dinput.diks[DIK_SPACE]) { m_dinput.diks[DIK_SPACE] = 0; return; }
#endif
// If we come here again before any key was set
if(ClickedButton) ClickedButton->SetLabel(oldLabel);
@ -380,19 +474,15 @@ void PADConfigDialogSimple::OnButtonClick(wxCommandEvent& event)
// Save the old button label so we can reapply it if necessary
ClickedButton = (wxButton *)event.GetEventObject();
oldLabel = ClickedButton->GetLabel();
ClickedButton->SetLabel(_("Press Key"));
ClickedButton->SetLabel(_("Press Key/Esc"));
ClickedButton->SetWindowStyle(wxWANTS_CHARS);
}
void PADConfigDialogSimple::OnCloseClick(wxCommandEvent& event)
{
Close();
}
void PADConfigDialogSimple::ControllerSettingsChanged(wxCommandEvent& event)
{
int page = m_Notebook->GetSelection();
std::stringstream ss;
switch (event.GetId())
{
@ -414,8 +504,25 @@ void PADConfigDialogSimple::ControllerSettingsChanged(wxCommandEvent& event)
pad[page].bRumble = m_Rumble[page]->GetValue();
break;
// Semi-press adjustment
case ID_TRIGGER_SEMIVALUE:
pad[page].Trigger_semivalue = m_Trigger_SemiValue[page]->GetValue();
ss << pad[page].Trigger_semivalue;
(*m_Trigger_SemiValue_Label[page]).SetLabel(wxString::FromAscii( ss.str().c_str() ));
break;
case ID_MAIN_SEMIVALUE:
pad[page].Main_stick_semivalue = m_Stick_SemiValue[page]->GetValue();
ss << pad[page].Main_stick_semivalue;
(*m_Stick_SemiValue_Label[page]).SetLabel(wxString::FromAscii( ss.str().c_str() ));
break;
case ID_SUB_SEMIVALUE:
pad[page].Sub_stick_semivalue = m_CStick_SemiValue[page]->GetValue();
ss << pad[page].Sub_stick_semivalue;
(*m_CStick_SemiValue_Label[page]).SetLabel(wxString::FromAscii( ss.str().c_str() ));
break;
// Input recording
#ifdef RERECORDING
#ifdef RERECORDING
case ID_RECORDING:
pad[page].bRecording = m_CheckRecording[page]->GetValue();
// Turn off the other option
@ -430,7 +537,7 @@ void PADConfigDialogSimple::ControllerSettingsChanged(wxCommandEvent& event)
// Double check again that we are still running a game
if (g_EmulatorRunning) SaveRecord();
break;
#endif
#endif
}
}

View File

@ -55,7 +55,6 @@ class PADConfigDialogSimple : public wxDialog
wxGridBagSizer *sPage[4];
wxStaticBoxSizer *sButtons[4];
wxStaticBoxSizer *sTriggers[4];
wxStaticBoxSizer *sModifiers[4];
wxStaticBoxSizer *sStick[4];
wxStaticBoxSizer *sCStick[4];
wxStaticBoxSizer *sDPad[4];
@ -79,15 +78,24 @@ class PADConfigDialogSimple : public wxDialog
wxButton *m_ButtonStart[4];
wxButton *m_ButtonL[4];
wxButton *m_ButtonR[4];
wxButton *m_HalfPress[4];
wxButton *m_ButtonL_Semi[4];
wxButton *m_ButtonR_Semi[4];
wxSlider *m_Trigger_SemiValue[4];
wxStaticText *m_Trigger_SemiValue_Label[4];
wxButton *m_StickUp[4];
wxButton *m_StickDown[4];
wxButton *m_StickLeft[4];
wxButton *m_StickRight[4];
wxButton *m_Stick_Semi[4];
wxSlider *m_Stick_SemiValue[4];
wxStaticText *m_Stick_SemiValue_Label[4];
wxButton *m_CStickUp[4];
wxButton *m_CStickDown[4];
wxButton *m_CStickLeft[4];
wxButton *m_CStickRight[4];
wxButton *m_CStick_Semi[4];
wxSlider *m_CStick_SemiValue[4];
wxStaticText *m_CStick_SemiValue_Label[4];
wxButton *m_DPadUp[4];
wxButton *m_DPadDown[4];
wxButton *m_DPadLeft[4];
@ -108,6 +116,11 @@ class PADConfigDialogSimple : public wxDialog
ID_X360PAD,
ID_RUMBLE,
// Semi-press values
ID_TRIGGER_SEMIVALUE,
ID_MAIN_SEMIVALUE,
ID_SUB_SEMIVALUE,
// Input recording
ID_RECORDING,
ID_PLAYBACK,
@ -115,7 +128,7 @@ class PADConfigDialogSimple : public wxDialog
// General settings
ID_DISABLE,
ID_PAD_ABOUT
ID_PAD_ABOUT,
};
void OnClose(wxCloseEvent& event);
@ -126,8 +139,9 @@ class PADConfigDialogSimple : public wxDialog
void OnButtonClick(wxCommandEvent& event);
void DllAbout(wxCommandEvent& event);
void OnShow(wxShowEvent& event);
void AddSlider(wxPanel *pan, wxSlider **slider,
wxStaticBoxSizer *sizer, const char *name, int ctl, int controller);
int keyPress;
wxButton *ClickedButton;
wxString oldLabel;
};

View File

@ -76,7 +76,7 @@ class wxDLLApp : public wxApp
return true;
}
};
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
#endif
@ -97,7 +97,7 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
return FALSE;
#endif
}
break;
break;
case DLL_PROCESS_DETACH:
#if defined(HAVE_WX) && HAVE_WX
@ -268,54 +268,96 @@ void DInput_Read(int _numPAD, SPADStatus* _pPADStatus)
{
dinput.Read();
int stickvalue = (dinput.diks[pad[_numPAD].keyForControl[CTL_HALFPRESS]] & 0xFF) ? 40 : 100;
int triggervalue = (dinput.diks[pad[_numPAD].keyForControl[CTL_HALFPRESS]] & 0xFF) ? 100 : 255;
// get the new keys
if (dinput.diks[pad[_numPAD].keyForControl[CTL_MAINLEFT]] & 0xFF){_pPADStatus->stickX -= stickvalue;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_MAINRIGHT]] & 0xFF){_pPADStatus->stickX += stickvalue;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_MAINDOWN]] & 0xFF){_pPADStatus->stickY -= stickvalue;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_MAINUP]] & 0xFF){_pPADStatus->stickY += stickvalue;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_SUBLEFT]] & 0xFF){_pPADStatus->substickX -= stickvalue;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_SUBRIGHT]] & 0xFF){_pPADStatus->substickX += stickvalue;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_SUBDOWN]] & 0xFF){_pPADStatus->substickY -= stickvalue;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_SUBUP]] & 0xFF){_pPADStatus->substickY += stickvalue;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_L]] & 0xFF)
{
if (triggervalue > 230)
_pPADStatus->button |= PAD_TRIGGER_L;
_pPADStatus->triggerLeft = triggervalue;
}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_R]] & 0xFF)
{
if (triggervalue > 230)
_pPADStatus->button |= PAD_TRIGGER_R;
_pPADStatus->triggerRight = triggervalue;
}
// Analog stick values based on semi-press keys
int mainstickvalue = (dinput.diks[pad[_numPAD].keyForControl[CTL_MAIN_SEMI]] & 0xFF) ? pad[_numPAD].Main_stick_semivalue : STICK_FULL;
int substickvalue = (dinput.diks[pad[_numPAD].keyForControl[CTL_SUB_SEMI]] & 0xFF) ? pad[_numPAD].Sub_stick_semivalue : STICK_FULL;
// Buttons (A/B/X/Y/Z/Start)
if (dinput.diks[pad[_numPAD].keyForControl[CTL_A]] & 0xFF)
{
_pPADStatus->button |= PAD_BUTTON_A;
_pPADStatus->analogA = 255;
_pPADStatus->analogA = BUTTON_FULL;
}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_B]] & 0xFF)
{
_pPADStatus->button |= PAD_BUTTON_B;
_pPADStatus->analogB = 255;
_pPADStatus->analogB = BUTTON_FULL;
}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_X]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_X;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_Y]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_Y;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_Z]] & 0xFF){_pPADStatus->button |= PAD_TRIGGER_Z;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADUP]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_UP;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADDOWN]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_DOWN;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADLEFT]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_LEFT;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADRIGHT]]& 0xFF){_pPADStatus->button |= PAD_BUTTON_RIGHT;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_START]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_START;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_START]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_START;}
// Triggers (L/R)
if (dinput.diks[pad[_numPAD].keyForControl[CTL_L]] & 0xFF)
{
_pPADStatus->button |= PAD_TRIGGER_L;
_pPADStatus->triggerLeft = TRIGGER_FULL;
}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_R]] & 0xFF)
{
_pPADStatus->button |= PAD_TRIGGER_R;
_pPADStatus->triggerRight = TRIGGER_FULL;
}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_L_SEMI]] & 0xFF)
{
_pPADStatus->triggerLeft = pad[_numPAD].Trigger_semivalue;
if (pad[_numPAD].Trigger_semivalue > TRIGGER_THRESHOLD)
_pPADStatus->button |= PAD_TRIGGER_L;
}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_R_SEMI]] & 0xFF)
{
_pPADStatus->triggerRight = pad[_numPAD].Trigger_semivalue;
if (pad[_numPAD].Trigger_semivalue > TRIGGER_THRESHOLD)
_pPADStatus->button |= PAD_TRIGGER_R;
}
// Main stick
int mainY = 0;
int mainX = 0;
if (dinput.diks[pad[_numPAD].keyForControl[CTL_MAINUP]] & 0xFF)
mainY = mainstickvalue;
else if (dinput.diks[pad[_numPAD].keyForControl[CTL_MAINDOWN]] & 0xFF)
mainY = -mainstickvalue;
if (dinput.diks[pad[_numPAD].keyForControl[CTL_MAINLEFT]] & 0xFF)
mainX = -mainstickvalue;
else if (dinput.diks[pad[_numPAD].keyForControl[CTL_MAINRIGHT]] & 0xFF)
mainX = mainstickvalue;
if (mainX == 0 || mainY == 0)
{
_pPADStatus->stickX += mainX;
_pPADStatus->stickY += mainY;
}
else
{
_pPADStatus->stickX += mainX*3/4; // 3/4 = 0.75 is a little faster
_pPADStatus->stickY += mainY*3/4; // than sqrt(2) = 0.7071...
// In SMS, 17/20 = 0.85 is perfect; in WW, 7/10 = 0.70 is closer.
}
// Sub-stick (C-stick)
int subY = 0;
int subX = 0;
if (dinput.diks[pad[_numPAD].keyForControl[CTL_SUBUP]] & 0xFF)
subY = substickvalue;
else if (dinput.diks[pad[_numPAD].keyForControl[CTL_SUBDOWN]] & 0xFF)
subY = -substickvalue;
if (dinput.diks[pad[_numPAD].keyForControl[CTL_SUBLEFT]] & 0xFF)
subX = -substickvalue;
else if (dinput.diks[pad[_numPAD].keyForControl[CTL_SUBRIGHT]] & 0xFF)
subX = substickvalue;
if (subX == 0 || subY == 0)
{
_pPADStatus->substickX += subX;
_pPADStatus->substickY += subY;
}
else
{
_pPADStatus->substickX += subX*17/20;
_pPADStatus->substickY += subY*17/20;
}
// D-pad
if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADUP]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_UP;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADDOWN]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_DOWN;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADLEFT]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_LEFT;}
if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADRIGHT]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_RIGHT;}
// Mic key
_pPADStatus->MicButton = (dinput.diks[pad[_numPAD].keyForControl[CTL_MIC]] & 0xFF) ? true : false;
}
@ -348,21 +390,21 @@ bool XInput_Read(int XPadPlayer, SPADStatus* _pPADStatus)
xpad.sThumbRY);
}
if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_UP) {_pPADStatus->button |= PAD_BUTTON_UP;}
if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) {_pPADStatus->button |= PAD_BUTTON_DOWN;}
if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) {_pPADStatus->button |= PAD_BUTTON_LEFT;}
if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) {_pPADStatus->button |= PAD_BUTTON_RIGHT;}
_pPADStatus->triggerLeft = xpad.bLeftTrigger;
_pPADStatus->triggerRight = xpad.bRightTrigger;
if (xpad.bLeftTrigger > 200) {_pPADStatus->button |= PAD_TRIGGER_L;}
if (xpad.bRightTrigger > 200) {_pPADStatus->button |= PAD_TRIGGER_R;}
if (xpad.wButtons & XINPUT_GAMEPAD_A) {_pPADStatus->button |= PAD_BUTTON_A;}
if (xpad.wButtons & XINPUT_GAMEPAD_X) {_pPADStatus->button |= PAD_BUTTON_B;}
if (xpad.wButtons & XINPUT_GAMEPAD_B) {_pPADStatus->button |= PAD_BUTTON_X;}
if (xpad.wButtons & XINPUT_GAMEPAD_Y) {_pPADStatus->button |= PAD_BUTTON_Y;}
if (xpad.bLeftTrigger > TRIGGER_THRESHOLD) {_pPADStatus->button |= PAD_TRIGGER_L;}
if (xpad.bRightTrigger > TRIGGER_THRESHOLD) {_pPADStatus->button |= PAD_TRIGGER_R;}
if (xpad.wButtons & XINPUT_GAMEPAD_START) {_pPADStatus->button |= PAD_BUTTON_START;}
if (xpad.wButtons & XINPUT_GAMEPAD_A) {_pPADStatus->button |= PAD_BUTTON_A;}
if (xpad.wButtons & XINPUT_GAMEPAD_B) {_pPADStatus->button |= PAD_BUTTON_X;}
if (xpad.wButtons & XINPUT_GAMEPAD_X) {_pPADStatus->button |= PAD_BUTTON_B;}
if (xpad.wButtons & XINPUT_GAMEPAD_Y) {_pPADStatus->button |= PAD_BUTTON_Y;}
if (xpad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER){_pPADStatus->button |= PAD_TRIGGER_Z;}
if (xpad.wButtons & XINPUT_GAMEPAD_START) {_pPADStatus->button |= PAD_BUTTON_START;}
if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) {_pPADStatus->button |= PAD_BUTTON_LEFT;}
if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) {_pPADStatus->button |= PAD_BUTTON_RIGHT;}
if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_UP) {_pPADStatus->button |= PAD_BUTTON_UP;}
if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) {_pPADStatus->button |= PAD_BUTTON_DOWN;}
//_pPADStatus->MicButton = (xpad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) ? true : false;
@ -375,234 +417,197 @@ bool XInput_Read(int XPadPlayer, SPADStatus* _pPADStatus)
}
#endif
#if (defined(HAVE_X11) && HAVE_X11) || (defined(HAVE_COCOA) && HAVE_COCOA)
#if defined(HAVE_X11) && HAVE_X11
// 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;
}
// This code is from Zerofrog's pcsx2 pad plugin
XEvent E;
//int keyPress=0, keyRelease=0;
KeySym key;
// keyboard input
int num_events;
for (num_events = XPending(GXdsp);num_events > 0;num_events--) {
XNextEvent(GXdsp, &E);
switch (E.type) {
case KeyPress:
//_KeyPress(pad, XLookupKeysym((XKeyEvent *)&E, 0)); break;
// Do all the stuff we need to do once per frame here
if (_numPAD != 0)
return;
// This code is from Zerofrog's pcsx2 pad plugin
XEvent E;
//int keyPress=0, keyRelease=0;
KeySym key;
key = XLookupKeysym((XKeyEvent*)&E, 0);
if((key >= XK_F1 && key <= XK_F9) ||
key == XK_Shift_L || key == XK_Shift_R ||
key == XK_Control_L || key == XK_Control_R) {
XPutBackEvent(GXdsp, &E);
break;
}
// keyboard input
int num_events;
for (num_events = XPending(GXdsp);num_events > 0;num_events--)
{
XNextEvent(GXdsp, &E);
switch (E.type)
{
case KeyPress:
//_KeyPress(pad, XLookupKeysym((XKeyEvent *)&E, 0));
//break;
key = XLookupKeysym((XKeyEvent*)&E, 0);
int i;
for (i = 0; i < NUMCONTROLS; i++) {
if (key == pad[_numPAD].keyForControl[i]) {
KeyStatus[i] = true;
break;
}
}
break;
case KeyRelease:
key = XLookupKeysym((XKeyEvent*)&E, 0);
if((key >= XK_F1 && key <= XK_F9) ||
key == XK_Shift_L || key == XK_Shift_R ||
key == XK_Control_L || key == XK_Control_R) {
XPutBackEvent(GXdsp, &E);
break;
}
//_KeyRelease(pad, XLookupKeysym((XKeyEvent *)&E, 0));
for (i = 0; i < NUMCONTROLS; i++) {
if (key == pad[_numPAD].keyForControl[i]) {
KeyStatus[i] = false;
break;
}
}
break;
default:
break;
}
}
int stickvalue = (KeyStatus[CTL_HALFPRESS]) ? 40 : 100;
int triggervalue = (KeyStatus[CTL_HALFPRESS]) ? 100 : 255;
if (KeyStatus[CTL_MAINLEFT]){_pPADStatus->stickX -= stickvalue;}
if (KeyStatus[CTL_MAINUP]){_pPADStatus->stickY += stickvalue;}
if (KeyStatus[CTL_MAINRIGHT]){_pPADStatus->stickX += stickvalue;}
if (KeyStatus[CTL_MAINDOWN]){_pPADStatus->stickY -= stickvalue;}
if (KeyStatus[CTL_SUBLEFT]){_pPADStatus->substickX -= stickvalue;}
if (KeyStatus[CTL_SUBUP]){_pPADStatus->substickY += stickvalue;}
if (KeyStatus[CTL_SUBRIGHT]){_pPADStatus->substickX += stickvalue;}
if (KeyStatus[CTL_SUBDOWN]){_pPADStatus->substickY -= stickvalue;}
if (KeyStatus[CTL_DPADLEFT]){_pPADStatus->button |= PAD_BUTTON_LEFT;}
if (KeyStatus[CTL_DPADUP]){_pPADStatus->button |= PAD_BUTTON_UP;}
if (KeyStatus[CTL_DPADRIGHT]){_pPADStatus->button |= PAD_BUTTON_RIGHT;}
if (KeyStatus[CTL_DPADDOWN]){_pPADStatus->button |= PAD_BUTTON_DOWN;}
if (KeyStatus[CTL_A]) {
_pPADStatus->button |= PAD_BUTTON_A;
_pPADStatus->analogA = 255;
}
if (KeyStatus[CTL_B]) {
_pPADStatus->button |= PAD_BUTTON_B;
_pPADStatus->analogB = 255;
}
if (KeyStatus[CTL_X]){_pPADStatus->button |= PAD_BUTTON_X;}
if (KeyStatus[CTL_Y]){_pPADStatus->button |= PAD_BUTTON_Y;}
if (KeyStatus[CTL_Z]){_pPADStatus->button |= PAD_TRIGGER_Z;}
if (KeyStatus[CTL_L]) {
_pPADStatus->button |= PAD_TRIGGER_L;
_pPADStatus->triggerLeft = triggervalue;
}
if (KeyStatus[CTL_R]) {
_pPADStatus->button |= PAD_TRIGGER_R;
_pPADStatus->triggerRight = triggervalue;
}
if (KeyStatus[CTL_START]){_pPADStatus->button |= PAD_BUTTON_START;}
if (KeyStatus[CTL_MIC])
_pPADStatus->MicButton = true;
else
_pPADStatus->MicButton = false;
}
#endif
#if defined(HAVE_COCOA) && HAVE_COCOA
if((key >= XK_F1 && key <= XK_F9) ||
key == XK_Shift_L || key == XK_Shift_R ||
key == XK_Control_L || key == XK_Control_R)
{
XPutBackEvent(GXdsp, &E);
break;
}
int i;
for (i = 0; i < NUMCONTROLS; i++) {
if (key == pad[_numPAD].keyForControl[i]) {
KeyStatus[i] = true;
break;
}
}
break;
case KeyRelease:
key = XLookupKeysym((XKeyEvent*)&E, 0);
if((key >= XK_F1 && key <= XK_F9) ||
key == XK_Shift_L || key == XK_Shift_R ||
key == XK_Control_L || key == XK_Control_R)
{
XPutBackEvent(GXdsp, &E);
break;
}
//_KeyRelease(pad, XLookupKeysym((XKeyEvent *)&E, 0));
for (i = 0; i < NUMCONTROLS; i++)
{
if (key == pad[_numPAD].keyForControl[i])
{
KeyStatus[i] = false;
break;
}
}
break;
}
}
#elif defined(HAVE_COCOA) && HAVE_COCOA
void cocoa_Read(int _numPAD, SPADStatus* _pPADStatus)
{
// Do all the stuff we need to do once per frame here
if (_numPAD != 0) {
return;
}
// Do all the stuff we need to do once per frame here
if (_numPAD != 0)
return;
//get event from main thread
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSConnection *conn;
NSDistantObject *proxy;
NSConnection *conn;
NSDistantObject *proxy;
conn = [NSConnection connectionWithRegisteredName:@"DolphinCocoaEvent" host:nil];
if (!conn) {
//printf("error creating cnx event client\n");
}
proxy = [conn rootProxy];
if (!proxy) {
//printf("error prox client\n");
}
//if (!conn) {
//printf("error creating cnx event client\n");
//}
proxy = [conn rootProxy];
//if (!proxy) {
// printf("error prox client\n");
//}
long cocoaKey = (long)[proxy keyCode];
int i;
if ((long)[proxy type] == 10)
if ((long)[proxy type] == 10)
{
for (i = 0; i < NUMCONTROLS; i++) {
if (cocoaKey == pad[_numPAD].keyForControl[i]) {
KeyStatus[i] = true;
break;
}
}
for (i = 0; i < NUMCONTROLS; i++)
{
if (cocoaKey == pad[_numPAD].keyForControl[i])
{
KeyStatus[i] = true;
break;
}
}
}
else
else
{
for (i = 0; i < NUMCONTROLS; i++) {
if (cocoaKey == pad[_numPAD].keyForControl[i]) {
KeyStatus[i] = false;
break;
}
}
for (i = 0; i < NUMCONTROLS; i++)
{
if (cocoaKey == pad[_numPAD].keyForControl[i])
{
KeyStatus[i] = false;
break;
}
}
}
int stickvalue = (KeyStatus[CTL_HALFPRESS]) ? 40 : 100;
int triggervalue = (KeyStatus[CTL_HALFPRESS]) ? 100 : 255;
if (KeyStatus[CTL_MAINLEFT]){_pPADStatus->stickX -= stickvalue;}
if (KeyStatus[CTL_MAINUP]){_pPADStatus->stickY += stickvalue;}
if (KeyStatus[CTL_MAINRIGHT]){_pPADStatus->stickX += stickvalue;}
if (KeyStatus[CTL_MAINDOWN]){_pPADStatus->stickY -= stickvalue;}
if (KeyStatus[CTL_SUBLEFT]){_pPADStatus->substickX -= stickvalue;}
if (KeyStatus[CTL_SUBUP]){_pPADStatus->substickY += stickvalue;}
if (KeyStatus[CTL_SUBRIGHT]){_pPADStatus->substickX += stickvalue;}
if (KeyStatus[CTL_SUBDOWN]){_pPADStatus->substickY -= stickvalue;}
if (KeyStatus[CTL_DPADLEFT]){_pPADStatus->button |= PAD_BUTTON_LEFT;}
if (KeyStatus[CTL_DPADUP]){_pPADStatus->button |= PAD_BUTTON_UP;}
if (KeyStatus[CTL_DPADRIGHT]){_pPADStatus->button |= PAD_BUTTON_RIGHT;}
if (KeyStatus[CTL_DPADDOWN]){_pPADStatus->button |= PAD_BUTTON_DOWN;}
if (KeyStatus[CTL_A]) {
_pPADStatus->button |= PAD_BUTTON_A;
_pPADStatus->analogA = 255;
}
if (KeyStatus[CTL_B]) {
_pPADStatus->button |= PAD_BUTTON_B;
_pPADStatus->analogB = 255;
}
if (KeyStatus[CTL_X]){_pPADStatus->button |= PAD_BUTTON_X;}
if (KeyStatus[CTL_Y]){_pPADStatus->button |= PAD_BUTTON_Y;}
if (KeyStatus[CTL_Z]){_pPADStatus->button |= PAD_TRIGGER_Z;}
if (KeyStatus[CTL_L]) {
_pPADStatus->button |= PAD_TRIGGER_L;
_pPADStatus->triggerLeft = triggervalue;
}
if (KeyStatus[CTL_R]) {
_pPADStatus->button |= PAD_TRIGGER_R;
_pPADStatus->triggerRight = triggervalue;
}
if (KeyStatus[CTL_START]){_pPADStatus->button |= PAD_BUTTON_START;}
if (KeyStatus[CTL_MIC])
_pPADStatus->MicButton = true;
else
_pPADStatus->MicButton = false;
[pool release];
}
#endif
// Analog stick values based on semi-press keys
int mainstickvalue = (KeyStatus[CTL_MAIN_SEMI]) ? pad[_numPAD].Main_stick_semivalue : STICK_FULL;
int substickvalue = (KeyStatus[CTL_SUB_SEMI]) ? pad[_numPAD].Sub_stick_semivalue : STICK_FULL;
// Buttons (A/B/X/Y/Z/Start)
if (KeyStatus[CTL_A])
{
_pPADStatus->button |= PAD_BUTTON_A;
_pPADStatus->analogA = BUTTON_FULL;
}
if (KeyStatus[CTL_B])
{
_pPADStatus->button |= PAD_BUTTON_B;
_pPADStatus->analogB = BUTTON_FULL;
}
if (KeyStatus[CTL_X]){_pPADStatus->button |= PAD_BUTTON_X;}
if (KeyStatus[CTL_Y]){_pPADStatus->button |= PAD_BUTTON_Y;}
if (KeyStatus[CTL_Z]){_pPADStatus->button |= PAD_TRIGGER_Z;}
if (KeyStatus[CTL_START]){_pPADStatus->button |= PAD_BUTTON_START;}
// Triggers (L/R)
if (KeyStatus[CTL_L]){_pPADStatus->triggerLeft = TRIGGER_FULL;}
if (KeyStatus[CTL_R]){_pPADStatus->triggerRight = TRIGGER_FULL;}
if (KeyStatus[CTL_L_SEMI]){_pPADStatus->triggerLeft = pad[_numPAD].Trigger_semivalue;}
if (KeyStatus[CTL_R_SEMI]){_pPADStatus->triggerRight = pad[_numPAD].Trigger_semivalue;}
// Main stick
int mainY = 0;
int mainX = 0;
if (KeyStatus[CTL_MAINUP])
mainY = mainstickvalue;
else if (KeyStatus[CTL_MAINDOWN])
mainY = -mainstickvalue;
if (KeyStatus[CTL_MAINLEFT])
mainX = -mainstickvalue;
else if (KeyStatus[CTL_MAINRIGHT])
mainX = mainstickvalue;
if (mainX == 0 || mainY == 0)
{
_pPADStatus->stickX += mainX;
_pPADStatus->stickY += mainY;
}
else
{
_pPADStatus->stickX += mainX*17/20;
_pPADStatus->stickY += mainY*17/20;
}
// Sub-stick (C-stick)
int subY = 0;
int subX = 0;
if (KeyStatus[CTL_SUBUP])
subY = substickvalue;
else if (KeyStatus[CTL_SUBDOWN])
subY = -substickvalue;
if (KeyStatus[CTL_SUBLEFT])
subX = -substickvalue;
else if (KeyStatus[CTL_SUBRIGHT])
subX = substickvalue;
if (subX == 0 || subY == 0)
{
_pPADStatus->substickX += subX;
_pPADStatus->substickY += subY;
}
else
{
_pPADStatus->substickX += subX*17/20;
_pPADStatus->substickY += subY*17/20;
}
// D-pad
if (KeyStatus[CTL_DPADUP]) {_pPADStatus->button |= PAD_BUTTON_UP;}
if (KeyStatus[CTL_DPADDOWN]) {_pPADStatus->button |= PAD_BUTTON_DOWN;}
if (KeyStatus[CTL_DPADLEFT]) {_pPADStatus->button |= PAD_BUTTON_LEFT;}
if (KeyStatus[CTL_DPADRIGHT]){_pPADStatus->button |= PAD_BUTTON_RIGHT;}
// Mic key
_pPADStatus->MicButton = KeyStatus[CTL_MIC];
#if defined(HAVE_X11) && HAVE_X11
}
#elif defined(HAVE_COCOA) && HAVE_COCOA
[pool release];
}
#endif
#endif
//******************************************************************************
// Plugin specification functions
//******************************************************************************
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
{
_PluginInfo->Version = 0x0100;
@ -772,7 +777,8 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
_pPADStatus->err = PAD_ERR_NONE;
// Read XInput
if (pad[_numPAD].bEnableXPad) XInput_Read(pad[_numPAD].XPadPlayer, _pPADStatus);
if (pad[_numPAD].bEnableXPad)
XInput_Read(pad[_numPAD].XPadPlayer, _pPADStatus);
// Read Direct Input
DInput_Read(_numPAD, _pPADStatus);
@ -834,82 +840,94 @@ void LoadConfig()
#ifdef _WIN32
const int defaultKeyForControl[NUMCONTROLS] =
{
DIK_X, //A
DIK_Z,
DIK_C,
DIK_S,
DIK_D,
DIK_RETURN,
DIK_Q,
DIK_W,
DIK_UP, //mainstick
DIK_DOWN,
DIK_LEFT,
DIK_RIGHT,
DIK_I, //substick
DIK_K,
DIK_J,
DIK_L,
DIK_T, //dpad
DIK_G,
DIK_F,
DIK_H,
DIK_LSHIFT, //halfpress
DIK_M //Mic
DIK_X, // A
DIK_Z, // B
DIK_C, // X
DIK_S, // Y
DIK_D, // Z
DIK_RETURN, // Start
DIK_Q, // L
DIK_W, // R
0x00, // L semi-press
0x00, // R semi-press
DIK_UP, // Main stick up
DIK_DOWN, // Main stick down
DIK_LEFT, // Main stick left
DIK_RIGHT, // Main stick right
DIK_LSHIFT, // Main stick semi-press
DIK_I, // C-stick up
DIK_K, // C-stick down
DIK_J, // C-stick left
DIK_L, // C-stick right
DIK_LCONTROL, // C-stick semi-press
DIK_T, // D-pad up
DIK_G, // D-pad down
DIK_F, // D-pad left
DIK_H, // D-pad right
DIK_M, // Mic
};
#elif defined(HAVE_X11) && HAVE_X11
const int defaultKeyForControl[NUMCONTROLS] =
{
XK_x, //A
XK_z,
XK_c,
XK_s,
XK_d,
XK_Return,
XK_q,
XK_w,
XK_Up, //mainstick
XK_Down,
XK_Left,
XK_Right,
XK_i, //substick
XK_K,
XK_j,
XK_l,
XK_t, //dpad
XK_g,
XK_f,
XK_h,
XK_Shift_L, //halfpress
XK_p //Mic
XK_x, // A
XK_z, // B
XK_c, // X
XK_s, // Y
XK_d, // Z
XK_Return, // Start
XK_q, // L
XK_w, // R
0x00, // L semi-press
0x00, // R semi-press
XK_Up, // Main stick up
XK_Down, // Main stick down
XK_Left, // Main stick left
XK_Right, // Main stick right
XK_Shift_L, // Main stick semi-press
XK_i, // C-stick up
XK_k, // C-stick down
XK_j, // C-stick left
XK_l, // C-stick right
XK_Control_L, // C-stick semi-press
XK_t, // D-pad up
XK_g, // D-pad down
XK_f, // D-pad left
XK_h, // D-pad right
XK_m, // Mic
};
#elif defined(HAVE_COCOA) && HAVE_COCOA
const int defaultKeyForControl[NUMCONTROLS] =
{
7, //A
6,
8,
1,
2,
36,
12,
13,
126, //mainstick
125,
123,
124,
34, //substick
40,
38,
37,
17, //dpad
5,
3,
4,
56, //halfpress
35 //Mic
};
// Reference for Cocoa key codes:
// http://boredzo.org/blog/archives/2007-05-22/virtual-key-codes
const int defaultKeyForControl[NUMCONTROLS] =
{
7, // A (x)
6, // B (z)
8, // X (c)
1, // Y (s)
2, // Z (d)
36, // Start (return)
12, // L (q)
13, // R (w)
-1, // L semi-press (none)
-1, // R semi-press (none)
126, // Main stick up (up)
125, // Main stick down (down)
123, // Main stick left (left)
124, // Main stick right (right)
56, // Main stick semi-press (left shift)
34, // C-stick up (i)
40, // C-stick down (k)
38, // C-stick left (j)
37, // C-stick right (l)
59, // C-stick semi-press (left control)
17, // D-pad up (t)
5, // D-pad down (g)
3, // D-pad left (f)
4, // D-pad right (h)
46, // Mic (m)
};
#endif
IniFile file;
file.Load(FULL_CONFIG_DIR "pad.ini");
@ -924,6 +942,10 @@ void LoadConfig()
file.Get(SectionName, "RumbleStrength", &pad[i].RumbleStrength, 8000);
file.Get(SectionName, "XPad#", &pad[i].XPadPlayer);
file.Get(SectionName, "Trigger_semivalue", &pad[i].Trigger_semivalue, TRIGGER_HALF_DEFAULT);
file.Get(SectionName, "Main_stick_semivalue", &pad[i].Main_stick_semivalue, STICK_HALF_DEFAULT);
file.Get(SectionName, "Sub_stick_semivalue", &pad[i].Sub_stick_semivalue, STICK_HALF_DEFAULT);
#ifdef RERECORDING
file.Get(SectionName, "Recording", &pad[0].bRecording, false);
file.Get(SectionName, "Playback", &pad[0].bPlayback, false);
@ -931,8 +953,9 @@ void LoadConfig()
for (int x = 0; x < NUMCONTROLS; x++)
{
file.Get(SectionName, controlNames[x], &pad[i].keyForControl[x],
(i==0)?defaultKeyForControl[x]:0);
file.Get(SectionName, controlNames[x],
&pad[i].keyForControl[x],
(i==0) ? defaultKeyForControl[x] : 0);
#if defined(HAVE_X11) && HAVE_X11
// In linux we have a problem assigning the upper case of the
// keys because they're not being recognized
@ -959,6 +982,10 @@ void SaveConfig()
file.Set(SectionName, "RumbleStrength", pad[i].RumbleStrength);
file.Set(SectionName, "XPad#", pad[i].XPadPlayer);
file.Set(SectionName, "Trigger_semivalue", pad[i].Trigger_semivalue);
file.Set(SectionName, "Main_stick_semivalue", pad[i].Main_stick_semivalue);
file.Set(SectionName, "Sub_stick_semivalue", pad[i].Sub_stick_semivalue);
#ifdef RERECORDING
file.Set(SectionName, "Recording", pad[0].bRecording);
file.Set(SectionName, "Playback", pad[0].bPlayback);

View File

@ -20,6 +20,14 @@
#include "Setup.h" // Common
// Constants for full-press sticks and triggers
const int BUTTON_FULL = 255;
const int STICK_FULL = 100;
const int STICK_HALF_DEFAULT = 50;
const int TRIGGER_FULL = 255;
const int TRIGGER_HALF_DEFAULT = 128;
const int TRIGGER_THRESHOLD = 230;
// Controls
enum
{
@ -31,21 +39,24 @@ enum
CTL_START,
CTL_L,
CTL_R,
CTL_L_SEMI,
CTL_R_SEMI,
CTL_MAINUP,
CTL_MAINDOWN,
CTL_MAINLEFT,
CTL_MAINRIGHT,
CTL_MAIN_SEMI,
CTL_SUBUP,
CTL_SUBDOWN,
CTL_SUBLEFT,
CTL_SUBRIGHT,
CTL_SUB_SEMI,
CTL_DPADUP,
CTL_DPADDOWN,
CTL_DPADLEFT,
CTL_DPADRIGHT,
CTL_HALFPRESS,
CTL_MIC,
NUMCONTROLS
NUMCONTROLS,
};
// Control names
@ -59,32 +70,38 @@ static const char* controlNames[] =
"Start",
"L_button",
"R_button",
"L_button_semi",
"R_button_semi",
"Main_stick_up",
"Main_stick_down",
"Main_stick_left",
"Main_stick_right",
"Main_stick_semi",
"Sub_stick_up",
"Sub_stick_down",
"Sub_stick_left",
"Sub_stick_right",
"Sub_stick_semi",
"D-Pad_up",
"D-Pad_down",
"D-Pad_left",
"D-Pad_right",
"half_press_toggle",
"Mic-button",
};
struct SPads
{
bool bEnableXPad; // Use an XPad in addition to the keyboard?
bool bDisable; // Disabled when dolphin isn't in focus
bool bRumble; // Rumble for xpad
unsigned int RumbleStrength; // Rumble strength
bool bRecording; // Record input?
bool bPlayback; // Playback input?
int XPadPlayer; // Player# of the xpad
unsigned int keyForControl[NUMCONTROLS]; // Keyboard mapping
bool bEnableXPad; // Use an XPad in addition to the keyboard?
bool bDisable; // Disabled when dolphin isn't in focus
bool bRumble; // Rumble for xpad
u32 RumbleStrength; // Rumble strength
bool bRecording; // Record input?
bool bPlayback; // Playback input?
s32 XPadPlayer; // Player# of the xpad
u32 keyForControl[NUMCONTROLS]; // Keyboard mapping
u32 Trigger_semivalue; // Semi-press value for triggers
u32 Main_stick_semivalue; // Semi-press value for main stick
u32 Sub_stick_semivalue; // Semi-press value for sub-stick
};
extern SPads pad[];