src/util/gui.c (view raw)
1/* Copyright (c) 2013-2015 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#include "gui.h"
7
8void GUIInit(struct GUIParams* params) {
9 memset(params->inputHistory, 0, sizeof(params->inputHistory));
10 strncpy(params->currentPath, params->basePath, PATH_MAX);
11}
12
13void GUIPollInput(struct GUIParams* params, uint32_t* newInputOut, uint32_t* heldInput) {
14 uint32_t input = params->pollInput(¶ms->keyMap);
15 uint32_t newInput = 0;
16 for (int i = 0; i < GUI_INPUT_MAX; ++i) {
17 if (input & (1 << i)) {
18 ++params->inputHistory[i];
19 } else {
20 params->inputHistory[i] = -1;
21 }
22 if (!params->inputHistory[i] || (params->inputHistory[i] >= 30 && !(params->inputHistory[i] % 6))) {
23 newInput |= (1 << i);
24 }
25 }
26 if (newInputOut) {
27 *newInputOut = newInput;
28 }
29 if (heldInput) {
30 *heldInput = input;
31 }
32}