include/mgba/core/config.h (view raw)
1/* Copyright (c) 2013-2016 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef M_CORE_CONFIG_H
7#define M_CORE_CONFIG_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba-util/configuration.h>
14
15struct mCoreConfig {
16 struct Configuration configTable;
17 struct Configuration defaultsTable;
18 struct Configuration overridesTable;
19 char* port;
20};
21
22enum mCoreConfigLevel {
23 mCONFIG_LEVEL_DEFAULT = 0,
24 mCONFIG_LEVEL_CUSTOM,
25 mCONFIG_LEVEL_OVERRIDE,
26};
27
28struct mCoreOptions {
29 char* bios;
30 bool skipBios;
31 bool useBios;
32 int logLevel;
33 int frameskip;
34 bool rewindEnable;
35 int rewindBufferCapacity;
36 float fpsTarget;
37 size_t audioBuffers;
38 unsigned sampleRate;
39
40 int fullscreen;
41 int width;
42 int height;
43 bool lockAspectRatio;
44 bool lockIntegerScaling;
45 bool interframeBlending;
46 bool resampleVideo;
47 bool suspendScreensaver;
48 char* shader;
49
50 char* savegamePath;
51 char* savestatePath;
52 char* screenshotPath;
53 char* patchPath;
54 char* cheatsPath;
55
56 int volume;
57 bool mute;
58
59 bool videoSync;
60 bool audioSync;
61};
62
63void mCoreConfigInit(struct mCoreConfig*, const char* port);
64void mCoreConfigDeinit(struct mCoreConfig*);
65
66#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
67bool mCoreConfigLoad(struct mCoreConfig*);
68bool mCoreConfigSave(const struct mCoreConfig*);
69bool mCoreConfigLoadPath(struct mCoreConfig*, const char* path);
70bool mCoreConfigSavePath(const struct mCoreConfig*, const char* path);
71bool mCoreConfigLoadVFile(struct mCoreConfig*, struct VFile* vf);
72bool mCoreConfigSaveVFile(const struct mCoreConfig*, struct VFile* vf);
73
74void mCoreConfigMakePortable(const struct mCoreConfig*);
75void mCoreConfigDirectory(char* out, size_t outLength);
76void mCoreConfigPortablePath(char* out, size_t outLength);
77bool mCoreConfigIsPortable(void);
78#endif
79
80const char* mCoreConfigGetValue(const struct mCoreConfig*, const char* key);
81bool mCoreConfigGetIntValue(const struct mCoreConfig*, const char* key, int* value);
82bool mCoreConfigGetUIntValue(const struct mCoreConfig*, const char* key, unsigned* value);
83bool mCoreConfigGetFloatValue(const struct mCoreConfig*, const char* key, float* value);
84
85void mCoreConfigSetValue(struct mCoreConfig*, const char* key, const char* value);
86void mCoreConfigSetIntValue(struct mCoreConfig*, const char* key, int value);
87void mCoreConfigSetUIntValue(struct mCoreConfig*, const char* key, unsigned value);
88void mCoreConfigSetFloatValue(struct mCoreConfig*, const char* key, float value);
89
90void mCoreConfigSetDefaultValue(struct mCoreConfig*, const char* key, const char* value);
91void mCoreConfigSetDefaultIntValue(struct mCoreConfig*, const char* key, int value);
92void mCoreConfigSetDefaultUIntValue(struct mCoreConfig*, const char* key, unsigned value);
93void mCoreConfigSetDefaultFloatValue(struct mCoreConfig*, const char* key, float value);
94
95void mCoreConfigSetOverrideValue(struct mCoreConfig*, const char* key, const char* value);
96void mCoreConfigSetOverrideIntValue(struct mCoreConfig*, const char* key, int value);
97void mCoreConfigSetOverrideUIntValue(struct mCoreConfig*, const char* key, unsigned value);
98void mCoreConfigSetOverrideFloatValue(struct mCoreConfig*, const char* key, float value);
99
100void mCoreConfigCopyValue(struct mCoreConfig* config, const struct mCoreConfig* src, const char* key);
101
102void mCoreConfigMap(const struct mCoreConfig* config, struct mCoreOptions* opts);
103void mCoreConfigLoadDefaults(struct mCoreConfig* config, const struct mCoreOptions* opts);
104
105void mCoreConfigEnumerate(const struct mCoreConfig* config, const char* prefix, void (*handler)(const char* key, const char* value, enum mCoreConfigLevel type, void* user), void* user);
106
107struct Configuration* mCoreConfigGetInput(struct mCoreConfig*);
108struct Configuration* mCoreConfigGetOverrides(struct mCoreConfig*);
109const struct Configuration* mCoreConfigGetOverridesConst(const struct mCoreConfig*);
110
111void mCoreConfigFreeOpts(struct mCoreOptions* opts);
112
113CXX_GUARD_END
114
115#endif