diff options
author | MerryMage <MerryMage@users.noreply.github.com> | 2016-12-10 00:59:09 +0100 |
---|---|---|
committer | linkmauve <linkmauve@linkmauve.fr> | 2016-12-11 00:30:28 +0100 |
commit | a2d474386c5e25346f68f4b5b8e1ce6da3b452ce (patch) | |
tree | 747e10ef30fb56386082fc72d84fa601889a3a3f /src/citra_qt/configure_input.h | |
parent | Merge pull request #2296 from MerryMage/auto_is_auto (diff) | |
download | yuzu-a2d474386c5e25346f68f4b5b8e1ce6da3b452ce.tar yuzu-a2d474386c5e25346f68f4b5b8e1ce6da3b452ce.tar.gz yuzu-a2d474386c5e25346f68f4b5b8e1ce6da3b452ce.tar.bz2 yuzu-a2d474386c5e25346f68f4b5b8e1ce6da3b452ce.tar.lz yuzu-a2d474386c5e25346f68f4b5b8e1ce6da3b452ce.tar.xz yuzu-a2d474386c5e25346f68f4b5b8e1ce6da3b452ce.tar.zst yuzu-a2d474386c5e25346f68f4b5b8e1ce6da3b452ce.zip |
Diffstat (limited to '')
-rw-r--r-- | src/citra_qt/configure_input.h | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/src/citra_qt/configure_input.h b/src/citra_qt/configure_input.h index 5183b904d..bc343db83 100644 --- a/src/citra_qt/configure_input.h +++ b/src/citra_qt/configure_input.h @@ -7,7 +7,7 @@ #include <memory> #include <QKeyEvent> #include <QWidget> -#include "citra_qt/config.h" +#include <boost/optional.hpp> #include "core/settings.h" #include "ui_configure_input.h" @@ -30,35 +30,28 @@ public: private: std::unique_ptr<Ui::ConfigureInput> ui; - std::map<Settings::NativeInput::Values, QPushButton*> input_mapping; - int key_pressed; - QPushButton* changing_button = nullptr; ///< button currently waiting for key press. - QString previous_mapping; - QTimer* timer; - /// Load configuration settings into button text - void setConfiguration(); + /// This input is currently awaiting configuration. + /// (i.e.: its corresponding QPushButton has been pressed.) + boost::optional<Settings::NativeInput::Values> current_input_id; + std::unique_ptr<QTimer> timer; - /// Check all inputs for duplicate keys. Clears out any other button with the same value as this - /// button's new value. - void removeDuplicates(const QString& newValue); - - /// Handle key press event for input tab when a button is 'waiting'. - void keyPressEvent(QKeyEvent* event) override; - - /// Convert key ASCII value to its' letter/name - QString getKeyName(int key_code) const; - - /// Convert letter/name of key to its ASCII value. - Qt::Key getKeyValue(const QString& text) const; - - /// Set button text to name of key pressed. - void setKey(); - -private slots: - /// Event handler for all button released() event. - void handleClick(); + /// Each input is represented by a QPushButton. + std::map<Settings::NativeInput::Values, QPushButton*> button_map; + /// Each input is configured to respond to the press of a Qt::Key. + std::map<Settings::NativeInput::Values, Qt::Key> key_map; + /// Load configuration settings. + void loadConfiguration(); /// Restore all buttons to their default values. void restoreDefaults(); + /// Update UI to reflect current configuration. + void updateButtonLabels(); + + /// Called when the button corresponding to input_id was pressed. + void handleClick(Settings::NativeInput::Values input_id); + /// Handle key press events. + void keyPressEvent(QKeyEvent* event) override; + /// Configure input input_id to respond to key key_pressed. + void setInput(Settings::NativeInput::Values input_id, Qt::Key key_pressed); }; |