mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 18:45:36 +00:00
Block all other sdl events instead of pausing game, automatic parse inputs after saving
This commit is contained in:
parent
7d14392874
commit
134ae3e997
@ -8,13 +8,13 @@
|
|||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "control_settings.h"
|
#include "control_settings.h"
|
||||||
#include "sdl_window.h"
|
#include "input/input_handler.h"
|
||||||
#include "ui_control_settings.h"
|
#include "ui_control_settings.h"
|
||||||
|
|
||||||
ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, bool isGameRunning,
|
ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, bool isGameRunning,
|
||||||
QWidget* parent)
|
std::string GameRunningSerial, QWidget* parent)
|
||||||
: QDialog(parent), m_game_info(game_info_get), GameRunning(isGameRunning),
|
: QDialog(parent), m_game_info(game_info_get), GameRunning(isGameRunning),
|
||||||
ui(new Ui::ControlSettings) {
|
RunningGameSerial(GameRunningSerial), ui(new Ui::ControlSettings) {
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@ -24,9 +24,6 @@ ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, b
|
|||||||
CheckGamePad();
|
CheckGamePad();
|
||||||
} else {
|
} else {
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||||
SDL_Event pauseGame{};
|
|
||||||
pauseGame.type = SDL_EVENT_TOGGLE_PAUSE;
|
|
||||||
SDL_PushEvent(&pauseGame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AddBoxItems();
|
AddBoxItems();
|
||||||
@ -327,6 +324,11 @@ void ControlSettings::SaveControllerConfig(bool CloseOnSave) {
|
|||||||
ui->BSlider->value());
|
ui->BSlider->value());
|
||||||
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
||||||
|
|
||||||
|
if (GameRunning) {
|
||||||
|
Config::GetUseUnifiedInputConfig() ? Input::ParseInputConfig("default")
|
||||||
|
: Input::ParseInputConfig(RunningGameSerial);
|
||||||
|
}
|
||||||
|
|
||||||
if (CloseOnSave)
|
if (CloseOnSave)
|
||||||
QWidget::close();
|
QWidget::close();
|
||||||
}
|
}
|
||||||
@ -929,9 +931,6 @@ void ControlSettings::Cleanup() {
|
|||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
} else {
|
} else {
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
|
||||||
SDL_Event resumeGame{};
|
|
||||||
resumeGame.type = SDL_EVENT_TOGGLE_PAUSE;
|
|
||||||
SDL_PushEvent(&resumeGame);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class ControlSettings : public QDialog {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, bool GameRunning,
|
explicit ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, bool GameRunning,
|
||||||
QWidget* parent = nullptr);
|
std::string GameRunningSerial, QWidget* parent = nullptr);
|
||||||
~ControlSettings();
|
~ControlSettings();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -50,6 +50,7 @@ private:
|
|||||||
QList<QPushButton*> AxisList;
|
QList<QPushButton*> AxisList;
|
||||||
QSet<QString> pressedButtons;
|
QSet<QString> pressedButtons;
|
||||||
|
|
||||||
|
std::string RunningGameSerial;
|
||||||
bool GameRunning;
|
bool GameRunning;
|
||||||
bool L2Pressed = false;
|
bool L2Pressed = false;
|
||||||
bool R2Pressed = false;
|
bool R2Pressed = false;
|
||||||
|
@ -10,29 +10,23 @@
|
|||||||
#include <SDL3/SDL_events.h>
|
#include <SDL3/SDL_events.h>
|
||||||
|
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
|
#include "input/input_handler.h"
|
||||||
#include "kbm_config_dialog.h"
|
#include "kbm_config_dialog.h"
|
||||||
#include "kbm_gui.h"
|
#include "kbm_gui.h"
|
||||||
#include "kbm_help_dialog.h"
|
#include "kbm_help_dialog.h"
|
||||||
#include "sdl_window.h"
|
|
||||||
#include "ui_kbm_gui.h"
|
#include "ui_kbm_gui.h"
|
||||||
|
|
||||||
HelpDialog* HelpWindow;
|
HelpDialog* HelpWindow;
|
||||||
KBMSettings::KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, bool isGameRunning,
|
KBMSettings::KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, bool isGameRunning,
|
||||||
QWidget* parent)
|
std::string GameRunningSerial, QWidget* parent)
|
||||||
: QDialog(parent), m_game_info(game_info_get), GameRunning(isGameRunning),
|
: QDialog(parent), m_game_info(game_info_get), GameRunning(isGameRunning),
|
||||||
ui(new Ui::KBMSettings) {
|
RunningGameSerial(GameRunningSerial), ui(new Ui::KBMSettings) {
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->PerGameCheckBox->setChecked(!Config::GetUseUnifiedInputConfig());
|
ui->PerGameCheckBox->setChecked(!Config::GetUseUnifiedInputConfig());
|
||||||
ui->TextEditorButton->setFocus();
|
ui->TextEditorButton->setFocus();
|
||||||
this->setFocusPolicy(Qt::StrongFocus);
|
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("none");
|
||||||
ui->MouseJoystickBox->addItem("right");
|
ui->MouseJoystickBox->addItem("right");
|
||||||
ui->MouseJoystickBox->addItem("left");
|
ui->MouseJoystickBox->addItem("left");
|
||||||
@ -340,6 +334,11 @@ QString(tr("Cannot bind any unique input more than once. Duplicate inputs mapped
|
|||||||
Config::SetUseUnifiedInputConfig(!ui->PerGameCheckBox->isChecked());
|
Config::SetUseUnifiedInputConfig(!ui->PerGameCheckBox->isChecked());
|
||||||
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
||||||
|
|
||||||
|
if (GameRunning) {
|
||||||
|
Config::GetUseUnifiedInputConfig() ? Input::ParseInputConfig("default")
|
||||||
|
: Input::ParseInputConfig(RunningGameSerial);
|
||||||
|
}
|
||||||
|
|
||||||
if (close_on_save)
|
if (close_on_save)
|
||||||
QWidget::close();
|
QWidget::close();
|
||||||
}
|
}
|
||||||
@ -1011,12 +1010,4 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||||||
return QDialog::eventFilter(obj, 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() {}
|
KBMSettings::~KBMSettings() {}
|
||||||
|
@ -24,7 +24,7 @@ class KBMSettings : public QDialog {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, bool GameRunning,
|
explicit KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, bool GameRunning,
|
||||||
QWidget* parent = nullptr);
|
std::string GameRunningSerial, QWidget* parent = nullptr);
|
||||||
~KBMSettings();
|
~KBMSettings();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
@ -47,6 +47,7 @@ private:
|
|||||||
void SetMapping(QString input);
|
void SetMapping(QString input);
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
|
|
||||||
|
std::string RunningGameSerial;
|
||||||
QSet<QString> pressedKeys;
|
QSet<QString> pressedKeys;
|
||||||
bool GameRunning;
|
bool GameRunning;
|
||||||
bool EnableMapping = false;
|
bool EnableMapping = false;
|
||||||
@ -69,9 +70,4 @@ private:
|
|||||||
|
|
||||||
"pad_left", "pad_right", "axis_left_x", "axis_left_y", "axis_right_x",
|
"pad_left", "pad_right", "axis_left_x", "axis_left_y", "axis_right_x",
|
||||||
"axis_right_y", "back"};
|
"axis_right_y", "back"};
|
||||||
|
|
||||||
protected:
|
|
||||||
void closeEvent(QCloseEvent* event) override {
|
|
||||||
Cleanup();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -473,12 +473,13 @@ void MainWindow::CreateConnects() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->controllerButton, &QPushButton::clicked, this, [this]() {
|
connect(ui->controllerButton, &QPushButton::clicked, this, [this]() {
|
||||||
ControlSettings* remapWindow = new ControlSettings(m_game_info, isGameRunning, this);
|
ControlSettings* remapWindow =
|
||||||
|
new ControlSettings(m_game_info, isGameRunning, runningGameSerial, this);
|
||||||
remapWindow->exec();
|
remapWindow->exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->keyboardButton, &QPushButton::clicked, this, [this]() {
|
connect(ui->keyboardButton, &QPushButton::clicked, this, [this]() {
|
||||||
auto kbmWindow = new KBMSettings(m_game_info, isGameRunning, this);
|
auto kbmWindow = new KBMSettings(m_game_info, isGameRunning, runningGameSerial, this);
|
||||||
kbmWindow->exec();
|
kbmWindow->exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -846,12 +847,14 @@ void MainWindow::StartGame() {
|
|||||||
if (m_game_list_frame->currentItem()) {
|
if (m_game_list_frame->currentItem()) {
|
||||||
int itemID = m_game_list_frame->currentItem()->row();
|
int itemID = m_game_list_frame->currentItem()->row();
|
||||||
Common::FS::PathToQString(gamePath, m_game_info->m_games[itemID].path / "eboot.bin");
|
Common::FS::PathToQString(gamePath, m_game_info->m_games[itemID].path / "eboot.bin");
|
||||||
|
runningGameSerial = m_game_info->m_games[itemID].serial;
|
||||||
}
|
}
|
||||||
} else if (table_mode == 1) {
|
} else if (table_mode == 1) {
|
||||||
if (m_game_grid_frame->cellClicked) {
|
if (m_game_grid_frame->cellClicked) {
|
||||||
int itemID = (m_game_grid_frame->crtRow * m_game_grid_frame->columnCnt) +
|
int itemID = (m_game_grid_frame->crtRow * m_game_grid_frame->columnCnt) +
|
||||||
m_game_grid_frame->crtColumn;
|
m_game_grid_frame->crtColumn;
|
||||||
Common::FS::PathToQString(gamePath, m_game_info->m_games[itemID].path / "eboot.bin");
|
Common::FS::PathToQString(gamePath, m_game_info->m_games[itemID].path / "eboot.bin");
|
||||||
|
runningGameSerial = m_game_info->m_games[itemID].serial;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (m_elf_viewer->currentItem()) {
|
if (m_elf_viewer->currentItem()) {
|
||||||
|
@ -75,11 +75,13 @@ private:
|
|||||||
void PlayBackgroundMusic();
|
void PlayBackgroundMusic();
|
||||||
QIcon RecolorIcon(const QIcon& icon, bool isWhite);
|
QIcon RecolorIcon(const QIcon& icon, bool isWhite);
|
||||||
void StartEmulator(std::filesystem::path);
|
void StartEmulator(std::filesystem::path);
|
||||||
|
|
||||||
bool isIconBlack = false;
|
bool isIconBlack = false;
|
||||||
bool isTableList = true;
|
bool isTableList = true;
|
||||||
bool isGameRunning = false;
|
bool isGameRunning = false;
|
||||||
bool isWhite = false;
|
bool isWhite = false;
|
||||||
bool is_paused = false;
|
bool is_paused = false;
|
||||||
|
std::string runningGameSerial = "";
|
||||||
|
|
||||||
QActionGroup* m_icon_size_act_group = nullptr;
|
QActionGroup* m_icon_size_act_group = nullptr;
|
||||||
QActionGroup* m_list_mode_act_group = nullptr;
|
QActionGroup* m_list_mode_act_group = nullptr;
|
||||||
|
@ -19,6 +19,10 @@ Wrapper* Wrapper::GetInstance() {
|
|||||||
|
|
||||||
bool Wrapper::ProcessEvent(SDL_Event* event) {
|
bool Wrapper::ProcessEvent(SDL_Event* event) {
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
|
case SDL_EVENT_GAMEPAD_ADDED:
|
||||||
|
return false;
|
||||||
|
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||||
|
return false;
|
||||||
case SDL_EVENT_QUIT:
|
case SDL_EVENT_QUIT:
|
||||||
emit SDLEvent(SDL_EVENT_QUIT, 0, 0);
|
emit SDLEvent(SDL_EVENT_QUIT, 0, 0);
|
||||||
return true;
|
return true;
|
||||||
@ -31,8 +35,9 @@ bool Wrapper::ProcessEvent(SDL_Event* event) {
|
|||||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||||
emit SDLEvent(SDL_EVENT_GAMEPAD_AXIS_MOTION, event->gaxis.axis, event->gaxis.value);
|
emit SDLEvent(SDL_EVENT_GAMEPAD_AXIS_MOTION, event->gaxis.axis, event->gaxis.value);
|
||||||
return true;
|
return true;
|
||||||
|
// block all other SDL events while wrapper is active
|
||||||
default:
|
default:
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Wrapper::~Wrapper() {}
|
Wrapper::~Wrapper() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user