2015-08-23 06:20:21 +00:00
|
|
|
/* Copyright (c) 2013-2015 Jeffrey Pfau
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef GUI_H
|
|
|
|
#define GUI_H
|
|
|
|
|
2016-12-31 01:00:22 +00:00
|
|
|
#include <mgba-util/common.h>
|
2015-08-23 06:20:21 +00:00
|
|
|
|
2016-12-27 05:01:55 +00:00
|
|
|
CXX_GUARD_START
|
|
|
|
|
2016-12-31 01:00:22 +00:00
|
|
|
// TODO: Fix layering violation
|
|
|
|
#include <mgba/core/input.h>
|
|
|
|
#include <mgba-util/vector.h>
|
2015-08-30 06:51:44 +00:00
|
|
|
|
2015-08-23 06:20:21 +00:00
|
|
|
struct GUIFont;
|
|
|
|
|
|
|
|
enum GUIInput {
|
|
|
|
GUI_INPUT_NONE = -1,
|
|
|
|
GUI_INPUT_SELECT = 0,
|
|
|
|
GUI_INPUT_BACK,
|
|
|
|
GUI_INPUT_CANCEL,
|
|
|
|
|
|
|
|
GUI_INPUT_UP,
|
|
|
|
GUI_INPUT_DOWN,
|
|
|
|
GUI_INPUT_LEFT,
|
|
|
|
GUI_INPUT_RIGHT,
|
2015-08-25 05:11:12 +00:00
|
|
|
|
2016-08-16 05:15:45 +00:00
|
|
|
GUI_INPUT_USER_START = 0x8,
|
2015-09-02 06:09:48 +00:00
|
|
|
|
|
|
|
GUI_INPUT_MAX = 0x20
|
2015-08-23 06:20:21 +00:00
|
|
|
};
|
|
|
|
|
2015-09-05 05:50:20 +00:00
|
|
|
enum GUICursorState {
|
2016-09-17 08:34:07 +00:00
|
|
|
GUI_CURSOR_NOT_PRESENT = 0,
|
2015-09-05 05:50:20 +00:00
|
|
|
GUI_CURSOR_UP,
|
|
|
|
GUI_CURSOR_DOWN,
|
|
|
|
GUI_CURSOR_CLICKED,
|
|
|
|
GUI_CURSOR_DRAGGING
|
|
|
|
};
|
|
|
|
|
2015-09-19 07:32:49 +00:00
|
|
|
enum {
|
|
|
|
BATTERY_EMPTY = 0,
|
2020-08-10 00:56:26 +00:00
|
|
|
BATTERY_LOW = 25,
|
|
|
|
BATTERY_HALF = 50,
|
|
|
|
BATTERY_HIGH = 75,
|
|
|
|
BATTERY_FULL = 100,
|
|
|
|
BATTERY_VALUE = 0x7F,
|
|
|
|
BATTERY_PERCENTAGE_VALID = 0x80,
|
|
|
|
|
|
|
|
BATTERY_CHARGING = 0x100,
|
|
|
|
BATTERY_NOT_PRESENT = 0x200,
|
2015-09-19 07:32:49 +00:00
|
|
|
};
|
|
|
|
|
2015-09-02 04:51:14 +00:00
|
|
|
struct GUIBackground {
|
2015-09-03 08:58:50 +00:00
|
|
|
void (*draw)(struct GUIBackground*, void* context);
|
2015-09-02 04:51:14 +00:00
|
|
|
};
|
|
|
|
|
2015-08-23 06:20:21 +00:00
|
|
|
struct GUIParams {
|
2015-08-27 03:11:51 +00:00
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
2015-08-23 06:20:21 +00:00
|
|
|
const struct GUIFont* font;
|
2015-08-30 06:51:44 +00:00
|
|
|
const char* basePath;
|
2015-08-23 06:20:21 +00:00
|
|
|
|
|
|
|
void (*drawStart)(void);
|
|
|
|
void (*drawEnd)(void);
|
2016-08-16 05:15:45 +00:00
|
|
|
uint32_t (*pollInput)(const struct mInputMap*);
|
2016-01-09 08:54:18 +00:00
|
|
|
enum GUICursorState (*pollCursor)(unsigned* x, unsigned* y);
|
2015-09-19 07:32:49 +00:00
|
|
|
int (*batteryState)(void);
|
2015-08-30 23:25:32 +00:00
|
|
|
void (*guiPrepare)(void);
|
|
|
|
void (*guiFinish)(void);
|
2015-08-30 06:21:41 +00:00
|
|
|
|
|
|
|
// State
|
2016-08-16 05:15:45 +00:00
|
|
|
struct mInputMap keyMap;
|
2015-08-30 06:21:41 +00:00
|
|
|
int inputHistory[GUI_INPUT_MAX];
|
2015-09-05 05:50:20 +00:00
|
|
|
enum GUICursorState cursorState;
|
|
|
|
int cx, cy;
|
2015-08-30 06:51:44 +00:00
|
|
|
|
|
|
|
// Directories
|
|
|
|
char currentPath[PATH_MAX];
|
|
|
|
size_t fileIndex;
|
2015-08-23 06:20:21 +00:00
|
|
|
};
|
|
|
|
|
2015-08-30 06:51:44 +00:00
|
|
|
void GUIInit(struct GUIParams* params);
|
2015-09-02 06:09:48 +00:00
|
|
|
void GUIPollInput(struct GUIParams* params, uint32_t* newInput, uint32_t* heldInput);
|
2016-01-09 08:54:18 +00:00
|
|
|
enum GUICursorState GUIPollCursor(struct GUIParams* params, unsigned* x, unsigned* y);
|
2015-08-30 06:51:44 +00:00
|
|
|
void GUIInvalidateKeys(struct GUIParams* params);
|
2015-08-30 06:21:41 +00:00
|
|
|
|
2016-12-27 05:01:55 +00:00
|
|
|
CXX_GUARD_END
|
|
|
|
|
2015-08-23 06:20:21 +00:00
|
|
|
#endif
|