-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.c
More file actions
30 lines (23 loc) · 792 Bytes
/
Copy pathinput.c
File metadata and controls
30 lines (23 loc) · 792 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
28
29
30
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "input.h"
#include "tinybit.h"
#include "memory.h"
bool prev_button_state[TB_BUTTON_COUNT] = {0};
// Check if a button is currently being pressed
bool button_down(enum TinyBitButton b){
return tinybit_memory->button_input[b];
}
// Save the current button state for next frame comparison
void save_button_state(){
memcpy(prev_button_state, tinybit_memory->button_input, sizeof(prev_button_state));
}
// Check if a button is currently being held down
bool input_btn(enum TinyBitButton b) {
return button_down(b);
}
// Check if a button was just pressed this frame (not held from previous frame)
bool input_btnp(enum TinyBitButton b) {
return button_down(b) && !prev_button_state[b];
}