mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 22:35:39 +00:00
HostInterface: Add -nocontroller CLI option to disable controller interface
Can use with buggy drivers where SDL is causing crashes.
This commit is contained in:
parent
e804fdfdba
commit
81aad196e8
|
@ -137,7 +137,7 @@ bool CommonHostInterface::BootSystem(const SystemBootParameters& parameters)
|
||||||
if (!HostInterface::BootSystem(parameters))
|
if (!HostInterface::BootSystem(parameters))
|
||||||
{
|
{
|
||||||
// if in batch mode, exit immediately if booting failed
|
// if in batch mode, exit immediately if booting failed
|
||||||
if (m_batch_mode)
|
if (InBatchMode())
|
||||||
RequestExit();
|
RequestExit();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -176,7 +176,7 @@ void CommonHostInterface::PowerOffSystem()
|
||||||
|
|
||||||
HostInterface::PowerOffSystem();
|
HostInterface::PowerOffSystem();
|
||||||
|
|
||||||
if (m_batch_mode)
|
if (InBatchMode())
|
||||||
RequestExit();
|
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, " -fullscreen: Enters fullscreen mode immediately after starting.\n");
|
||||||
std::fprintf(stderr, " -nofullscreen: Prevents fullscreen mode from triggering if enabled.\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, " -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"
|
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"
|
" parameters make up the filename. Use when the filename contains\n"
|
||||||
" spaces or starts with a dash.\n");
|
" spaces or starts with a dash.\n");
|
||||||
|
@ -258,7 +261,7 @@ bool CommonHostInterface::ParseCommandLineParameters(int argc, char* argv[],
|
||||||
else if (CHECK_ARG("-batch"))
|
else if (CHECK_ARG("-batch"))
|
||||||
{
|
{
|
||||||
Log_InfoPrintf("Enabling batch mode.");
|
Log_InfoPrintf("Enabling batch mode.");
|
||||||
m_batch_mode = true;
|
m_command_line_flags.batch_mode = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-fastboot"))
|
else if (CHECK_ARG("-fastboot"))
|
||||||
|
@ -273,6 +276,12 @@ bool CommonHostInterface::ParseCommandLineParameters(int argc, char* argv[],
|
||||||
force_fast_boot = false;
|
force_fast_boot = false;
|
||||||
continue;
|
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"))
|
else if (CHECK_ARG("-resume"))
|
||||||
{
|
{
|
||||||
state_index = -1;
|
state_index = -1;
|
||||||
|
@ -470,7 +479,7 @@ void CommonHostInterface::UpdateControllerInterface()
|
||||||
ControllerInterface::ParseBackendName(backend_str.c_str());
|
ControllerInterface::ParseBackendName(backend_str.c_str());
|
||||||
const ControllerInterface::Backend current_backend =
|
const ControllerInterface::Backend current_backend =
|
||||||
(m_controller_interface ? m_controller_interface->GetBackend() : ControllerInterface::Backend::None);
|
(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;
|
return;
|
||||||
|
|
||||||
if (m_controller_interface)
|
if (m_controller_interface)
|
||||||
|
@ -1463,7 +1472,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
||||||
StaticString(TRANSLATABLE("Hotkeys", "Power Off System")), [this](bool pressed) {
|
StaticString(TRANSLATABLE("Hotkeys", "Power Off System")), [this](bool pressed) {
|
||||||
if (pressed && System::IsValid())
|
if (pressed && System::IsValid())
|
||||||
{
|
{
|
||||||
if (g_settings.confim_power_off && !m_batch_mode)
|
if (g_settings.confim_power_off && !InBatchMode())
|
||||||
{
|
{
|
||||||
SmallString confirmation_message(
|
SmallString confirmation_message(
|
||||||
TranslateString("CommonHostInterface", "Are you sure you want to stop emulation?"));
|
TranslateString("CommonHostInterface", "Are you sure you want to stop emulation?"));
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "common/bitfield.h"
|
||||||
#include "common/string.h"
|
#include "common/string.h"
|
||||||
#include "core/controller.h"
|
#include "core/controller.h"
|
||||||
#include "core/host_interface.h"
|
#include "core/host_interface.h"
|
||||||
|
@ -94,7 +95,7 @@ public:
|
||||||
ALWAYS_INLINE ControllerInterface* GetControllerInterface() const { return m_controller_interface.get(); }
|
ALWAYS_INLINE ControllerInterface* GetControllerInterface() const { return m_controller_interface.get(); }
|
||||||
|
|
||||||
/// Returns true if running in batch mode, i.e. exit after emulation.
|
/// 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.
|
/// Parses command line parameters for all frontends.
|
||||||
bool ParseCommandLineParameters(int argc, char* argv[], std::unique_ptr<SystemBootParameters>* out_boot_params);
|
bool ParseCommandLineParameters(int argc, char* argv[], std::unique_ptr<SystemBootParameters>* out_boot_params);
|
||||||
|
@ -389,8 +390,16 @@ private:
|
||||||
};
|
};
|
||||||
std::vector<ControllerRumbleState> m_controller_vibration_motors;
|
std::vector<ControllerRumbleState> m_controller_vibration_motors;
|
||||||
|
|
||||||
// running in batch mode? i.e. exit after stopping emulation
|
union
|
||||||
bool m_batch_mode = false;
|
{
|
||||||
|
u8 bits;
|
||||||
|
|
||||||
|
// running in batch mode? i.e. exit after stopping emulation
|
||||||
|
BitField<u8, bool, 0, 1> batch_mode;
|
||||||
|
|
||||||
|
// disable controller interface (buggy devices with SDL)
|
||||||
|
BitField<u8, bool, 1, 1> disable_controller_interface;
|
||||||
|
} m_command_line_flags = {};
|
||||||
|
|
||||||
#ifdef WITH_DISCORD_PRESENCE
|
#ifdef WITH_DISCORD_PRESENCE
|
||||||
// discord rich presence
|
// discord rich presence
|
||||||
|
|
Loading…
Reference in a new issue