mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-21 03:54:45 +00:00
add stopping games by esc or main window
This commit is contained in:
parent
351f2e1073
commit
71fefbf596
6 changed files with 42 additions and 0 deletions
|
@ -578,6 +578,8 @@ else()
|
|||
src/emulator.h
|
||||
src/sdl_window.h
|
||||
src/sdl_window.cpp
|
||||
src/sdl_window_manager.cpp
|
||||
src/sdl_window_manager.h
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "core/loader.h"
|
||||
#include "game_install_dialog.h"
|
||||
#include "main_window.h"
|
||||
#include "sdl_window_manager.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
|
@ -185,6 +186,8 @@ void MainWindow::CreateConnects() {
|
|||
connect(m_game_list_frame.get(), &QTableWidget::cellDoubleClicked, this,
|
||||
&MainWindow::StartGame);
|
||||
|
||||
connect(ui->stopButton, &QPushButton::clicked, this, &MainWindow::StopGame);
|
||||
|
||||
connect(ui->setIconSizeTinyAct, &QAction::triggered, this, [this]() {
|
||||
if (isTableList) {
|
||||
m_game_list_frame->icon_size =
|
||||
|
@ -392,6 +395,10 @@ void MainWindow::StartGame() {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::StopGame() {
|
||||
Frontend::QuitAllSDLWindows();
|
||||
}
|
||||
|
||||
void MainWindow::SearchGameTable(const QString& text) {
|
||||
if (isTableList) {
|
||||
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 InstallDirectory();
|
||||
void StartGame();
|
||||
void StopGame();
|
||||
|
||||
private Q_SLOTS:
|
||||
void ConfigureGuiFromSettings();
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "input/controller.h"
|
||||
#include "sdl_window.h"
|
||||
#include "video_core/renderdoc.h"
|
||||
#include "sdl_window_manager.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <SDL3/SDL_metal.h>
|
||||
|
@ -265,6 +266,11 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
|
|||
case SDLK_SPACE:
|
||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
|
||||
break;
|
||||
case SDLK_ESCAPE:
|
||||
if (event->type == SDL_EVENT_KEY_UP) {
|
||||
Frontend::QuitAllSDLWindows();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
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…
Add table
Reference in a new issue