-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunction_patches.cpp
More file actions
62 lines (49 loc) · 1.87 KB
/
Copy pathfunction_patches.cpp
File metadata and controls
62 lines (49 loc) · 1.87 KB
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
#include "ButtonComboInfo.h"
#include "ButtonComboManager.h"
#include "TVOverlayManager.h"
#include "globals.h"
#include <function_patcher/fpatching_defines.h>
#include <logger.h>
#include <padscore/wpad.h>
#include <vpad/input.h>
DECL_FUNCTION(int32_t, VPADRead, VPADChan chan, VPADStatus *buffer, uint32_t buffer_size, VPADReadError *error) {
VPADReadError real_error;
const int32_t result = real_VPADRead(chan, buffer, buffer_size, &real_error);
if (result > 0 && real_error == VPAD_READ_SUCCESS) {
if (const auto comboManager = gButtonComboManager) {
comboManager->UpdateInputVPAD(chan, buffer, result > static_cast<int32_t>(buffer_size) ? buffer_size : result, error);
}
}
if (error) {
*error = real_error;
}
TVOverlayManager::UpdateVPAD(chan);
return result;
}
DECL_FUNCTION(void, WPADRead, WPADChan chan, WPADStatus *data) {
real_WPADRead(chan, data);
if (const auto comboManager = gButtonComboManager) {
comboManager->UpdateInputWPAD(chan, data);
}
}
struct WUT_PACKED CCRCDCCallbackData {
uint32_t attached;
VPADChan chan;
WUT_UNKNOWN_BYTES(6);
};
DECL_FUNCTION(void, __VPADBASEAttachCallback, CCRCDCCallbackData *data, void *context) {
real___VPADBASEAttachCallback(data, context);
if (data) {
if (data->attached) {
TVOverlayManager::InitVPAD(data->chan);
} else {
TVOverlayManager::ResetVPAD(data->chan);
}
}
}
function_replacement_data_t function_replacements[] = {
REPLACE_FUNCTION(VPADRead, LIBRARY_VPAD, VPADRead),
REPLACE_FUNCTION(WPADRead, LIBRARY_PADSCORE, WPADRead),
REPLACE_FUNCTION_VIA_ADDRESS(__VPADBASEAttachCallback, 0x31000000 + 0x0200146c - 0x00EE0100, 0x0200146c - 0x00EE0100),
};
uint32_t function_replacements_size = sizeof(function_replacements) / sizeof(function_replacement_data_t);