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 lockIntegerScaling;
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);
71
72void mCoreConfigMakePortable(const struct mCoreConfig*);
73void mCoreConfigDirectory(char* out, size_t outLength);
74#endif
75
76const char* mCoreConfigGetValue(const struct mCoreConfig*, const char* key);
77bool mCoreConfigGetIntValue(const struct mCoreConfig*, const char* key, int* value);
78bool mCoreConfigGetUIntValue(const struct mCoreConfig*, const char* key, unsigned* value);
79bool mCoreConfigGetFloatValue(const struct mCoreConfig*, const char* key, float* value);
80
81void mCoreConfigSetValue(struct mCoreConfig*, const char* key, const char* value);
82void mCoreConfigSetIntValue(struct mCoreConfig*, const char* key, int value);
83void mCoreConfigSetUIntValue(struct mCoreConfig*, const char* key, unsigned value);
84void mCoreConfigSetFloatValue(struct mCoreConfig*, const char* key, float value);
85
86void mCoreConfigSetDefaultValue(struct mCoreConfig*, const char* key, const char* value);
87void mCoreConfigSetDefaultIntValue(struct mCoreConfig*, const char* key, int value);
88void mCoreConfigSetDefaultUIntValue(struct mCoreConfig*, const char* key, unsigned value);
89void mCoreConfigSetDefaultFloatValue(struct mCoreConfig*, const char* key, float value);
90
91void mCoreConfigSetOverrideValue(struct mCoreConfig*, const char* key, const char* value);
92void mCoreConfigSetOverrideIntValue(struct mCoreConfig*, const char* key, int value);
93void mCoreConfigSetOverrideUIntValue(struct mCoreConfig*, const char* key, unsigned value);
94void mCoreConfigSetOverrideFloatValue(struct mCoreConfig*, const char* key, float value);
95
96void mCoreConfigCopyValue(struct mCoreConfig* config, const struct mCoreConfig* src, const char* key);
97
98void mCoreConfigMap(const struct mCoreConfig* config, struct mCoreOptions* opts);
99void mCoreConfigLoadDefaults(struct mCoreConfig* config, const struct mCoreOptions* opts);
100
101void mCoreConfigEnumerate(const struct mCoreConfig* config, const char* prefix, void (*handler)(const char* key, const char* value, enum mCoreConfigLevel type, void* user), void* user);
102
103struct Configuration* mCoreConfigGetInput(struct mCoreConfig*);
104struct Configuration* mCoreConfigGetOverrides(struct mCoreConfig*);
105const struct Configuration* mCoreConfigGetOverridesConst(const struct mCoreConfig*);
106
107void mCoreConfigFreeOpts(struct mCoreOptions* opts);
108
109CXX_GUARD_END
110
111#endif