mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-26 23:34:54 +00:00
DolphinQt: Add setting to enable iterative input mappings.
This commit is contained in:
parent
a8fae9b826
commit
3189de6c7a
7 changed files with 48 additions and 34 deletions
|
@ -11,8 +11,6 @@
|
||||||
#include "DolphinQt/Config/Mapping/IOWindow.h"
|
#include "DolphinQt/Config/Mapping/IOWindow.h"
|
||||||
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
||||||
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
||||||
#include "DolphinQt/QtUtils/BlockUserInputFilter.h"
|
|
||||||
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
|
||||||
|
|
||||||
#include "InputCommon/ControlReference/ControlReference.h"
|
#include "InputCommon/ControlReference/ControlReference.h"
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
|
@ -67,15 +65,10 @@ static QString RefToDisplayString(ControlReference* ref)
|
||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MappingButton::IsInput() const
|
|
||||||
{
|
|
||||||
return m_reference->IsInput();
|
|
||||||
}
|
|
||||||
|
|
||||||
MappingButton::MappingButton(MappingWidget* parent, ControlReference* ref)
|
MappingButton::MappingButton(MappingWidget* parent, ControlReference* ref)
|
||||||
: ElidedButton(RefToDisplayString(ref)), m_mapping_window(parent->GetParent()), m_reference(ref)
|
: ElidedButton(RefToDisplayString(ref)), m_mapping_window(parent->GetParent()), m_reference(ref)
|
||||||
{
|
{
|
||||||
if (IsInput())
|
if (m_reference->IsInput())
|
||||||
{
|
{
|
||||||
setToolTip(
|
setToolTip(
|
||||||
tr("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
|
tr("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
|
||||||
|
@ -88,10 +81,8 @@ MappingButton::MappingButton(MappingWidget* parent, ControlReference* ref)
|
||||||
connect(this, &MappingButton::clicked, this, &MappingButton::Clicked);
|
connect(this, &MappingButton::clicked, this, &MappingButton::Clicked);
|
||||||
|
|
||||||
connect(parent, &MappingWidget::ConfigChanged, this, &MappingButton::ConfigChanged);
|
connect(parent, &MappingWidget::ConfigChanged, this, &MappingButton::ConfigChanged);
|
||||||
connect(this, &MappingButton::ConfigChanged, [this] {
|
connect(this, &MappingButton::ConfigChanged,
|
||||||
setText(RefToDisplayString(m_reference));
|
[this] { setText(RefToDisplayString(m_reference)); });
|
||||||
m_is_mapping = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingButton::AdvancedPressed()
|
void MappingButton::AdvancedPressed()
|
||||||
|
@ -114,7 +105,6 @@ void MappingButton::Clicked()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_is_mapping = true;
|
|
||||||
m_mapping_window->QueueInputDetection(this);
|
m_mapping_window->QueueInputDetection(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,14 +121,6 @@ void MappingButton::Clear()
|
||||||
m_mapping_window->UnQueueInputDetection(this);
|
m_mapping_window->UnQueueInputDetection(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingButton::StartMapping()
|
|
||||||
{
|
|
||||||
// Focus just makes it more clear which button is currently being mapped.
|
|
||||||
setFocus();
|
|
||||||
setText(tr("[ Press Now ]"));
|
|
||||||
QtUtils::InstallKeyboardBlocker(this, this, &MappingButton::ConfigChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MappingButton::mouseReleaseEvent(QMouseEvent* event)
|
void MappingButton::mouseReleaseEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
switch (event->button())
|
switch (event->button())
|
||||||
|
|
|
@ -17,12 +17,11 @@ class MappingButton : public ElidedButton
|
||||||
public:
|
public:
|
||||||
MappingButton(MappingWidget* widget, ControlReference* ref);
|
MappingButton(MappingWidget* widget, ControlReference* ref);
|
||||||
|
|
||||||
bool IsInput() const;
|
|
||||||
ControlReference* GetControlReference();
|
ControlReference* GetControlReference();
|
||||||
void StartMapping();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ConfigChanged();
|
void ConfigChanged();
|
||||||
|
void QueueNextButtonMapping();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Clear();
|
void Clear();
|
||||||
|
@ -33,5 +32,4 @@ private:
|
||||||
|
|
||||||
MappingWindow* const m_mapping_window;
|
MappingWindow* const m_mapping_window;
|
||||||
ControlReference* const m_reference;
|
ControlReference* const m_reference;
|
||||||
bool m_is_mapping = false;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "DolphinQt/Config/Mapping/MappingButton.h"
|
#include "DolphinQt/Config/Mapping/MappingButton.h"
|
||||||
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
||||||
|
#include "DolphinQt/QtUtils/BlockUserInputFilter.h"
|
||||||
|
|
||||||
#include "InputCommon/ControlReference/ControlReference.h"
|
#include "InputCommon/ControlReference/ControlReference.h"
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
|
@ -49,7 +50,10 @@ public:
|
||||||
const auto& default_device = m_parent->GetController()->GetDefaultDevice();
|
const auto& default_device = m_parent->GetController()->GetDefaultDevice();
|
||||||
auto& button = m_clicked_mapping_buttons.front();
|
auto& button = m_clicked_mapping_buttons.front();
|
||||||
|
|
||||||
button->StartMapping();
|
// Focus just makes it more clear which button is currently being mapped.
|
||||||
|
button->setFocus();
|
||||||
|
button->setText(tr("[ Press Now ]"));
|
||||||
|
QtUtils::InstallKeyboardBlocker(button, button, &MappingButton::ConfigChanged);
|
||||||
|
|
||||||
std::vector device_strings{default_device.ToString()};
|
std::vector device_strings{default_device.ToString()};
|
||||||
if (m_parent->IsCreateOtherDeviceMappingsEnabled())
|
if (m_parent->IsCreateOtherDeviceMappingsEnabled())
|
||||||
|
@ -73,9 +77,17 @@ public:
|
||||||
|
|
||||||
if (m_input_detector->IsComplete())
|
if (m_input_detector->IsComplete())
|
||||||
{
|
{
|
||||||
// No inputs detected. Cancel this and any other queued mappings.
|
auto* const button = m_clicked_mapping_buttons.back();
|
||||||
|
|
||||||
if (!FinalizeMapping(m_input_detector->TakeResults()))
|
if (!FinalizeMapping(m_input_detector->TakeResults()))
|
||||||
|
{
|
||||||
|
// No inputs detected. Cancel this and any other queued mappings.
|
||||||
CancelMapping();
|
CancelMapping();
|
||||||
|
}
|
||||||
|
else if (m_parent->IsIterativeMappingEnabled() && m_clicked_mapping_buttons.empty())
|
||||||
|
{
|
||||||
|
button->QueueNextButtonMapping();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,22 +122,20 @@ public:
|
||||||
m_input_detection_start_timer->start(INPUT_DETECT_INITIAL_DELAY);
|
m_input_detection_start_timer->start(INPUT_DETECT_INITIAL_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnQueueInputDetection(MappingButton* button)
|
bool UnQueueInputDetection(MappingButton* button)
|
||||||
{
|
{
|
||||||
std::erase(m_clicked_mapping_buttons, button);
|
if (!std::erase(m_clicked_mapping_buttons, button))
|
||||||
|
return false;
|
||||||
button->ConfigChanged();
|
button->ConfigChanged();
|
||||||
UpdateInputDetectionStartTimer();
|
UpdateInputDetectionStartTimer();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueueInputDetection(MappingButton* button)
|
void QueueInputDetection(MappingButton* button)
|
||||||
{
|
{
|
||||||
// UnQueue if already queued.
|
// Just UnQueue if already queued.
|
||||||
if (std::erase(m_clicked_mapping_buttons, button))
|
if (UnQueueInputDetection(button))
|
||||||
{
|
|
||||||
button->ConfigChanged();
|
|
||||||
UpdateInputDetectionStartTimer();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
button->setText(QStringLiteral("[ ... ]"));
|
button->setText(QStringLiteral("[ ... ]"));
|
||||||
m_clicked_mapping_buttons.push_back(button);
|
m_clicked_mapping_buttons.push_back(button);
|
||||||
|
|
|
@ -314,6 +314,17 @@ void MappingWidget::CreateControl(const ControllerEmu::Control* control, QFormLa
|
||||||
bool indicator)
|
bool indicator)
|
||||||
{
|
{
|
||||||
auto* const button = new MappingButton(this, control->control_ref.get());
|
auto* const button = new MappingButton(this, control->control_ref.get());
|
||||||
|
|
||||||
|
if (control->control_ref->IsInput())
|
||||||
|
{
|
||||||
|
if (m_previous_mapping_button)
|
||||||
|
{
|
||||||
|
connect(m_previous_mapping_button, &MappingButton::QueueNextButtonMapping,
|
||||||
|
[this, button]() { m_parent->QueueInputDetection(button); });
|
||||||
|
}
|
||||||
|
m_previous_mapping_button = button;
|
||||||
|
}
|
||||||
|
|
||||||
button->setMinimumWidth(100);
|
button->setMinimumWidth(100);
|
||||||
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class InputConfig;
|
class InputConfig;
|
||||||
|
class MappingButton;
|
||||||
class MappingNumeric;
|
class MappingNumeric;
|
||||||
class MappingWindow;
|
class MappingWindow;
|
||||||
class QFormLayout;
|
class QFormLayout;
|
||||||
|
@ -55,4 +56,5 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MappingWindow* m_parent;
|
MappingWindow* m_parent;
|
||||||
|
MappingButton* m_previous_mapping_button = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -117,9 +117,13 @@ void MappingWindow::CreateDevicesLayout()
|
||||||
m_wait_for_alternate_mappings = new QAction(tr("Wait for Alternate Input Mappings"), options);
|
m_wait_for_alternate_mappings = new QAction(tr("Wait for Alternate Input Mappings"), options);
|
||||||
m_wait_for_alternate_mappings->setCheckable(true);
|
m_wait_for_alternate_mappings->setCheckable(true);
|
||||||
|
|
||||||
|
m_iterative_mapping = new QAction(tr("Enable Iterative Input Mapping"), options);
|
||||||
|
m_iterative_mapping->setCheckable(true);
|
||||||
|
|
||||||
options->addAction(refresh_action);
|
options->addAction(refresh_action);
|
||||||
options->addAction(m_other_device_mappings);
|
options->addAction(m_other_device_mappings);
|
||||||
options->addAction(m_wait_for_alternate_mappings);
|
options->addAction(m_wait_for_alternate_mappings);
|
||||||
|
options->addAction(m_iterative_mapping);
|
||||||
options->setDefaultAction(refresh_action);
|
options->setDefaultAction(refresh_action);
|
||||||
|
|
||||||
m_devices_combo->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
m_devices_combo->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||||
|
@ -368,6 +372,11 @@ bool MappingWindow::IsWaitForAlternateMappingsEnabled() const
|
||||||
return m_wait_for_alternate_mappings->isChecked();
|
return m_wait_for_alternate_mappings->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MappingWindow::IsIterativeMappingEnabled() const
|
||||||
|
{
|
||||||
|
return m_iterative_mapping->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
void MappingWindow::RefreshDevices()
|
void MappingWindow::RefreshDevices()
|
||||||
{
|
{
|
||||||
g_controller_interface.RefreshDevices();
|
g_controller_interface.RefreshDevices();
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
ControllerEmu::EmulatedController* GetController() const;
|
ControllerEmu::EmulatedController* GetController() const;
|
||||||
bool IsCreateOtherDeviceMappingsEnabled() const;
|
bool IsCreateOtherDeviceMappingsEnabled() const;
|
||||||
bool IsWaitForAlternateMappingsEnabled() const;
|
bool IsWaitForAlternateMappingsEnabled() const;
|
||||||
|
bool IsIterativeMappingEnabled() const;
|
||||||
void ShowExtensionMotionTabs(bool show);
|
void ShowExtensionMotionTabs(bool show);
|
||||||
void ActivateExtensionTab();
|
void ActivateExtensionTab();
|
||||||
|
|
||||||
|
@ -106,6 +107,7 @@ private:
|
||||||
QComboBox* m_devices_combo;
|
QComboBox* m_devices_combo;
|
||||||
QAction* m_other_device_mappings;
|
QAction* m_other_device_mappings;
|
||||||
QAction* m_wait_for_alternate_mappings;
|
QAction* m_wait_for_alternate_mappings;
|
||||||
|
QAction* m_iterative_mapping;
|
||||||
|
|
||||||
// Profiles
|
// Profiles
|
||||||
QGroupBox* m_profiles_box;
|
QGroupBox* m_profiles_box;
|
||||||
|
|
Loading…
Add table
Reference in a new issue