blob: 5c53ba8ec674346d19dc09fe0a7c733f5cd3fba8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#ifndef KEYBOARD_H
#define KEYBOARD_H
#include <keyboard_key.h>
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C"
{
#endif
#define KEYBOARD_COMBO(...) (const struct keyboard_combo){.keys = {__VA_ARGS__}}
enum {KEYBOARD_MAX_COMBO_KEYS = 3};
struct keyboard
{
struct keyboard_combo
{
enum keyboard_key keys[KEYBOARD_MAX_COMBO_KEYS];
} combo, oldcombo;
size_t i;
};
void keyboard_init(struct keyboard *k);
void keyboard_update(struct keyboard *k);
bool keyboard_justpressed(const struct keyboard *k, const struct keyboard_combo *c);
bool keyboard_pressed(const struct keyboard *k, const struct keyboard_combo *c);
bool keyboard_justreleased(const struct keyboard *k, const struct keyboard_combo *c);
const char *keyboard_key_str(enum keyboard_key k);
#ifdef __cplusplus
}
#endif
#endif /* KEYBOARD_H */
|