UI: Massive revamp, new features and improvements
This commit is contained in:
@@ -1,32 +1,29 @@
|
||||
#pragma once
|
||||
#include "common/types.h"
|
||||
#include "core/controller.h"
|
||||
#include "frontend-common/input_manager.h"
|
||||
#include "ui_inputbindingdialog.h"
|
||||
#include <QtWidgets/QDialog>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class QtHostInterface;
|
||||
class SettingsInterface;
|
||||
|
||||
class InputBindingDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputBindingDialog(QtHostInterface* host_interface, std::string section_name, std::string key_name,
|
||||
InputBindingDialog(SettingsInterface* sif, std::string section_name, std::string key_name,
|
||||
std::vector<std::string> bindings, QWidget* parent);
|
||||
~InputBindingDialog();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void bindToControllerAxis(int controller_index, int axis_index, bool inverted,
|
||||
std::optional<bool> half_axis_positive);
|
||||
void bindToControllerButton(int controller_index, int button_index);
|
||||
void bindToControllerHat(int controller_index, int hat_index, const QString& hat_direction);
|
||||
void onAddBindingButtonClicked();
|
||||
void onRemoveBindingButtonClicked();
|
||||
void onClearBindingsButtonClicked();
|
||||
void onInputListenTimerTimeout();
|
||||
void inputManagerHookCallback(InputBindingKey key, float value);
|
||||
|
||||
protected:
|
||||
enum : u32
|
||||
@@ -40,56 +37,24 @@ protected:
|
||||
virtual void stopListeningForInput();
|
||||
|
||||
bool isListeningForInput() const { return m_input_listen_timer != nullptr; }
|
||||
void addNewBinding(std::string new_binding);
|
||||
void addNewBinding();
|
||||
|
||||
void updateList();
|
||||
void saveListToSettings();
|
||||
|
||||
void hookInputManager();
|
||||
void unhookInputManager();
|
||||
|
||||
Ui::InputBindingDialog m_ui;
|
||||
|
||||
QtHostInterface* m_host_interface;
|
||||
|
||||
SettingsInterface* m_sif;
|
||||
std::string m_section_name;
|
||||
std::string m_key_name;
|
||||
std::vector<std::string> m_bindings;
|
||||
std::string m_new_binding_value;
|
||||
std::vector<InputBindingKey> m_new_bindings;
|
||||
|
||||
QTimer* m_input_listen_timer = nullptr;
|
||||
u32 m_input_listen_remaining_seconds = 0;
|
||||
};
|
||||
|
||||
class InputButtonBindingDialog final : public InputBindingDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputButtonBindingDialog(QtHostInterface* host_interface, std::string section_name, std::string key_name,
|
||||
std::vector<std::string> bindings, QWidget* parent);
|
||||
~InputButtonBindingDialog();
|
||||
|
||||
protected:
|
||||
void startListeningForInput(u32 timeout_in_seconds) override;
|
||||
void stopListeningForInput() override;
|
||||
void hookControllerInput();
|
||||
void unhookControllerInput();
|
||||
};
|
||||
|
||||
class InputAxisBindingDialog final : public InputBindingDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputAxisBindingDialog(QtHostInterface* host_interface, std::string section_name, std::string key_name,
|
||||
std::vector<std::string> bindings, Controller::AxisType axis_type, QWidget* parent);
|
||||
~InputAxisBindingDialog();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
void startListeningForInput(u32 timeout_in_seconds) override;
|
||||
void stopListeningForInput() override;
|
||||
void hookControllerInput();
|
||||
void unhookControllerInput();
|
||||
|
||||
private:
|
||||
Controller::AxisType m_axis_type;
|
||||
QPointF m_input_listen_start_position{};
|
||||
bool m_mouse_mapping_enabled = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user