2019-09-12 14:18:13 +00:00
|
|
|
#pragma once
|
2020-03-15 12:03:53 +00:00
|
|
|
#include "common/string.h"
|
2020-01-10 03:31:12 +00:00
|
|
|
#include "common/timer.h"
|
2019-11-03 14:39:48 +00:00
|
|
|
#include "settings.h"
|
2019-11-16 10:12:03 +00:00
|
|
|
#include "types.h"
|
|
|
|
#include <chrono>
|
2019-12-01 11:33:56 +00:00
|
|
|
#include <deque>
|
2020-01-24 04:51:52 +00:00
|
|
|
#include <functional>
|
2019-09-14 10:28:47 +00:00
|
|
|
#include <memory>
|
2019-12-01 11:33:56 +00:00
|
|
|
#include <mutex>
|
2019-11-16 05:27:57 +00:00
|
|
|
#include <optional>
|
2019-12-01 11:33:56 +00:00
|
|
|
#include <string>
|
2019-11-16 05:27:57 +00:00
|
|
|
#include <vector>
|
2019-09-12 14:18:13 +00:00
|
|
|
|
2020-04-30 14:58:32 +00:00
|
|
|
enum LOGLEVEL;
|
|
|
|
|
2019-10-10 16:20:21 +00:00
|
|
|
class AudioStream;
|
2020-02-15 15:14:28 +00:00
|
|
|
class ByteStream;
|
2020-01-24 04:50:46 +00:00
|
|
|
class CDImage;
|
2019-11-03 14:39:48 +00:00
|
|
|
class HostDisplay;
|
2020-01-24 04:50:46 +00:00
|
|
|
class GameList;
|
2019-09-12 14:18:13 +00:00
|
|
|
|
2020-03-02 01:08:16 +00:00
|
|
|
struct SystemBootParameters;
|
2019-09-14 10:28:47 +00:00
|
|
|
|
2019-09-12 14:18:13 +00:00
|
|
|
class HostInterface
|
|
|
|
{
|
|
|
|
public:
|
2020-05-09 14:44:37 +00:00
|
|
|
enum : u32
|
|
|
|
{
|
|
|
|
AUDIO_SAMPLE_RATE = 44100,
|
|
|
|
AUDIO_CHANNELS = 2,
|
2020-06-06 04:40:20 +00:00
|
|
|
DEFAULT_AUDIO_BUFFER_SIZE = 2048
|
2020-05-09 14:44:37 +00:00
|
|
|
};
|
|
|
|
|
2019-09-14 10:28:47 +00:00
|
|
|
HostInterface();
|
|
|
|
virtual ~HostInterface();
|
|
|
|
|
2019-11-07 15:07:39 +00:00
|
|
|
/// Access to host display.
|
2020-06-29 16:46:57 +00:00
|
|
|
ALWAYS_INLINE HostDisplay* GetDisplay() const { return m_display.get(); }
|
2019-11-07 15:07:39 +00:00
|
|
|
|
|
|
|
/// Access to host audio stream.
|
2020-02-15 15:14:28 +00:00
|
|
|
ALWAYS_INLINE AudioStream* GetAudioStream() const { return m_audio_stream.get(); }
|
2019-10-10 16:20:21 +00:00
|
|
|
|
2020-04-05 12:59:06 +00:00
|
|
|
/// Initializes the emulator frontend.
|
|
|
|
virtual bool Initialize();
|
|
|
|
|
|
|
|
/// Shuts down the emulator frontend.
|
|
|
|
virtual void Shutdown();
|
|
|
|
|
2020-04-13 12:13:46 +00:00
|
|
|
virtual bool BootSystem(const SystemBootParameters& parameters);
|
|
|
|
virtual void PowerOffSystem();
|
|
|
|
|
2020-06-08 16:05:55 +00:00
|
|
|
virtual void ResetSystem();
|
|
|
|
virtual void DestroySystem();
|
2019-11-07 15:07:39 +00:00
|
|
|
|
2020-02-28 07:00:09 +00:00
|
|
|
/// Loads state from the specified filename.
|
|
|
|
bool LoadState(const char* filename);
|
|
|
|
|
2019-11-16 05:27:57 +00:00
|
|
|
virtual void ReportError(const char* message);
|
|
|
|
virtual void ReportMessage(const char* message);
|
2020-02-26 09:25:57 +00:00
|
|
|
virtual bool ConfirmMessage(const char* message);
|
2019-09-12 14:18:13 +00:00
|
|
|
|
2020-01-10 03:31:12 +00:00
|
|
|
void ReportFormattedError(const char* format, ...);
|
|
|
|
void ReportFormattedMessage(const char* format, ...);
|
2020-02-26 09:25:57 +00:00
|
|
|
bool ConfirmFormattedMessage(const char* format, ...);
|
2020-01-10 03:31:12 +00:00
|
|
|
|
2019-12-01 11:33:56 +00:00
|
|
|
/// Adds OSD messages, duration is in seconds.
|
2020-06-08 16:05:55 +00:00
|
|
|
virtual void AddOSDMessage(std::string message, float duration = 2.0f);
|
2020-01-10 03:31:12 +00:00
|
|
|
void AddFormattedOSDMessage(float duration, const char* format, ...);
|
2019-09-14 10:28:47 +00:00
|
|
|
|
2020-01-24 04:51:00 +00:00
|
|
|
/// Returns the base user directory path.
|
2020-02-15 15:14:28 +00:00
|
|
|
ALWAYS_INLINE const std::string& GetUserDirectory() const { return m_user_directory; }
|
2020-01-24 04:51:00 +00:00
|
|
|
|
|
|
|
/// Returns a path relative to the user directory.
|
2020-01-24 04:51:03 +00:00
|
|
|
std::string GetUserDirectoryRelativePath(const char* format, ...) const;
|
2020-01-24 04:51:00 +00:00
|
|
|
|
2020-05-16 12:18:02 +00:00
|
|
|
/// Returns a path relative to the application directory (for system files).
|
|
|
|
std::string GetProgramDirectoryRelativePath(const char* format, ...) const;
|
|
|
|
|
2020-03-15 12:03:53 +00:00
|
|
|
/// Returns a string which can be used as part of a filename, based on the current date/time.
|
|
|
|
static TinyString GetTimestampStringForFileName();
|
|
|
|
|
2020-02-15 15:15:16 +00:00
|
|
|
/// Displays a loading screen with the logo, rendered with ImGui. Use when executing possibly-time-consuming tasks
|
|
|
|
/// such as compiling shaders when starting up.
|
2020-06-30 14:33:45 +00:00
|
|
|
virtual void DisplayLoadingScreen(const char* message, int progress_min = -1, int progress_max = -1,
|
|
|
|
int progress_value = -1);
|
2020-04-20 16:50:45 +00:00
|
|
|
|
2020-06-08 16:05:55 +00:00
|
|
|
/// Retrieves information about specified game from game list.
|
|
|
|
virtual void GetGameInfo(const char* path, CDImage* image, std::string* code, std::string* title);
|
2020-03-02 01:08:16 +00:00
|
|
|
|
2020-06-29 16:46:57 +00:00
|
|
|
/// Returns the default path to a memory card.
|
|
|
|
virtual std::string GetSharedMemoryCardPath(u32 slot) const;
|
|
|
|
|
|
|
|
/// Returns the default path to a memory card for a specific game.
|
|
|
|
virtual std::string GetGameMemoryCardPath(const char* game_code, u32 slot) const;
|
|
|
|
|
2020-07-04 10:45:54 +00:00
|
|
|
/// Returns the path to the shader cache directory.
|
|
|
|
virtual std::string GetShaderCacheBasePath() const;
|
|
|
|
|
2020-06-30 14:33:45 +00:00
|
|
|
/// Returns a setting value from the configuration.
|
2020-07-21 09:49:04 +00:00
|
|
|
virtual std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "") = 0;
|
2020-06-30 14:33:45 +00:00
|
|
|
|
|
|
|
/// Returns a boolean setting from the configuration.
|
2020-07-21 09:49:04 +00:00
|
|
|
virtual bool GetBoolSettingValue(const char* section, const char* key, bool default_value = false);
|
2020-06-30 14:33:45 +00:00
|
|
|
|
|
|
|
/// Returns an integer setting from the configuration.
|
2020-07-21 09:49:04 +00:00
|
|
|
virtual int GetIntSettingValue(const char* section, const char* key, int default_value = 0);
|
2020-06-30 14:33:45 +00:00
|
|
|
|
|
|
|
/// Returns a float setting from the configuration.
|
2020-07-21 09:49:04 +00:00
|
|
|
virtual float GetFloatSettingValue(const char* section, const char* key, float default_value = 0.0f);
|
2020-06-07 16:53:53 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
/// Loads the BIOS image for the specified region.
|
|
|
|
std::optional<std::vector<u8>> GetBIOSImage(ConsoleRegion region);
|
|
|
|
|
|
|
|
virtual void OnRunningGameChanged();
|
|
|
|
virtual void OnSystemPerformanceCountersUpdated();
|
|
|
|
|
2019-09-30 04:22:30 +00:00
|
|
|
protected:
|
2020-02-15 15:14:28 +00:00
|
|
|
virtual bool AcquireHostDisplay() = 0;
|
|
|
|
virtual void ReleaseHostDisplay() = 0;
|
|
|
|
virtual std::unique_ptr<AudioStream> CreateAudioStream(AudioBackend backend) = 0;
|
|
|
|
|
|
|
|
virtual void OnSystemCreated();
|
|
|
|
virtual void OnSystemDestroyed();
|
2020-02-28 07:00:09 +00:00
|
|
|
virtual void OnSystemStateSaved(bool global, s32 slot);
|
2020-02-15 15:14:44 +00:00
|
|
|
virtual void OnControllerTypeChanged(u32 slot);
|
2020-01-24 04:49:47 +00:00
|
|
|
|
2020-06-08 16:05:55 +00:00
|
|
|
/// Restores all settings to defaults.
|
|
|
|
virtual void SetDefaultSettings(SettingsInterface& si);
|
2020-04-13 12:13:46 +00:00
|
|
|
|
2020-06-08 16:05:55 +00:00
|
|
|
/// Loads settings to m_settings and any frontend-specific parameters.
|
|
|
|
virtual void LoadSettings(SettingsInterface& si);
|
2020-01-24 04:51:10 +00:00
|
|
|
|
2020-06-08 16:05:55 +00:00
|
|
|
/// Saves current settings variables to ini.
|
|
|
|
virtual void SaveSettings(SettingsInterface& si);
|
2020-04-30 14:58:32 +00:00
|
|
|
|
2020-08-19 13:26:57 +00:00
|
|
|
/// Checks and fixes up any incompatible settings.
|
2020-08-20 12:25:49 +00:00
|
|
|
virtual void FixIncompatibleSettings(bool display_osd_messages);
|
2020-08-19 13:26:57 +00:00
|
|
|
|
2020-06-08 16:05:55 +00:00
|
|
|
/// Checks for settings changes, std::move() the old settings away for comparing beforehand.
|
|
|
|
virtual void CheckForSettingsChanges(const Settings& old_settings);
|
2020-01-24 04:51:03 +00:00
|
|
|
|
2020-06-08 16:05:55 +00:00
|
|
|
/// Switches the GPU renderer by saving state, recreating the display window, and restoring state (if needed).
|
|
|
|
virtual void RecreateSystem();
|
2020-01-24 04:52:03 +00:00
|
|
|
|
2020-06-08 16:05:55 +00:00
|
|
|
/// Sets the user directory to the program directory, i.e. "portable mode".
|
|
|
|
void SetUserDirectoryToProgramDirectory();
|
2020-01-24 04:52:03 +00:00
|
|
|
|
2020-01-24 04:51:53 +00:00
|
|
|
/// Quick switch between software and hardware rendering.
|
|
|
|
void ToggleSoftwareRendering();
|
|
|
|
|
2020-01-24 04:51:56 +00:00
|
|
|
/// Adjusts the internal (render) resolution of the hardware backends.
|
|
|
|
void ModifyResolutionScale(s32 increment);
|
|
|
|
|
2020-06-30 14:35:13 +00:00
|
|
|
/// Updates software cursor state, based on controllers.
|
|
|
|
void UpdateSoftwareCursor();
|
|
|
|
|
2020-06-08 16:05:55 +00:00
|
|
|
bool SaveState(const char* filename);
|
|
|
|
void CreateAudioStream();
|
2019-12-01 11:33:56 +00:00
|
|
|
|
2020-06-29 16:46:57 +00:00
|
|
|
std::unique_ptr<HostDisplay> m_display;
|
2019-10-10 16:20:21 +00:00
|
|
|
std::unique_ptr<AudioStream> m_audio_stream;
|
2020-05-16 12:18:02 +00:00
|
|
|
std::string m_program_directory;
|
2020-01-24 04:51:00 +00:00
|
|
|
std::string m_user_directory;
|
2019-09-12 14:18:13 +00:00
|
|
|
};
|
2020-07-31 07:09:18 +00:00
|
|
|
|
|
|
|
extern HostInterface* g_host_interface;
|