summaryrefslogtreecommitdiffstats
path: root/src/citra_qt/configure_input.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra_qt/configure_input.h')
-rw-r--r--src/citra_qt/configure_input.h34
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 @@
#pragma once
+#include <array>
+#include <functional>
#include <memory>
+#include <string>
#include <QKeyEvent>
#include <QWidget>
#include <boost/optional.hpp>
+#include "common/param_package.h"
#include "core/settings.h"
#include "ui_configure_input.h"
@@ -31,15 +35,25 @@ public:
private:
std::unique_ptr<Ui::ConfigureInput> ui;
- /// 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;
- /// 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;
+ /// This will be the the setting function when an input is awaiting configuration.
+ boost::optional<std::function<void(int)>> key_setter;
+
+ std::array<Common::ParamPackage, Settings::NativeButton::NumButtons> buttons_param;
+ std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs> analogs_param;
+
+ static constexpr int ANALOG_SUB_BUTTONS_NUM = 5;
+
+ /// Each button input is represented by a QPushButton.
+ std::array<QPushButton*, Settings::NativeButton::NumButtons> button_map;
+
+ /// Each analog input is represented by five QPushButtons which represents up, down, left, right
+ /// and modifier
+ std::array<std::array<QPushButton*, ANALOG_SUB_BUTTONS_NUM>, Settings::NativeAnalog::NumAnalogs>
+ analog_map;
+
+ static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons;
/// Load configuration settings.
void loadConfiguration();
@@ -48,10 +62,8 @@ private:
/// 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);
+ /// Called when the button was pressed.
+ void handleClick(QPushButton* button, std::function<void(int)> new_key_setter);
/// 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);
};