all repos — mgba @ 7097d249af677d955f7f58a56242a2e35253423e

mGBA Game Boy Advance Emulator

src/feature/gui/gui-runner.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 GUI_RUNNER_H
 7#define GUI_RUNNER_H
 8
 9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba/core/config.h>
14#include "feature/gui/remap.h"
15#include <mgba/internal/gba/hardware.h>
16#include <mgba-util/circle-buffer.h>
17#include <mgba-util/gui.h>
18
19enum mGUIInput {
20	mGUI_INPUT_INCREASE_BRIGHTNESS = GUI_INPUT_USER_START,
21	mGUI_INPUT_DECREASE_BRIGHTNESS,
22	mGUI_INPUT_SCREEN_MODE,
23	mGUI_INPUT_SCREENSHOT,
24	mGUI_INPUT_FAST_FORWARD,
25};
26
27struct mGUIBackground {
28	struct GUIBackground d;
29	struct mGUIRunner* p;
30
31	color_t* screenshot;
32	int screenshotId;
33};
34
35struct mCore;
36struct mGUIRunnerLux {
37	struct GBALuminanceSource d;
38	int luxLevel;
39};
40
41struct mGUIRunner {
42	struct mCore* core;
43	struct GUIParams params;
44
45	struct mGUIBackground background;
46	struct mGUIRunnerLux luminanceSource;
47
48	struct mInputMap guiKeys;
49	struct mCoreConfig config;
50	struct GUIMenuItem* configExtra;
51	size_t nConfigExtra;
52
53	struct GUIInputKeys* keySources;
54
55	const char* port;
56	float fps;
57	int64_t lastFpsCheck;
58	int32_t totalDelta;
59	struct CircleBuffer fpsBuffer;
60
61	void (*setup)(struct mGUIRunner*);
62	void (*teardown)(struct mGUIRunner*);
63	void (*gameLoaded)(struct mGUIRunner*);
64	void (*gameUnloaded)(struct mGUIRunner*);
65	void (*prepareForFrame)(struct mGUIRunner*);
66	void (*drawFrame)(struct mGUIRunner*, bool faded);
67	void (*drawScreenshot)(struct mGUIRunner*, const color_t* pixels, unsigned width, unsigned height, bool faded);
68	void (*paused)(struct mGUIRunner*);
69	void (*unpaused)(struct mGUIRunner*);
70	void (*incrementScreenMode)(struct mGUIRunner*);
71	void (*setFrameLimiter)(struct mGUIRunner*, bool limit);
72	uint16_t (*pollGameInput)(struct mGUIRunner*);
73};
74
75void mGUIInit(struct mGUIRunner*, const char* port);
76void mGUIDeinit(struct mGUIRunner*);
77void mGUIRun(struct mGUIRunner*, const char* path);
78void mGUIRunloop(struct mGUIRunner*);
79
80CXX_GUARD_END
81
82#endif