From e6bd1fd1b8487e421f71d43b6073ee56de1a043d Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Tue, 14 Jul 2020 19:01:36 +0200 Subject: yuzu: Add motion and touch configuration --- .../configuration/configure_touch_from_button.h | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/yuzu/configuration/configure_touch_from_button.h (limited to 'src/yuzu/configuration/configure_touch_from_button.h') diff --git a/src/yuzu/configuration/configure_touch_from_button.h b/src/yuzu/configuration/configure_touch_from_button.h new file mode 100644 index 000000000..c926db012 --- /dev/null +++ b/src/yuzu/configuration/configure_touch_from_button.h @@ -0,0 +1,86 @@ +// Copyright 2020 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include +#include +#include +#include "core/frontend/framebuffer_layout.h" +#include "core/settings.h" + +class QItemSelection; +class QModelIndex; +class QStandardItemModel; +class QStandardItem; +class QTimer; + +namespace Common { +class ParamPackage; +} + +namespace InputCommon { +namespace Polling { +class DevicePoller; +} +} // namespace InputCommon + +namespace Ui { +class ConfigureTouchFromButton; +} + +class ConfigureTouchFromButton : public QDialog { + Q_OBJECT + +public: + explicit ConfigureTouchFromButton(QWidget* parent, + const std::vector& touch_maps, + int default_index = 0); + ~ConfigureTouchFromButton() override; + + int GetSelectedIndex() const; + std::vector GetMaps() const; + +public slots: + void ApplyConfiguration(); + void NewBinding(const QPoint& pos); + void SetActiveBinding(int dot_id); + void SetCoordinates(int dot_id, const QPoint& pos); + +protected: + virtual void showEvent(QShowEvent* ev) override; + virtual void keyPressEvent(QKeyEvent* event) override; + +private slots: + void NewMapping(); + void DeleteMapping(); + void RenameMapping(); + void EditBinding(const QModelIndex& qi); + void DeleteBinding(); + void OnBindingSelection(const QItemSelection& selected, const QItemSelection& deselected); + void OnBindingChanged(QStandardItem* item); + void OnBindingDeleted(const QModelIndex& parent, int first, int last); + +private: + void SetConfiguration(); + void UpdateUiDisplay(); + void ConnectEvents(); + void GetButtonInput(int row_index, bool is_new); + void SetPollingResult(const Common::ParamPackage& params, bool cancel); + void SaveCurrentMapping(); + + std::unique_ptr ui; + std::unique_ptr binding_list_model; + std::vector touch_maps; + int selected_index; + + std::unique_ptr timeout_timer; + std::unique_ptr poll_timer; + std::vector> device_pollers; + std::optional> input_setter; + + static constexpr int DataRoleDot = Qt::ItemDataRole::UserRole + 2; +}; -- cgit v1.2.3 From d176feffad824bce20b694432ade28fe8273c8e4 Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Sat, 29 Aug 2020 20:56:51 +0200 Subject: Address review comments and fix code compilation --- src/yuzu/configuration/configure_touch_from_button.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/yuzu/configuration/configure_touch_from_button.h') diff --git a/src/yuzu/configuration/configure_touch_from_button.h b/src/yuzu/configuration/configure_touch_from_button.h index c926db012..0ddc54268 100644 --- a/src/yuzu/configuration/configure_touch_from_button.h +++ b/src/yuzu/configuration/configure_touch_from_button.h @@ -9,8 +9,6 @@ #include #include #include -#include "core/frontend/framebuffer_layout.h" -#include "core/settings.h" class QItemSelection; class QModelIndex; @@ -18,6 +16,10 @@ class QStandardItemModel; class QStandardItem; class QTimer; +namespace InputCommon { +class InputSubsystem; +} + namespace Common { class ParamPackage; } @@ -32,12 +34,17 @@ namespace Ui { class ConfigureTouchFromButton; } +namespace Settings { +struct TouchFromButtonMap; +} + class ConfigureTouchFromButton : public QDialog { Q_OBJECT public: explicit ConfigureTouchFromButton(QWidget* parent, const std::vector& touch_maps, + InputCommon::InputSubsystem* input_subsystem_, int default_index = 0); ~ConfigureTouchFromButton() override; @@ -51,8 +58,8 @@ public slots: void SetCoordinates(int dot_id, const QPoint& pos); protected: - virtual void showEvent(QShowEvent* ev) override; - virtual void keyPressEvent(QKeyEvent* event) override; + void showEvent(QShowEvent* ev) override; + void keyPressEvent(QKeyEvent* event) override; private slots: void NewMapping(); @@ -73,10 +80,12 @@ private: void SaveCurrentMapping(); std::unique_ptr ui; - std::unique_ptr binding_list_model; std::vector touch_maps; + QStandardItemModel* binding_list_model; int selected_index; + InputCommon::InputSubsystem* input_subsystem; + std::unique_ptr timeout_timer; std::unique_ptr poll_timer; std::vector> device_pollers; -- cgit v1.2.3 From d1e1ea0fef0ddfe914f14a2d547b922b71081695 Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Sun, 30 Aug 2020 00:07:38 +0200 Subject: Address second batch of reviews --- src/yuzu/configuration/configure_touch_from_button.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/yuzu/configuration/configure_touch_from_button.h') diff --git a/src/yuzu/configuration/configure_touch_from_button.h b/src/yuzu/configuration/configure_touch_from_button.h index 0ddc54268..d9513e3bc 100644 --- a/src/yuzu/configuration/configure_touch_from_button.h +++ b/src/yuzu/configuration/configure_touch_from_button.h @@ -16,28 +16,26 @@ class QStandardItemModel; class QStandardItem; class QTimer; -namespace InputCommon { -class InputSubsystem; -} - namespace Common { class ParamPackage; } namespace InputCommon { -namespace Polling { -class DevicePoller; +class InputSubsystem; } -} // namespace InputCommon -namespace Ui { -class ConfigureTouchFromButton; +namespace InputCommon::Polling { +class DevicePoller; } namespace Settings { struct TouchFromButtonMap; } +namespace Ui { +class ConfigureTouchFromButton; +} + class ConfigureTouchFromButton : public QDialog { Q_OBJECT @@ -82,9 +80,8 @@ private: std::unique_ptr ui; std::vector touch_maps; QStandardItemModel* binding_list_model; - int selected_index; - InputCommon::InputSubsystem* input_subsystem; + int selected_index; std::unique_ptr timeout_timer; std::unique_ptr poll_timer; -- cgit v1.2.3