mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 18:45:36 +00:00
pause game while KBM window is open for consistency
This commit is contained in:
parent
86be802223
commit
8b08e2b382
@ -918,7 +918,7 @@ void ControlSettings::pollSDLEvents() {
|
||||
}
|
||||
}
|
||||
|
||||
void ControlSettings::cleanup() {
|
||||
void ControlSettings::Cleanup() {
|
||||
SdlEventWrapper::Wrapper::wrapperActive = false;
|
||||
if (gamepad)
|
||||
SDL_CloseGamepad(gamepad);
|
||||
|
@ -44,7 +44,7 @@ private:
|
||||
void SetMapping(QString input);
|
||||
void DisableMappingButtons();
|
||||
void EnableMappingButtons();
|
||||
void cleanup();
|
||||
void Cleanup();
|
||||
|
||||
QList<QPushButton*> ButtonsList;
|
||||
QList<QPushButton*> AxisList;
|
||||
@ -76,6 +76,6 @@ private:
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override {
|
||||
cleanup();
|
||||
Cleanup();
|
||||
}
|
||||
};
|
||||
|
@ -7,22 +7,32 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QPushButton>
|
||||
#include <QWheelEvent>
|
||||
#include <SDL3/SDL_events.h>
|
||||
|
||||
#include "common/path_util.h"
|
||||
#include "kbm_config_dialog.h"
|
||||
#include "kbm_gui.h"
|
||||
#include "kbm_help_dialog.h"
|
||||
#include "sdl_window.h"
|
||||
#include "ui_kbm_gui.h"
|
||||
|
||||
HelpDialog* HelpWindow;
|
||||
KBMSettings::KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, QWidget* parent)
|
||||
: QDialog(parent), m_game_info(game_info_get), ui(new Ui::KBMSettings) {
|
||||
KBMSettings::KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, bool isGameRunning,
|
||||
QWidget* parent)
|
||||
: QDialog(parent), m_game_info(game_info_get), GameRunning(isGameRunning),
|
||||
ui(new Ui::KBMSettings) {
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->PerGameCheckBox->setChecked(!Config::GetUseUnifiedInputConfig());
|
||||
ui->TextEditorButton->setFocus();
|
||||
this->setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
if (GameRunning) {
|
||||
SDL_Event pauseGame{};
|
||||
pauseGame.type = SDL_EVENT_TOGGLE_PAUSE;
|
||||
SDL_PushEvent(&pauseGame);
|
||||
}
|
||||
|
||||
ui->MouseJoystickBox->addItem("none");
|
||||
ui->MouseJoystickBox->addItem("right");
|
||||
ui->MouseJoystickBox->addItem("left");
|
||||
@ -998,8 +1008,15 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QDialog::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void KBMSettings::Cleanup() {
|
||||
if (GameRunning) {
|
||||
SDL_Event resumeGame{};
|
||||
resumeGame.type = SDL_EVENT_TOGGLE_PAUSE;
|
||||
SDL_PushEvent(&resumeGame);
|
||||
}
|
||||
}
|
||||
|
||||
KBMSettings::~KBMSettings() {}
|
||||
|
@ -23,7 +23,8 @@ class KBMSettings;
|
||||
class KBMSettings : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, QWidget* parent = nullptr);
|
||||
explicit KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, bool GameRunning,
|
||||
QWidget* parent = nullptr);
|
||||
~KBMSettings();
|
||||
|
||||
private Q_SLOTS:
|
||||
@ -44,8 +45,10 @@ private:
|
||||
void DisableMappingButtons();
|
||||
void EnableMappingButtons();
|
||||
void SetMapping(QString input);
|
||||
void Cleanup();
|
||||
|
||||
QSet<QString> pressedKeys;
|
||||
bool GameRunning;
|
||||
bool EnableMapping = false;
|
||||
bool MappingCompleted = false;
|
||||
bool HelpWindowOpen = false;
|
||||
@ -66,4 +69,9 @@ private:
|
||||
|
||||
"pad_left", "pad_right", "axis_left_x", "axis_left_y", "axis_right_x",
|
||||
"axis_right_y", "back"};
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override {
|
||||
Cleanup();
|
||||
}
|
||||
};
|
||||
|
@ -478,7 +478,7 @@ void MainWindow::CreateConnects() {
|
||||
});
|
||||
|
||||
connect(ui->keyboardButton, &QPushButton::clicked, this, [this]() {
|
||||
auto kbmWindow = new KBMSettings(m_game_info, this);
|
||||
auto kbmWindow = new KBMSettings(m_game_info, isGameRunning, this);
|
||||
kbmWindow->exec();
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user