Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/core/core.h
7197 views
1
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <[email protected]>
2
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
3
4
#pragma once
5
6
#include "common/small_string.h"
7
#include "common/types.h"
8
9
#include <mutex>
10
#include <string>
11
#include <string_view>
12
#include <vector>
13
14
class SettingsInterface;
15
16
namespace Core {
17
18
// Base setting retrieval, bypasses layers.
19
std::string GetBaseStringSettingValue(const char* section, const char* key, const char* default_value = "");
20
SmallString GetBaseSmallStringSettingValue(const char* section, const char* key, const char* default_value = "");
21
TinyString GetBaseTinyStringSettingValue(const char* section, const char* key, const char* default_value = "");
22
bool GetBaseBoolSettingValue(const char* section, const char* key, bool default_value = false);
23
s32 GetBaseIntSettingValue(const char* section, const char* key, s32 default_value = 0);
24
u32 GetBaseUIntSettingValue(const char* section, const char* key, u32 default_value = 0);
25
float GetBaseFloatSettingValue(const char* section, const char* key, float default_value = 0.0f);
26
double GetBaseDoubleSettingValue(const char* section, const char* key, double default_value = 0.0);
27
std::vector<std::string> GetBaseStringListSetting(const char* section, const char* key);
28
29
// Allows the emucore to write settings back to the frontend. Use with care.
30
// You should call CommitBaseSettingChanges() if you directly write to the layer (i.e. not these functions), or it may
31
// not be written to disk.
32
void SetBaseBoolSettingValue(const char* section, const char* key, bool value);
33
void SetBaseIntSettingValue(const char* section, const char* key, s32 value);
34
void SetBaseUIntSettingValue(const char* section, const char* key, u32 value);
35
void SetBaseFloatSettingValue(const char* section, const char* key, float value);
36
void SetBaseStringSettingValue(const char* section, const char* key, const char* value);
37
void SetBaseStringListSettingValue(const char* section, const char* key, const std::vector<std::string>& values);
38
bool AddValueToBaseStringListSetting(const char* section, const char* key, const char* value);
39
bool RemoveValueFromBaseStringListSetting(const char* section, const char* key, const char* value);
40
bool ContainsBaseSettingValue(const char* section, const char* key);
41
void DeleteBaseSettingValue(const char* section, const char* key);
42
43
// Settings access, thread-safe.
44
std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "");
45
SmallString GetSmallStringSettingValue(const char* section, const char* key, const char* default_value = "");
46
TinyString GetTinyStringSettingValue(const char* section, const char* key, const char* default_value = "");
47
bool GetBoolSettingValue(const char* section, const char* key, bool default_value = false);
48
int GetIntSettingValue(const char* section, const char* key, s32 default_value = 0);
49
u32 GetUIntSettingValue(const char* section, const char* key, u32 default_value = 0);
50
float GetFloatSettingValue(const char* section, const char* key, float default_value = 0.0f);
51
double GetDoubleSettingValue(const char* section, const char* key, double default_value = 0.0);
52
std::vector<std::string> GetStringListSetting(const char* section, const char* key);
53
54
/// Direct access to settings interface. Must hold the lock when calling GetSettingsInterface() and while using it.
55
std::unique_lock<std::mutex> GetSettingsLock();
56
SettingsInterface* GetSettingsInterface();
57
58
/// Retrieves the base settings layer. Must call with lock held.
59
SettingsInterface* GetBaseSettingsLayer();
60
61
/// Retrieves the game settings layer, if present. Must call with lock held.
62
SettingsInterface* GetGameSettingsLayer();
63
64
/// Retrieves the input settings layer, if present. Must call with lock held.
65
SettingsInterface* GetInputSettingsLayer();
66
67
/// Returns the user agent to use for HTTP requests.
68
std::string GetHTTPUserAgent();
69
70
} // namespace Core
71
72