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 bool rewindSave;
37 float fpsTarget;
38 size_t audioBuffers;
39 unsigned sampleRate;
40
41 int fullscreen;
42 int width;
43 int height;
44 bool lockAspectRatio;
45 bool resampleVideo;
46 bool suspendScreensaver;
47 char* shader;
48
49 char* savegamePath;
50 char* savestatePath;
51 char* screenshotPath;
52 char* patchPath;
53
54 int volume;
55 bool mute;
56
57 bool videoSync;
58 bool audioSync;
59};
60
61void mCoreConfigInit(struct mCoreConfig*, const char* port);
62void mCoreConfigDeinit(struct mCoreConfig*);
63
64#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
65bool mCoreConfigLoad(struct mCoreConfig*);
66bool mCoreConfigSave(const struct mCoreConfig*);
67bool mCoreConfigLoadPath(struct mCoreConfig*, const char* path);
68bool mCoreConfigSavePath(const struct mCoreConfig*, const char* path);
69
70void mCoreConfigMakePortable(const struct mCoreConfig*);
71void mCoreConfigDirectory(char* out, size_t outLength);
72#endif
73
74const char* mCoreConfigGetValue(const struct mCoreConfig*, const char* key);
75bool mCoreConfigGetIntValue(const struct mCoreConfig*, const char* key, int* value);
76bool mCoreConfigGetUIntValue(const struct mCoreConfig*, const char* key, unsigned* value);
77bool mCoreConfigGetFloatValue(const struct mCoreConfig*, const char* key, float* value);
78
79void mCoreConfigSetValue(struct mCoreConfig*, const char* key, const char* value);
80void mCoreConfigSetIntValue(struct mCoreConfig*, const char* key, int value);
81void mCoreConfigSetUIntValue(struct mCoreConfig*, const char* key, unsigned value);
82void mCoreConfigSetFloatValue(struct mCoreConfig*, const char* key, float value);
83
84void mCoreConfigSetDefaultValue(struct mCoreConfig*, const char* key, const char* value);
85void mCoreConfigSetDefaultIntValue(struct mCoreConfig*, const char* key, int value);
86void mCoreConfigSetDefaultUIntValue(struct mCoreConfig*, const char* key, unsigned value);
87void mCoreConfigSetDefaultFloatValue(struct mCoreConfig*, const char* key, float value);
88
89void mCoreConfigSetOverrideValue(struct mCoreConfig*, const char* key, const char* value);
90void mCoreConfigSetOverrideIntValue(struct mCoreConfig*, const char* key, int value);
91void mCoreConfigSetOverrideUIntValue(struct mCoreConfig*, const char* key, unsigned value);
92void mCoreConfigSetOverrideFloatValue(struct mCoreConfig*, const char* key, float value);
93
94void mCoreConfigCopyValue(struct mCoreConfig* config, const struct mCoreConfig* src, const char* key);
95
96void mCoreConfigMap(const struct mCoreConfig* config, struct mCoreOptions* opts);
97void mCoreConfigLoadDefaults(struct mCoreConfig* config, const struct mCoreOptions* opts);
98
99void mCoreConfigEnumerate(const struct mCoreConfig* config, const char* prefix, void (*handler)(const char* key, const char* value, enum mCoreConfigLevel type, void* user), void* user);
100
101struct Configuration* mCoreConfigGetInput(struct mCoreConfig*);
102struct Configuration* mCoreConfigGetOverrides(struct mCoreConfig*);
103const struct Configuration* mCoreConfigGetOverridesConst(const struct mCoreConfig*);
104
105void mCoreConfigFreeOpts(struct mCoreOptions* opts);
106
107CXX_GUARD_END
108
109#endif