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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
#include "global.h"
#include <string.h>
void PadUtils_Init(Input* input) {
memset(input, 0, sizeof(Input));
}
void func_800FCB70(void) {
}
void PadUtils_ResetPressRel(Input* input) {
input->press.button = 0;
input->rel.button = 0;
}
u32 PadUtils_CheckCurExact(Input* input, u16 value) {
return value == input->cur.button;
}
u32 PadUtils_CheckCur(Input* input, u16 key) {
return key == (input->cur.button & key);
}
u32 PadUtils_CheckPressed(Input* input, u16 key) {
return key == (input->press.button & key);
}
u32 PadUtils_CheckReleased(Input* input, u16 key) {
return key == (input->rel.button & key);
}
u16 PadUtils_GetCurButton(Input* input) {
return input->cur.button;
}
u16 PadUtils_GetPressButton(Input* input) {
return input->press.button;
}
s8 PadUtils_GetCurX(Input* input) {
return input->cur.stick_x;
}
s8 PadUtils_GetCurY(Input* input) {
return input->cur.stick_y;
}
void PadUtils_SetRelXY(Input* input, s32 x, s32 y) {
input->rel.stick_x = x;
input->rel.stick_y = y;
}
s8 PadUtils_GetRelXImpl(Input* input) {
return input->rel.stick_x;
}
s8 PadUtils_GetRelYImpl(Input* input) {
return input->rel.stick_y;
}
s8 PadUtils_GetRelX(Input* input) {
return PadUtils_GetRelXImpl(input);
}
s8 PadUtils_GetRelY(Input* input) {
return PadUtils_GetRelYImpl(input);
}
void PadUtils_UpdateRelXY(Input* input) {
s32 curX = PadUtils_GetCurX(input);
s32 curY = PadUtils_GetCurY(input);
s32 relX;
s32 relY;
if (curX > 7) {
relX = (curX < 0x43) ? curX - 7 : 0x43 - 7;
} else if (curX < -7) {
relX = (curX > -0x43) ? curX + 7 : -0x43 + 7;
} else {
relX = 0;
}
if (curY > 7) {
relY = (curY < 0x43) ? curY - 7 : 0x43 - 7;
} else if (curY < -7) {
relY = (curY > -0x43) ? curY + 7 : -0x43 + 7;
} else {
relY = 0;
}
PadUtils_SetRelXY(input, relX, relY);
}
// #region SOH [Enhancement]
s8 PadUtils_GetCurRX(Input* input) {
return input->cur.right_stick_x;
}
s8 PadUtils_GetCurRY(Input* input) {
return input->cur.right_stick_y;
}
void PadUtils_SetRelRXY(Input* input, s32 x, s32 y) {
input->rel.right_stick_x = x;
input->rel.right_stick_y = y;
}
s8 PadUtils_GetRelRXImpl(Input* input) {
return input->rel.right_stick_x;
}
s8 PadUtils_GetRelRYImpl(Input* input) {
return input->rel.right_stick_y;
}
s8 PadUtils_GetRelRX(Input* input) {
return PadUtils_GetRelRXImpl(input);
}
s8 PadUtils_GetRelRY(Input* input) {
return PadUtils_GetRelRYImpl(input);
}
void PadUtils_UpdateRelRXY(Input* input) {
s32 curX = PadUtils_GetCurRX(input);
s32 curY = PadUtils_GetCurRY(input);
s32 relX;
s32 relY;
if (curX > 7) {
relX = (curX < 0x43) ? curX - 7 : 0x43 - 7;
} else if (curX < -7) {
relX = (curX > -0x43) ? curX + 7 : -0x43 + 7;
} else {
relX = 0;
}
if (curY > 7) {
relY = (curY < 0x43) ? curY - 7 : 0x43 - 7;
} else if (curY < -7) {
relY = (curY > -0x43) ? curY + 7 : -0x43 + 7;
} else {
relY = 0;
}
PadUtils_SetRelRXY(input, relX, relY);
}
// #endregion
|