mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
InputConfigDiag: Fix complex bindings with with left-click Detect
This fixes the binding of XBox 360 controllers and similar devices with complex control names.
This commit is contained in:
parent
21ca344a21
commit
55950365e3
@ -327,12 +327,33 @@ void ControlDialog::ClearControl(wxCommandEvent&)
|
|||||||
|
|
||||||
inline bool IsAlphabetic(wxString &str)
|
inline bool IsAlphabetic(wxString &str)
|
||||||
{
|
{
|
||||||
for (wxString::const_iterator it = str.begin(); it != str.end(); ++it)
|
for (wxString::const_iterator it = str.begin(); it != str.end(); ++it)
|
||||||
if (!isalpha(*it))
|
if (!isalpha(*it))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void GetExpressionForControl(wxString &expr,
|
||||||
|
wxString &control_name,
|
||||||
|
DeviceQualifier *control_device = NULL,
|
||||||
|
DeviceQualifier *default_device = NULL)
|
||||||
|
{
|
||||||
|
expr = "";
|
||||||
|
|
||||||
|
// non-default device
|
||||||
|
if (control_device && default_device && !(*control_device == *default_device))
|
||||||
|
{
|
||||||
|
expr += ":";
|
||||||
|
expr += control_device->ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// append the control name
|
||||||
|
expr += control_name;
|
||||||
|
|
||||||
|
if (!IsAlphabetic(expr))
|
||||||
|
expr = wxString::Format("`%s`", expr);
|
||||||
|
}
|
||||||
|
|
||||||
bool ControlDialog::GetExpressionForSelectedControl(wxString &expr)
|
bool ControlDialog::GetExpressionForSelectedControl(wxString &expr)
|
||||||
{
|
{
|
||||||
const int num = control_lbox->GetSelection();
|
const int num = control_lbox->GetSelection();
|
||||||
@ -340,17 +361,11 @@ bool ControlDialog::GetExpressionForSelectedControl(wxString &expr)
|
|||||||
if (num < 0)
|
if (num < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
expr = "";
|
wxString control_name = control_lbox->GetString(num);
|
||||||
|
GetExpressionForControl(expr,
|
||||||
// non-default device
|
control_name,
|
||||||
if (!(m_devq == m_parent->controller->default_device))
|
&m_devq,
|
||||||
expr += m_devq.ToString();
|
&m_parent->controller->default_device);
|
||||||
|
|
||||||
// append the control name
|
|
||||||
expr += control_lbox->GetString(num);
|
|
||||||
|
|
||||||
if (!IsAlphabetic(expr))
|
|
||||||
expr = wxString::Format("`%s`", expr);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -482,12 +497,15 @@ void GamepadPage::DetectControl(wxCommandEvent& event)
|
|||||||
// if we got input, update expression and reference
|
// if we got input, update expression and reference
|
||||||
if (ctrl)
|
if (ctrl)
|
||||||
{
|
{
|
||||||
btn->control_reference->expression = ctrl->GetName();
|
wxString control_name = ctrl->GetName();
|
||||||
|
wxString expr;
|
||||||
|
GetExpressionForControl(expr, control_name);
|
||||||
|
btn->control_reference->expression = expr;
|
||||||
g_controller_interface.UpdateReference(btn->control_reference, controller->default_device);
|
g_controller_interface.UpdateReference(btn->control_reference, controller->default_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
btn->SetLabel(StrToWxStr(btn->control_reference->expression));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent)
|
wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user