2023-12-22 11:57:49 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0+
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
#pragma once
|
2023-05-13 04:30:41 +00:00
|
|
|
|
2022-12-04 15:00:06 +00:00
|
|
|
#include "pcsx2/Config.h"
|
2023-05-13 04:30:41 +00:00
|
|
|
#include "pcsx2/Input/InputManager.h"
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
#include <QtWidgets/QPushButton>
|
|
|
|
#include <optional>
|
2022-12-17 12:10:33 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
class QTimer;
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
class ControllerSettingsWindow;
|
2022-06-08 12:15:10 +00:00
|
|
|
class SettingsInterface;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
class InputBindingWidget : public QPushButton
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
InputBindingWidget(QWidget* parent);
|
2022-12-04 15:00:06 +00:00
|
|
|
InputBindingWidget(
|
|
|
|
QWidget* parent, SettingsInterface* sif, InputBindingInfo::Type bind_type, std::string section_name, std::string key_name);
|
2021-12-13 12:12:54 +00:00
|
|
|
~InputBindingWidget();
|
|
|
|
|
2023-09-09 04:13:27 +00:00
|
|
|
static bool isMouseMappingEnabled(SettingsInterface* sif);
|
2022-06-29 10:08:30 +00:00
|
|
|
|
2022-12-04 15:00:06 +00:00
|
|
|
void initialize(SettingsInterface* sif, InputBindingInfo::Type bind_type, std::string section_name, std::string key_name);
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void clearBinding();
|
|
|
|
void reloadBinding();
|
|
|
|
|
|
|
|
protected Q_SLOTS:
|
|
|
|
void onClicked();
|
|
|
|
void onInputListenTimerTimeout();
|
|
|
|
void inputManagerHookCallback(InputBindingKey key, float value);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
enum : u32
|
|
|
|
{
|
|
|
|
TIMEOUT_FOR_SINGLE_BINDING = 5,
|
|
|
|
TIMEOUT_FOR_ALL_BINDING = 10
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual bool eventFilter(QObject* watched, QEvent* event) override;
|
|
|
|
virtual bool event(QEvent* event) override;
|
|
|
|
virtual void mouseReleaseEvent(QMouseEvent* e) override;
|
|
|
|
|
|
|
|
virtual void startListeningForInput(u32 timeout_in_seconds);
|
|
|
|
virtual void stopListeningForInput();
|
|
|
|
virtual void openDialog();
|
|
|
|
|
|
|
|
bool isListeningForInput() const { return m_input_listen_timer != nullptr; }
|
|
|
|
void setNewBinding();
|
|
|
|
void updateText();
|
|
|
|
|
|
|
|
void hookInputManager();
|
|
|
|
void unhookInputManager();
|
|
|
|
|
2022-06-08 12:15:10 +00:00
|
|
|
SettingsInterface* m_sif = nullptr;
|
2022-12-04 15:00:06 +00:00
|
|
|
InputBindingInfo::Type m_bind_type = InputBindingInfo::Type::Unknown;
|
2021-12-13 12:12:54 +00:00
|
|
|
std::string m_section_name;
|
|
|
|
std::string m_key_name;
|
|
|
|
std::vector<std::string> m_bindings;
|
|
|
|
std::vector<InputBindingKey> m_new_bindings;
|
2022-12-17 12:10:33 +00:00
|
|
|
std::vector<std::pair<InputBindingKey, std::pair<float, float>>> m_value_ranges;
|
2021-12-13 12:12:54 +00:00
|
|
|
QTimer* m_input_listen_timer = nullptr;
|
|
|
|
u32 m_input_listen_remaining_seconds = 0;
|
2022-05-15 08:15:27 +00:00
|
|
|
QPoint m_input_listen_start_position{};
|
2022-06-29 10:08:30 +00:00
|
|
|
bool m_mouse_mapping_enabled = false;
|
2021-12-13 12:12:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class InputVibrationBindingWidget : public QPushButton
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
InputVibrationBindingWidget(QWidget* parent);
|
2023-10-14 08:45:09 +00:00
|
|
|
InputVibrationBindingWidget(QWidget* parent, ControllerSettingsWindow* dialog, std::string section_name, std::string key_name);
|
2021-12-13 12:12:54 +00:00
|
|
|
~InputVibrationBindingWidget();
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
void setKey(ControllerSettingsWindow* dialog, std::string section_name, std::string key_name);
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void clearBinding();
|
|
|
|
|
|
|
|
protected Q_SLOTS:
|
|
|
|
void onClicked();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void mouseReleaseEvent(QMouseEvent* e) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string m_section_name;
|
|
|
|
std::string m_key_name;
|
|
|
|
std::string m_binding;
|
2022-12-04 15:00:06 +00:00
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
ControllerSettingsWindow* m_dialog;
|
2021-12-13 12:12:54 +00:00
|
|
|
};
|