mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-03 07:52:31 +00:00
Suggestions / Fixes - Pause and FullScreen Buttons
This commit is contained in:
parent
f172fc0784
commit
25876bbeb8
@ -107,6 +107,7 @@ static bool showBackgroundImage = true;
|
|||||||
static bool isFullscreen = false;
|
static bool isFullscreen = false;
|
||||||
static std::string fullscreenMode = "Windowed";
|
static std::string fullscreenMode = "Windowed";
|
||||||
static bool isHDRAllowed = false;
|
static bool isHDRAllowed = false;
|
||||||
|
static bool showLabelsUnderIcons = true;
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
u32 m_language = 1; // english
|
u32 m_language = 1; // english
|
||||||
@ -176,6 +177,14 @@ bool getIsFullscreen() {
|
|||||||
return isFullscreen;
|
return isFullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getShowLabelsUnderIcons() {
|
||||||
|
return showLabelsUnderIcons;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool setShowLabelsUnderIcons() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::string getFullscreenMode() {
|
std::string getFullscreenMode() {
|
||||||
return fullscreenMode;
|
return fullscreenMode;
|
||||||
}
|
}
|
||||||
@ -427,6 +436,9 @@ void setVblankDiv(u32 value) {
|
|||||||
void setIsFullscreen(bool enable) {
|
void setIsFullscreen(bool enable) {
|
||||||
isFullscreen = enable;
|
isFullscreen = enable;
|
||||||
}
|
}
|
||||||
|
void setShowLabelsUnderIcons(bool enable) {
|
||||||
|
showLabelsUnderIcons = enable;
|
||||||
|
}
|
||||||
|
|
||||||
void setFullscreenMode(std::string mode) {
|
void setFullscreenMode(std::string mode) {
|
||||||
fullscreenMode = mode;
|
fullscreenMode = mode;
|
||||||
|
@ -26,6 +26,8 @@ bool GetLoadGameSizeEnabled();
|
|||||||
std::filesystem::path GetSaveDataPath();
|
std::filesystem::path GetSaveDataPath();
|
||||||
void setLoadGameSizeEnabled(bool enable);
|
void setLoadGameSizeEnabled(bool enable);
|
||||||
bool getIsFullscreen();
|
bool getIsFullscreen();
|
||||||
|
bool getShowLabelsUnderIcons();
|
||||||
|
bool setShowLabelsUnderIcons();
|
||||||
std::string getFullscreenMode();
|
std::string getFullscreenMode();
|
||||||
bool isNeoModeConsole();
|
bool isNeoModeConsole();
|
||||||
bool isDevKitConsole();
|
bool isDevKitConsole();
|
||||||
|
BIN
src/images/fullscreen_icon.png
Normal file
BIN
src/images/fullscreen_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.8 KiB |
@ -1,6 +1,8 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "SDL3/SDL_events.h"
|
||||||
|
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
@ -132,41 +134,118 @@ void MainWindow::CreateActions() {
|
|||||||
m_theme_act_group->addAction(ui->setThemeOled);
|
m_theme_act_group->addAction(ui->setThemeOled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddUiWidgets() {
|
void MainWindow::PauseGame() {
|
||||||
// add toolbar widgets
|
SDL_Event event;
|
||||||
|
SDL_memset(&event, 0, sizeof(event));
|
||||||
|
event.type = SDL_EVENT_TOGGLE_PAUSE;
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::toggleLabelsUnderIcons() {
|
||||||
|
bool showLabels = ui->toggleLabelsAct->isChecked();
|
||||||
|
Config::setShowLabelsUnderIcons();
|
||||||
|
UpdateToolbarLabels();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::toggleFullscreen() {
|
||||||
|
SDL_Event event;
|
||||||
|
SDL_memset(&event, 0, sizeof(event));
|
||||||
|
event.type = SDL_EVENT_TOGGLE_FULLSCREEN;
|
||||||
|
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
|
||||||
|
SDL_Event check_event;
|
||||||
|
while (SDL_PollEvent(&check_event)) {
|
||||||
|
SDL_PushEvent(&check_event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::AddUiWidgets() {
|
||||||
|
// Add toolbar widgets
|
||||||
QApplication::setStyle("Fusion");
|
QApplication::setStyle("Fusion");
|
||||||
ui->toolBar->setObjectName("mw_toolbar");
|
ui->toolBar->setObjectName("mw_toolbar");
|
||||||
|
|
||||||
// Detect background color
|
ui->toolBar->clear();
|
||||||
QColor bgColor = palette().color(QPalette::Window);
|
|
||||||
QString textColor = (bgColor.lightness() > 128) ? "#000" : "#fff";
|
|
||||||
|
|
||||||
ui->playButton->setToolTip(
|
QWidget* toolbarContainer = new QWidget(this);
|
||||||
QString("<span style='color:%1;'><b>Play</b></span>").arg(textColor));
|
QHBoxLayout* mainLayout = new QHBoxLayout(toolbarContainer);
|
||||||
ui->pauseButton->setToolTip(
|
mainLayout->setContentsMargins(5, 5, 5, 5);
|
||||||
QString("<span style='color:%1;'><b>Pause</b></span>").arg(textColor));
|
mainLayout->setSpacing(15);
|
||||||
ui->stopButton->setToolTip(
|
|
||||||
QString("<span style='color:%1;'><b>Stop</b></span>").arg(textColor));
|
|
||||||
ui->settingsButton->setToolTip(
|
|
||||||
QString("<span style='color:%1;'><b>Config</b></span>").arg(textColor));
|
|
||||||
ui->controllerButton->setToolTip(
|
|
||||||
QString("<span style='color:%1;'><b>Pads</b></span>").arg(textColor));
|
|
||||||
ui->keyboardButton->setToolTip(
|
|
||||||
QString("<span style='color:%1;'><b>KBM</b></span>").arg(textColor));
|
|
||||||
ui->refreshButton->setToolTip(
|
|
||||||
QString("<span style='color:%1;'><b>RefreshList</b></span>").arg(textColor));
|
|
||||||
|
|
||||||
ui->toolBar->addWidget(ui->playButton);
|
bool showLabels = ui->toggleLabelsAct->isChecked();
|
||||||
ui->toolBar->addWidget(ui->pauseButton);
|
|
||||||
ui->toolBar->addWidget(ui->stopButton);
|
|
||||||
ui->toolBar->addWidget(ui->settingsButton);
|
|
||||||
ui->toolBar->addWidget(ui->controllerButton);
|
|
||||||
ui->toolBar->addWidget(ui->keyboardButton);
|
|
||||||
ui->toolBar->addWidget(ui->refreshButton);
|
|
||||||
|
|
||||||
ui->toolBar->addWidget(ui->sizeSliderContainer);
|
auto createButtonWithLabel = [&](QPushButton* button, const QString& labelText) {
|
||||||
ui->toolBar->addWidget(ui->mw_searchbar);
|
QWidget* container = new QWidget(this);
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout(container);
|
||||||
|
layout->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
layout->addWidget(button);
|
||||||
|
|
||||||
|
if (ui->toggleLabelsAct->isChecked()) {
|
||||||
|
QLabel* label = new QLabel(labelText, this);
|
||||||
|
label->setAlignment(Qt::AlignCenter);
|
||||||
|
layout->addWidget(label);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
button->setToolTip(
|
||||||
|
QString("<span style='color:%1;'><b>%2</b></span>")
|
||||||
|
.arg(palette().color(QPalette::Window).lightness() > 128 ? "#000" : "#000",
|
||||||
|
labelText));
|
||||||
|
}
|
||||||
|
|
||||||
|
container->setLayout(layout);
|
||||||
|
return container;
|
||||||
|
};
|
||||||
|
|
||||||
|
QWidget* buttonGroup = new QWidget(this);
|
||||||
|
QHBoxLayout* buttonLayout = new QHBoxLayout(buttonGroup);
|
||||||
|
|
||||||
|
auto createLine = [this]() {
|
||||||
|
QFrame* line = new QFrame(this);
|
||||||
|
line->setFrameShape(QFrame::VLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
line->setFixedWidth(2);
|
||||||
|
return line;
|
||||||
|
};
|
||||||
|
|
||||||
|
buttonLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
buttonLayout->setSpacing(15);
|
||||||
|
|
||||||
|
buttonLayout->addWidget(createButtonWithLabel(ui->playButton, tr("Play")));
|
||||||
|
buttonLayout->addWidget(createButtonWithLabel(ui->pauseButton, tr("Pause")));
|
||||||
|
buttonLayout->addWidget(createButtonWithLabel(ui->stopButton, tr("Stop")));
|
||||||
|
buttonLayout->addWidget(createLine());
|
||||||
|
|
||||||
|
buttonLayout->addWidget(createButtonWithLabel(ui->settingsButton, tr("Settings")));
|
||||||
|
buttonLayout->addWidget(createButtonWithLabel(ui->fullscreenButton, tr("Full Screen")));
|
||||||
|
buttonLayout->addWidget(createLine());
|
||||||
|
|
||||||
|
buttonLayout->addWidget(createButtonWithLabel(ui->controllerButton, tr("Controllers")));
|
||||||
|
buttonLayout->addWidget(createButtonWithLabel(ui->keyboardButton, tr("Keyboard")));
|
||||||
|
buttonLayout->addWidget(createButtonWithLabel(ui->refreshButton, tr("Refresh List")));
|
||||||
|
buttonLayout->addWidget(createLine());
|
||||||
|
|
||||||
|
QWidget* searchSliderContainer = new QWidget(this);
|
||||||
|
QHBoxLayout* searchSliderLayout = new QHBoxLayout(searchSliderContainer);
|
||||||
|
searchSliderLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
searchSliderLayout->setSpacing(10);
|
||||||
|
|
||||||
|
searchSliderLayout->addWidget(ui->sizeSliderContainer);
|
||||||
|
|
||||||
|
searchSliderLayout->addWidget(ui->mw_searchbar);
|
||||||
|
|
||||||
|
searchSliderContainer->setLayout(searchSliderLayout);
|
||||||
|
|
||||||
|
mainLayout->addWidget(buttonGroup);
|
||||||
|
mainLayout->addWidget(searchSliderContainer);
|
||||||
|
|
||||||
|
toolbarContainer->setLayout(mainLayout);
|
||||||
|
ui->toolBar->addWidget(toolbarContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::UpdateToolbarLabels() {
|
||||||
|
AddUiWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::CreateDockWindows() {
|
void MainWindow::CreateDockWindows() {
|
||||||
@ -271,6 +350,8 @@ void MainWindow::CreateConnects() {
|
|||||||
connect(ui->refreshButton, &QPushButton::clicked, this, &MainWindow::RefreshGameTable);
|
connect(ui->refreshButton, &QPushButton::clicked, this, &MainWindow::RefreshGameTable);
|
||||||
connect(ui->showGameListAct, &QAction::triggered, this, &MainWindow::ShowGameList);
|
connect(ui->showGameListAct, &QAction::triggered, this, &MainWindow::ShowGameList);
|
||||||
connect(this, &MainWindow::ExtractionFinished, this, &MainWindow::RefreshGameTable);
|
connect(this, &MainWindow::ExtractionFinished, this, &MainWindow::RefreshGameTable);
|
||||||
|
connect(ui->toggleLabelsAct, &QAction::toggled, this, &MainWindow::toggleLabelsUnderIcons);
|
||||||
|
connect(ui->fullscreenButton, &QPushButton::clicked, this, &MainWindow::toggleFullscreen);
|
||||||
|
|
||||||
connect(ui->sizeSlider, &QSlider::valueChanged, this, [this](int value) {
|
connect(ui->sizeSlider, &QSlider::valueChanged, this, [this](int value) {
|
||||||
if (isTableList) {
|
if (isTableList) {
|
||||||
@ -294,6 +375,7 @@ void MainWindow::CreateConnects() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->playButton, &QPushButton::clicked, this, &MainWindow::StartGame);
|
connect(ui->playButton, &QPushButton::clicked, this, &MainWindow::StartGame);
|
||||||
|
connect(ui->pauseButton, &QPushButton::clicked, this, &MainWindow::PauseGame);
|
||||||
connect(m_game_grid_frame.get(), &QTableWidget::cellDoubleClicked, this,
|
connect(m_game_grid_frame.get(), &QTableWidget::cellDoubleClicked, this,
|
||||||
&MainWindow::StartGame);
|
&MainWindow::StartGame);
|
||||||
connect(m_game_list_frame.get(), &QTableWidget::cellDoubleClicked, this,
|
connect(m_game_list_frame.get(), &QTableWidget::cellDoubleClicked, this,
|
||||||
@ -1236,6 +1318,7 @@ void MainWindow::SetUiIcons(bool isWhite) {
|
|||||||
ui->stopButton->setIcon(RecolorIcon(ui->stopButton->icon(), isWhite));
|
ui->stopButton->setIcon(RecolorIcon(ui->stopButton->icon(), isWhite));
|
||||||
ui->refreshButton->setIcon(RecolorIcon(ui->refreshButton->icon(), isWhite));
|
ui->refreshButton->setIcon(RecolorIcon(ui->refreshButton->icon(), isWhite));
|
||||||
ui->settingsButton->setIcon(RecolorIcon(ui->settingsButton->icon(), isWhite));
|
ui->settingsButton->setIcon(RecolorIcon(ui->settingsButton->icon(), isWhite));
|
||||||
|
ui->fullscreenButton->setIcon(RecolorIcon(ui->fullscreenButton->icon(), isWhite));
|
||||||
ui->controllerButton->setIcon(RecolorIcon(ui->controllerButton->icon(), isWhite));
|
ui->controllerButton->setIcon(RecolorIcon(ui->controllerButton->icon(), isWhite));
|
||||||
ui->keyboardButton->setIcon(RecolorIcon(ui->keyboardButton->icon(), isWhite));
|
ui->keyboardButton->setIcon(RecolorIcon(ui->keyboardButton->icon(), isWhite));
|
||||||
ui->refreshGameListAct->setIcon(RecolorIcon(ui->refreshGameListAct->icon(), isWhite));
|
ui->refreshGameListAct->setIcon(RecolorIcon(ui->refreshGameListAct->icon(), isWhite));
|
||||||
|
@ -38,6 +38,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 PauseGame();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void ConfigureGuiFromSettings();
|
void ConfigureGuiFromSettings();
|
||||||
@ -47,15 +48,19 @@ private Q_SLOTS:
|
|||||||
void RefreshGameTable();
|
void RefreshGameTable();
|
||||||
void HandleResize(QResizeEvent* event);
|
void HandleResize(QResizeEvent* event);
|
||||||
void OnLanguageChanged(const std::string& locale);
|
void OnLanguageChanged(const std::string& locale);
|
||||||
|
void toggleLabelsUnderIcons();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_MainWindow* ui;
|
Ui_MainWindow* ui;
|
||||||
void AddUiWidgets();
|
void AddUiWidgets();
|
||||||
|
void UpdateToolbarLabels();
|
||||||
void CreateActions();
|
void CreateActions();
|
||||||
|
void toggleFullscreen();
|
||||||
void CreateRecentGameActions();
|
void CreateRecentGameActions();
|
||||||
void CreateDockWindows();
|
void CreateDockWindows();
|
||||||
void GetPhysicalDevices();
|
void GetPhysicalDevices();
|
||||||
void LoadGameLists();
|
void LoadGameLists();
|
||||||
|
|
||||||
#ifdef ENABLE_UPDATER
|
#ifdef ENABLE_UPDATER
|
||||||
void CheckUpdateMain(bool checkSave);
|
void CheckUpdateMain(bool checkSave);
|
||||||
#endif
|
#endif
|
||||||
@ -70,6 +75,7 @@ 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 is_paused = false;
|
||||||
bool isIconBlack = false;
|
bool isIconBlack = false;
|
||||||
bool isTableList = true;
|
bool isTableList = true;
|
||||||
bool isGameRunning = false;
|
bool isGameRunning = false;
|
||||||
|
@ -20,6 +20,7 @@ public:
|
|||||||
QAction* setIconSizeSmallAct;
|
QAction* setIconSizeSmallAct;
|
||||||
QAction* setIconSizeMediumAct;
|
QAction* setIconSizeMediumAct;
|
||||||
QAction* setIconSizeLargeAct;
|
QAction* setIconSizeLargeAct;
|
||||||
|
QAction* toggleLabelsAct;
|
||||||
QAction* setlistModeListAct;
|
QAction* setlistModeListAct;
|
||||||
QAction* setlistModeGridAct;
|
QAction* setlistModeGridAct;
|
||||||
QAction* setlistElfAct;
|
QAction* setlistElfAct;
|
||||||
@ -50,6 +51,7 @@ public:
|
|||||||
QPushButton* settingsButton;
|
QPushButton* settingsButton;
|
||||||
QPushButton* controllerButton;
|
QPushButton* controllerButton;
|
||||||
QPushButton* keyboardButton;
|
QPushButton* keyboardButton;
|
||||||
|
QPushButton* fullscreenButton;
|
||||||
|
|
||||||
QWidget* sizeSliderContainer;
|
QWidget* sizeSliderContainer;
|
||||||
QHBoxLayout* sizeSliderContainer_layout;
|
QHBoxLayout* sizeSliderContainer_layout;
|
||||||
@ -105,6 +107,14 @@ public:
|
|||||||
refreshGameListAct = new QAction(MainWindow);
|
refreshGameListAct = new QAction(MainWindow);
|
||||||
refreshGameListAct->setObjectName("refreshGameListAct");
|
refreshGameListAct->setObjectName("refreshGameListAct");
|
||||||
refreshGameListAct->setIcon(QIcon(":images/refresh_icon.png"));
|
refreshGameListAct->setIcon(QIcon(":images/refresh_icon.png"));
|
||||||
|
|
||||||
|
toggleLabelsAct = new QAction(MainWindow);
|
||||||
|
toggleLabelsAct->setObjectName("toggleLabelsAct");
|
||||||
|
toggleLabelsAct->setText(
|
||||||
|
QCoreApplication::translate("MainWindow", "Show Labels Under Icons"));
|
||||||
|
toggleLabelsAct->setCheckable(true);
|
||||||
|
toggleLabelsAct->setChecked(Config::getShowLabelsUnderIcons());
|
||||||
|
|
||||||
setIconSizeTinyAct = new QAction(MainWindow);
|
setIconSizeTinyAct = new QAction(MainWindow);
|
||||||
setIconSizeTinyAct->setObjectName("setIconSizeTinyAct");
|
setIconSizeTinyAct->setObjectName("setIconSizeTinyAct");
|
||||||
setIconSizeTinyAct->setCheckable(true);
|
setIconSizeTinyAct->setCheckable(true);
|
||||||
@ -211,11 +221,15 @@ public:
|
|||||||
refreshButton = new QPushButton(centralWidget);
|
refreshButton = new QPushButton(centralWidget);
|
||||||
refreshButton->setFlat(true);
|
refreshButton->setFlat(true);
|
||||||
refreshButton->setIcon(QIcon(":images/refresh_icon.png"));
|
refreshButton->setIcon(QIcon(":images/refresh_icon.png"));
|
||||||
refreshButton->setIconSize(QSize(32, 32));
|
refreshButton->setIconSize(QSize(38, 38));
|
||||||
|
fullscreenButton = new QPushButton(centralWidget);
|
||||||
|
fullscreenButton->setFlat(true);
|
||||||
|
fullscreenButton->setIcon(QIcon(":images/fullscreen_icon.png"));
|
||||||
|
fullscreenButton->setIconSize(QSize(38, 38));
|
||||||
settingsButton = new QPushButton(centralWidget);
|
settingsButton = new QPushButton(centralWidget);
|
||||||
settingsButton->setFlat(true);
|
settingsButton->setFlat(true);
|
||||||
settingsButton->setIcon(QIcon(":images/settings_icon.png"));
|
settingsButton->setIcon(QIcon(":images/settings_icon.png"));
|
||||||
settingsButton->setIconSize(QSize(44, 44));
|
settingsButton->setIconSize(QSize(42, 42));
|
||||||
controllerButton = new QPushButton(centralWidget);
|
controllerButton = new QPushButton(centralWidget);
|
||||||
controllerButton->setFlat(true);
|
controllerButton->setFlat(true);
|
||||||
controllerButton->setIcon(QIcon(":images/controller_icon.png"));
|
controllerButton->setIcon(QIcon(":images/controller_icon.png"));
|
||||||
@ -304,6 +318,7 @@ public:
|
|||||||
menuView->addAction(refreshGameListAct);
|
menuView->addAction(refreshGameListAct);
|
||||||
menuView->addAction(menuGame_List_Mode->menuAction());
|
menuView->addAction(menuGame_List_Mode->menuAction());
|
||||||
menuView->addAction(menuGame_List_Icons->menuAction());
|
menuView->addAction(menuGame_List_Icons->menuAction());
|
||||||
|
menuView->addAction(toggleLabelsAct);
|
||||||
menuView->addAction(menuThemes->menuAction());
|
menuView->addAction(menuThemes->menuAction());
|
||||||
menuThemes->addAction(setThemeDark);
|
menuThemes->addAction(setThemeDark);
|
||||||
menuThemes->addAction(setThemeLight);
|
menuThemes->addAction(setThemeLight);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "common/elf_info.h"
|
#include "common/elf_info.h"
|
||||||
#include "common/version.h"
|
#include "common/version.h"
|
||||||
|
#include "core/debug_state.h"
|
||||||
#include "core/libraries/kernel/time.h"
|
#include "core/libraries/kernel/time.h"
|
||||||
#include "core/libraries/pad/pad.h"
|
#include "core/libraries/pad/pad.h"
|
||||||
#include "imgui/renderer/imgui_core.h"
|
#include "imgui/renderer/imgui_core.h"
|
||||||
@ -254,9 +255,10 @@ static Uint32 SDLCALL PollController(void* userdata, SDL_TimerID timer_id, Uint3
|
|||||||
return controller->Poll();
|
return controller->Poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_,
|
WindowSDL::WindowSDL(s32 width, s32 height, Input::GameController* controller,
|
||||||
std::string_view window_title)
|
std::string_view window_title)
|
||||||
: width{width_}, height{height_}, controller{controller_} {
|
: width(width), height(height), controller(controller), is_open(true), is_shown(true),
|
||||||
|
is_paused(false) {
|
||||||
if (!SDL_SetHint(SDL_HINT_APP_NAME, "shadPS4")) {
|
if (!SDL_SetHint(SDL_HINT_APP_NAME, "shadPS4")) {
|
||||||
UNREACHABLE_MSG("Failed to set SDL window hint: {}", SDL_GetError());
|
UNREACHABLE_MSG("Failed to set SDL window hint: {}", SDL_GetError());
|
||||||
}
|
}
|
||||||
@ -333,7 +335,6 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_
|
|||||||
WindowSDL::~WindowSDL() = default;
|
WindowSDL::~WindowSDL() = default;
|
||||||
|
|
||||||
void WindowSDL::WaitEvent() {
|
void WindowSDL::WaitEvent() {
|
||||||
// Called on main thread
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
if (!SDL_WaitEvent(&event)) {
|
if (!SDL_WaitEvent(&event)) {
|
||||||
@ -343,7 +344,7 @@ void WindowSDL::WaitEvent() {
|
|||||||
if (ImGui::Core::ProcessEvent(&event)) {
|
if (ImGui::Core::ProcessEvent(&event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bool is_game_running = true;
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_EVENT_WINDOW_RESIZED:
|
case SDL_EVENT_WINDOW_RESIZED:
|
||||||
case SDL_EVENT_WINDOW_MAXIMIZED:
|
case SDL_EVENT_WINDOW_MAXIMIZED:
|
||||||
@ -379,8 +380,6 @@ void WindowSDL::WaitEvent() {
|
|||||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||||
OnGamepadEvent(&event);
|
OnGamepadEvent(&event);
|
||||||
break;
|
break;
|
||||||
// i really would have appreciated ANY KIND OF DOCUMENTATION ON THIS
|
|
||||||
// AND IT DOESN'T EVEN USE PROPER ENUMS
|
|
||||||
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE:
|
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE:
|
||||||
switch ((SDL_SensorType)event.gsensor.sensor) {
|
switch ((SDL_SensorType)event.gsensor.sensor) {
|
||||||
case SDL_SENSOR_GYRO:
|
case SDL_SENSOR_GYRO:
|
||||||
@ -396,7 +395,24 @@ void WindowSDL::WaitEvent() {
|
|||||||
case SDL_EVENT_QUIT:
|
case SDL_EVENT_QUIT:
|
||||||
is_open = false;
|
is_open = false;
|
||||||
break;
|
break;
|
||||||
default:
|
case SDL_EVENT_TOGGLE_FULLSCREEN: {
|
||||||
|
if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
|
||||||
|
SDL_SetWindowFullscreen(window, 0);
|
||||||
|
} else {
|
||||||
|
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDL_EVENT_TOGGLE_PAUSE:
|
||||||
|
SDL_Log("Received SDL_EVENT_TOGGLE_PAUSE");
|
||||||
|
is_paused = !is_paused;
|
||||||
|
if (is_paused) {
|
||||||
|
SDL_Log("Game Paused");
|
||||||
|
DebugState.PauseGuestThreads();
|
||||||
|
} else {
|
||||||
|
SDL_Log("Game Resumed");
|
||||||
|
DebugState.ResumeGuestThreads();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include "core/libraries/pad/pad.h"
|
#include "core/libraries/pad/pad.h"
|
||||||
#include "input/controller.h"
|
#include "input/controller.h"
|
||||||
#include "string"
|
#include "string"
|
||||||
|
#define SDL_EVENT_TOGGLE_FULLSCREEN (SDL_EVENT_USER + 1)
|
||||||
|
#define SDL_EVENT_TOGGLE_PAUSE (SDL_EVENT_USER + 2)
|
||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
struct SDL_Gamepad;
|
struct SDL_Gamepad;
|
||||||
@ -106,6 +108,7 @@ private:
|
|||||||
SDL_Window* window{};
|
SDL_Window* window{};
|
||||||
bool is_shown{};
|
bool is_shown{};
|
||||||
bool is_open{true};
|
bool is_open{true};
|
||||||
|
bool is_paused = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Frontend
|
} // namespace Frontend
|
||||||
|
@ -34,5 +34,6 @@
|
|||||||
<file>images/ps4_controller.png</file>
|
<file>images/ps4_controller.png</file>
|
||||||
<file>images/keyboard_icon.png</file>
|
<file>images/keyboard_icon.png</file>
|
||||||
<file>images/KBM.png</file>
|
<file>images/KBM.png</file>
|
||||||
|
<file>images/fullscreen_icon.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
Reference in New Issue
Block a user