Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/RSDKv5/RSDK/User/Core/UserCore.hpp
1162 views
1
#ifndef USER_CORE_H
2
#define USER_CORE_H
3
4
namespace RSDK
5
{
6
7
namespace SKU
8
{
9
10
#undef STATUS_TIMEOUT
11
12
enum StatusCodes {
13
STATUS_NONE = 0,
14
STATUS_CONTINUE = 100,
15
STATUS_OK = 200,
16
STATUS_FORBIDDEN = 403,
17
STATUS_NOTFOUND = 404,
18
STATUS_ERROR = 500,
19
STATUS_NOWIFI = 503,
20
STATUS_TIMEOUT = 504,
21
STATUS_CORRUPT = 505,
22
STATUS_NOSPACE = 506,
23
};
24
25
#if RETRO_REV02
26
struct SKUInfo {
27
int32 platform;
28
int32 language;
29
int32 region;
30
};
31
32
struct UnknownInfo {
33
int32 unknown1;
34
int32 unknown2;
35
int32 unknown3;
36
int32 unknown4;
37
bool32 pausePress;
38
int32 unknown5;
39
int32 unknown6;
40
int32 unknown7;
41
int32 unknown8;
42
int32 unknown9;
43
bool32 anyKeyPress;
44
int32 unknown10;
45
};
46
47
extern SKUInfo curSKU;
48
extern UnknownInfo unknownInfo;
49
50
#define Unknown_pausePress UnknownInfo->pausePress
51
#define Unknown_anyKeyPress UnknownInfo->anyPress
52
#else
53
#define Unknown_pausePress TouchInfo->pausePress
54
#define Unknown_anyKeyPress TouchInfo->anyPress
55
#endif
56
57
#if RETRO_REV02
58
59
// This is the base struct, it serves as the base for any API-specific stats
60
// This struct should never be removed
61
struct UserCore {
62
virtual ~UserCore() = default;
63
64
virtual void Shutdown() {}
65
virtual bool32 CheckAPIInitialized() { return true; }
66
virtual bool32 CheckFocusLost() { return false; }
67
virtual bool32 CheckEnginePause() { return false; }
68
virtual void StageLoad();
69
virtual void FrameInit();
70
// I do not know what this is, both PC & Switch vers never call it as far as I can see
71
virtual void OnUnknownEvent();
72
virtual int32 GetUserLanguage() { return LANGUAGE_EN; }
73
virtual int32 GetUserRegion() { return REGION_US; }
74
virtual int32 GetUserPlatform() { return PLATFORM_PC; }
75
virtual bool32 GetConfirmButtonFlip() { return false; }
76
virtual void LaunchManual() {}
77
virtual void ExitGame() {}
78
virtual int32 GetDefaultGamepadType() { return (DEVICE_API_NONE << 16) | (DEVICE_TYPE_CONTROLLER << 8) | (0 << 0); }
79
virtual bool32 IsOverlayEnabled(uint32 deviceID) { return false; }
80
virtual bool32 CheckDLC(uint8 id)
81
{
82
if (id < 8)
83
return values[id];
84
else
85
return 0;
86
}
87
#if RETRO_VER_EGS
88
virtual bool32 SetupExtensionOverlay() { return true; }
89
virtual bool32 CanShowExtensionOverlay(int32 overlay) { return true; }
90
virtual bool32 ShowExtensionOverlay(int32 overlay) { return false; }
91
virtual bool32 CanShowAltExtensionOverlay(int32 overlay) { return false; }
92
virtual bool32 ShowAltExtensionOverlay(int32 overlay) { return ShowExtensionOverlay(overlay); }
93
virtual int32 GetConnectingStringID() { return -1; }
94
virtual bool32 ShowLimitedVideoOptions(int32 id) { return false; }
95
virtual void InitInputDevices() {}
96
virtual void Unknown() {}
97
#else
98
virtual bool32 ShowExtensionOverlay(int32 overlay) { return false; }
99
#endif
100
101
bool32 values[8] = { false, false, false, false, false, false, false, false };
102
uint8 valueCount = 0;
103
104
// Not Original, but I gotta store it somewhere /shrug
105
uint8 focusState = 0;
106
};
107
108
extern UserCore *userCore;
109
110
// ====================
111
// API Cores
112
// ====================
113
114
// Dummy API
115
#if RETRO_USERCORE_DUMMY
116
#include "RSDK/User/Dummy/DummyCore.hpp"
117
#endif
118
119
// Steam API
120
#if RETRO_USERCORE_STEAM
121
#include "RSDK/User/Steam/SteamCore.hpp"
122
#endif
123
124
// Epic Games API
125
#if RETRO_USERCORE_EOS
126
#include "RSDK/User/EOS/EOSCore.hpp"
127
#endif
128
129
// Switch API
130
#if RETRO_USERCORE_NX
131
#include "RSDK/User/NX/NXCore.hpp"
132
#endif
133
134
#endif
135
136
void InitUserCore();
137
void ReleaseUserCore();
138
void SaveUserData();
139
140
#if RETRO_REV02
141
void HandleUserStatuses();
142
#endif
143
144
#if RETRO_REV02
145
inline int32 GetUserLanguage() { return userCore->GetUserLanguage(); }
146
inline bool32 GetConfirmButtonFlip() { return userCore->GetConfirmButtonFlip(); }
147
#if RETRO_REV0U
148
inline int32 GetDefaultGamepadType() { return userCore->GetDefaultGamepadType(); }
149
#endif
150
inline void ExitGame() { userCore->ExitGame(); }
151
inline void LaunchManual() { userCore->LaunchManual(); }
152
inline bool32 IsOverlayEnabled(uint32 deviceID) { return userCore->IsOverlayEnabled(deviceID); }
153
inline bool32 CheckDLC(uint8 id) { return userCore->CheckDLC(id); }
154
inline bool32 ShowExtensionOverlay(int32 overlay) { return userCore->ShowExtensionOverlay(overlay); }
155
#else
156
bool32 GetConfirmButtonFlip();
157
void LaunchManual();
158
void ExitGame();
159
int32 GetDefaultGamepadType();
160
bool32 ShowExtensionOverlay(uint8 overlay);
161
#endif
162
163
bool32 GetXYButtonFlip();
164
165
#if RETRO_VER_EGS
166
inline bool32 SetupExtensionOverlay() { return userCore->SetupExtensionOverlay(); }
167
inline bool32 CanShowExtensionOverlay(int32 overlay) { return userCore->CanShowExtensionOverlay(overlay); }
168
inline bool32 CanShowAltExtensionOverlay(int32 overlay) { return userCore->CanShowAltExtensionOverlay(overlay); }
169
inline bool32 ShowAltExtensionOverlay(int32 overlay) { return userCore->ShowAltExtensionOverlay(overlay); }
170
inline int32 GetConnectingStringID() { return userCore->GetConnectingStringID(); }
171
inline void ShowLimitedVideoOptions(int32 id) { userCore->ShowLimitedVideoOptions(id); }
172
#endif
173
174
} // namespace SKU
175
176
#if !RETRO_USE_ORIGINAL_CODE
177
struct CustomSettings {
178
int8 region;
179
bool32 confirmButtonFlip;
180
bool32 xyButtonFlip;
181
bool32 enableControllerDebugging;
182
bool32 disableFocusPause;
183
#if RETRO_REV0U
184
bool32 forceScripts;
185
#endif
186
int32 maxPixWidth;
187
char username[0x80];
188
};
189
190
extern CustomSettings customSettings;
191
#endif
192
193
void LoadSettingsINI();
194
void SaveSettingsINI(bool32 writeToFile);
195
196
inline void WriteText(FileIO *file, const char *string, ...)
197
{
198
// make the full string
199
char buffer[0x100];
200
va_list args;
201
va_start(args, string);
202
vsprintf(buffer, string, args);
203
va_end(args);
204
205
fWrite(buffer, sizeof(char), strlen(buffer), file);
206
}
207
208
} // namespace RSDK
209
210
#endif // !USER_CORE_H
211
212