[gamemode] Make available on other platforms (#353)

Signed-off-by: lizzie <lizzie@eden-emu.dev>
Co-authored-by: crueter <crueter@eden-emu.dev>
Co-authored-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/353
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2025-12-07 07:13:43 +01:00 committed by crueter
parent 3141019fcd
commit 83332316aa
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
29 changed files with 123 additions and 775 deletions

View file

@ -164,9 +164,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#endif
#ifdef __linux__
#include "common/linux/gamemode.h"
#endif
#include "qt_common/gamemode.h"
#ifdef _WIN32
#include "core/core_timing.h"
@ -423,9 +421,7 @@ MainWindow::MainWindow(bool has_broken_vulkan)
SetupSigInterrupts();
#endif
#ifdef __linux__
SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue());
#endif
SetGamemodeEnabled(UISettings::values.enable_gamemode.GetValue());
UISettings::RestoreWindowState(config);
@ -2198,10 +2194,7 @@ void MainWindow::OnEmulationStopped() {
emulation_running = false;
discord_rpc->Update();
#ifdef __linux__
Common::Linux::StopGamemode();
#endif
Common::FeralGamemode::Stop();
// The emulation is stopped, so closing the window or not does not matter anymore
disconnect(render_window, &GRenderWindow::Closed, this, &MainWindow::OnStopGame);
@ -3072,10 +3065,7 @@ void MainWindow::OnStartGame() {
play_time_manager->Start();
discord_rpc->Update();
#ifdef __linux__
Common::Linux::StartGamemode();
#endif
Common::FeralGamemode::Start();
}
void MainWindow::OnRestartGame() {
@ -3096,10 +3086,7 @@ void MainWindow::OnPauseGame() {
play_time_manager->Stop();
UpdateMenuState();
AllowOSSleep();
#ifdef __linux__
Common::Linux::StopGamemode();
#endif
Common::FeralGamemode::Stop();
}
void MainWindow::OnPauseContinueGame() {
@ -3384,11 +3371,9 @@ void MainWindow::OnConfigure() {
const auto old_theme = UISettings::values.theme;
const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue();
const auto old_language_index = Settings::values.language_index.GetValue();
#ifdef __linux__
const bool old_gamemode = Settings::values.enable_gamemode.GetValue();
#endif
const bool old_gamemode = UISettings::values.enable_gamemode.GetValue();
#ifdef __unix__
const bool old_force_x11 = Settings::values.gui_force_x11.GetValue();
const bool old_force_x11 = UISettings::values.gui_force_x11.GetValue();
#endif
Settings::SetConfiguringGlobal(true);
@ -3449,14 +3434,12 @@ void MainWindow::OnConfigure() {
if (UISettings::values.enable_discord_presence.GetValue() != old_discord_presence) {
SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue());
}
#ifdef __linux__
if (Settings::values.enable_gamemode.GetValue() != old_gamemode) {
SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue());
if (UISettings::values.enable_gamemode.GetValue() != old_gamemode) {
SetGamemodeEnabled(UISettings::values.enable_gamemode.GetValue());
}
#endif
#ifdef __unix__
if (Settings::values.gui_force_x11.GetValue() != old_force_x11) {
GraphicsBackend::SetForceX11(Settings::values.gui_force_x11.GetValue());
if (UISettings::values.gui_force_x11.GetValue() != old_force_x11) {
GraphicsBackend::SetForceX11(UISettings::values.gui_force_x11.GetValue());
}
#endif
@ -4403,7 +4386,7 @@ void MainWindow::OnCheckGraphicsBackend() {
if (!isWayland)
return;
const bool currently_hidden = Settings::values.gui_hide_backend_warning.GetValue();
const bool currently_hidden = UISettings::values.gui_hide_backend_warning.GetValue();
if (currently_hidden)
return;
@ -4426,11 +4409,11 @@ void MainWindow::OnCheckGraphicsBackend() {
const bool hide = cb->isChecked();
if (hide != currently_hidden) {
Settings::values.gui_hide_backend_warning.SetValue(hide);
UISettings::values.gui_hide_backend_warning.SetValue(hide);
}
if (msgbox.clickedButton() == okButton) {
Settings::values.gui_force_x11.SetValue(true);
UISettings::values.gui_force_x11.SetValue(true);
GraphicsBackend::SetForceX11(true);
QMessageBox::information(this,
tr("Restart Required"),
@ -4760,13 +4743,14 @@ void MainWindow::SetDiscordEnabled([[maybe_unused]] bool state) {
discord_rpc->Update();
}
#ifdef __linux__
void MainWindow::SetGamemodeEnabled(bool state) {
if (emulation_running) {
Common::Linux::SetGamemodeState(state);
if (state)
Common::FeralGamemode::Start();
else
Common::FeralGamemode::Stop();
}
}
#endif
void MainWindow::changeEvent(QEvent* event) {
#ifdef __unix__