-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmisc.c
executable file
·191 lines (166 loc) · 6.81 KB
/
misc.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#include <vitasdk.h>
#include <taihen.h>
#include "osd.h"
#include "main.h"
static uint8_t sceCtrlPeekBufferPositive_used = 0;
static uint8_t sceCtrlPeekBufferNegative_used = 0;
static uint8_t sceCtrlReadBufferPositive_used = 0;
static uint8_t sceCtrlReadBufferNegative_used = 0;
static uint8_t sceMotionGetState_used = 0;
static uint8_t sceMotionGetSensorState_used = 0;
static uint8_t sceMotionGetBasicOrientation_used = 0;
static uint8_t sceTouchPeek_front = 0;
static uint8_t sceTouchPeek_back = 0;
static uint8_t sceTouchRead_front = 0;
static uint8_t sceTouchRead_back = 0;
static int sceCtrlPeekBufferPositive_patched(int port, SceCtrlData *pad_data, int count) {
int ret = TAI_CONTINUE(int, g_hookrefs[13], port, pad_data, count);
sceCtrlPeekBufferPositive_used = 1;
if (g_menuVisible && pad_data)
pad_data->buttons = 0;
return ret;
}
static int sceCtrlPeekBufferNegative_patched(int port, SceCtrlData *pad_data, int count) {
int ret = TAI_CONTINUE(int, g_hookrefs[14], port, pad_data, count);
sceCtrlPeekBufferNegative_used = 1;
if (g_menuVisible && pad_data)
pad_data->buttons = 0;
return ret;
}
static int sceCtrlReadBufferPositive_patched(int port, SceCtrlData *pad_data, int count) {
int ret = TAI_CONTINUE(int, g_hookrefs[15], port, pad_data, count);
sceCtrlReadBufferPositive_used = 1;
if (g_menuVisible && pad_data)
pad_data->buttons = 0;
return ret;
}
static int sceCtrlReadBufferNegative_patched(int port, SceCtrlData *pad_data, int count) {
int ret = TAI_CONTINUE(int, g_hookrefs[16], port, pad_data, count);
sceCtrlReadBufferNegative_used = 1;
if (g_menuVisible && pad_data)
pad_data->buttons = 0;
return ret;
}
static int sceMotionGetState_patched(SceMotionState *motionState) {
sceMotionGetState_used = 1;
return TAI_CONTINUE(int, g_hookrefs[17], motionState);
}
static int sceMotionGetSensorState_patched(SceMotionSensorState *sensorState, int numRecords) {
sceMotionGetSensorState_used = 1;
return TAI_CONTINUE(int, g_hookrefs[18], sensorState, numRecords);
}
static int sceMotionGetBasicOrientation_patched(SceFVector3 *basicOrientation) {
sceMotionGetBasicOrientation_used = 1;
return TAI_CONTINUE(int, g_hookrefs[19], basicOrientation);
}
static int sceTouchPeek_patched(SceUInt32 port, SceTouchData *pData, SceUInt32 nBufs) {
int ret = TAI_CONTINUE(int, g_hookrefs[20], port, pData, nBufs);
if (port == SCE_TOUCH_PORT_FRONT) {
sceTouchPeek_front = 1;
} else if (port == SCE_TOUCH_PORT_BACK) {
sceTouchPeek_back = 1;
}
if (g_menuVisible && pData) {
pData->reportNum = 0;
memset(pData->report, 0, sizeof(SceTouchReport) * SCE_TOUCH_MAX_REPORT);
}
return ret;
}
static int sceTouchRead_patched(SceUInt32 port, SceTouchData *pData, SceUInt32 nBufs) {
int ret = TAI_CONTINUE(int, g_hookrefs[21], port, pData, nBufs);
if (port == SCE_TOUCH_PORT_FRONT) {
sceTouchRead_front = 1;
} else if (port == SCE_TOUCH_PORT_BACK) {
sceTouchRead_back = 1;
}
if (g_menuVisible && pData) {
pData->reportNum = 0;
memset(pData->report, 0, sizeof(SceTouchReport) * SCE_TOUCH_MAX_REPORT);
}
return ret;
}
void drawMiscMenu(const SceDisplayFrameBuf *pParam) {
osdSetTextScale(2);
osdDrawStringF((pParam->width / 2) - osdGetTextWidth(MENU_TITLE_MISC) / 2, 5, MENU_TITLE_MISC);
osdSetTextScale(1);
osdDrawStringF(10, 60, "Input handlers:");
int x = 30, y = 82;
if (sceCtrlPeekBufferPositive_used)
osdDrawStringF(x, y += 22, "sceCtrlPeekBufferPositive()");
if (sceCtrlPeekBufferNegative_used)
osdDrawStringF(x, y += 22, "sceCtrlPeekBufferNegative()");
if (sceCtrlReadBufferPositive_used)
osdDrawStringF(x, y += 22, "sceCtrlReadBufferPositive()");
if (sceCtrlReadBufferNegative_used)
osdDrawStringF(x, y += 22, "sceCtrlReadBufferNegative()");
if (sceMotionGetState_used)
osdDrawStringF(x, y += 22, "sceMotionGetState()");
if (sceMotionGetSensorState_used)
osdDrawStringF(x, y += 22, "sceMotionGetSensorState()");
if (sceMotionGetBasicOrientation_used)
osdDrawStringF(x, y += 22, "sceMotionGetBasicOrientation()");
if (sceTouchPeek_front)
osdDrawStringF(x, y += 22, "sceTouchPeek( FRONT )");
if (sceTouchPeek_back)
osdDrawStringF(x, y += 22, "sceTouchPeek( BACK )");
if (sceTouchRead_front)
osdDrawStringF(x, y += 22, "sceTouchRead( FRONT )");
if (sceTouchRead_back)
osdDrawStringF(x, y += 22, "sceTouchRead( BACK )");
}
void setupMiscMenu() {
g_hooks[13] = taiHookFunctionImport(
&g_hookrefs[13],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0xA9C3CED6,
sceCtrlPeekBufferPositive_patched);
g_hooks[14] = taiHookFunctionImport(
&g_hookrefs[14],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x104ED1A7,
sceCtrlPeekBufferNegative_patched);
g_hooks[15] = taiHookFunctionImport(
&g_hookrefs[15],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x67E7AB83,
sceCtrlReadBufferPositive_patched);
g_hooks[16] = taiHookFunctionImport(
&g_hookrefs[16],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x15F96FB0,
sceCtrlReadBufferNegative_patched);
g_hooks[17] = taiHookFunctionImport(
&g_hookrefs[17],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0xBDB32767,
sceMotionGetState_patched);
g_hooks[18] = taiHookFunctionImport(
&g_hookrefs[18],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x47D679EA,
sceMotionGetSensorState_patched);
g_hooks[19] = taiHookFunctionImport(
&g_hookrefs[19],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x4F28BFE0,
sceMotionGetBasicOrientation_patched);
g_hooks[20] = taiHookFunctionImport(
&g_hookrefs[20],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0xFF082DF0,
sceTouchPeek_patched);
g_hooks[21] = taiHookFunctionImport(
&g_hookrefs[21],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x169A1D58,
sceTouchRead_patched);
}