From afe8df5020d575ee361078aa3bd52706f818dee4 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Thu, 1 Nov 2018 22:10:51 -0400 Subject: qt: Add UI to configure touchscreen parameters This allows adjusting the finger, diameter, and angle of the emulated touchscreen. It also provides a warning to the user about what changing these parameters can do. --- src/yuzu/CMakeLists.txt | 3 + .../configure_touchscreen_advanced.cpp | 48 +++++ .../configuration/configure_touchscreen_advanced.h | 31 ++++ .../configure_touchscreen_advanced.ui | 199 +++++++++++++++++++++ 4 files changed, 281 insertions(+) create mode 100644 src/yuzu/configuration/configure_touchscreen_advanced.cpp create mode 100644 src/yuzu/configuration/configure_touchscreen_advanced.h create mode 100644 src/yuzu/configuration/configure_touchscreen_advanced.ui (limited to 'src') diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 36714f55e..ff06d2a9a 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -31,6 +31,8 @@ add_executable(yuzu configuration/configure_mouse_advanced.h configuration/configure_system.cpp configuration/configure_system.h + configuration/configure_touchscreen_advanced.cpp + configuration/configure_touchscreen_advanced.h configuration/configure_web.cpp configuration/configure_web.h debugger/graphics/graphics_breakpoint_observer.cpp @@ -80,6 +82,7 @@ set(UIS configuration/configure_input.ui configuration/configure_mouse_advanced.ui configuration/configure_system.ui + configuration/configure_touchscreen_advanced.ui configuration/configure_web.ui hotkeys.ui main.ui diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.cpp b/src/yuzu/configuration/configure_touchscreen_advanced.cpp new file mode 100644 index 000000000..6cf3dab97 --- /dev/null +++ b/src/yuzu/configuration/configure_touchscreen_advanced.cpp @@ -0,0 +1,48 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include +#include +#include +#include +#include +#include +#include "common/assert.h" +#include "common/param_package.h" +#include "input_common/main.h" +#include "ui_configure_touchscreen_advanced.h" +#include "yuzu/configuration/config.h" +#include "yuzu/configuration/configure_touchscreen_advanced.h" + +ConfigureTouchscreenAdvanced::ConfigureTouchscreenAdvanced(QWidget* parent) + : QDialog(parent), ui(std::make_unique()) { + ui->setupUi(this); + + connect(ui->restore_defaults_button, &QPushButton::pressed, this, + &ConfigureTouchscreenAdvanced::restoreDefaults); + + this->loadConfiguration(); + this->resize(0, 0); +} + +void ConfigureTouchscreenAdvanced::applyConfiguration() { + Settings::values.touchscreen.finger = ui->finger_box->value(); + Settings::values.touchscreen.diameter_x = ui->diameter_x_box->value(); + Settings::values.touchscreen.diameter_y = ui->diameter_y_box->value(); + Settings::values.touchscreen.rotation_angle = ui->angle_box->value(); +} + +void ConfigureTouchscreenAdvanced::loadConfiguration() { + ui->finger_box->setValue(Settings::values.touchscreen.finger); + ui->diameter_x_box->setValue(Settings::values.touchscreen.diameter_x); + ui->diameter_y_box->setValue(Settings::values.touchscreen.diameter_y); + ui->angle_box->setValue(Settings::values.touchscreen.rotation_angle); +} + +void ConfigureTouchscreenAdvanced::restoreDefaults() { + ui->finger_box->setValue(0); + ui->diameter_x_box->setValue(15); + ui->diameter_y_box->setValue(15); + ui->angle_box->setValue(0); +} diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.h b/src/yuzu/configuration/configure_touchscreen_advanced.h new file mode 100644 index 000000000..938a62ed3 --- /dev/null +++ b/src/yuzu/configuration/configure_touchscreen_advanced.h @@ -0,0 +1,31 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include +#include "yuzu/configuration/config.h" + +namespace Ui { +class ConfigureTouchscreenAdvanced; +} + +class ConfigureTouchscreenAdvanced : public QDialog { + Q_OBJECT + +public: + explicit ConfigureTouchscreenAdvanced(QWidget* parent); + + void applyConfiguration(); + +private: + /// Load configuration settings. + void loadConfiguration(); + /// Restore all buttons to their default values. + void restoreDefaults(); + + std::unique_ptr ui; +}; diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.ui b/src/yuzu/configuration/configure_touchscreen_advanced.ui new file mode 100644 index 000000000..1171c2dd1 --- /dev/null +++ b/src/yuzu/configuration/configure_touchscreen_advanced.ui @@ -0,0 +1,199 @@ + + + ConfigureTouchscreenAdvanced + + + + 0 + 0 + 298 + 339 + + + + Configure Touchscreen + + + + + + + 280 + 0 + + + + Warning: The settings in this page affect the inner workings of yuzu's emulated touchscreen. Changing them may result in undesirable behavior, such as the touchscreen partially or not working. You should only use this page if you know what you are doing. + + + true + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Touch Parameters + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Touch Diameter Y + + + + + + + Finger + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Touch Diameter X + + + + + + + + 80 + 0 + + + + + + + + Rotational Angle + + + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Restore Defaults + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + ConfigureTouchscreenAdvanced + accept() + + + 140 + 318 + + + 140 + 169 + + + + + buttonBox + rejected() + ConfigureTouchscreenAdvanced + reject() + + + 140 + 318 + + + 140 + 169 + + + + + -- cgit v1.2.3