2022-12-04 11:03:45 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
|
|
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
|
|
|
2022-07-08 14:25:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-08-27 06:00:06 +00:00
|
|
|
#include "util/host.h"
|
|
|
|
|
2023-09-20 13:49:14 +00:00
|
|
|
#include "common/small_string.h"
|
2022-07-08 14:25:16 +00:00
|
|
|
#include "common/types.h"
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
#include <ctime>
|
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
2023-08-23 12:06:48 +00:00
|
|
|
#include <mutex>
|
2022-07-08 14:25:16 +00:00
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-08-23 12:06:48 +00:00
|
|
|
class SettingsInterface;
|
2022-07-11 13:03:29 +00:00
|
|
|
struct WindowInfo;
|
|
|
|
enum class AudioBackend : u8;
|
2022-07-27 14:42:41 +00:00
|
|
|
enum class AudioStretchMode : u8;
|
2023-08-23 12:06:48 +00:00
|
|
|
enum class RenderAPI : u32;
|
2022-07-11 13:03:29 +00:00
|
|
|
class AudioStream;
|
|
|
|
class CDImage;
|
|
|
|
|
2023-08-19 14:08:03 +00:00
|
|
|
namespace Host {
|
2023-08-23 12:06:48 +00:00
|
|
|
// Base setting retrieval, bypasses layers.
|
|
|
|
std::string GetBaseStringSettingValue(const char* section, const char* key, const char* default_value = "");
|
|
|
|
bool GetBaseBoolSettingValue(const char* section, const char* key, bool default_value = false);
|
|
|
|
s32 GetBaseIntSettingValue(const char* section, const char* key, s32 default_value = 0);
|
|
|
|
u32 GetBaseUIntSettingValue(const char* section, const char* key, u32 default_value = 0);
|
|
|
|
float GetBaseFloatSettingValue(const char* section, const char* key, float default_value = 0.0f);
|
|
|
|
double GetBaseDoubleSettingValue(const char* section, const char* key, double default_value = 0.0);
|
|
|
|
std::vector<std::string> GetBaseStringListSetting(const char* section, const char* key);
|
|
|
|
|
|
|
|
// Allows the emucore to write settings back to the frontend. Use with care.
|
|
|
|
// You should call CommitBaseSettingChanges() if you directly write to the layer (i.e. not these functions), or it may
|
|
|
|
// not be written to disk.
|
|
|
|
void SetBaseBoolSettingValue(const char* section, const char* key, bool value);
|
|
|
|
void SetBaseIntSettingValue(const char* section, const char* key, s32 value);
|
|
|
|
void SetBaseUIntSettingValue(const char* section, const char* key, u32 value);
|
|
|
|
void SetBaseFloatSettingValue(const char* section, const char* key, float value);
|
|
|
|
void SetBaseStringSettingValue(const char* section, const char* key, const char* value);
|
|
|
|
void SetBaseStringListSettingValue(const char* section, const char* key, const std::vector<std::string>& values);
|
|
|
|
bool AddValueToBaseStringListSetting(const char* section, const char* key, const char* value);
|
|
|
|
bool RemoveValueFromBaseStringListSetting(const char* section, const char* key, const char* value);
|
|
|
|
void DeleteBaseSettingValue(const char* section, const char* key);
|
|
|
|
void CommitBaseSettingChanges();
|
|
|
|
|
|
|
|
// Settings access, thread-safe.
|
|
|
|
std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "");
|
|
|
|
bool GetBoolSettingValue(const char* section, const char* key, bool default_value = false);
|
|
|
|
int GetIntSettingValue(const char* section, const char* key, s32 default_value = 0);
|
|
|
|
u32 GetUIntSettingValue(const char* section, const char* key, u32 default_value = 0);
|
|
|
|
float GetFloatSettingValue(const char* section, const char* key, float default_value = 0.0f);
|
|
|
|
double GetDoubleSettingValue(const char* section, const char* key, double default_value = 0.0);
|
|
|
|
std::vector<std::string> GetStringListSetting(const char* section, const char* key);
|
|
|
|
|
|
|
|
/// Direct access to settings interface. Must hold the lock when calling GetSettingsInterface() and while using it.
|
|
|
|
std::unique_lock<std::mutex> GetSettingsLock();
|
|
|
|
SettingsInterface* GetSettingsInterface();
|
|
|
|
|
|
|
|
/// Returns the settings interface that controller bindings should be loaded from.
|
|
|
|
/// If an input profile is being used, this will be the input layer, otherwise the layered interface.
|
|
|
|
SettingsInterface* GetSettingsInterfaceForBindings();
|
|
|
|
|
2023-08-19 13:43:37 +00:00
|
|
|
|
|
|
|
|
2022-07-27 14:42:41 +00:00
|
|
|
std::unique_ptr<AudioStream> CreateAudioStream(AudioBackend backend, u32 sample_rate, u32 channels, u32 buffer_ms,
|
|
|
|
u32 latency_ms, AudioStretchMode stretch);
|
2022-07-11 13:03:29 +00:00
|
|
|
|
|
|
|
/// Debugger feedback.
|
|
|
|
void ReportDebuggerMessage(const std::string_view& message);
|
|
|
|
void ReportFormattedDebuggerMessage(const char* format, ...);
|
|
|
|
|
|
|
|
/// Displays a loading screen with the logo, rendered with ImGui. Use when executing possibly-time-consuming tasks
|
|
|
|
/// such as compiling shaders when starting up.
|
|
|
|
void DisplayLoadingScreen(const char* message, int progress_min = -1, int progress_max = -1, int progress_value = -1);
|
|
|
|
|
|
|
|
/// Safely executes a function on the VM thread.
|
|
|
|
void RunOnCPUThread(std::function<void()> function, bool block = false);
|
2022-08-25 15:26:55 +00:00
|
|
|
|
2023-08-13 03:42:02 +00:00
|
|
|
/// Requests shut down and exit of the hosting application. This may not actually exit,
|
|
|
|
/// if the user cancels the shutdown confirmation.
|
|
|
|
void RequestExit(bool allow_confirm);
|
|
|
|
|
2023-08-23 12:06:48 +00:00
|
|
|
/// Attempts to create the rendering device backend.
|
|
|
|
bool CreateGPUDevice(RenderAPI api);
|
|
|
|
|
|
|
|
/// Handles fullscreen transitions and such.
|
|
|
|
void UpdateDisplayWindow();
|
|
|
|
|
|
|
|
/// Called when the window is resized.
|
|
|
|
void ResizeDisplayWindow(s32 width, s32 height, float scale);
|
|
|
|
|
|
|
|
/// Destroys any active rendering device.
|
|
|
|
void ReleaseGPUDevice();
|
|
|
|
|
2023-08-13 03:42:02 +00:00
|
|
|
/// Called before drawing the OSD and other display elements.
|
|
|
|
void BeginPresentFrame();
|
|
|
|
|
2023-08-19 14:08:03 +00:00
|
|
|
namespace Internal {
|
2023-08-23 12:06:48 +00:00
|
|
|
/// Retrieves the base settings layer. Must call with lock held.
|
|
|
|
SettingsInterface* GetBaseSettingsLayer();
|
|
|
|
|
|
|
|
/// Retrieves the game settings layer, if present. Must call with lock held.
|
|
|
|
SettingsInterface* GetGameSettingsLayer();
|
|
|
|
|
|
|
|
/// Retrieves the input settings layer, if present. Must call with lock held.
|
|
|
|
SettingsInterface* GetInputSettingsLayer();
|
|
|
|
|
|
|
|
/// Sets the base settings layer. Should be called by the host at initialization time.
|
|
|
|
void SetBaseSettingsLayer(SettingsInterface* sif);
|
|
|
|
|
|
|
|
/// Sets the game settings layer. Called by VMManager when the game changes.
|
|
|
|
void SetGameSettingsLayer(SettingsInterface* sif);
|
|
|
|
|
|
|
|
/// Sets the input profile settings layer. Called by VMManager when the game changes.
|
|
|
|
void SetInputSettingsLayer(SettingsInterface* sif);
|
2023-08-19 14:08:03 +00:00
|
|
|
} // namespace Internal
|
2022-07-08 14:25:16 +00:00
|
|
|
} // namespace Host
|