mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
Auto iterate through configuration inputs
Allows user to map all inputs seamlessly without having to click on each button. Also increased button timeout to 5 seconds from 1.5 due to pita. Motion controls are not included since they will be special cases.
This commit is contained in:
parent
f9650c52f8
commit
ffa6572116
@ -521,18 +521,34 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
|
||||
void GamepadPage::DetectControl(wxCommandEvent& event)
|
||||
{
|
||||
ControlButton* btn = (ControlButton*)event.GetEventObject();
|
||||
if (DetectButton(btn))
|
||||
{
|
||||
auto it = std::find(control_buttons.begin(), control_buttons.end(), btn);
|
||||
|
||||
// std find will never return end since btn will always be found in control_buttons
|
||||
++it;
|
||||
for (; it != control_buttons.end(); ++it)
|
||||
{
|
||||
if (!DetectButton(*it))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GamepadPage::DetectButton(ControlButton* button)
|
||||
{
|
||||
bool success = false;
|
||||
// find device :/
|
||||
Device* const dev = g_controller_interface.FindDevice(controller->default_device);
|
||||
if (dev)
|
||||
{
|
||||
btn->SetLabel(_("[ waiting ]"));
|
||||
button->SetLabel(_("[ waiting ]"));
|
||||
|
||||
// This makes the "waiting" text work on Linux. true (only if needed) prevents crash on Windows
|
||||
wxTheApp->Yield(true);
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lk(m_config.controls_lock);
|
||||
Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);
|
||||
Device::Control* const ctrl = button->control_reference->Detect(DETECT_WAIT_TIME, dev);
|
||||
|
||||
// if we got input, update expression and reference
|
||||
if (ctrl)
|
||||
@ -540,12 +556,15 @@ void GamepadPage::DetectControl(wxCommandEvent& event)
|
||||
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);
|
||||
button->control_reference->expression = expr;
|
||||
g_controller_interface.UpdateReference(button->control_reference, controller->default_device);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateGUI();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent)
|
||||
@ -740,6 +759,8 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
, control_group(group)
|
||||
{
|
||||
static_bitmap = nullptr;
|
||||
const std::vector<std::string> exclude_buttons = {"Mic", "Modifier"};
|
||||
const std::vector<std::string> exclude_groups = {"IR", "Swing", "Tilt", "Shake", "UDP Wiimote", "Extension", "Rumble"};
|
||||
|
||||
wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
for (auto& control : group->controls)
|
||||
@ -750,6 +771,10 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
control_button->SetFont(m_SmallFont);
|
||||
|
||||
control_buttons.push_back(control_button);
|
||||
if (std::find(exclude_groups.begin(), exclude_groups.end(), control_group->name) == exclude_groups.end() &&
|
||||
std::find(exclude_buttons.begin(), exclude_buttons.end(), control->name) == exclude_buttons.end())
|
||||
eventsink->control_buttons.push_back(control_button);
|
||||
|
||||
|
||||
if (control->control_ref->is_input)
|
||||
{
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#define SLIDER_TICK_COUNT 100
|
||||
#define DETECT_WAIT_TIME 1500
|
||||
#define DETECT_WAIT_TIME 5000
|
||||
#define PREVIEW_UPDATE_TIME 25
|
||||
|
||||
// might have to change this setup for wiimote
|
||||
@ -203,6 +203,7 @@ public:
|
||||
wxComboBox* device_cbox;
|
||||
|
||||
std::vector<ControlGroupBox*> control_groups;
|
||||
std::vector<ControlButton*> control_buttons;
|
||||
|
||||
protected:
|
||||
|
||||
@ -213,6 +214,7 @@ private:
|
||||
ControlDialog* m_control_dialog;
|
||||
InputConfigDialog* const m_config_dialog;
|
||||
InputConfig& m_config;
|
||||
bool DetectButton(ControlButton* button);
|
||||
};
|
||||
|
||||
class InputConfigDialog : public wxDialog
|
||||
|
Loading…
x
Reference in New Issue
Block a user