New Wiimote Plugin: Fix Emulated Wiimote Problem.(fixes issue 3230) Made the "Connect...
[dolphin.git] / Source / Plugins / Plugin_WiimoteNew / Src / WiimoteEmu / WiimoteHid.h
blobf08f8852423060546c7b0022473ce607afe0924f
1 // Copyright (C) 2003 Dolphin Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official SVN repository and contact information can be found at
16 // http://code.google.com/p/dolphin-emu/
18 #ifndef WIIMOTE_HID_H
19 #define WIIMOTE_HID_H
21 #include "CommonTypes.h"
23 // what is this ?
24 #ifdef _MSC_VER
25 #pragma warning(disable:4200)
26 #endif
27 #pragma pack(push, 1)
29 // Source: HID_010_SPC_PFL/1.0 (official HID specification)
31 struct hid_packet {
32 u8 param : 4;
33 u8 type : 4;
34 u8 data[0];
37 #define HID_TYPE_HANDSHAKE 0
38 #define HID_TYPE_SET_REPORT 5
39 #define HID_TYPE_DATA 0xA
41 #define HID_HANDSHAKE_SUCCESS 0
43 #define HID_PARAM_INPUT 1
44 #define HID_PARAM_OUTPUT 2
46 //source: http://wiibrew.org/wiki/Wiimote
48 typedef u16 wm_core;
50 struct wm_accel
52 u8 x, y, z;
55 // Four bytes for two objects. Filled with 0xFF if empty
56 struct wm_ir_basic
58 u8 x1;
59 u8 y1;
60 u8 x2hi : 2;
61 u8 y2hi : 2;
62 u8 x1hi : 2;
63 u8 y1hi : 2;
64 u8 x2;
65 u8 y2;
68 // Three bytes for one object
69 struct wm_ir_extended
71 u8 x;
72 u8 y;
73 u8 size : 4;
74 u8 xhi : 2;
75 u8 yhi : 2;
78 struct wm_extension
80 u8 jx; // joystick x, y
81 u8 jy;
82 u8 ax; // accelerometer
83 u8 ay;
84 u8 az;
85 u8 bt; // buttons
88 struct wm_classic_extension
90 u8 lx : 6; // byte 0
91 u8 rx3 : 2;
92 u8 ly : 6; // byte 1
93 u8 rx2 : 2;
94 u8 ry : 5; // byte 2
95 u8 lt2 : 2;
96 u8 rx1 : 1;
97 u8 rt : 5; // byte 3
98 u8 lt1 : 3;
99 u16 bt; // byte 4, 5
102 struct wm_guitar_extension
104 u8 sx : 6;
105 u8 pad1 : 2; // 1 on gh3, 0 on ghwt
107 u8 sy : 6;
108 u8 pad2 : 2; // 1 on gh3, 0 on ghwt
110 u8 tb : 5; // not used in gh3
111 u8 pad3 : 3; // always 0
113 u8 whammy : 5;
114 u8 pad4 : 3; // always 0
116 u16 bt; // buttons
119 struct wm_drums_extension
121 u8 sx : 6;
122 u8 pad1 : 2; // always 0
124 u8 sy : 6;
125 u8 pad2 : 2; // always 0
127 u8 pad3 : 1; // unknown
128 u8 which : 5;
129 u8 none : 1;
130 u8 hhp : 1;
132 u8 pad4 : 1; // unknown
133 u8 velocity : 4; // unknown
134 u8 softness : 3;
136 u16 bt; // buttons
139 struct wm_report
141 u8 wm;
142 union
144 u8 data[0];
145 struct
147 u8 rumble : 1; // enable/disable rumble
148 // only valid for certain reports
149 u8 ack : 1; // respond with an ack
150 u8 enable : 1; // enable/disable certain features
155 #define WM_RUMBLE 0x10
157 #define WM_LEDS 0x11
158 struct wm_leds {
159 u8 rumble : 1;
160 u8 : 3;
161 u8 leds : 4;
164 #define WM_REPORT_MODE 0x12
165 struct wm_report_mode {
166 u8 rumble : 1;
167 u8 continuous : 1; // these 2 seem to be named wrong
168 u8 all_the_time : 1;
169 u8 : 5;
170 u8 mode;
173 #define WM_IR_PIXEL_CLOCK 0x13
174 #define WM_IR_LOGIC 0x1A
176 #define WM_REQUEST_STATUS 0x15
177 struct wm_request_status {
178 u8 rumble : 1;
179 u8 : 7;
182 #define WM_STATUS_REPORT 0x20
183 struct wm_status_report {
184 wm_core buttons;
185 u8 battery_low : 1;
186 u8 extension : 1;
187 u8 speaker : 1;
188 u8 ir : 1;
189 u8 leds : 4;
190 u8 padding2[2]; // two 00, TODO: this needs more investigation
191 u8 battery;
194 #define WM_WRITE_DATA 0x16
195 struct wm_write_data
197 u8 rumble : 1;
198 u8 space : 2; //see WM_SPACE_*
199 u8 : 5;
200 u8 address[3];
201 u8 size;
202 u8 data[16];
205 #define WM_ACK_DATA 0x22
206 struct wm_acknowledge
208 wm_core buttons;
209 u8 reportID;
210 u8 errorID;
213 #define WM_READ_DATA 0x17
214 struct wm_read_data {
215 u8 rumble : 1;
216 u8 space : 2; //see WM_SPACE_*
217 u8 : 5;
218 u8 address[3];
219 u16 size;
222 #define WM_SPACE_EEPROM 0
223 #define WM_SPACE_REGS1 1
224 #define WM_SPACE_REGS2 2
225 #define WM_SPACE_INVALID 3
227 #define WM_READ_DATA_REPLY 0x21
228 struct wm_read_data_reply {
229 wm_core buttons;
230 u8 error : 4; //see WM_RDERR_*
231 u8 size : 4;
232 u16 address;
233 u8 data[16];
236 #define WM_RDERR_WOREG 7
237 #define WM_RDERR_NOMEM 8
240 // Data reports
242 #define WM_REPORT_CORE 0x30
243 struct wm_report_core {
244 wm_core c;
247 #define WM_REPORT_CORE_ACCEL 0x31
248 struct wm_report_core_accel {
249 wm_core c;
250 wm_accel a;
253 #define WM_REPORT_CORE_EXT8 0x32
255 #define WM_REPORT_CORE_ACCEL_IR12 0x33
256 struct wm_report_core_accel_ir12 {
257 wm_core c;
258 wm_accel a;
259 wm_ir_extended ir[4];
262 #define WM_REPORT_CORE_EXT19 0x34
263 #define WM_REPORT_CORE_ACCEL_EXT16 0x35
264 struct wm_report_core_accel_ext16
266 wm_core c;
267 wm_accel a;
268 wm_extension ext;
269 //wm_ir_basic ir[2];
270 u8 pad[10];
274 #define WM_REPORT_CORE_IR10_EXT9 0x36
276 #define WM_REPORT_CORE_ACCEL_IR10_EXT6 0x37
277 struct wm_report_core_accel_ir10_ext6
279 wm_core c;
280 wm_accel a;
281 wm_ir_basic ir[2];
282 //u8 ext[6];
283 wm_extension ext;
286 #define WM_REPORT_EXT21 0x3d // never used?
287 struct wm_report_ext21
289 u8 ext[21];
292 #define WM_REPORT_INTERLEAVE1 0x3e
293 #define WM_REPORT_INTERLEAVE2 0x3f
295 #define WM_SPEAKER_ENABLE 0x14
296 #define WM_SPEAKER_MUTE 0x19
297 #define WM_WRITE_SPEAKER_DATA 0x18
298 struct wm_speaker_data {
299 u8 unknown : 3;
300 u8 length : 5;
301 u8 data[20];
304 // Custom structs
307 * @struct accel_t
308 * @brief Accelerometer struct. For any device with an accelerometer.
310 struct accel_cal
312 struct
314 u8 x, y, z;
315 u8 xlo : 2;
316 u8 ylo : 2;
317 u8 zlo : 2;
318 } zero_g;
320 struct
322 u8 x, y, z;
323 u8 xlo : 2;
324 u8 ylo : 2;
325 u8 zlo : 2;
326 } one_g;
329 struct nu_js {
330 u8 max, min, center;
332 struct cc_trigger {
333 u8 neutral;
335 struct nu_cal
337 wm_accel cal_zero; // zero calibratio
338 wm_accel cal_g; // g size
339 nu_js jx; //
340 nu_js jy; //
342 struct cc_cal
344 nu_js Lx; //
345 nu_js Ly; //
346 nu_js Rx; //
347 nu_js Ry; //
348 cc_trigger Tl; //
349 cc_trigger Tr; //
351 struct gh3_cal
353 nu_js Lx;
354 nu_js Ly;
357 #pragma pack(pop)
359 #endif //WIIMOTE_HID_H