diff options
Diffstat (limited to 'src/citra_qt/configure_input.h')
| -rw-r--r-- | src/citra_qt/configure_input.h | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/citra_qt/configure_input.h b/src/citra_qt/configure_input.h index bc343db83..c950fbcb4 100644 --- a/src/citra_qt/configure_input.h +++ b/src/citra_qt/configure_input.h | |||
| @@ -4,10 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 8 | #include <functional> | ||
| 7 | #include <memory> | 9 | #include <memory> |
| 10 | #include <string> | ||
| 8 | #include <QKeyEvent> | 11 | #include <QKeyEvent> |
| 9 | #include <QWidget> | 12 | #include <QWidget> |
| 10 | #include <boost/optional.hpp> | 13 | #include <boost/optional.hpp> |
| 14 | #include "common/param_package.h" | ||
| 11 | #include "core/settings.h" | 15 | #include "core/settings.h" |
| 12 | #include "ui_configure_input.h" | 16 | #include "ui_configure_input.h" |
| 13 | 17 | ||
| @@ -31,15 +35,25 @@ public: | |||
| 31 | private: | 35 | private: |
| 32 | std::unique_ptr<Ui::ConfigureInput> ui; | 36 | std::unique_ptr<Ui::ConfigureInput> ui; |
| 33 | 37 | ||
| 34 | /// This input is currently awaiting configuration. | ||
| 35 | /// (i.e.: its corresponding QPushButton has been pressed.) | ||
| 36 | boost::optional<Settings::NativeInput::Values> current_input_id; | ||
| 37 | std::unique_ptr<QTimer> timer; | 38 | std::unique_ptr<QTimer> timer; |
| 38 | 39 | ||
| 39 | /// Each input is represented by a QPushButton. | 40 | /// This will be the the setting function when an input is awaiting configuration. |
| 40 | std::map<Settings::NativeInput::Values, QPushButton*> button_map; | 41 | boost::optional<std::function<void(int)>> key_setter; |
| 41 | /// Each input is configured to respond to the press of a Qt::Key. | 42 | |
| 42 | std::map<Settings::NativeInput::Values, Qt::Key> key_map; | 43 | std::array<Common::ParamPackage, Settings::NativeButton::NumButtons> buttons_param; |
| 44 | std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs> analogs_param; | ||
| 45 | |||
| 46 | static constexpr int ANALOG_SUB_BUTTONS_NUM = 5; | ||
| 47 | |||
| 48 | /// Each button input is represented by a QPushButton. | ||
| 49 | std::array<QPushButton*, Settings::NativeButton::NumButtons> button_map; | ||
| 50 | |||
| 51 | /// Each analog input is represented by five QPushButtons which represents up, down, left, right | ||
| 52 | /// and modifier | ||
| 53 | std::array<std::array<QPushButton*, ANALOG_SUB_BUTTONS_NUM>, Settings::NativeAnalog::NumAnalogs> | ||
| 54 | analog_map; | ||
| 55 | |||
| 56 | static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons; | ||
| 43 | 57 | ||
| 44 | /// Load configuration settings. | 58 | /// Load configuration settings. |
| 45 | void loadConfiguration(); | 59 | void loadConfiguration(); |
| @@ -48,10 +62,8 @@ private: | |||
| 48 | /// Update UI to reflect current configuration. | 62 | /// Update UI to reflect current configuration. |
| 49 | void updateButtonLabels(); | 63 | void updateButtonLabels(); |
| 50 | 64 | ||
| 51 | /// Called when the button corresponding to input_id was pressed. | 65 | /// Called when the button was pressed. |
| 52 | void handleClick(Settings::NativeInput::Values input_id); | 66 | void handleClick(QPushButton* button, std::function<void(int)> new_key_setter); |
| 53 | /// Handle key press events. | 67 | /// Handle key press events. |
| 54 | void keyPressEvent(QKeyEvent* event) override; | 68 | void keyPressEvent(QKeyEvent* event) override; |
| 55 | /// Configure input input_id to respond to key key_pressed. | ||
| 56 | void setInput(Settings::NativeInput::Values input_id, Qt::Key key_pressed); | ||
| 57 | }; | 69 | }; |