Frontends: Add shared command line interface

Also provides batch mode and automatic fullscreen switching.

  -help: Displays this information and exits.
  -version: Displays version information and exits.
  -batch: Enables batch mode (exits after powering off)
  -fastboot: Force fast boot for provided filename
  -slowboot: Force slow boot for provided filename
  -resume: Load resume save state. If a boot filename is provided,
    that game's resume state will be loaded, otherwise the most
    recent resume save state will be loaded.
  -state <index>: Loads specified save state by index. If a boot
    filename is provided, a per-game state will be loaded, otherwise
    a global state will be loaded.
  -statefile <filename>: Loads state from the specified filename.
    No boot filename is required with this option.
  -fullscreen: Enters fullscreen mode immediately after starting.
  -nofullscreen: Prevents fullscreen mode from triggering if enabled.
  -portable: Forces "portable mode", data in same directory.
  --: Signals that no more arguments will follow and the remaining
    parameters make up the filename. Use when the filename contains
    spaces or starts with a dash.
This commit is contained in:
Connor McLaughlin
2020-04-13 22:13:46 +10:00
parent 6a03bb2d15
commit 81cf4b469f
12 changed files with 365 additions and 80 deletions

View File

@ -33,19 +33,34 @@ public:
using HotkeyInfoList = std::vector<HotkeyInfo>;
/// Returns the name of the frontend.
virtual const char* GetFrontendName() const = 0;
virtual bool Initialize() override;
virtual void Shutdown() override;
virtual bool BootSystem(const SystemBootParameters& parameters) override;
virtual void PowerOffSystem() override;
/// Returns a list of all available hotkeys.
ALWAYS_INLINE const HotkeyInfoList& GetHotkeyInfoList() const { return m_hotkeys; }
/// Access to current controller interface.
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; }
/// Parses command line parameters for all frontends.
bool ParseCommandLineParameters(int argc, char* argv[], std::unique_ptr<SystemBootParameters>* out_boot_params);
protected:
CommonHostInterface();
~CommonHostInterface();
/// Request the frontend to exit.
virtual void RequestExit() = 0;
virtual bool IsFullscreen() const;
virtual bool SetFullscreen(bool enabled);
@ -85,4 +100,7 @@ private:
// input key maps
std::map<HostKeyCode, InputButtonHandler> m_keyboard_input_handlers;
// running in batch mode? i.e. exit after stopping emulation
bool m_batch_mode = false;
};