NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
WPAD.h
1#ifndef RVL_SDK_WPAD_H
2#define RVL_SDK_WPAD_H
3#include <types.h>
4
5#include <revolution/SC.h>
6#include <revolution/WUD.h>
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#define WPAD_MAX_DPD_OBJECTS 4
12
13#define WPAD_MIN_DPD_SENS 1
14#define WPAD_MAX_DPD_SENS 5
15
16#define WPAD_MAX_DPD_X 1023
17#define WPAD_MAX_DPD_Y 767
18
19#define WPAD_MAX_SPEAKER_VOLUME 127
20
21extern u8 _scFlush;
22
23typedef WUDAllocFunc WPADAllocFunc;
24typedef WUDFreeFunc WPADFreeFunc;
25
26typedef void (*WPADCallback)(s32 chan, s32 result);
27typedef void (*WPADSamplingCallback)(s32 chan);
28typedef void (*WPADConnectCallback)(s32 chan, s32 result);
29typedef void (*WPADExtensionCallback)(s32 chan, s32 dev);
30
31typedef WUDSyncDeviceCallback WPADSyncDeviceCallback;
32typedef WUDClearDeviceCallback WPADClearDeviceCallback;
33typedef SCFlushCallback WPADSaveCallback;
34
35typedef enum {
36 WPAD_LIB_STATUS_0 = WUD_LIB_STATUS_0,
37 WPAD_LIB_STATUS_1 = WUD_LIB_STATUS_1,
38 WPAD_LIB_STATUS_2 = WUD_LIB_STATUS_2,
39 WPAD_LIB_STATUS_3 = WUD_LIB_STATUS_3,
40 WPAD_LIB_STATUS_4 = WUD_LIB_STATUS_4,
41} WPADLibStatus;
42
43typedef enum {
44 WPAD_ERR_OK = 0,
45 WPAD_ERR_NO_CONTROLLER = -1,
46 WPAD_ERR_COMMUNICATION_ERROR = -2,
47 WPAD_ERR_TRANSFER = -3,
48 WPAD_ERR_INVALID = -4,
49 WPAD_ERR_CORRUPTED = -7,
50
51 WPAD_ERR_BUSY = WPAD_ERR_COMMUNICATION_ERROR,
52} WPADResult;
53
54typedef enum {
55 WPAD_CHAN0,
56 WPAD_CHAN1,
57 WPAD_CHAN2,
58 WPAD_CHAN3,
59
60 WPAD_MAX_CONTROLLERS,
61 WPAD_CHAN_INVALID = -1
62} WPADChannel;
63
64typedef enum {
65 // Wii Remote (Core)
66 WPAD_BUTTON_LEFT = (1 << 0),
67 WPAD_BUTTON_RIGHT = (1 << 1),
68 WPAD_BUTTON_DOWN = (1 << 2),
69 WPAD_BUTTON_UP = (1 << 3),
70
71 WPAD_BUTTON_A = (1 << 11),
72 WPAD_BUTTON_B = (1 << 10),
73 WPAD_BUTTON_1 = (1 << 9),
74 WPAD_BUTTON_2 = (1 << 8),
75
76 WPAD_BUTTON_PLUS = (1 << 4),
77 WPAD_BUTTON_MINUS = (1 << 12),
78 WPAD_BUTTON_HOME = (1 << 15),
79
80 // Nunchuk (Free Style)
81 WPAD_BUTTON_FS_Z = (1 << 13),
82 WPAD_BUTTON_FS_C = (1 << 14),
83
84 // Classic Controller
85 WPAD_BUTTON_CL_LEFT = (1 << 1),
86 WPAD_BUTTON_CL_RIGHT = (1 << 15),
87 WPAD_BUTTON_CL_DOWN = (1 << 14),
88 WPAD_BUTTON_CL_UP = (1 << 0),
89
90 WPAD_BUTTON_CL_A = (1 << 4),
91 WPAD_BUTTON_CL_B = (1 << 6),
92 WPAD_BUTTON_CL_X = (1 << 3),
93 WPAD_BUTTON_CL_Y = (1 << 5),
94 WPAD_BUTTON_CL_ZL = (1 << 7),
95 WPAD_BUTTON_CL_ZR = (1 << 2),
96
97 WPAD_BUTTON_CL_L = (1 << 13),
98 WPAD_BUTTON_CL_R = (1 << 9),
99
100 WPAD_BUTTON_CL_PLUS = (1 << 10),
101 WPAD_BUTTON_CL_MINUS = (1 << 12),
102 WPAD_BUTTON_CL_HOME = (1 << 11),
103} WPADButton;
104
105typedef enum {
106 WPAD_DEV_CORE,
107 WPAD_DEV_FREESTYLE,
108 WPAD_DEV_CLASSIC,
109
110 WPAD_DEV_FUTURE = 251,
111 WPAD_DEV_NOT_SUPPORTED = 252,
112 WPAD_DEV_NOT_FOUND = 253,
113 WPAD_DEV_NULL = 254,
114 WPAD_DEV_UNKNOWN = 255,
115} WPADDeviceType;
116
117typedef enum {
118 WPAD_FMT_CORE_BTN,
119 WPAD_FMT_CORE_BTN_ACC,
120 WPAD_FMT_CORE_BTN_ACC_DPD,
121
122 WPAD_FMT_FS_BTN,
123 WPAD_FMT_FS_BTN_ACC,
124 WPAD_FMT_FS_BTN_ACC_DPD,
125
126 WPAD_FMT_CLASSIC_BTN,
127 WPAD_FMT_CLASSIC_BTN_ACC,
128 WPAD_FMT_CLASSIC_BTN_ACC_DPD,
129
130 WPAD_FMT_BTN_ACC_DPD_EXTENDED,
131} WPADDataFormat;
132
133typedef enum {
134 WPAD_DEV_MODE_NORMAL,
135 WPAD_DEV_MODE_CLASSIC_REDUCED,
136 WPAD_DEV_MODE_CLASSIC_EXTENDED,
137 WPAD_DEV_MODE_CLASSIC_STANDARD,
138} WPADDeviceMode;
139
140typedef enum {
141 WPAD_MOTOR_STOP,
142 WPAD_MOTOR_RUMBLE,
143} WPADMotorCommand;
144
145typedef enum {
146 WPAD_SPEAKER_OFF,
147 WPAD_SPEAKER_ON,
148 WPAD_SPEAKER_MUTE,
149 WPAD_SPEAKER_UNMUTE,
150 WPAD_SPEAKER_PLAY,
151 WPAD_SPEAKER_5
152} WPADSpeakerCommand;
153
154typedef enum {
155 WPAD_DPD_DISABLE = 0x00,
156 WPAD_DPD_BASIC = 0x01,
157 WPAD_DPD_STANDARD = 0x03,
158 WPAD_DPD_EXTENDED = 0x05,
159} WPADDpdCommand;
160
161typedef enum {
162 WPAD_SENSOR_BAR_BOTTOM = SC_SENSOR_BAR_BOTTOM,
163 WPAD_SENSOR_BAR_TOP = SC_SENSOR_BAR_TOP
164} WPADSensorBarPos;
165
166typedef enum {
167 WPAD_MOTOR_OFF = SC_MOTOR_OFF,
168 WPAD_MOTOR_ON = SC_MOTOR_ON
169} WPADMotorMode;
170
171typedef enum {
172 WPAD_ACC_GRAVITY_UNIT_CORE,
173 WPAD_ACC_GRAVITY_UNIT_FS,
174} WPADAccGravityUnitType;
175
176typedef struct DPDObject {
177 s16 x; // at 0x0
178 s16 y; // at 0x2
179 u16 size; // at 0x4
180 u8 traceId; // at 0x6
181} DPDObject;
182
183typedef struct DPDObjEx {
184 s16 range_x1; // at 0x0
185 s16 range_y1; // at 0x2
186 s16 range_x2; // at 0x4
187 s16 range_y2; // at 0x6
188 u16 pixel; // at 0x8
189 s8 radius; // at 0xA
190} DPDObjEx;
191
192typedef struct WPADInfo {
193 BOOL dpd; // at 0x0
194 BOOL speaker; // at 0x4
195 BOOL attach; // at 0x8
196 BOOL lowBat; // at 0xC
197 BOOL nearempty; // at 0x10
198 u8 battery; // at 0x14
199 u8 led; // at 0x15
200 u8 protocol; // at 0x16
201 u8 firmware; // at 0x17
202} WPADInfo;
203
204typedef struct WPADStatus {
205 u16 button; // at 0x0
206 s16 accX; // at 0x2
207 s16 accY; // at 0x4
208 s16 accZ; // at 0x6
209 DPDObject obj[WPAD_MAX_DPD_OBJECTS]; // at 0x8
210 u8 dev; // at 0x28
211 s8 err; // at 0x29
212} WPADStatus;
213
214typedef struct WPADStatusEx {
215 u16 button; // at 0x0
216 s16 accX; // at 0x2
217 s16 accY; // at 0x4
218 s16 accZ; // at 0x6
219 DPDObject obj[WPAD_MAX_DPD_OBJECTS]; // at 0x8
220 u8 dev; // at 0x28
221 s8 err; // at 0x29
222
223 DPDObjEx exp[WPAD_MAX_DPD_OBJECTS]; // at 0x2A
225
226typedef struct WPADFSStatus {
227 u16 button; // at 0x0
228 s16 accX; // at 0x2
229 s16 accY; // at 0x4
230 s16 accZ; // at 0x6
231 DPDObject obj[WPAD_MAX_DPD_OBJECTS]; // at 0x8
232 u8 dev; // at 0x28
233 s8 err; // at 0x29
234
235 s16 fsAccX; // at 0x2A
236 s16 fsAccY; // at 0x2C
237 s16 fsAccZ; // at 0x2E
238 s8 fsStickX; // at 0x30
239 s8 fsStickY; // at 0x31
241
242typedef struct WPADCLStatus {
243 u16 button; // at 0x0
244 s16 accX; // at 0x2
245 s16 accY; // at 0x4
246 s16 accZ; // at 0x6
247 DPDObject obj[WPAD_MAX_DPD_OBJECTS]; // at 0x8
248 u8 dev; // at 0x28
249 s8 err; // at 0x29
250
251 u16 clButton; // at 0x2A
252 s16 clLStickX; // at 0x2C
253 s16 clLStickY; // at 0x2E
254 s16 clRStickX; // at 0x30
255 s16 clRStickY; // at 0x32
256 u8 clTriggerL; // at 0x34
257 u8 clTriggerR; // at 0x35
259
260typedef struct WPADAccGravityUnit {
261 s16 x; // at 0x0
262 s16 y; // at 0x2
263 s16 z; // at 0x4
265
266void WPADInit(void);
267void WPADShutdown(void);
268
269BOOL WPADStartSimpleSync(void);
270BOOL WPADStartFastSimpleSync(void);
271BOOL WPADStopSimpleSync(void);
272BOOL WPADStartClearDevice(void);
273
274WPADSyncDeviceCallback
275WPADSetSimpleSyncCallback(WPADSyncDeviceCallback pCallback);
276
277WPADClearDeviceCallback
278WPADSetClearDeviceCallback(WPADClearDeviceCallback pCallback);
279
280void WPADRegisterAllocator(WPADAllocFunc pAllocFunc, WPADFreeFunc pFreeFunc);
281u32 WPADGetWorkMemorySize(void);
282
283WPADLibStatus WPADGetStatus(void);
284void WPADGetAddress(s32 chan, BD_ADDR_PTR pAddr);
285u8 WPADGetSensorBarPosition(void);
286
287void WPADGetAccGravityUnit(s32 chan, u32 type, WPADAccGravityUnit* pAcc);
288
289void WPADDisconnect(s32 chan);
290s32 WPADProbe(s32 chan, s32* pDevType);
291
292WPADSamplingCallback WPADSetSamplingCallback(s32 chan,
293 WPADSamplingCallback pCallback);
294WPADConnectCallback WPADSetConnectCallback(s32 chan,
295 WPADConnectCallback pCallback);
296WPADExtensionCallback WPADSetExtensionCallback(s32 chan,
297 WPADExtensionCallback pCallback);
298
299u32 WPADGetDataFormat(s32 chan);
300s32 WPADSetDataFormat(s32 chan, u32 format);
301
302s32 WPADGetInfoAsync(s32 chan, WPADInfo* pInfo, WPADCallback pCallback);
303
304void WPADControlMotor(s32 chan, u32 command);
305void WPADEnableMotor(BOOL enable);
306BOOL WPADIsMotorEnabled(void);
307
308s32 WPADControlLed(s32 chan, u8 flags, WPADCallback pCallback);
309
310BOOL WPADSaveConfig(WPADSaveCallback pCallback);
311
312void WPADRead(s32 chan, WPADStatus* pStatus);
313void WPADSetAutoSamplingBuf(s32 chan, void* pBuffer, u32 len);
314
315BOOL WPADIsSpeakerEnabled(s32 chan);
316s32 WPADControlSpeaker(s32 chan, u32 command, WPADCallback pCallback);
317u8 WPADGetSpeakerVolume(void);
318void WPADSetSpeakerVolume(u8 volume);
319
320BOOL WPADCanSendStreamData(s32 chan);
321s32 WPADSendStreamData(s32 chan, void* pData, u16 len);
322
323u8 WPADGetDpdSensitivity(void);
324BOOL WPADSetSensorBarPower(BOOL enable);
325BOOL WPADIsDpdEnabled(s32 chan);
326s32 WPADControlDpd(s32 chan, u32 command, WPADCallback pCallback);
327
328void WPADRecalibrate(s32 chan);
329
330//! /////////////////////////////////
331
332s32 WPADReadFaceData(s32 chan, void* dst, u32 size, u32 src, WPADCallback cb);
333
334//! /////////////////////////////////
335
336#ifdef __cplusplus
337}
338#endif
339#endif