diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 61473e574..0765e9bb8 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -137,7 +137,7 @@ bool CommonHostInterface::BootSystem(const SystemBootParameters& parameters) if (!HostInterface::BootSystem(parameters)) { // if in batch mode, exit immediately if booting failed - if (m_batch_mode) + if (InBatchMode()) RequestExit(); return false; @@ -176,7 +176,7 @@ void CommonHostInterface::PowerOffSystem() HostInterface::PowerOffSystem(); - if (m_batch_mode) + if (InBatchMode()) RequestExit(); } @@ -219,6 +219,9 @@ static void PrintCommandLineHelp(const char* progname, const char* frontend_name std::fprintf(stderr, " -fullscreen: Enters fullscreen mode immediately after starting.\n"); std::fprintf(stderr, " -nofullscreen: Prevents fullscreen mode from triggering if enabled.\n"); std::fprintf(stderr, " -portable: Forces \"portable mode\", data in same directory.\n"); + std::fprintf(stderr, " -nocontroller: Prevents the emulator from polling for controllers.\n" + " Try this option if you're having difficulties starting\n" + " the emulator.\n"); std::fprintf(stderr, " --: Signals that no more arguments will follow and the remaining\n" " parameters make up the filename. Use when the filename contains\n" " spaces or starts with a dash.\n"); @@ -258,7 +261,7 @@ bool CommonHostInterface::ParseCommandLineParameters(int argc, char* argv[], else if (CHECK_ARG("-batch")) { Log_InfoPrintf("Enabling batch mode."); - m_batch_mode = true; + m_command_line_flags.batch_mode = true; continue; } else if (CHECK_ARG("-fastboot")) @@ -273,6 +276,12 @@ bool CommonHostInterface::ParseCommandLineParameters(int argc, char* argv[], force_fast_boot = false; continue; } + else if (CHECK_ARG("-nocontroller")) + { + Log_InfoPrintf("Disabling controller support."); + m_command_line_flags.disable_controller_interface = true; + continue; + } else if (CHECK_ARG("-resume")) { state_index = -1; @@ -470,7 +479,7 @@ void CommonHostInterface::UpdateControllerInterface() ControllerInterface::ParseBackendName(backend_str.c_str()); const ControllerInterface::Backend current_backend = (m_controller_interface ? m_controller_interface->GetBackend() : ControllerInterface::Backend::None); - if (new_backend == current_backend) + if (new_backend == current_backend || m_command_line_flags.disable_controller_interface) return; if (m_controller_interface) @@ -1463,7 +1472,7 @@ void CommonHostInterface::RegisterGeneralHotkeys() StaticString(TRANSLATABLE("Hotkeys", "Power Off System")), [this](bool pressed) { if (pressed && System::IsValid()) { - if (g_settings.confim_power_off && !m_batch_mode) + if (g_settings.confim_power_off && !InBatchMode()) { SmallString confirmation_message( TranslateString("CommonHostInterface", "Are you sure you want to stop emulation?")); diff --git a/src/frontend-common/common_host_interface.h b/src/frontend-common/common_host_interface.h index d520487d8..cee7731fe 100644 --- a/src/frontend-common/common_host_interface.h +++ b/src/frontend-common/common_host_interface.h @@ -1,4 +1,5 @@ #pragma once +#include "common/bitfield.h" #include "common/string.h" #include "core/controller.h" #include "core/host_interface.h" @@ -94,7 +95,7 @@ public: ALWAYS_INLINE ControllerInterface* GetControllerInterface() const { return m_controller_interface.get(); } /// Returns true if running in batch mode, i.e. exit after emulation. - ALWAYS_INLINE bool InBatchMode() const { return m_batch_mode; } + ALWAYS_INLINE bool InBatchMode() const { return m_command_line_flags.batch_mode; } /// Parses command line parameters for all frontends. bool ParseCommandLineParameters(int argc, char* argv[], std::unique_ptr* out_boot_params); @@ -389,8 +390,16 @@ private: }; std::vector m_controller_vibration_motors; - // running in batch mode? i.e. exit after stopping emulation - bool m_batch_mode = false; + union + { + u8 bits; + + // running in batch mode? i.e. exit after stopping emulation + BitField batch_mode; + + // disable controller interface (buggy devices with SDL) + BitField disable_controller_interface; + } m_command_line_flags = {}; #ifdef WITH_DISCORD_PRESENCE // discord rich presence