mirror of https://github.com/yuzu-mirror/yuzu
commit
20111c86b6
@ -0,0 +1,79 @@
|
||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <QCloseEvent>
|
||||
|
||||
#include "common/settings.h"
|
||||
#include "ui_configure_mouse_panning.h"
|
||||
#include "yuzu/configuration/configure_mouse_panning.h"
|
||||
|
||||
ConfigureMousePanning::ConfigureMousePanning(QWidget* parent,
|
||||
InputCommon::InputSubsystem* input_subsystem_,
|
||||
float right_stick_deadzone, float right_stick_range)
|
||||
: QDialog(parent), input_subsystem{input_subsystem_},
|
||||
ui(std::make_unique<Ui::ConfigureMousePanning>()) {
|
||||
ui->setupUi(this);
|
||||
SetConfiguration(right_stick_deadzone, right_stick_range);
|
||||
ConnectEvents();
|
||||
}
|
||||
|
||||
ConfigureMousePanning::~ConfigureMousePanning() = default;
|
||||
|
||||
void ConfigureMousePanning::closeEvent(QCloseEvent* event) {
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void ConfigureMousePanning::SetConfiguration(float right_stick_deadzone, float right_stick_range) {
|
||||
ui->enable->setChecked(Settings::values.mouse_panning.GetValue());
|
||||
ui->x_sensitivity->setValue(Settings::values.mouse_panning_x_sensitivity.GetValue());
|
||||
ui->y_sensitivity->setValue(Settings::values.mouse_panning_y_sensitivity.GetValue());
|
||||
ui->deadzone_x_counterweight->setValue(
|
||||
Settings::values.mouse_panning_deadzone_x_counterweight.GetValue());
|
||||
ui->deadzone_y_counterweight->setValue(
|
||||
Settings::values.mouse_panning_deadzone_y_counterweight.GetValue());
|
||||
ui->decay_strength->setValue(Settings::values.mouse_panning_decay_strength.GetValue());
|
||||
ui->min_decay->setValue(Settings::values.mouse_panning_min_decay.GetValue());
|
||||
|
||||
if (right_stick_deadzone > 0.0f || right_stick_range != 1.0f) {
|
||||
ui->warning_label->setText(QString::fromStdString(
|
||||
"Mouse panning works better with a deadzone of 0% and a range of 100%.\n"
|
||||
"Current values are " +
|
||||
std::to_string(static_cast<int>(right_stick_deadzone * 100.0f)) + "% and " +
|
||||
std::to_string(static_cast<int>(right_stick_range * 100.0f)) + "% respectively."));
|
||||
} else {
|
||||
ui->warning_label->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureMousePanning::SetDefaultConfiguration() {
|
||||
ui->x_sensitivity->setValue(Settings::values.mouse_panning_x_sensitivity.GetDefault());
|
||||
ui->y_sensitivity->setValue(Settings::values.mouse_panning_y_sensitivity.GetDefault());
|
||||
ui->deadzone_x_counterweight->setValue(
|
||||
Settings::values.mouse_panning_deadzone_x_counterweight.GetDefault());
|
||||
ui->deadzone_y_counterweight->setValue(
|
||||
Settings::values.mouse_panning_deadzone_y_counterweight.GetDefault());
|
||||
ui->decay_strength->setValue(Settings::values.mouse_panning_decay_strength.GetDefault());
|
||||
ui->min_decay->setValue(Settings::values.mouse_panning_min_decay.GetDefault());
|
||||
}
|
||||
|
||||
void ConfigureMousePanning::ConnectEvents() {
|
||||
connect(ui->default_button, &QPushButton::clicked, this,
|
||||
&ConfigureMousePanning::SetDefaultConfiguration);
|
||||
connect(ui->button_box, &QDialogButtonBox::accepted, this,
|
||||
&ConfigureMousePanning::ApplyConfiguration);
|
||||
connect(ui->button_box, &QDialogButtonBox::rejected, this, [this] { reject(); });
|
||||
}
|
||||
|
||||
void ConfigureMousePanning::ApplyConfiguration() {
|
||||
Settings::values.mouse_panning = ui->enable->isChecked();
|
||||
Settings::values.mouse_panning_x_sensitivity = static_cast<float>(ui->x_sensitivity->value());
|
||||
Settings::values.mouse_panning_y_sensitivity = static_cast<float>(ui->y_sensitivity->value());
|
||||
Settings::values.mouse_panning_deadzone_x_counterweight =
|
||||
static_cast<float>(ui->deadzone_x_counterweight->value());
|
||||
Settings::values.mouse_panning_deadzone_y_counterweight =
|
||||
static_cast<float>(ui->deadzone_y_counterweight->value());
|
||||
Settings::values.mouse_panning_decay_strength = static_cast<float>(ui->decay_strength->value());
|
||||
Settings::values.mouse_panning_min_decay = static_cast<float>(ui->min_decay->value());
|
||||
|
||||
accept();
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <QDialog>
|
||||
|
||||
namespace InputCommon {
|
||||
class InputSubsystem;
|
||||
}
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureMousePanning;
|
||||
}
|
||||
|
||||
class ConfigureMousePanning : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConfigureMousePanning(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_,
|
||||
float right_stick_deadzone, float right_stick_range);
|
||||
~ConfigureMousePanning() override;
|
||||
|
||||
public slots:
|
||||
void ApplyConfiguration();
|
||||
|
||||
private:
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
void SetConfiguration(float right_stick_deadzone, float right_stick_range);
|
||||
void SetDefaultConfiguration();
|
||||
void ConnectEvents();
|
||||
|
||||
InputCommon::InputSubsystem* input_subsystem;
|
||||
std::unique_ptr<Ui::ConfigureMousePanning> ui;
|
||||
};
|
@ -0,0 +1,238 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigureMousePanning</class>
|
||||
<widget class="QDialog" name="configure_mouse_panning">
|
||||
<property name="windowTitle">
|
||||
<string>Configure mouse panning</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="enable">
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Can be toggled via a hotkey</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="sensitivity_box">
|
||||
<property name="title">
|
||||
<string>Sensitivity</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="x_sensitivity_label">
|
||||
<property name="text">
|
||||
<string>Horizontal</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="x_sensitivity">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="y_sensitivity_label">
|
||||
<property name="text">
|
||||
<string>Vertical</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="y_sensitivity">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="deadzone_counterweight_box">
|
||||
<property name="title">
|
||||
<string>Deadzone counterweight</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Counteracts a game's built-in deadzone</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="deadzone_x_counterweight_label">
|
||||
<property name="text">
|
||||
<string>Horizontal</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="deadzone_x_counterweight">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="deadzone_y_counterweight_label">
|
||||
<property name="text">
|
||||
<string>Vertical</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="deadzone_y_counterweight">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="decay_box">
|
||||
<property name="title">
|
||||
<string>Stick decay</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="decay_strength_label">
|
||||
<property name="text">
|
||||
<string>Strength</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="decay_strength">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>22</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="min_decay_label">
|
||||
<property name="text">
|
||||
<string>Minimum</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="min_decay">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="warning_label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="default_button">
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="button_box">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue