mirror of https://github.com/mgba-emu/mgba.git
GUI: Move running check into frontend
This commit is contained in:
parent
7097d249af
commit
e40cba5c8b
|
@ -18,10 +18,6 @@
|
||||||
#include <mgba-util/png-io.h>
|
#include <mgba-util/png-io.h>
|
||||||
#include <mgba-util/vfs.h>
|
#include <mgba-util/vfs.h>
|
||||||
|
|
||||||
#ifdef _3DS
|
|
||||||
#include <3ds.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
mLOG_DECLARE_CATEGORY(GUI_RUNNER);
|
mLOG_DECLARE_CATEGORY(GUI_RUNNER);
|
||||||
|
@ -334,13 +330,13 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
|
||||||
gettimeofday(&tv, 0);
|
gettimeofday(&tv, 0);
|
||||||
runner->lastFpsCheck = 1000000LL * tv.tv_sec + tv.tv_usec;
|
runner->lastFpsCheck = 1000000LL * tv.tv_sec + tv.tv_usec;
|
||||||
|
|
||||||
while (true) {
|
while (running) {
|
||||||
#ifdef _3DS
|
if (runner->running) {
|
||||||
running = aptMainLoop();
|
running = runner->running(runner);
|
||||||
if (!running) {
|
if (!running) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
uint32_t guiKeys;
|
uint32_t guiKeys;
|
||||||
uint32_t heldKeys;
|
uint32_t heldKeys;
|
||||||
GUIPollInput(&runner->params, &guiKeys, &heldKeys);
|
GUIPollInput(&runner->params, &guiKeys, &heldKeys);
|
||||||
|
|
|
@ -70,6 +70,7 @@ struct mGUIRunner {
|
||||||
void (*incrementScreenMode)(struct mGUIRunner*);
|
void (*incrementScreenMode)(struct mGUIRunner*);
|
||||||
void (*setFrameLimiter)(struct mGUIRunner*, bool limit);
|
void (*setFrameLimiter)(struct mGUIRunner*, bool limit);
|
||||||
uint16_t (*pollGameInput)(struct mGUIRunner*);
|
uint16_t (*pollGameInput)(struct mGUIRunner*);
|
||||||
|
bool (*running)(struct mGUIRunner*);
|
||||||
};
|
};
|
||||||
|
|
||||||
void mGUIInit(struct mGUIRunner*, const char* port);
|
void mGUIInit(struct mGUIRunner*, const char* port);
|
||||||
|
|
|
@ -678,6 +678,10 @@ static void _setFrameLimiter(struct mGUIRunner* runner, bool limit) {
|
||||||
tickCounter = svcGetSystemTick();
|
tickCounter = svcGetSystemTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool _running(struct mGUIRunner* runner) {
|
||||||
|
return aptMainLoop();
|
||||||
|
}
|
||||||
|
|
||||||
static uint32_t _pollInput(const struct mInputMap* map) {
|
static uint32_t _pollInput(const struct mInputMap* map) {
|
||||||
hidScanInput();
|
hidScanInput();
|
||||||
int activeKeys = hidKeysHeld();
|
int activeKeys = hidKeysHeld();
|
||||||
|
@ -1020,7 +1024,8 @@ int main() {
|
||||||
.unpaused = _gameLoaded,
|
.unpaused = _gameLoaded,
|
||||||
.incrementScreenMode = _incrementScreenMode,
|
.incrementScreenMode = _incrementScreenMode,
|
||||||
.setFrameLimiter = _setFrameLimiter,
|
.setFrameLimiter = _setFrameLimiter,
|
||||||
.pollGameInput = _pollGameInput
|
.pollGameInput = _pollGameInput,
|
||||||
|
.running = _running
|
||||||
};
|
};
|
||||||
|
|
||||||
mGUIInit(&runner, "3ds");
|
mGUIInit(&runner, "3ds");
|
||||||
|
|
Loading…
Reference in New Issue