momento/src/mainmenu/update.c

35 lines
816 B
C
Raw Normal View History

2021-04-20 12:49:55 +02:00
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Copyright (C) 2021 KikooDX */
#include "filepaths.h"
#include "input.h"
#include "mainmenu.h"
#include <gint/keyboard.h>
/* Return 1 if game state should change. */
int
mainmenu_update(struct MainMenu *mainmenu, struct Input input)
2021-04-20 12:49:55 +02:00
{
/* decrease selected pack id */
if (input.keystates[K_UP] == KS_PRESS ||
input.keystates[K_LEFT] == KS_PRESS) {
if (mainmenu->cursor > 0)
mainmenu->cursor -= 1;
else
mainmenu->cursor = MENU_ENTRIES - 1;
}
2021-04-20 12:49:55 +02:00
/* increase selected pack id */
if (input.keystates[K_DOWN] == KS_PRESS ||
2021-04-21 17:51:59 +02:00
input.keystates[K_RIGHT] == KS_PRESS) {
if (mainmenu->cursor < MENU_ENTRIES - 1)
mainmenu->cursor += 1;
else
mainmenu->cursor = 0;
}
2021-04-20 12:49:55 +02:00
/* confirm */
if (input.keystates[K_A] == KS_PRESS)
return 1;
return 0;
}