wut  v1.7.0
Wii U Toolchain
hpad.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
16 #define HPAD_STICK_AXIS_MIN -56
18 #define HPAD_STICK_AXIS_MAX 56
20 #define HPAD_SUBSTICK_AXIS_MIN -44
22 #define HPAD_SUBSTICK_AXIS_MAX 44
24 #define HPAD_TRIGGER_MIN 0
26 #define HPAD_TRIGGER_MAX 150
27 
28 typedef struct HPADStatus HPADStatus;
29 typedef struct HPADGGGGStatus HPADGGGGStatus;
30 
31 typedef enum HPADChan
32 {
42 
43 typedef enum HPADGGGGChan
44 {
50 
51 typedef enum HPADButtons
52 {
53  HPAD_BUTTON_A = 0x0001,
54  HPAD_BUTTON_B = 0x0002,
55  HPAD_BUTTON_X = 0x0004,
56  HPAD_BUTTON_Y = 0x0008,
57  HPAD_BUTTON_LEFT = 0x0010,
59  HPAD_BUTTON_DOWN = 0x0040,
60  HPAD_BUTTON_UP = 0x0080,
62  HPAD_TRIGGER_Z = 0x0200,
63  HPAD_TRIGGER_R = 0x0400,
64  HPAD_TRIGGER_L = 0x0800,
65 
75 
76 typedef enum HPADMotorCommand
77 {
82 
83 struct HPADStatus
84 {
86  int32_t hold;
88  int32_t trigger;
90  int32_t release;
92  int8_t stickX;
94  int8_t stickY;
96  int8_t substickX;
98  int8_t substickY;
100  uint8_t triggerL;
102  uint8_t triggerR;
104  uint8_t status;
105  WUT_PADDING_BYTES(0x1);
107  int32_t error;
108 };
109 WUT_CHECK_OFFSET(HPADStatus, 0x00, hold);
110 WUT_CHECK_OFFSET(HPADStatus, 0x04, trigger);
111 WUT_CHECK_OFFSET(HPADStatus, 0x08, release);
112 WUT_CHECK_OFFSET(HPADStatus, 0x0C, stickX);
113 WUT_CHECK_OFFSET(HPADStatus, 0x0D, stickY);
114 WUT_CHECK_OFFSET(HPADStatus, 0x0E, substickX);
115 WUT_CHECK_OFFSET(HPADStatus, 0x0F, substickY);
116 WUT_CHECK_OFFSET(HPADStatus, 0x10, triggerL);
117 WUT_CHECK_OFFSET(HPADStatus, 0x11, triggerR);
118 WUT_CHECK_OFFSET(HPADStatus, 0x12, status);
119 WUT_CHECK_OFFSET(HPADStatus, 0x14, error);
120 WUT_CHECK_SIZE(HPADStatus, 0x18);
121 
123 {
130 };
131 WUT_CHECK_OFFSET(HPADGGGGStatus, 0x0, connected);
132 WUT_CHECK_OFFSET(HPADGGGGStatus, 0x4, powerSupplyConnected);
133 WUT_CHECK_OFFSET(HPADGGGGStatus, 0x8, active);
134 WUT_CHECK_SIZE(HPADGGGGStatus, 0xC);
135 
136 typedef void (*HPADConnectCallback)(HPADChan chan, int32_t status);
137 typedef void (*HPADGGGGConnectCallback)(HPADGGGGChan chan, BOOL connected);
138 typedef void (*HPADPowerSupplyCallback)(HPADGGGGChan chan, BOOL connected);
139 typedef void (*HPADSamplingCallback)(HPADGGGGChan chan);
140 typedef void (*HPADResetCallback)(HPADGGGGChan chan, int32_t status);
141 
148 int32_t
149 HPADInit(void);
150 
157 int32_t
159 
179 int32_t
181  HPADStatus *buffers,
182  int32_t count);
183 
199 static inline int32_t
201  HPADStatus *buffers,
202  int32_t count)
203 {
204  // HPADRead ignores the count and will always fill up to 16 sampling buffers
205  if (count != 16) {
206  return -6;
207  }
208 
209  return RPLWRAP(HPADRead)(chan, buffers, count);
210 }
211 
224 int32_t
226  HPADMotorCommand command);
227 
237 int32_t
239 
254  HPADConnectCallback callback);
255 
268 int32_t
270  HPADGGGGStatus *status);
271 
286  HPADGGGGConnectCallback callback);
287 
302  HPADPowerSupplyCallback callback);
303 
318  HPADSamplingCallback callback);
319 
332 int32_t
334  HPADResetCallback callback);
335 
336 #ifdef __cplusplus
337 }
338 #endif
339 
uint8_t triggerR
Position of the right analog trigger.
Definition: hpad.h:102
uint8_t triggerL
Position of the left analog trigger.
Definition: hpad.h:100
BOOL active
TRUE if the adapter is active/is sending samples
Definition: hpad.h:129
int8_t substickX
X-Position of the analog substick/C-Stick.
Definition: hpad.h:96
int32_t error
Read error, 0 for success.
Definition: hpad.h:105
int32_t trigger
Indicates what HPADButtons have been pressed since last sample.
Definition: hpad.h:88
int32_t release
Indicates what HPADButtons have been released since last sample.
Definition: hpad.h:90
BOOL powerSupplyConnected
TRUE if the power supply is connected
Definition: hpad.h:127
int8_t substickY
Y-Position of the analog substick/C-Stick.
Definition: hpad.h:98
BOOL connected
TRUE if the adapeter is connected
Definition: hpad.h:125
int8_t stickX
X-Position of the analog stick.
Definition: hpad.h:92
int32_t hold
Indicates what HPADButtons are held down.
Definition: hpad.h:86
int8_t stickY
Y-Position of the analog stick.
Definition: hpad.h:94
uint8_t status
Status of the controller.
Definition: hpad.h:104
HPADChan
Definition: hpad.h:32
int32_t HPADShutdown(void)
Shuts down the HPAD library.
int32_t HPADResetDevice(HPADGGGGChan chan, HPADResetCallback callback)
Resets the specified GGGG Adapter.
int32_t HPADControlMotor(HPADChan chan, HPADMotorCommand command)
Sends a motor/rumble command to the specified HPAD channel.
HPADConnectCallback HPADSetConnectCallback(HPADChan chan, HPADConnectCallback callback)
Sets a callback for once the specified HPAD channel is connected.
int32_t HPADGetGGGGStatus(HPADGGGGChan chan, HPADGGGGStatus *status)
Get the status of the specified GGGG channel (GC Adapter).
HPADPowerSupplyCallback HPADSetPowerSupplyCallback(HPADGGGGChan chan, HPADPowerSupplyCallback callback)
Sets a callback for once the power supply of the specified GGGG Adapter is connected.
HPADMotorCommand
Definition: hpad.h:77
HPADButtons
Definition: hpad.h:52
HPADGGGGConnectCallback HPADSetGgggConnectCallback(HPADGGGGChan chan, HPADGGGGConnectCallback callback)
Sets a callback for once the specified GGGG Adapter is connected.
void(* HPADPowerSupplyCallback)(HPADGGGGChan chan, BOOL connected)
Definition: hpad.h:138
int32_t HPADInit(void)
Initializes the HPAD library.
void(* HPADResetCallback)(HPADGGGGChan chan, int32_t status)
Definition: hpad.h:140
HPADGGGGChan
Definition: hpad.h:44
int32_t RPLWRAP() HPADRead(HPADChan chan, HPADStatus *buffers, int32_t count)
Reads status buffers from a specified HPAD channel.
Definition: hpad.h:200
HPADSamplingCallback HPADSetSamplingCallback(HPADGGGGChan chan, HPADSamplingCallback callback)
Sets a callback for once a sample is received from the specified GGGG Adapter.
void(* HPADConnectCallback)(HPADChan chan, int32_t status)
Definition: hpad.h:136
void(* HPADSamplingCallback)(HPADGGGGChan chan)
Definition: hpad.h:139
int32_t HPADRecalibrate(HPADChan chan)
Invalidates calibration data of the specified HPAD channel.
void(* HPADGGGGConnectCallback)(HPADGGGGChan chan, BOOL connected)
Definition: hpad.h:137
@ HPAD_CHAN_4
Definition: hpad.h:37
@ HPAD_CHAN_1
Definition: hpad.h:34
@ HPAD_CHAN_6
Definition: hpad.h:39
@ HPAD_CHAN_5
Definition: hpad.h:38
@ HPAD_CHAN_2
Definition: hpad.h:35
@ HPAD_CHAN_7
Definition: hpad.h:40
@ HPAD_CHAN_3
Definition: hpad.h:36
@ HPAD_CHAN_0
Definition: hpad.h:33
@ HPAD_MOTOR_COMMAND_STOP_HARD
Definition: hpad.h:80
@ HPAD_MOTOR_COMMAND_RUMBLE
Definition: hpad.h:79
@ HPAD_MOTOR_COMMAND_STOP
Definition: hpad.h:78
@ HPAD_STICK_EMULATION_LEFT
Definition: hpad.h:66
@ HPAD_BUTTON_DOWN
Definition: hpad.h:59
@ HPAD_BUTTON_A
Definition: hpad.h:53
@ HPAD_SUBSTICK_EMULATION_LEFT
Definition: hpad.h:70
@ HPAD_STICK_EMULATION_RIGHT
Definition: hpad.h:67
@ HPAD_SUBSTICK_EMULATION_UP
Definition: hpad.h:73
@ HPAD_SUBSTICK_EMULATION_RIGHT
Definition: hpad.h:71
@ HPAD_TRIGGER_R
Definition: hpad.h:63
@ HPAD_BUTTON_UP
Definition: hpad.h:60
@ HPAD_BUTTON_Y
Definition: hpad.h:56
@ HPAD_BUTTON_X
Definition: hpad.h:55
@ HPAD_BUTTON_START
Definition: hpad.h:61
@ HPAD_SUBSTICK_EMULATION_DOWN
Definition: hpad.h:72
@ HPAD_TRIGGER_Z
Definition: hpad.h:62
@ HPAD_BUTTON_LEFT
Definition: hpad.h:57
@ HPAD_STICK_EMULATION_UP
Definition: hpad.h:69
@ HPAD_TRIGGER_L
Definition: hpad.h:64
@ HPAD_BUTTON_B
Definition: hpad.h:54
@ HPAD_STICK_EMULATION_DOWN
Definition: hpad.h:68
@ HPAD_BUTTON_RIGHT
Definition: hpad.h:58
@ HPAD_GGGG_CHAN_1
Adapter Channel 1.
Definition: hpad.h:48
@ HPAD_GGGG_CHAN_0
Adapter Channel 0.
Definition: hpad.h:46
#define RPLWRAP(func)
Definition: wut_rplwrap.h:3
int32_t BOOL
Definition: wut_types.h:7