all repos — mgba @ d3a018c35b159d498a76df7f5dbfdc72ca811acc

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