wut  1.0.0-beta9
Wii U Toolchain
hid.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 typedef struct HIDClient HIDClient;
14 typedef struct HIDDevice HIDDevice;
15 
16 typedef enum HIDAttachEvent
17 {
21 
22 typedef int32_t
24  HIDDevice *device,
25  HIDAttachEvent attach);
26 
27 typedef void
28 (*HIDCallback)(uint32_t handle,
29  int32_t error,
30  uint8_t *buffer,
31  uint32_t bytesTransferred,
32  void *userContext);
33 
34 struct HIDDevice
35 {
36  uint32_t handle;
38  uint16_t vid;
39  uint16_t pid;
40  uint8_t interfaceIndex;
41  uint8_t subClass;
42  uint8_t protocol;
43  WUT_PADDING_BYTES(1);
44  uint16_t maxPacketSizeRx;
45  uint16_t maxPacketSizeTx;
46 };
47 WUT_CHECK_OFFSET(HIDDevice, 0x00, handle);
48 WUT_CHECK_OFFSET(HIDDevice, 0x04, physicalDeviceInst);
49 WUT_CHECK_OFFSET(HIDDevice, 0x08, vid);
50 WUT_CHECK_OFFSET(HIDDevice, 0x0A, pid);
51 WUT_CHECK_OFFSET(HIDDevice, 0x0C, interfaceIndex);
52 WUT_CHECK_OFFSET(HIDDevice, 0x0D, subClass);
53 WUT_CHECK_OFFSET(HIDDevice, 0x0E, protocol);
54 WUT_CHECK_OFFSET(HIDDevice, 0x10, maxPacketSizeRx);
55 WUT_CHECK_OFFSET(HIDDevice, 0x12, maxPacketSizeTx);
56 WUT_CHECK_SIZE(HIDDevice, 0x14);
57 
58 struct HIDClient
59 {
62 };
63 WUT_CHECK_OFFSET(HIDClient, 0x00, next);
64 WUT_CHECK_OFFSET(HIDClient, 0x04, attachCallback);
65 WUT_CHECK_SIZE(HIDClient, 0x08);
66 
67 
68 int32_t
69 HIDSetup();
70 
71 int32_t
72 HIDTeardown();
73 
74 int32_t
75 HIDAddClient(HIDClient *client,
76  HIDAttachCallback attachCallback);
77 
78 int32_t
79 HIDDelClient(HIDClient *client);
80 
81 int32_t
82 HIDGetDescriptor(uint32_t handle,
83  uint8_t descriptorType,
84  uint8_t descriptorIndex,
85  uint16_t languageId,
86  uint8_t *buffer,
87  uint32_t bufferLength,
88  HIDCallback callback,
89  void *userContext);
90 
91 int32_t
92 HIDSetDescriptor(uint32_t handle,
93  uint8_t descriptorType,
94  uint8_t descriptorIndex,
95  uint16_t languageId,
96  uint8_t *buffer,
97  uint32_t bufferLength,
98  HIDCallback callback,
99  void *userContext);
100 
101 int32_t
102 HIDGetReport(uint32_t handle,
103  uint8_t reportType,
104  uint8_t reportId,
105  uint8_t *buffer,
106  uint32_t bufferLength,
107  HIDCallback callback,
108  void *userContext);
109 
110 int32_t
111 HIDSetReport(uint32_t handle,
112  uint8_t reportType,
113  uint8_t reportId,
114  uint8_t *buffer,
115  uint32_t bufferLength,
116  HIDCallback callback,
117  void *userContext);
118 
119 int32_t
120 HIDSetIdle(uint32_t handle,
121  uint8_t interfaceIndex,
122  uint8_t duration,
123  HIDCallback callback,
124  void *userContext);
125 
126 int32_t
127 HIDSetProtocol(uint32_t handle,
128  uint8_t interfaceIndex,
129  uint8_t protocol,
130  HIDCallback callback,
131  void *userContext);
132 
133 int32_t
134 HIDGetProtocol(uint32_t handle,
135  uint8_t interfaceIndex,
136  uint8_t *protocol,
137  HIDCallback callback,
138  void *userContext);
139 
140 int32_t
141 HIDRead(uint32_t handle,
142  uint8_t *buffer,
143  uint32_t bufferLength,
144  HIDCallback callback,
145  void *userContext);
146 
147 int32_t
148 HIDWrite(uint32_t handle,
149  uint8_t *buffer,
150  uint32_t bufferLength,
151  HIDCallback hc,
152  void *userContext);
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
HIDAttachEvent
HIDAttachEvent
Definition: hid.h:16
HIDDevice::maxPacketSizeRx
uint16_t maxPacketSizeRx
Definition: hid.h:44
HIDSetProtocol
int32_t HIDSetProtocol(uint32_t handle, uint8_t interfaceIndex, uint8_t protocol, HIDCallback callback, void *userContext)
HIDClient::next
HIDClient * next
Definition: hid.h:60
HIDSetReport
int32_t HIDSetReport(uint32_t handle, uint8_t reportType, uint8_t reportId, uint8_t *buffer, uint32_t bufferLength, HIDCallback callback, void *userContext)
HIDSetup
int32_t HIDSetup()
HIDSetDescriptor
int32_t HIDSetDescriptor(uint32_t handle, uint8_t descriptorType, uint8_t descriptorIndex, uint16_t languageId, uint8_t *buffer, uint32_t bufferLength, HIDCallback callback, void *userContext)
HIDDevice::subClass
uint8_t subClass
Definition: hid.h:41
HID_DEVICE_ATTACH
@ HID_DEVICE_ATTACH
Definition: hid.h:19
HIDRead
int32_t HIDRead(uint32_t handle, uint8_t *buffer, uint32_t bufferLength, HIDCallback callback, void *userContext)
HIDDevice
Definition: hid.h:34
wut.h
HIDAddClient
int32_t HIDAddClient(HIDClient *client, HIDAttachCallback attachCallback)
HIDDevice::interfaceIndex
uint8_t interfaceIndex
Definition: hid.h:40
HIDGetProtocol
int32_t HIDGetProtocol(uint32_t handle, uint8_t interfaceIndex, uint8_t *protocol, HIDCallback callback, void *userContext)
HIDClient
Definition: hid.h:58
HIDDevice::vid
uint16_t vid
Definition: hid.h:38
HID_DEVICE_DETACH
@ HID_DEVICE_DETACH
Definition: hid.h:18
HIDDevice::handle
uint32_t handle
Definition: hid.h:36
HIDSetIdle
int32_t HIDSetIdle(uint32_t handle, uint8_t interfaceIndex, uint8_t duration, HIDCallback callback, void *userContext)
HIDDevice::pid
uint16_t pid
Definition: hid.h:39
HIDClient::attachCallback
HIDAttachCallback attachCallback
Definition: hid.h:61
HIDGetDescriptor
int32_t HIDGetDescriptor(uint32_t handle, uint8_t descriptorType, uint8_t descriptorIndex, uint16_t languageId, uint8_t *buffer, uint32_t bufferLength, HIDCallback callback, void *userContext)
HIDAttachCallback
int32_t(* HIDAttachCallback)(HIDClient *client, HIDDevice *device, HIDAttachEvent attach)
Definition: hid.h:23
HIDWrite
int32_t HIDWrite(uint32_t handle, uint8_t *buffer, uint32_t bufferLength, HIDCallback hc, void *userContext)
HIDDevice::protocol
uint8_t protocol
Definition: hid.h:42
HIDGetReport
int32_t HIDGetReport(uint32_t handle, uint8_t reportType, uint8_t reportId, uint8_t *buffer, uint32_t bufferLength, HIDCallback callback, void *userContext)
HIDTeardown
int32_t HIDTeardown()
HIDDelClient
int32_t HIDDelClient(HIDClient *client)
HIDDevice::physicalDeviceInst
uint32_t physicalDeviceInst
Definition: hid.h:37
HIDCallback
void(* HIDCallback)(uint32_t handle, int32_t error, uint8_t *buffer, uint32_t bytesTransferred, void *userContext)
Definition: hid.h:28
HIDDevice::maxPacketSizeTx
uint16_t maxPacketSizeTx
Definition: hid.h:45