Qt: Make mouse mapping opt-in (less annoying)

This commit is contained in:
Connor McLaughlin 2022-06-29 20:08:30 +10:00 committed by refractionpcsx2
parent 403b93daf6
commit 65ae3e1d8d
6 changed files with 71 additions and 51 deletions

View File

@ -33,6 +33,7 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent,
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLSource, "InputSources", "SDL", true); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLSource, "InputSources", "SDL", true);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLEnhancedMode, "InputSources", "SDLControllerEnhancedMode", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLEnhancedMode, "InputSources", "SDLControllerEnhancedMode", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableXInputSource, "InputSources", "XInput", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableXInputSource, "InputSources", "XInput", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableMouseMapping, "UI", "EnableMouseMapping", false);
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.multitapPort1, "Pad", "MultitapPort1", false); ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.multitapPort1, "Pad", "MultitapPort1", false);
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.multitapPort2, "Pad", "MultitapPort2", false); ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.multitapPort2, "Pad", "MultitapPort2", false);
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.pointerXInvert, "Pad", "PointerXInvert", false); ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.pointerXInvert, "Pad", "PointerXInvert", false);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>900</width> <width>902</width>
<height>675</height> <height>677</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -91,8 +91,27 @@
<string>Mouse/Pointer Source</string> <string>Mouse/Pointer Source</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_6"> <layout class="QGridLayout" name="gridLayout_6">
<item row="2" column="1"> <item row="1" column="2">
<widget class="QSlider" name="pointerYScale"> <widget class="QLabel" name="pointerXScaleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>10</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="pointerXScale">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -116,16 +135,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Using raw input improves precision when you bind controller sticks to the mouse pointer. Also enables multiple mice to be used.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="3"> <item row="2" column="3">
<widget class="QCheckBox" name="pointerYInvert"> <widget class="QCheckBox" name="pointerYInvert">
<property name="text"> <property name="text">
@ -133,41 +142,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="2" column="1">
<widget class="QLabel" name="pointerXScaleLabel"> <widget class="QSlider" name="pointerYScale">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>10</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="pointerXInvert">
<property name="text">
<string>Invert</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Vertical Sensitivity:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="pointerXScale">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -210,6 +186,30 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3">
<widget class="QCheckBox" name="pointerXInvert">
<property name="text">
<string>Invert</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Using raw input improves precision when you bind controller sticks to the mouse pointer. Also enables multiple mice to be used.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Vertical Sensitivity:</string>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
@ -217,6 +217,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="4">
<widget class="QCheckBox" name="enableMouseMapping">
<property name="text">
<string>Enable Mouse Mapping</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -19,6 +19,7 @@
#include "QtHost.h" #include "QtHost.h"
#include "QtUtils.h" #include "QtUtils.h"
#include "Settings/InputBindingDialog.h" #include "Settings/InputBindingDialog.h"
#include "Settings/InputBindingWidget.h"
#include <QtCore/QTimer> #include <QtCore/QTimer>
#include <QtGui/QKeyEvent> #include <QtGui/QKeyEvent>
#include <QtGui/QMouseEvent> #include <QtGui/QMouseEvent>
@ -76,7 +77,7 @@ bool InputBindingDialog::eventFilter(QObject* watched, QEvent* event)
m_new_bindings.push_back(InputManager::MakePointerButtonKey(0, button_index)); m_new_bindings.push_back(InputManager::MakePointerButtonKey(0, button_index));
return true; return true;
} }
else if (event_type == QEvent::MouseMove) else if (event_type == QEvent::MouseMove && m_mouse_mapping_enabled)
{ {
// if we've moved more than a decent distance from the center of the widget, bind it. // if we've moved more than a decent distance from the center of the widget, bind it.
// this is so we don't accidentally bind to the mouse if you bump it while reaching for your pad. // this is so we don't accidentally bind to the mouse if you bump it while reaching for your pad.
@ -125,6 +126,7 @@ void InputBindingDialog::onInputListenTimerTimeout()
void InputBindingDialog::startListeningForInput(u32 timeout_in_seconds) void InputBindingDialog::startListeningForInput(u32 timeout_in_seconds)
{ {
m_new_bindings.clear(); m_new_bindings.clear();
m_mouse_mapping_enabled = InputBindingWidget::isMouseMappingEnabled();
m_input_listen_start_position = QCursor::pos(); m_input_listen_start_position = QCursor::pos();
m_input_listen_timer = new QTimer(this); m_input_listen_timer = new QTimer(this);
m_input_listen_timer->setSingleShot(false); m_input_listen_timer->setSingleShot(false);

View File

@ -69,4 +69,5 @@ protected:
QTimer* m_input_listen_timer = nullptr; QTimer* m_input_listen_timer = nullptr;
u32 m_input_listen_remaining_seconds = 0; u32 m_input_listen_remaining_seconds = 0;
QPoint m_input_listen_start_position{}; QPoint m_input_listen_start_position{};
bool m_mouse_mapping_enabled = false;
}; };

View File

@ -56,6 +56,11 @@ InputBindingWidget::~InputBindingWidget()
Q_ASSERT(!isListeningForInput()); Q_ASSERT(!isListeningForInput());
} }
bool InputBindingWidget::isMouseMappingEnabled()
{
return Host::GetBaseBoolSettingValue("UI", "EnableMouseMapping", false);
}
void InputBindingWidget::initialize(SettingsInterface* sif, std::string section_name, std::string key_name) void InputBindingWidget::initialize(SettingsInterface* sif, std::string section_name, std::string key_name)
{ {
m_sif = sif; m_sif = sif;
@ -126,7 +131,7 @@ bool InputBindingWidget::eventFilter(QObject* watched, QEvent* event)
m_new_bindings.push_back(InputManager::MakePointerButtonKey(0, button_index)); m_new_bindings.push_back(InputManager::MakePointerButtonKey(0, button_index));
return true; return true;
} }
else if (event_type == QEvent::MouseMove) else if (event_type == QEvent::MouseMove && m_mouse_mapping_enabled)
{ {
// if we've moved more than a decent distance from the center of the widget, bind it. // if we've moved more than a decent distance from the center of the widget, bind it.
// this is so we don't accidentally bind to the mouse if you bump it while reaching for your pad. // this is so we don't accidentally bind to the mouse if you bump it while reaching for your pad.
@ -266,6 +271,7 @@ void InputBindingWidget::onInputListenTimerTimeout()
void InputBindingWidget::startListeningForInput(u32 timeout_in_seconds) void InputBindingWidget::startListeningForInput(u32 timeout_in_seconds)
{ {
m_new_bindings.clear(); m_new_bindings.clear();
m_mouse_mapping_enabled = isMouseMappingEnabled();
m_input_listen_start_position = QCursor::pos(); m_input_listen_start_position = QCursor::pos();
m_input_listen_timer = new QTimer(this); m_input_listen_timer = new QTimer(this);
m_input_listen_timer->setSingleShot(false); m_input_listen_timer->setSingleShot(false);

View File

@ -33,6 +33,8 @@ public:
InputBindingWidget(QWidget* parent, SettingsInterface* sif, std::string section_name, std::string key_name); InputBindingWidget(QWidget* parent, SettingsInterface* sif, std::string section_name, std::string key_name);
~InputBindingWidget(); ~InputBindingWidget();
static bool isMouseMappingEnabled();
void initialize(SettingsInterface* sif, std::string section_name, std::string key_name); void initialize(SettingsInterface* sif, std::string section_name, std::string key_name);
public Q_SLOTS: public Q_SLOTS:
@ -74,6 +76,7 @@ protected:
QTimer* m_input_listen_timer = nullptr; QTimer* m_input_listen_timer = nullptr;
u32 m_input_listen_remaining_seconds = 0; u32 m_input_listen_remaining_seconds = 0;
QPoint m_input_listen_start_position{}; QPoint m_input_listen_start_position{};
bool m_mouse_mapping_enabled = false;
}; };
class InputVibrationBindingWidget : public QPushButton class InputVibrationBindingWidget : public QPushButton