mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-31 14:35:19 +00:00
stop games with esc key or stop button
This commit is contained in:
parent
ab56665d4b
commit
2c5264b927
@ -517,6 +517,8 @@ set(EMULATOR src/emulator.cpp
|
|||||||
src/emulator.h
|
src/emulator.h
|
||||||
src/sdl_window.h
|
src/sdl_window.h
|
||||||
src/sdl_window.cpp
|
src/sdl_window.cpp
|
||||||
|
src/sdl_window_manager.cpp
|
||||||
|
src/sdl_window_manager.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# The above is shared in SDL and Qt version (TODO share them all)
|
# The above is shared in SDL and Qt version (TODO share them all)
|
||||||
@ -563,6 +565,8 @@ if (ENABLE_QT_GUI)
|
|||||||
${VIDEO_CORE}
|
${VIDEO_CORE}
|
||||||
${EMULATOR}
|
${EMULATOR}
|
||||||
src/images/shadPS4.icns
|
src/images/shadPS4.icns
|
||||||
|
src/sdl_window_manager.cpp
|
||||||
|
src/sdl_window_manager.h
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_executable(shadps4
|
add_executable(shadps4
|
||||||
@ -578,6 +582,8 @@ else()
|
|||||||
src/emulator.h
|
src/emulator.h
|
||||||
src/sdl_window.h
|
src/sdl_window.h
|
||||||
src/sdl_window.cpp
|
src/sdl_window.cpp
|
||||||
|
src/sdl_window_manager.cpp
|
||||||
|
src/sdl_window_manager.h
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "core/loader.h"
|
#include "core/loader.h"
|
||||||
#include "game_install_dialog.h"
|
#include "game_install_dialog.h"
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
|
#include "sdl_window_manager.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -185,6 +186,8 @@ void MainWindow::CreateConnects() {
|
|||||||
connect(m_game_list_frame.get(), &QTableWidget::cellDoubleClicked, this,
|
connect(m_game_list_frame.get(), &QTableWidget::cellDoubleClicked, this,
|
||||||
&MainWindow::StartGame);
|
&MainWindow::StartGame);
|
||||||
|
|
||||||
|
connect(ui->stopButton, &QPushButton::clicked, this, &MainWindow::StopGame);
|
||||||
|
|
||||||
connect(ui->setIconSizeTinyAct, &QAction::triggered, this, [this]() {
|
connect(ui->setIconSizeTinyAct, &QAction::triggered, this, [this]() {
|
||||||
if (isTableList) {
|
if (isTableList) {
|
||||||
m_game_list_frame->icon_size =
|
m_game_list_frame->icon_size =
|
||||||
@ -392,6 +395,10 @@ void MainWindow::StartGame() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::StopGame() {
|
||||||
|
Frontend::QuitAllSDLWindows();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::SearchGameTable(const QString& text) {
|
void MainWindow::SearchGameTable(const QString& text) {
|
||||||
if (isTableList) {
|
if (isTableList) {
|
||||||
for (int row = 0; row < m_game_list_frame->rowCount(); row++) {
|
for (int row = 0; row < m_game_list_frame->rowCount(); row++) {
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
void InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg);
|
void InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg);
|
||||||
void InstallDirectory();
|
void InstallDirectory();
|
||||||
void StartGame();
|
void StartGame();
|
||||||
|
void StopGame();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void ConfigureGuiFromSettings();
|
void ConfigureGuiFromSettings();
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "core/libraries/pad/pad.h"
|
#include "core/libraries/pad/pad.h"
|
||||||
#include "input/controller.h"
|
#include "input/controller.h"
|
||||||
#include "sdl_window.h"
|
#include "sdl_window.h"
|
||||||
|
#include "sdl_window_manager.h"
|
||||||
#include "video_core/renderdoc.h"
|
#include "video_core/renderdoc.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@ -265,6 +266,11 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
|
|||||||
case SDLK_SPACE:
|
case SDLK_SPACE:
|
||||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
|
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
|
||||||
break;
|
break;
|
||||||
|
case SDLK_ESCAPE:
|
||||||
|
if (event->type == SDL_EVENT_KEY_UP) {
|
||||||
|
Frontend::QuitAllSDLWindows();
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
16
src/sdl_window_manager.cpp
Normal file
16
src/sdl_window_manager.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <SDL3/SDL_events.h>
|
||||||
|
|
||||||
|
namespace Frontend {
|
||||||
|
|
||||||
|
void QuitAllSDLWindows() {
|
||||||
|
// In the future, windows would have to be stored accessibly outside functions to close just a
|
||||||
|
// specific window
|
||||||
|
SDL_Event quitEvent;
|
||||||
|
quitEvent.type = SDL_EVENT_QUIT;
|
||||||
|
SDL_PushEvent(&quitEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Frontend
|
10
src/sdl_window_manager.h
Normal file
10
src/sdl_window_manager.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Frontend {
|
||||||
|
|
||||||
|
void QuitAllSDLWindows();
|
||||||
|
|
||||||
|
} // namespace Frontend
|
Loading…
Reference in New Issue
Block a user