Fixed a potential crash when mapping keys to Wiimote
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4703 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
7d1fdb85f3
commit
f255f08a99
|
@ -410,6 +410,7 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId)
|
||||||
int value; // Axis value or Hat value
|
int value; // Axis value or Hat value
|
||||||
int type; // Button type
|
int type; // Button type
|
||||||
|
|
||||||
|
int KeyPressed = 0;
|
||||||
int pressed = 0;
|
int pressed = 0;
|
||||||
bool Succeed = false;
|
bool Succeed = false;
|
||||||
bool Stop = false; // Stop the timer
|
bool Stop = false; // Stop the timer
|
||||||
|
@ -426,8 +427,6 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId)
|
||||||
// Save the button Id
|
// Save the button Id
|
||||||
GetButtonWaitingID = _GetId;
|
GetButtonWaitingID = _GetId;
|
||||||
GetButtonWaitingTimer = 0;
|
GetButtonWaitingTimer = 0;
|
||||||
// Reset the key in case we happen to have an old one
|
|
||||||
g_Pressed = 0;
|
|
||||||
|
|
||||||
// Start the timer
|
// Start the timer
|
||||||
#if wxUSE_TIMER
|
#if wxUSE_TIMER
|
||||||
|
@ -446,7 +445,7 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId)
|
||||||
{
|
{
|
||||||
InputCommon::GetButton(
|
InputCommon::GetButton(
|
||||||
WiiMoteEmu::joyinfo[PadID].joy, PadID, WiiMoteEmu::joyinfo[PadID].NumButtons, WiiMoteEmu::joyinfo[PadID].NumAxes, WiiMoteEmu::joyinfo[PadID].NumHats,
|
WiiMoteEmu::joyinfo[PadID].joy, PadID, WiiMoteEmu::joyinfo[PadID].NumButtons, WiiMoteEmu::joyinfo[PadID].NumAxes, WiiMoteEmu::joyinfo[PadID].NumHats,
|
||||||
g_Pressed, value, type, pressed, Succeed, Stop,
|
KeyPressed, value, type, pressed, Succeed, Stop,
|
||||||
LeftRight, Axis, XInput, Button, Hat, NoTriggerFilter);
|
LeftRight, Axis, XInput, Button, Hat, NoTriggerFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +522,7 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we got a bad button
|
// If we got a bad button
|
||||||
if(g_Pressed == -1)
|
if(KeyPressed == -1)
|
||||||
{
|
{
|
||||||
// Update text
|
// Update text
|
||||||
SetButtonTextAll(_GetId, (char *)"PAD: -1");
|
SetButtonTextAll(_GetId, (char *)"PAD: -1");
|
||||||
|
|
|
@ -120,6 +120,8 @@ WiimotePadConfigDialog::WiimotePadConfigDialog(wxWindow *parent, wxWindowID id,
|
||||||
m_UpdatePadTimer = new wxTimer(this, IDTM_UPDATE_PAD);
|
m_UpdatePadTimer = new wxTimer(this, IDTM_UPDATE_PAD);
|
||||||
|
|
||||||
// Reset values
|
// Reset values
|
||||||
|
g_Pressed = 0;
|
||||||
|
ClickedButton = NULL;
|
||||||
GetButtonWaitingID = 0;
|
GetButtonWaitingID = 0;
|
||||||
GetButtonWaitingTimer = 0;
|
GetButtonWaitingTimer = 0;
|
||||||
|
|
||||||
|
@ -130,11 +132,10 @@ WiimotePadConfigDialog::WiimotePadConfigDialog(wxWindow *parent, wxWindowID id,
|
||||||
|
|
||||||
ControlsCreated = false;
|
ControlsCreated = false;
|
||||||
Page = 0;
|
Page = 0;
|
||||||
ClickedButton = NULL;
|
|
||||||
|
|
||||||
//g_Config.Load();
|
//g_Config.Load();
|
||||||
CreatePadGUIControls();
|
CreatePadGUIControls();
|
||||||
SetBackgroundColour(m_Notebook->GetBackgroundColour());
|
//SetBackgroundColour(m_Notebook->GetBackgroundColour());
|
||||||
|
|
||||||
// Set control values
|
// Set control values
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -195,10 +196,10 @@ void WiimotePadConfigDialog::OnKeyDown(wxKeyEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(HAVE_X11) && HAVE_X11
|
#elif defined(HAVE_X11) && HAVE_X11
|
||||||
g_Pressed = InputCommon::wxCharCodeWXToX(g_Pressed);
|
int XKey = InputCommon::wxCharCodeWXToX(g_Pressed);
|
||||||
InputCommon::XKeyToString(g_Pressed, keyStr);
|
InputCommon::XKeyToString(XKey, keyStr);
|
||||||
SetButtonText(ClickedButton->GetId(), keyStr);
|
SetButtonText(ClickedButton->GetId(), keyStr);
|
||||||
SaveKeyboardMapping(Page, ClickedButton->GetId(), g_Pressed);
|
SaveKeyboardMapping(Page, ClickedButton->GetId(), XKey);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
m_ButtonMappingTimer->Stop();
|
m_ButtonMappingTimer->Stop();
|
||||||
|
@ -211,13 +212,13 @@ void WiimotePadConfigDialog::OnKeyDown(wxKeyEvent& event)
|
||||||
// Input button clicked
|
// Input button clicked
|
||||||
void WiimotePadConfigDialog::OnButtonClick(wxCommandEvent& event)
|
void WiimotePadConfigDialog::OnButtonClick(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
//DEBUG_LOG(WIIMOTE, "OnButtonClick: %i", g_Pressed);
|
event.Skip();
|
||||||
|
|
||||||
if (m_ButtonMappingTimer->IsRunning()) return;
|
|
||||||
|
|
||||||
// Don't allow space to start a new Press Key option, that will interfer with setting a key to space
|
// Don't allow space to start a new Press Key option, that will interfer with setting a key to space
|
||||||
if (g_Pressed == WXK_SPACE) { g_Pressed = 0; return; }
|
if (g_Pressed == WXK_SPACE) { g_Pressed = 0; return; }
|
||||||
|
|
||||||
|
if (m_ButtonMappingTimer->IsRunning()) return;
|
||||||
|
|
||||||
// Create the button object
|
// Create the button object
|
||||||
ClickedButton = (wxButton *)event.GetEventObject();
|
ClickedButton = (wxButton *)event.GetEventObject();
|
||||||
// Save old label so we can revert back
|
// Save old label so we can revert back
|
||||||
|
|
|
@ -75,7 +75,7 @@ class WiimotePadConfigDialog : public wxDialog
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
bool ControlsCreated;
|
bool ControlsCreated;
|
||||||
int Page, g_Pressed, BoxW, BoxH;
|
int Page, BoxW, BoxH;
|
||||||
|
|
||||||
wxString OldLabel;
|
wxString OldLabel;
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ class WiimotePadConfigDialog : public wxDialog
|
||||||
void OnButtonClick(wxCommandEvent& event);
|
void OnButtonClick(wxCommandEvent& event);
|
||||||
|
|
||||||
// Configure buttons
|
// Configure buttons
|
||||||
int GetButtonWaitingID, GetButtonWaitingTimer;
|
int GetButtonWaitingID, GetButtonWaitingTimer, g_Pressed;
|
||||||
wxString GetButtonText(int id, int Page = -1);
|
wxString GetButtonText(int id, int Page = -1);
|
||||||
};
|
};
|
||||||
extern WiimotePadConfigDialog *m_PadConfigFrame;
|
extern WiimotePadConfigDialog *m_PadConfigFrame;
|
||||||
|
|
Loading…
Reference in New Issue