mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 10:35:03 +00:00
Automatically pause game when GUI open to better manage event queue
This commit is contained in:
parent
b74eb796fe
commit
db65bf48c4
@ -8,6 +8,7 @@
|
||||
#include "common/logging/log.h"
|
||||
#include "common/path_util.h"
|
||||
#include "control_settings.h"
|
||||
#include "sdl_window.h"
|
||||
#include "ui_control_settings.h"
|
||||
|
||||
ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, bool isGameRunning,
|
||||
@ -22,6 +23,9 @@ ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, b
|
||||
SDL_InitSubSystem(SDL_INIT_EVENTS);
|
||||
} else {
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||
SDL_Event pauseGame{};
|
||||
pauseGame.type = SDL_EVENT_TOGGLE_PAUSE;
|
||||
SDL_PushEvent(&pauseGame);
|
||||
}
|
||||
|
||||
CheckGamePad();
|
||||
@ -775,19 +779,6 @@ bool ControlSettings::eventFilter(QObject* obj, QEvent* event) {
|
||||
}
|
||||
|
||||
void ControlSettings::processSDLEvents(int Type, int Input, int Value) {
|
||||
if (Type == SDL_EVENT_QUIT) {
|
||||
SdlEventWrapper::Wrapper::wrapperActive = false;
|
||||
if (gamepad)
|
||||
SDL_CloseGamepad(gamepad);
|
||||
if (!GameRunning) {
|
||||
SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
|
||||
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
||||
SDL_Quit();
|
||||
} else {
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
|
||||
}
|
||||
}
|
||||
|
||||
if (Type == SDL_EVENT_GAMEPAD_ADDED) {
|
||||
if (!GameRunning)
|
||||
CheckGamePad();
|
||||
@ -908,4 +899,21 @@ void ControlSettings::pollSDLEvents() {
|
||||
}
|
||||
}
|
||||
|
||||
void ControlSettings::cleanup() {
|
||||
SdlEventWrapper::Wrapper::wrapperActive = false;
|
||||
if (gamepad)
|
||||
SDL_CloseGamepad(gamepad);
|
||||
|
||||
if (!GameRunning) {
|
||||
SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
|
||||
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
||||
SDL_Quit();
|
||||
} else {
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
|
||||
SDL_Event resumeGame{};
|
||||
resumeGame.type = SDL_EVENT_TOGGLE_PAUSE;
|
||||
SDL_PushEvent(&resumeGame);
|
||||
}
|
||||
}
|
||||
|
||||
ControlSettings::~ControlSettings() {}
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
void SetMapping(QString input);
|
||||
void DisableMappingButtons();
|
||||
void EnableMappingButtons();
|
||||
void cleanup();
|
||||
|
||||
QList<QPushButton*> ButtonsList;
|
||||
QList<QPushButton*> AxisList;
|
||||
@ -73,8 +74,6 @@ private:
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override {
|
||||
SDL_Event quitLoop{};
|
||||
quitLoop.type = SDL_EVENT_QUIT;
|
||||
SDL_PushEvent(&quitLoop);
|
||||
cleanup();
|
||||
}
|
||||
};
|
||||
|
@ -18,9 +18,6 @@ Wrapper* Wrapper::GetInstance() {
|
||||
}
|
||||
|
||||
bool Wrapper::ProcessEvent(SDL_Event* event) {
|
||||
if (!wrapperActive)
|
||||
return false;
|
||||
|
||||
switch (event->type) {
|
||||
case SDL_EVENT_QUIT:
|
||||
emit SDLEvent(SDL_EVENT_QUIT, 0, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user