mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-13 07:08:49 +00:00
Controller Remapping GUI v2 (#3144)
* Remapping GUI V2 - initial commit * Unmap button with escape key * Allow combination inputs * Use separate class for SDL event signals so that i can work with the SDL window event loop * Automatically pause game when GUI open to better manage event queue * Move sd;_gamepad_added event from remap object to GUI object to avoid conflicts with sdl window * Use signals on button/trigger to release to make GUI more responsive * pause game while KBM window is open for consistency * don't check gamepad when game is running to avoid conflicts * Block all other sdl events instead of pausing game, automatic parse inputs after saving * Don't block window restored or window exposed cases * Properly exit event loop thread on exit
This commit is contained in:
@@ -2,7 +2,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <QDialog>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_gamepad.h>
|
||||
#include "game_info.h"
|
||||
#include "sdl_event_wrapper.h"
|
||||
|
||||
namespace Ui {
|
||||
class ControlSettings;
|
||||
@@ -11,22 +14,56 @@ class ControlSettings;
|
||||
class ControlSettings : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ControlSettings(std::shared_ptr<GameInfoClass> game_info_get,
|
||||
QWidget* parent = nullptr);
|
||||
explicit ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, bool GameRunning,
|
||||
std::string GameRunningSerial, QWidget* parent = nullptr);
|
||||
~ControlSettings();
|
||||
|
||||
signals:
|
||||
void PushGamepadEvent();
|
||||
void AxisChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void SaveControllerConfig(bool CloseOnSave);
|
||||
void SetDefault();
|
||||
void UpdateLightbarColor();
|
||||
void CheckMapping(QPushButton*& button);
|
||||
void StartTimer(QPushButton*& button, bool isButton);
|
||||
void ConnectAxisInputs(QPushButton*& button);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::ControlSettings> ui;
|
||||
std::shared_ptr<GameInfoClass> m_game_info;
|
||||
|
||||
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||
void AddBoxItems();
|
||||
void SetUIValuestoMappings();
|
||||
void GetGameTitle();
|
||||
void CheckGamePad();
|
||||
void processSDLEvents(int Type, int Input, int Value);
|
||||
void pollSDLEvents();
|
||||
void SetMapping(QString input);
|
||||
void DisableMappingButtons();
|
||||
void EnableMappingButtons();
|
||||
void Cleanup();
|
||||
|
||||
QList<QPushButton*> ButtonsList;
|
||||
QList<QPushButton*> AxisList;
|
||||
QSet<QString> pressedButtons;
|
||||
|
||||
std::string RunningGameSerial;
|
||||
bool GameRunning;
|
||||
bool L2Pressed = false;
|
||||
bool R2Pressed = false;
|
||||
bool EnableButtonMapping = false;
|
||||
bool EnableAxisMapping = false;
|
||||
bool MappingCompleted = false;
|
||||
QString mapping;
|
||||
int MappingTimer;
|
||||
QTimer* timer;
|
||||
QPushButton* MappingButton;
|
||||
SDL_Gamepad* gamepad = nullptr;
|
||||
SdlEventWrapper::Wrapper* RemapWrapper;
|
||||
QFuture<void> Polling;
|
||||
|
||||
const std::vector<std::string> ControllerInputs = {
|
||||
"cross", "circle", "square", "triangle", "l1",
|
||||
@@ -39,29 +76,8 @@ private:
|
||||
"pad_left", "pad_right", "axis_left_x", "axis_left_y", "axis_right_x",
|
||||
"axis_right_y", "back"};
|
||||
|
||||
const QStringList ButtonOutputs = {"cross",
|
||||
"circle",
|
||||
"square",
|
||||
"triangle",
|
||||
"l1",
|
||||
"r1",
|
||||
"l2",
|
||||
"r2",
|
||||
"l3",
|
||||
|
||||
"r3",
|
||||
"options",
|
||||
"pad_up",
|
||||
|
||||
"pad_down",
|
||||
|
||||
"pad_left",
|
||||
"pad_right",
|
||||
"touchpad_left",
|
||||
"touchpad_center",
|
||||
"touchpad_right",
|
||||
"unmapped"};
|
||||
|
||||
const QStringList StickOutputs = {"axis_left_x", "axis_left_y", "axis_right_x", "axis_right_y",
|
||||
"unmapped"};
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override {
|
||||
Cleanup();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user