src/platform/qt/ConfigController.cpp (view raw)
1#include "ConfigController.h"
2
3#include "GameController.h"
4
5extern "C" {
6#include "platform/commandline.h"
7}
8
9using namespace QGBA;
10
11ConfigController::ConfigController(QObject* parent)
12 : QObject(parent)
13 , m_opts()
14{
15 GBAConfigInit(&m_config, PORT);
16
17 m_opts.audioSync = GameController::AUDIO_SYNC;
18 m_opts.videoSync = GameController::VIDEO_SYNC;
19 GBAConfigLoadDefaults(&m_config, &m_opts);
20 GBAConfigLoad(&m_config);
21 GBAConfigMap(&m_config, &m_opts);
22}
23
24ConfigController::~ConfigController() {
25 write();
26
27 GBAConfigDeinit(&m_config);
28 GBAConfigFreeOpts(&m_opts);
29}
30
31bool ConfigController::parseArguments(GBAArguments* args, int argc, char* argv[]) {
32 return ::parseArguments(args, &m_config, argc, argv, 0);
33}
34
35void ConfigController::setOption(const char* key, bool value) {
36 setOption(key, (int) value);
37}
38
39void ConfigController::setOption(const char* key, int value) {
40 GBAConfigSetIntValue(&m_config, key, value);
41}
42
43void ConfigController::setOption(const char* key, unsigned value) {
44 GBAConfigSetUIntValue(&m_config, key, value);
45}
46
47void ConfigController::setOption(const char* key, const char* value) {
48 GBAConfigSetValue(&m_config, key, value);
49}
50
51void ConfigController::write() {
52 GBAConfigSave(&m_config);
53}