diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 69bdfb5341..e4a561c522 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -63,13 +63,6 @@ #include "llvm/Config/llvm-config.h" #endif -// GameMode Inclusion -#ifdef GAMEMODE_AVAILABLE -#pragma GCC diagnostic ignored "-Wold-style-cast" -#endif -extern "C" { - #include "3rdparty/feralinteractive/feralinteractive/lib/gamemode_client.h" -} LOG_CHANNEL(sys_log, "SYS"); @@ -994,12 +987,6 @@ void Emulator::SetContinuousMode(bool continuous_mode) game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch, usz recursion_count) { - if (g_cfg.misc.enable_gamemode) { - u8 s_gamemode_start = gamemode_request_start(); - if(s_gamemode_start < 0 ) { - fprintf(stderr, "gamemode start request failed: %s\n", gamemode_error_string()); - } - } if (recursion_count == 0 && m_restrict_emu_state_change) { @@ -3067,13 +3054,6 @@ extern bool try_lock_spu_threads_in_a_state_compatible_with_savestates(bool reve void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_stage) { - if (g_cfg.misc.enable_gamemode) { - u8 s_gamemode_end = gamemode_request_end(); - if(s_gamemode_end < 0 ) { - fprintf(stderr, "gamemode exit request failed: %s\n", gamemode_error_string()); - } - } - static const auto make_ptr = [](auto ptr) { return std::shared_ptr>(ptr); diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 76f601e758..417bef41b8 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -480,4 +480,3 @@ extern Emulator Emu; extern bool g_use_rtm; extern u64 g_rtm_tx_limit1; extern u64 g_rtm_tx_limit2; -extern b8 g_FERAL_GAMEMODE_ON; diff --git a/rpcs3/enable_gamemode.cpp b/rpcs3/enable_gamemode.cpp new file mode 100644 index 0000000000..d2e7e5cb1a --- /dev/null +++ b/rpcs3/enable_gamemode.cpp @@ -0,0 +1,34 @@ +#include "enable_gamemode.h" + +#ifdef GAMEMODE_AVAILABLE +#pragma GCC diagnostic ignored "-Wold-style-cast" +#endif +extern "C" { + #include "3rdparty/feralinteractive/feralinteractive/lib/gamemode_client.h" +} + +// Checks if Gamemode is supported on system +bool gamemode_supported() +{ +#if defined(GAMEMODE_AVAILABLE) + return true +#else + return false; +#endif +} + +// Enables GameMode +// Returns -2 if Gamemode isn't supported. +// Returns the value of gamemode_request_start() otherwise. +// This is either 0 or -1 depending on whether gamemode was successfully enabled or not respectively. +int enable_gamemode(bool enabled) { + if (!gamemode_supported()) { + return -2; + } + + // Enable Gamemode + if (enabled) { + u8 s_gamemode_start = gamemode_request_start(); + return s_gamemode_start; + } +} diff --git a/rpcs3/enable_gamemode.h b/rpcs3/enable_gamemode.h new file mode 100644 index 0000000000..f447a953a4 --- /dev/null +++ b/rpcs3/enable_gamemode.h @@ -0,0 +1,4 @@ +#pragma once + +bool gamemode_supported(); +int enable_gamemode(bool enabled); diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index f7efb7728b..445ee8bfcc 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -1315,7 +1315,6 @@ int run_rpcs3(int argc, char** argv) Emu.Quit(true); return 0; } - // run event loop (maybe only needed for the gui application) return app->exec(); }