wut  v1.7.0
Wii U Toolchain
kpad.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include <padscore/wpad.h>
4 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
18 typedef enum WPADChan KPADChan;
20 typedef enum WPADDataFormat KPADDataFormat;
24 typedef enum WPADMplsMode KPADMplsMode;
25 
26 typedef struct KPADStatus KPADStatus;
27 typedef struct KPADVec2D KPADVec2D;
28 typedef struct KPADVec3D KPADVec3D;
29 
31 typedef enum KPADError
32 {
46 
48 struct KPADVec2D
49 {
51  float x;
53  float y;
54 };
55 WUT_CHECK_OFFSET(KPADVec2D, 0x00, x);
56 WUT_CHECK_OFFSET(KPADVec2D, 0x04, y);
57 WUT_CHECK_SIZE(KPADVec2D, 0x08);
58 
60 struct KPADVec3D
61 {
63  float x;
65  float y;
67  float z;
68 };
69 WUT_CHECK_OFFSET(KPADVec3D, 0x00, x);
70 WUT_CHECK_OFFSET(KPADVec3D, 0x04, y);
71 WUT_CHECK_OFFSET(KPADVec3D, 0x08, z);
72 WUT_CHECK_SIZE(KPADVec3D, 0x0C);
73 
75 struct KPADStatus
76 {
78  uint32_t hold;
79 
81  uint32_t trigger;
82 
84  uint32_t release;
85 
88 
90  float accMagnitude;
91 
93  float accVariation;
94 
97 
98  WUT_UNKNOWN_BYTES(3 * 4);
99 
102 
103  WUT_UNKNOWN_BYTES(8 * 4);
104 
106  uint8_t extensionType;
107 
109  int8_t error;
110 
112  int8_t posValid;
113 
115  uint8_t format;
116 
118  union
119  {
121  struct
122  {
124  KPADVec2D stick;
126  KPADVec3D acc;
128  float accMagnitude;
130  float accVariation;
132  uint32_t hold;
134  uint32_t trigger;
136  uint32_t release;
137  } nunchuk;
138 
140  struct
141  {
143  uint32_t hold;
145  uint32_t trigger;
147  uint32_t release;
149  KPADVec2D leftStick;
151  KPADVec2D rightStick;
153  float leftTrigger;
155  float rightTrigger;
156  } classic;
157 
159  struct
160  {
162  uint32_t hold;
164  uint32_t trigger;
166  uint32_t release;
168  KPADVec2D leftStick;
170  KPADVec2D rightStick;
172  int32_t charging;
174  int32_t wired;
175  } pro;
176 
177  WUT_UNKNOWN_BYTES(20 * 4);
178  };
179 
180  WUT_UNKNOWN_BYTES(16 * 4);
181 };
182 WUT_CHECK_OFFSET(KPADStatus, 0x00, hold);
183 WUT_CHECK_OFFSET(KPADStatus, 0x04, trigger);
184 WUT_CHECK_OFFSET(KPADStatus, 0x08, release);
185 WUT_CHECK_OFFSET(KPADStatus, 0x0C, acc);
186 WUT_CHECK_OFFSET(KPADStatus, 0x18, accMagnitude);
187 WUT_CHECK_OFFSET(KPADStatus, 0x1C, accVariation);
188 WUT_CHECK_OFFSET(KPADStatus, 0x20, pos);
189 WUT_CHECK_OFFSET(KPADStatus, 0x34, angle);
190 WUT_CHECK_OFFSET(KPADStatus, 0x5C, extensionType);
191 WUT_CHECK_OFFSET(KPADStatus, 0x5D, error);
192 WUT_CHECK_OFFSET(KPADStatus, 0x5E, posValid);
193 WUT_CHECK_OFFSET(KPADStatus, 0x5F, format);
194 // For WPAD_EXT_NUNCHUK
195 WUT_CHECK_OFFSET(KPADStatus, 0x60, nunchuk.stick);
196 WUT_CHECK_OFFSET(KPADStatus, 0x68, nunchuk.acc);
197 WUT_CHECK_OFFSET(KPADStatus, 0x74, nunchuk.accMagnitude);
198 WUT_CHECK_OFFSET(KPADStatus, 0x78, nunchuk.accVariation);
199 WUT_CHECK_OFFSET(KPADStatus, 0x7C, nunchuk.hold);
200 WUT_CHECK_OFFSET(KPADStatus, 0x80, nunchuk.trigger);
201 WUT_CHECK_OFFSET(KPADStatus, 0x84, nunchuk.release);
202 // For WPAD_EXT_CLASSIC
203 WUT_CHECK_OFFSET(KPADStatus, 0x60, classic.hold);
204 WUT_CHECK_OFFSET(KPADStatus, 0x64, classic.trigger);
205 WUT_CHECK_OFFSET(KPADStatus, 0x68, classic.release);
206 WUT_CHECK_OFFSET(KPADStatus, 0x6C, classic.leftStick);
207 WUT_CHECK_OFFSET(KPADStatus, 0x74, classic.rightStick);
208 WUT_CHECK_OFFSET(KPADStatus, 0x7C, classic.leftTrigger);
209 WUT_CHECK_OFFSET(KPADStatus, 0x80, classic.rightTrigger);
210 // For WPAD_EXT_PRO_CONTROLLER
211 WUT_CHECK_OFFSET(KPADStatus, 0x60, pro.hold);
212 WUT_CHECK_OFFSET(KPADStatus, 0x64, pro.trigger);
213 WUT_CHECK_OFFSET(KPADStatus, 0x68, pro.release);
214 WUT_CHECK_OFFSET(KPADStatus, 0x6C, pro.leftStick);
215 WUT_CHECK_OFFSET(KPADStatus, 0x74, pro.rightStick);
216 WUT_CHECK_OFFSET(KPADStatus, 0x7C, pro.charging);
217 WUT_CHECK_OFFSET(KPADStatus, 0x80, pro.wired);
218 WUT_CHECK_SIZE(KPADStatus, 0xF0);
219 
221 
225 void
227 
231 void
233 
249 int32_t
251  KPADStatus *data,
252  uint32_t size);
253 
272 int32_t
274  KPADStatus *data,
275  uint32_t size,
276  KPADError *error);
277 
287 int32_t
288 KPADSetMaxControllers(uint32_t maxControllers);
289 
296 uint32_t
298 
305 uint32_t
307 
322  KPADConnectCallback callback);
323 
332 void
334  KPADMplsMode mode);
335 
339 void
341 
349 
353 void
355 
359 void
361 
362 #ifdef __cplusplus
363 }
364 #endif
365 
uint8_t extensionType
Value from KPADExtensionType.
Definition: kpad.h:103
KPADVec3D acc
Indicates the value of the acceleration sensor.
Definition: kpad.h:87
uint32_t hold
Indicates what KPADButtons are held down.
Definition: kpad.h:78
int8_t posValid
Validity of the result.
Definition: kpad.h:112
KPADVec2D angle
Angle.
Definition: kpad.h:98
uint8_t format
Value from KPADDataFormat.
Definition: kpad.h:115
float y
y.
Definition: kpad.h:53
uint32_t release
Indicates what KPADButtons have been released since last sample.
Definition: kpad.h:84
int8_t error
Value from KPADError.
Definition: kpad.h:109
uint32_t trigger
Indicates what KPADButtons have been pressed since last sample.
Definition: kpad.h:81
float x
x.
Definition: kpad.h:51
float accVariation
Indicates the variation in acceleration.
Definition: kpad.h:93
float accMagnitude
Indicates the magnitude of acceleration.
Definition: kpad.h:90
float z
z.
Definition: kpad.h:67
KPADVec2D pos
Indicates the position where the Wii Remote is pointing.
Definition: kpad.h:96
WPADConnectCallback KPADConnectCallback
Definition: kpad.h:182
void KPADShutdown()
Cleans up and frees the KPAD library.
KPADError
Error.
Definition: kpad.h:32
enum WPADExtensionType KPADExtensionType
Extension type.
Definition: kpad.h:22
enum WPADDataFormat KPADDataFormat
Data format.
Definition: kpad.h:20
void KPADDisableDPD(KPADChan chan)
Disable IR pointing.
KPADConnectCallback KPADSetConnectCallback(KPADChan chan, KPADConnectCallback callback)
Set a callback for when a controller connection status changes.
uint32_t KPADGetGameMaxControllers(void)
Get the maximum amount of controllers which can be connected, as reported by IOS-PAD.
void KPADInit()
Initialises the KPAD library for use.
enum WPADMplsMode KPADMplsMode
MotionPlus Mode.
Definition: kpad.h:24
uint32_t KPADGetMaxControllers(void)
Get the maximum amount of controllers which can be connected to the system.
void KPADDisableMpls(KPADChan channel)
Disables MotionPlus for the controller.
enum WPADChan KPADChan
Wii Remote channel.
Definition: kpad.h:18
int32_t KPADRead(KPADChan chan, KPADStatus *data, uint32_t size)
Read data from the desired controller.
KPADMplsMode KPADGetMplsStatus(KPADChan chan)
Get MotionPlus mode.
int32_t KPADReadEx(KPADChan chan, KPADStatus *data, uint32_t size, KPADError *error)
Read data from the desired controller.
void KPADEnableMpls(KPADChan channel, KPADMplsMode mode)
Sets MotionPlus for the controller in specified mode.
void KPADEnableDPD(KPADChan chan)
Enable IR pointing.
int32_t KPADSetMaxControllers(uint32_t maxControllers)
Set the maximum amount of controllers which can be connected to the system.
@ KPAD_ERROR_OK
No error occurred, and data was written to the buffers.
Definition: kpad.h:34
@ KPAD_ERROR_WPAD_UNINIT
WPAD is uninitialized, shouldn't happen unless WPADShutdown() is manually called.
Definition: kpad.h:40
@ KPAD_ERROR_BUSY
KPAD channel is busy, perhaps being accessed by another thread.
Definition: kpad.h:42
@ KPAD_ERROR_NO_SAMPLES
There was no sample new data available to write.
Definition: kpad.h:36
@ KPAD_ERROR_INVALID_CONTROLLER
The requested controller or channel was invalid.
Definition: kpad.h:38
@ KPAD_ERROR_UNINITIALIZED
KPAD is uninitialized, need to call KPADInit()
Definition: kpad.h:44
A structure containing the Wii Remote data.
Definition: kpad.h:76
2D vector.
Definition: kpad.h:49
3D vector.
Definition: kpad.h:61
WPADDataFormat
Data format.
Definition: wpad.h:45
WPADChan
Wii Remote channel.
Definition: wpad.h:26
WPADExtensionType
Extension type.
Definition: wpad.h:84
WPADMplsMode
MotionPlus Mode.
Definition: wpad.h:300
void(* WPADConnectCallback)(WPADChan chan, int32_t status)
Callback called when a controller connects or disconnects.
Definition: wpad.h:439