mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 10:35:03 +00:00
Unmap button with escape key
This commit is contained in:
parent
cbf08f7f88
commit
71bca8be8b
@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <QKeyEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
@ -23,6 +24,7 @@ ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, Q
|
|||||||
AddBoxItems();
|
AddBoxItems();
|
||||||
SetUIValuestoMappings();
|
SetUIValuestoMappings();
|
||||||
UpdateLightbarColor();
|
UpdateLightbarColor();
|
||||||
|
installEventFilter(this);
|
||||||
|
|
||||||
ButtonsList = {ui->CrossButton,
|
ButtonsList = {ui->CrossButton,
|
||||||
ui->CircleButton,
|
ui->CircleButton,
|
||||||
@ -705,17 +707,28 @@ void ControlSettings::CheckMapping(QPushButton*& button) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControlSettings::SetMapping(QString input) {
|
||||||
|
mapping = input;
|
||||||
|
MappingCompleted = true;
|
||||||
|
emit gamepadInputEvent();
|
||||||
|
if (EnableAxisMapping)
|
||||||
|
emit AxisChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ControlSettings::eventFilter(QObject* obj, QEvent* event) {
|
||||||
|
if (event->type() == QEvent::KeyPress && EnableButtonMapping) {
|
||||||
|
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||||
|
if (keyEvent->key() == Qt::Key_Escape) {
|
||||||
|
SetMapping("unmapped");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QDialog::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
void ControlSettings::pollSDLEvents() {
|
void ControlSettings::pollSDLEvents() {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
auto SetMapping = [&](const QString& input) {
|
|
||||||
mapping = input;
|
|
||||||
MappingCompleted = true;
|
|
||||||
emit gamepadInputEvent();
|
|
||||||
if (EnableAxisMapping)
|
|
||||||
emit AxisChanged();
|
|
||||||
};
|
|
||||||
|
|
||||||
while (isRunning) {
|
while (isRunning) {
|
||||||
if (!SDL_WaitEvent(&event)) {
|
if (!SDL_WaitEvent(&event)) {
|
||||||
return;
|
return;
|
||||||
|
@ -34,11 +34,13 @@ private:
|
|||||||
std::unique_ptr<Ui::ControlSettings> ui;
|
std::unique_ptr<Ui::ControlSettings> ui;
|
||||||
std::shared_ptr<GameInfoClass> m_game_info;
|
std::shared_ptr<GameInfoClass> m_game_info;
|
||||||
|
|
||||||
|
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||||
void AddBoxItems();
|
void AddBoxItems();
|
||||||
void SetUIValuestoMappings();
|
void SetUIValuestoMappings();
|
||||||
void GetGameTitle();
|
void GetGameTitle();
|
||||||
void CheckGamePad();
|
void CheckGamePad();
|
||||||
void pollSDLEvents();
|
void pollSDLEvents();
|
||||||
|
void SetMapping(QString input);
|
||||||
void DisableMappingButtons();
|
void DisableMappingButtons();
|
||||||
void EnableMappingButtons();
|
void EnableMappingButtons();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user