2022-12-04 11:03:45 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
|
|
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
|
|
|
2020-07-22 16:35:15 +00:00
|
|
|
#pragma once
|
|
|
|
#include "common/types.h"
|
2023-08-13 06:28:28 +00:00
|
|
|
#include "util/input_manager.h"
|
2020-07-22 16:35:15 +00:00
|
|
|
#include "ui_inputbindingdialog.h"
|
|
|
|
#include <QtWidgets/QDialog>
|
2020-08-29 12:19:28 +00:00
|
|
|
#include <optional>
|
2020-07-22 16:35:15 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
class SettingsInterface;
|
2020-07-22 16:35:15 +00:00
|
|
|
|
|
|
|
class InputBindingDialog : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-01-15 04:00:51 +00:00
|
|
|
InputBindingDialog(SettingsInterface* sif, InputBindingInfo::Type bind_type, std::string section_name,
|
|
|
|
std::string key_name, std::vector<std::string> bindings, QWidget* parent);
|
2020-07-22 16:35:15 +00:00
|
|
|
~InputBindingDialog();
|
|
|
|
|
|
|
|
protected Q_SLOTS:
|
|
|
|
void onAddBindingButtonClicked();
|
|
|
|
void onRemoveBindingButtonClicked();
|
|
|
|
void onClearBindingsButtonClicked();
|
|
|
|
void onInputListenTimerTimeout();
|
2022-07-11 13:03:29 +00:00
|
|
|
void inputManagerHookCallback(InputBindingKey key, float value);
|
2020-07-22 16:35:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
enum : u32
|
|
|
|
{
|
|
|
|
TIMEOUT_FOR_BINDING = 5
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual bool eventFilter(QObject* watched, QEvent* event) override;
|
|
|
|
|
|
|
|
virtual void startListeningForInput(u32 timeout_in_seconds);
|
|
|
|
virtual void stopListeningForInput();
|
|
|
|
|
|
|
|
bool isListeningForInput() const { return m_input_listen_timer != nullptr; }
|
2022-07-11 13:03:29 +00:00
|
|
|
void addNewBinding();
|
2020-07-22 16:35:15 +00:00
|
|
|
|
|
|
|
void updateList();
|
|
|
|
void saveListToSettings();
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
void hookInputManager();
|
|
|
|
void unhookInputManager();
|
2020-07-22 16:35:15 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
Ui::InputBindingDialog m_ui;
|
2020-07-22 16:35:15 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
SettingsInterface* m_sif;
|
2023-01-15 04:00:51 +00:00
|
|
|
InputBindingInfo::Type m_bind_type;
|
2020-07-22 16:35:15 +00:00
|
|
|
std::string m_section_name;
|
|
|
|
std::string m_key_name;
|
|
|
|
std::vector<std::string> m_bindings;
|
2022-07-11 13:03:29 +00:00
|
|
|
std::vector<InputBindingKey> m_new_bindings;
|
2023-01-15 04:00:51 +00:00
|
|
|
std::vector<std::pair<InputBindingKey, std::pair<float, float>>> m_value_ranges;
|
2020-07-22 16:35:15 +00:00
|
|
|
|
|
|
|
QTimer* m_input_listen_timer = nullptr;
|
|
|
|
u32 m_input_listen_remaining_seconds = 0;
|
2023-01-15 04:00:51 +00:00
|
|
|
QPoint m_input_listen_start_position{};
|
2022-07-11 13:03:29 +00:00
|
|
|
bool m_mouse_mapping_enabled = false;
|
2020-07-22 16:35:15 +00:00
|
|
|
};
|