jtmm2/include/input.h

41 lines
713 B
C

#ifndef _DEF_INPUT
#define _DEF_INPUT
#include <gint/defs/types.h>
#define KEYS_COUNT 5
enum {
K_LEFT,
K_RIGHT,
K_UP,
K_DOWN,
K_EXIT
};
enum {
S_PRESSED, /* 0 */
S_DOWN, /* 1 */
S_RELEASED, /* 2 */
S_UP /* 3 */
};
typedef struct Input
{
uint8_t keys[KEYS_COUNT];
uint8_t states[KEYS_COUNT];
} Input;
/* will check for new key inputs and update states[] */
void input_step(Input *input);
/* display all keys states and information */
void input_draw_debug(Input *input);
_Bool input_is_pressed(Input *input, uint8_t key);
_Bool input_is_down(Input *input, uint8_t key);
_Bool input_is_released(Input *input, uint8_t key);
_Bool input_is_up(Input *input, uint8_t key);
#endif /* _DEF_INPUT */