all repos — mgba @ cb7f150cc2b647ae5a9dca2175bd5464d7d5e42f

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#include <mgba-util/threading.h>
 19
 20enum mGUIInput {
 21	mGUI_INPUT_INCREASE_BRIGHTNESS = GUI_INPUT_USER_START,
 22	mGUI_INPUT_DECREASE_BRIGHTNESS,
 23	mGUI_INPUT_SCREEN_MODE,
 24	mGUI_INPUT_SCREENSHOT,
 25	mGUI_INPUT_FAST_FORWARD_HELD,
 26	mGUI_INPUT_FAST_FORWARD_TOGGLE,
 27	mGUI_INPUT_MUTE_TOGGLE,
 28};
 29
 30struct mGUIBackground {
 31	struct GUIBackground d;
 32	struct mGUIRunner* p;
 33
 34	color_t* screenshot;
 35	int screenshotId;
 36};
 37
 38struct mCore;
 39struct mGUIRunnerLux {
 40	struct GBALuminanceSource d;
 41	int luxLevel;
 42};
 43
 44#ifndef DISABLE_THREADING
 45struct VFile;
 46struct mGUIAutosaveContext {
 47	struct VFile* buffer;
 48	struct mCore* core;
 49	Thread thread;
 50	Mutex mutex;
 51	Condition cond;
 52	bool running;
 53};
 54#endif
 55
 56struct mGUIRunner {
 57	struct mCore* core;
 58	struct GUIParams params;
 59
 60	struct mGUIBackground background;
 61	struct mGUIRunnerLux luminanceSource;
 62#ifndef DISABLE_THREADING
 63	struct mGUIAutosaveContext autosave;
 64#endif
 65
 66	struct mInputMap guiKeys;
 67	struct mCoreConfig config;
 68	struct GUIMenuItem* configExtra;
 69	size_t nConfigExtra;
 70
 71	struct GUIInputKeys* keySources;
 72
 73	const char* port;
 74	float fps;
 75	int64_t lastFpsCheck;
 76	int32_t totalDelta;
 77	struct CircleBuffer fpsBuffer;
 78
 79	void (*setup)(struct mGUIRunner*);
 80	void (*teardown)(struct mGUIRunner*);
 81	void (*gameLoaded)(struct mGUIRunner*);
 82	void (*gameUnloaded)(struct mGUIRunner*);
 83	void (*prepareForFrame)(struct mGUIRunner*);
 84	void (*drawFrame)(struct mGUIRunner*, bool faded);
 85	void (*drawScreenshot)(struct mGUIRunner*, const color_t* pixels, unsigned width, unsigned height, bool faded);
 86	void (*paused)(struct mGUIRunner*);
 87	void (*unpaused)(struct mGUIRunner*);
 88	void (*incrementScreenMode)(struct mGUIRunner*);
 89	void (*setFrameLimiter)(struct mGUIRunner*, bool limit);
 90	uint16_t (*pollGameInput)(struct mGUIRunner*);
 91	bool (*running)(struct mGUIRunner*);
 92};
 93
 94void mGUIInit(struct mGUIRunner*, const char* port);
 95void mGUIDeinit(struct mGUIRunner*);
 96void mGUIRun(struct mGUIRunner*, const char* path);
 97void mGUIRunloop(struct mGUIRunner*);
 98
 99#ifndef DISABLE_THREADING
100THREAD_ENTRY mGUIAutosaveThread(void* context);
101#endif
102
103CXX_GUARD_END
104
105#endif