mirror of https://github.com/mgba-emu/mgba.git
GUI: Add key repeat
This commit is contained in:
parent
86c7b478e2
commit
0cc32d98fb
|
@ -20,6 +20,8 @@ enum GUIInput {
|
|||
GUI_INPUT_DOWN,
|
||||
GUI_INPUT_LEFT,
|
||||
GUI_INPUT_RIGHT,
|
||||
|
||||
GUI_INPUT_MAX
|
||||
};
|
||||
|
||||
struct GUIParams {
|
||||
|
|
|
@ -58,7 +58,6 @@ static bool _refreshDirectory(const char* currentPath, struct FileList* currentF
|
|||
bool selectFile(const struct GUIParams* params, const char* basePath, char* outPath, size_t outLen, const char* suffix) {
|
||||
char currentPath[256];
|
||||
strncpy(currentPath, basePath, sizeof(currentPath));
|
||||
int oldInput = -1;
|
||||
size_t fileIndex = 0;
|
||||
size_t start = 0;
|
||||
|
||||
|
@ -66,10 +65,21 @@ bool selectFile(const struct GUIParams* params, const char* basePath, char* outP
|
|||
FileListInit(¤tFiles, 0);
|
||||
_refreshDirectory(currentPath, ¤tFiles);
|
||||
|
||||
int inputHistory[GUI_INPUT_MAX] = { 0 };
|
||||
|
||||
while (true) {
|
||||
int input = params->pollInput();
|
||||
int newInput = input & (oldInput ^ input);
|
||||
oldInput = input;
|
||||
int newInput = 0;
|
||||
for (int i = 0; i < GUI_INPUT_MAX; ++i) {
|
||||
if (input & (1 << i)) {
|
||||
++inputHistory[i];
|
||||
} else {
|
||||
inputHistory[i] = -1;
|
||||
}
|
||||
if (!inputHistory[i] || (inputHistory[i] >= 30 && !(inputHistory[i] % 6))) {
|
||||
newInput |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
if (newInput & (1 << GUI_INPUT_UP) && fileIndex > 0) {
|
||||
--fileIndex;
|
||||
|
|
Loading…
Reference in New Issue