-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeyboard.h
More file actions
27 lines (22 loc) · 741 Bytes
/
keyboard.h
File metadata and controls
27 lines (22 loc) · 741 Bytes
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
#include "./display.h"
enum {
KeyUp = 1,
KeyDown = 0
};
typedef struct Keyboard {
int keys[16];
int(*is_key_down)(int key, struct Keyboard*);
int(*is_key_up)(int key, struct Keyboard*);
void (*press_up_key)(int key, struct Keyboard*);
void (*press_down_key)(int key, struct Keyboard*);
void (*reset)(struct Keyboard*);
} Keyboard;
void setup_keyboard(void);
void reset(Keyboard* keyboard);
int is_key_down(int key, Keyboard* keyboard);
int is_key_up(int key, Keyboard* keyboard);
void press_up_key(int key, Keyboard* keyboard);
void press_down_key(int key, Keyboard* keyboard);
void keyboard_update_state(Keyboard* keyboard, Display* display);
int is_at_least_one_key_pressed(Keyboard* keyboard);
Keyboard* build_keyboard(void);