-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgamepad.c
55 lines (44 loc) · 1.08 KB
/
gamepad.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
51
52
53
54
55
#include <libpad.h>
struct s_gamePad {
u_char status:8;
u_char recvSize:4;
u_char type:4;
u_char select:1;
u_char na2:1;
u_char na1:1;
u_char start:1;
u_char up:1;
u_char right:1;
u_char down:1;
u_char left:1;
u_char l2:1;
u_char r2:1;
u_char l1:1;
u_char r1:1;
u_char triangle:1;
u_char circle:1;
u_char ex:1;
u_char square:1;
u_char an1h;
u_char an1v;
u_char an2h;
u_char an2v;
u_char padding[26];
};
struct s_gamePad gamePad[2];
u_char gamePadLeft(u_char pad) {
if (!gamePad[pad].left) return 1;
return ((gamePad[pad].type==5 || gamePad[pad].type==7) && gamePad[pad].an2h<64);
}
u_char gamePadRight(u_char pad) {
if (!gamePad[pad].right) return 1;
return ((gamePad[pad].type==5 || gamePad[pad].type==7) && gamePad[pad].an2h>192);
}
u_char gamePadUp(u_char pad) {
if (!gamePad[pad].up) return 1;
return ((gamePad[pad].type==5 || gamePad[pad].type==7) && gamePad[pad].an2v<64);
}
u_char gamePadDown(u_char pad) {
if (!gamePad[pad].down) return 1;
return ((gamePad[pad].type==5 || gamePad[pad].type==7) && gamePad[pad].an2v>192);
}