-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinput.c
50 lines (39 loc) · 1.12 KB
/
input.c
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
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdbool.h>
#include <stdio.h>
#include "input.h"
#include "menu.h"
#include "common.h"
ButtonState Keys[256] = {
{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, //0-12
{13,13},{0},{0},{0}, // 13-15
{16,16},{17,17},{18,18}, //16-18
{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, //19-31
// todo: finish
};
MouseState mouse = {0};
bool Mouse_risingClick;
int Mouse_fallingDirection;
extern int Pen_oldx, Pen_oldy;
void Input_update2(void) {
for(int i=0;i<3;i++) {
mouse.buttons[i].gotPress = false;
mouse.buttons[i].gotRelease = false;
mouse.buttons[i].wasHeld = mouse.buttons[i].held;
}
mouse.oldPos = mouse.pos;
for (int i=0;i<256;i++) {
Keys[i].gotPress = false;
Keys[i].gotRelease = false;
Keys[i].wasHeld = Keys[i].held;
}
}
void Input_update(void) {
for(int i=0;i<3;i++) {
mouse.buttons[i].held = mouse.buttons[i].heldNow || mouse.buttons[i].gotPress;
}
for (int i=0;i<256;i++) {
Keys[i].held = Keys[i].heldNow || Keys[i].gotPress;
}
Mouse_risingClick = !(mouse.left.held||mouse.right.held);
Mouse_fallingDirection = mouse.left.gotRelease ? 1 : mouse.right.gotRelease ? -1 : 0;
}