93 control_dcid[0] = 0x60;
94 control_dcid[1] = 0x00;
95 interrupt_dcid[0] = 0x61;
96 interrupt_dcid[1] = 0x00;
105 activateNunchuck =
false;
106 motionValuesReset =
false;
107 activeConnection =
false;
108 motionPlusInside =
false;
116 if(!motionPlusInside) {
118 #ifdef DEBUG_USB_HOST
119 Notify(
PSTR(
"\r\nDeactivating Motion Plus"), 0x80);
123 timer = millis() + 1000;
135 if((l2capinbuf[12] | (l2capinbuf[13] << 8)) ==
HID_CTRL_PSM) {
139 activeConnection =
true;
147 if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) {
149 #ifdef DEBUG_USB_HOST
150 Notify(
PSTR(
"\r\nL2CAP Command Rejected - Reason: "), 0x80);
151 D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
153 D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
155 D_PrintHex<uint8_t > (l2capinbuf[17], 0x80);
157 D_PrintHex<uint8_t > (l2capinbuf[16], 0x80);
159 D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
161 D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
164 if(((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) && ((l2capinbuf[18] | (l2capinbuf[19] << 8)) ==
SUCCESSFUL)) {
165 if(l2capinbuf[14] == control_dcid[0] && l2capinbuf[15] == control_dcid[1]) {
168 control_scid[0] = l2capinbuf[12];
169 control_scid[1] = l2capinbuf[13];
171 }
else if(l2capinbuf[14] == interrupt_dcid[0] && l2capinbuf[15] == interrupt_dcid[1]) {
174 interrupt_scid[0] = l2capinbuf[12];
175 interrupt_scid[1] = l2capinbuf[13];
181 Notify(
PSTR(
"\r\nL2CAP Connection Request - PSM: "), 0x80);
182 D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
184 D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
186 D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
188 D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
190 D_PrintHex<uint8_t > (l2capinbuf[9], 0x80);
192 if((l2capinbuf[12] | (l2capinbuf[13] << 8)) ==
HID_CTRL_PSM) {
194 control_scid[0] = l2capinbuf[14];
195 control_scid[1] = l2capinbuf[15];
197 }
else if((l2capinbuf[12] | (l2capinbuf[13] << 8)) ==
HID_INTR_PSM) {
199 interrupt_scid[0] = l2capinbuf[14];
200 interrupt_scid[1] = l2capinbuf[15];
204 if((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) {
205 if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
209 }
else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
216 if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
219 }
else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
224 if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
225 #ifdef DEBUG_USB_HOST
226 Notify(
PSTR(
"\r\nDisconnect Request: Control Channel"), 0x80);
231 }
else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
232 #ifdef DEBUG_USB_HOST
233 Notify(
PSTR(
"\r\nDisconnect Request: Interrupt Channel"), 0x80);
240 if(l2capinbuf[12] == control_scid[0] && l2capinbuf[13] == control_scid[1]) {
244 }
else if(l2capinbuf[12] == interrupt_scid[0] && l2capinbuf[13] == interrupt_scid[1]) {
253 Notify(
PSTR(
"\r\nL2CAP Unknown Signaling Command: "), 0x80);
254 D_PrintHex<uint8_t > (l2capinbuf[8], 0x80);
257 }
else if(l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) {
259 if(l2capinbuf[8] == 0xA1) {
260 if((l2capinbuf[9] >= 0x20 && l2capinbuf[9] <= 0x22) || (l2capinbuf[9] >= 0x30 && l2capinbuf[9] <= 0x37) || l2capinbuf[9] == 0x3e || l2capinbuf[9] == 0x3f) {
261 if((l2capinbuf[9] >= 0x20 && l2capinbuf[9] <= 0x22) || l2capinbuf[9] == 0x31 || l2capinbuf[9] == 0x33)
262 ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8));
264 ButtonState = (uint32_t)(((~l2capinbuf[23]) & 0xFE) | ((uint16_t)(~l2capinbuf[24]) << 8) | ((uint32_t)((~l2capinbuf[25]) & 0x03) << 16));
266 if(l2capinbuf[20] & 0x02)
267 ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8) | ((uint32_t)(ButtonState & 0xFFFF0000)));
269 ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8) | ((uint32_t)((~l2capinbuf[20]) & 0x0C) << 14));
272 ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8) | ((uint32_t)((~l2capinbuf[20]) & 0x03) << 16));
274 else if(!unknownExtensionConnected)
275 ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8));
278 D_PrintHex<uint32_t > (ButtonState, 0x80);
281 if(ButtonState != OldButtonState) {
282 ButtonClickState = ButtonState & ~OldButtonState;
283 OldButtonState = ButtonState;
286 if(l2capinbuf[9] == 0x31 || l2capinbuf[9] == 0x33 || l2capinbuf[9] == 0x35 || l2capinbuf[9] == 0x37) {
287 accXwiimote = ((l2capinbuf[12] << 2) | (l2capinbuf[10] & 0x60 >> 5)) - 500;
288 accYwiimote = ((l2capinbuf[13] << 2) | (l2capinbuf[11] & 0x20 >> 4)) - 500;
289 accZwiimote = ((l2capinbuf[14] << 2) | (l2capinbuf[11] & 0x40 >> 5)) - 500;
291 switch(l2capinbuf[9]) {
294 Notify(
PSTR(
"\r\nStatus report was received"), 0x80);
296 wiiState = l2capinbuf[12];
297 batteryLevel = l2capinbuf[15];
298 #ifdef DEBUG_USB_HOST
299 if(l2capinbuf[12] & 0x01)
300 Notify(
PSTR(
"\r\nWARNING: Battery is nearly empty"), 0x80);
303 if(l2capinbuf[12] & 0x02) {
304 #ifdef DEBUG_USB_HOST
305 if(!unknownExtensionConnected)
306 Notify(
PSTR(
"\r\nExtension connected"), 0x80);
308 unknownExtensionConnected =
true;
312 setReportMode(
false, 0x35);
314 #ifdef DEBUG_USB_HOST
315 Notify(
PSTR(
"\r\nExtension disconnected"), 0x80);
318 #ifdef DEBUG_USB_HOST
322 if(!activateNunchuck)
326 #ifdef DEBUG_USB_HOST
332 setReportMode(
false, 0x31);
334 setReportMode(
false, 0x31);
337 checkExtension =
true;
340 if((l2capinbuf[12] & 0x0F) == 0) {
342 if(l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x00 && l2capinbuf[20] == 0x00) {
343 #ifdef DEBUG_USB_HOST
347 }
else if(l2capinbuf[16] == 0x00 && (l2capinbuf[17] == 0xA6 || l2capinbuf[17] == 0xA4) && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x00 && l2capinbuf[20] == 0x05) {
348 #ifdef DEBUG_USB_HOST
349 Notify(
PSTR(
"\r\nMotion Plus connected"), 0x80);
352 }
else if(l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x04 && l2capinbuf[20] == 0x05) {
353 #ifdef DEBUG_USB_HOST
354 Notify(
PSTR(
"\r\nMotion Plus activated in normal mode"), 0x80);
360 setReportMode(
false, 0x35);
361 }
else if(l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x05 && l2capinbuf[20] == 0x05) {
362 #ifdef DEBUG_USB_HOST
363 Notify(
PSTR(
"\r\nMotion Plus activated in Nunchuck pass-through mode"), 0x80);
365 activateNunchuck =
false;
371 setReportMode(
false, 0x35);
372 }
else if(l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA6 && l2capinbuf[18] == 0x20 && (l2capinbuf[19] == 0x00 || l2capinbuf[19] == 0x04 || l2capinbuf[19] == 0x05 || l2capinbuf[19] == 0x07) && l2capinbuf[20] == 0x05) {
373 #ifdef DEBUG_USB_HOST
374 Notify(
PSTR(
"\r\nInactive Wii Motion Plus"), 0x80);
375 Notify(
PSTR(
"\r\nPlease unplug the Motion Plus, disconnect the Wiimote and then replug the Motion Plus Extension"), 0x80);
378 }
else if(l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x01 && l2capinbuf[20] == 0x20) {
379 #ifdef DEBUG_USB_HOST
380 Notify(
PSTR(
"\r\nWii U Pro Controller connected"), 0x80);
384 #ifdef DEBUG_USB_HOST
387 D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
388 D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
390 for(uint8_t i = 0; i < ((l2capinbuf[12] >> 4) + 1); i++) {
391 D_PrintHex<uint8_t > (l2capinbuf[15 + i], 0x80);
400 D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
401 D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
406 #ifdef DEBUG_USB_HOST
407 if(l2capinbuf[13] != 0x00) {
409 D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
422 IR_object_x1 = (l2capinbuf[15] | ((uint16_t)(l2capinbuf[17] & 0x30) << 4));
423 IR_object_y1 = (l2capinbuf[16] | ((uint16_t)(l2capinbuf[17] & 0xC0) << 2));
424 IR_object_s1 = (l2capinbuf[17] & 0x0F);
426 IR_object_x2 = (l2capinbuf[18] | ((uint16_t)(l2capinbuf[20] & 0x30) << 4));
427 IR_object_y2 = (l2capinbuf[19] | ((uint16_t)(l2capinbuf[20] & 0xC0) << 2));
428 IR_object_s2 = (l2capinbuf[20] & 0x0F);
430 IR_object_x3 = (l2capinbuf[21] | ((uint16_t)(l2capinbuf[23] & 0x30) << 4));
431 IR_object_y3 = (l2capinbuf[22] | ((uint16_t)(l2capinbuf[23] & 0xC0) << 2));
432 IR_object_s3 = (l2capinbuf[23] & 0x0F);
434 IR_object_x4 = (l2capinbuf[24] | ((uint16_t)(l2capinbuf[26] & 0x30) << 4));
435 IR_object_y4 = (l2capinbuf[25] | ((uint16_t)(l2capinbuf[26] & 0xC0) << 2));
436 IR_object_s4 = (l2capinbuf[26] & 0x0F);
464 if(l2capinbuf[20] & 0x02) {
465 if(motionValuesReset) {
475 if(!(l2capinbuf[18] & 0x02))
477 if(!(l2capinbuf[18] & 0x01))
479 if(!(l2capinbuf[19] & 0x02))
505 if((micros() - timer) > 1000000) {
506 #ifdef DEBUG_USB_HOST
507 Notify(
PSTR(
"\r\nThe gyro values has been reset"), 0x80);
509 gyroYawZero = (l2capinbuf[15] | ((l2capinbuf[18] & 0xFC) << 6));
510 gyroRollZero = (l2capinbuf[16] | ((l2capinbuf[19] & 0xFC) << 6));
511 gyroPitchZero = (l2capinbuf[17] | ((l2capinbuf[20] & 0xFC) << 6));
521 motionValuesReset =
true;
527 hatValues[
HatX] = l2capinbuf[15];
528 hatValues[
HatY] = l2capinbuf[16];
529 accXnunchuck = ((l2capinbuf[17] << 2) | (l2capinbuf[20] & 0x10 >> 3)) - 416;
530 accYnunchuck = ((l2capinbuf[18] << 2) | (l2capinbuf[20] & 0x20 >> 4)) - 416;
531 accZnunchuck = (((l2capinbuf[19] & 0xFE) << 2) | (l2capinbuf[20] & 0xC0 >> 5)) - 416;
535 if(l2capinbuf[19] & 0x01) {
536 if(!extensionConnected) {
537 extensionConnected =
true;
538 unknownExtensionConnected =
true;
539 #ifdef DEBUG_USB_HOST
540 Notify(
PSTR(
"\r\nExtension connected to Motion Plus"), 0x80);
544 if(extensionConnected && !unknownExtensionConnected) {
545 extensionConnected =
false;
546 unknownExtensionConnected =
true;
547 #ifdef DEBUG_USB_HOST
548 Notify(
PSTR(
"\r\nExtension disconnected from Motion Plus"), 0x80);
555 hatValues[
HatX] = l2capinbuf[15];
556 hatValues[
HatY] = l2capinbuf[16];
557 accXnunchuck = ((l2capinbuf[17] << 2) | (l2capinbuf[20] & 0x0C >> 2)) - 416;
558 accYnunchuck = ((l2capinbuf[18] << 2) | (l2capinbuf[20] & 0x30 >> 4)) - 416;
559 accZnunchuck = ((l2capinbuf[19] << 2) | (l2capinbuf[20] & 0xC0 >> 6)) - 416;
561 hatValues[
LeftHatX] = (l2capinbuf[15] | l2capinbuf[16] << 8);
562 hatValues[
RightHatX] = (l2capinbuf[17] | l2capinbuf[18] << 8);
563 hatValues[
LeftHatY] = (l2capinbuf[19] | l2capinbuf[20] << 8);
564 hatValues[
RightHatY] = (l2capinbuf[21] | l2capinbuf[22] << 8);
567 #ifdef DEBUG_USB_HOST
569 Notify(
PSTR(
"\r\nUnknown Report type: "), 0x80);
570 D_PrintHex<uint8_t > (l2capinbuf[9], 0x80);
580 void WII::L2CAP_task() {
581 switch(l2cap_state) {
585 #ifdef DEBUG_USB_HOST
586 Notify(
PSTR(
"\r\nHID Control Successfully Configured"), 0x80);
594 #ifdef DEBUG_USB_HOST
595 Notify(
PSTR(
"\r\nHID Interrupt Incoming Connection Request"), 0x80);
611 #ifdef DEBUG_USB_HOST
612 Notify(
PSTR(
"\r\nSend HID Control Config Request"), 0x80);
622 #ifdef DEBUG_USB_HOST
623 Notify(
PSTR(
"\r\nSend HID Interrupt Connection Request"), 0x80);
633 #ifdef DEBUG_USB_HOST
634 Notify(
PSTR(
"\r\nSend HID Interrupt Config Request"), 0x80);
644 #ifdef DEBUG_USB_HOST
645 Notify(
PSTR(
"\r\nHID Channels Established"), 0x80);
658 #ifdef DEBUG_USB_HOST
659 Notify(
PSTR(
"\r\nDisconnected Interrupt Channel"), 0x80);
669 #ifdef DEBUG_USB_HOST
670 Notify(
PSTR(
"\r\nDisconnected Control Channel"), 0x80);
685 switch(l2cap_state) {
689 activeConnection =
true;
691 #ifdef DEBUG_USB_HOST
692 Notify(
PSTR(
"\r\nSend HID Control Connection Request"), 0x80);
700 #ifdef DEBUG_USB_HOST
701 Notify(
PSTR(
"\r\nHID Control Incoming Connection Request"), 0x80);
714 #ifdef DEBUG_USB_HOST
715 if(stateCounter == 0)
716 Notify(
PSTR(
"\r\nChecking if a Motion Plus is connected"), 0x80);
719 if(stateCounter % 200 == 0)
720 checkMotionPresent();
726 if(unknownExtensionConnected) {
727 #ifdef DEBUG_USB_HOST
728 Notify(
PSTR(
"\r\nA extension is also connected"), 0x80);
730 activateNunchuck =
true;
733 }
else if(stateCounter == 601) {
734 #ifdef DEBUG_USB_HOST
735 Notify(
PSTR(
"\r\nNo Motion Plus was detected"), 0x80);
743 #ifdef DEBUG_USB_HOST
744 if(stateCounter == 0)
745 Notify(
PSTR(
"\r\nChecking if there is any extension connected"), 0x80);
748 if(stateCounter == 1)
750 if(stateCounter == 100) {
751 if(unknownExtensionConnected)
755 }
else if(stateCounter == 200)
757 else if(stateCounter == 300) {
759 unknownExtensionConnected =
false;
760 }
else if(stateCounter == 400) {
768 if(stateCounter == 1)
770 else if(stateCounter == 100)
771 activateMotionPlus();
772 else if(stateCounter == 200)
774 else if(stateCounter == 300) {
776 unknownExtensionConnected =
false;
790 if(unknownExtensionConnected) {
791 #ifdef DEBUG_USB_HOST
792 if(stateCounter == 0)
793 Notify(
PSTR(
"\r\nChecking extension port"), 0x80);
796 if(stateCounter == 50)
798 else if(stateCounter == 100)
800 else if(stateCounter == 150)
805 else if(stateCounter == 200)
807 else if(stateCounter == 250) {
809 #ifdef DEBUG_USB_HOST
810 Notify(
PSTR(
"\r\nNunchuck was reconnected"), 0x80);
812 activateNunchuck =
true;
817 }
else if(stateCounter == 300) {
819 #ifdef DEBUG_USB_HOST
820 Notify(
PSTR(
"\r\nReactivating the Motion Plus"), 0x80);
825 }
else if(stateCounter == 350)
826 activateMotionPlus();
827 else if(stateCounter == 400)
829 else if(stateCounter == 450) {
832 unknownExtensionConnected =
false;
844 void WII::HID_Command(uint8_t* data, uint8_t nbytes) {
854 HID_Command(HIDBuffer, 3);
859 HIDBuffer[2] &= ~0x01;
860 HID_Command(HIDBuffer, 3);
865 HIDBuffer[2] |= 0x01;
866 HID_Command(HIDBuffer, 3);
871 HIDBuffer[2] ^= 0x01;
872 HID_Command(HIDBuffer, 3);
877 HIDBuffer[2] = value | (HIDBuffer[2] & 0x01);
878 HID_Command(HIDBuffer, 3);
884 HID_Command(HIDBuffer, 3);
893 HID_Command(HIDBuffer, 3);
900 HID_Command(HIDBuffer, 3);
905 HIDBuffer[2] = (HIDBuffer[2] & 0x01);
907 HIDBuffer[2] |= 0x10;
909 HIDBuffer[2] |= 0x20;
911 HIDBuffer[2] |= 0x40;
913 HID_Command(HIDBuffer, 3);
917 checkExtension =
false;
922 void WII::setReportMode(
bool continuous, uint8_t mode) {
927 cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01);
929 cmd_buf[2] = 0x00 | (HIDBuffer[2] & 0x01);
931 HID_Command(cmd_buf, 4);
934 void WII::statusRequest() {
938 cmd_buf[2] = (HIDBuffer[2] & 0x01);
939 HID_Command(cmd_buf, 3);
946 void WII::writeData(uint32_t offset, uint8_t size, uint8_t* data) {
950 cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01);
951 cmd_buf[3] = (uint8_t)((offset & 0xFF0000) >> 16);
952 cmd_buf[4] = (uint8_t)((offset & 0xFF00) >> 8);
953 cmd_buf[5] = (uint8_t)(offset & 0xFF);
957 cmd_buf[7 + i] = data[i];
959 cmd_buf[7 + i] = 0x00;
960 HID_Command(cmd_buf, 23);
963 void WII::initExtension1() {
966 writeData(0xA400F0, 1, buf);
969 void WII::initExtension2() {
972 writeData(0xA400FB, 1, buf);
975 void WII::initMotionPlus() {
978 writeData(0xA600F0, 1, buf);
981 void WII::activateMotionPlus() {
984 #ifdef DEBUG_USB_HOST
985 Notify(
PSTR(
"\r\nActivating Wii U Pro Controller"), 0x80);
988 }
else if(activateNunchuck) {
989 #ifdef DEBUG_USB_HOST
990 Notify(
PSTR(
"\r\nActivating Motion Plus in pass-through mode"), 0x80);
996 #ifdef DEBUG_USB_HOST
997 Notify(
PSTR(
"\r\nActivating Motion Plus in normal mode"), 0x80);
1001 writeData(0xA600FE, 1, buf);
1004 void WII::readData(uint32_t offset, uint16_t size,
bool EEPROM) {
1009 cmd_buf[2] = 0x00 | (HIDBuffer[2] & 0x01);
1011 cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01);
1012 cmd_buf[3] = (uint8_t)((offset & 0xFF0000) >> 16);
1013 cmd_buf[4] = (uint8_t)((offset & 0xFF00) >> 8);
1014 cmd_buf[5] = (uint8_t)(offset & 0xFF);
1015 cmd_buf[6] = (uint8_t)((size & 0xFF00) >> 8);
1016 cmd_buf[7] = (uint8_t)(size & 0xFF);
1018 HID_Command(cmd_buf, 8);
1021 void WII::readExtensionType() {
1022 readData(0xA400FA, 6,
false);
1025 void WII::readCalData() {
1026 readData(0x0016, 8,
true);
1029 void WII::checkMotionPresent() {
1030 readData(0xA600FA, 6,
false);
1051 bool click = (ButtonClickState & button);
1052 ButtonClickState &= ~button;
1060 uint8_t output = hatValues[(uint8_t)a];
1061 if(output == 0xFF || output == 0x00)
1072 uint16_t output = hatValues[(uint8_t)a];
1096 #ifdef DEBUG_USB_HOST
1097 Notify(
PSTR(
"\r\nEnable IR Camera1 Complete"), 0x80);
1102 #ifdef DEBUG_USB_HOST
1103 Notify(
PSTR(
"\r\nEnable IR Camera2 Complete"), 0x80);
1108 #ifdef DEBUG_USB_HOST
1109 Notify(
PSTR(
"\r\nWrote hex number 0x08"), 0x80);
1113 writeSensitivityBlock1();
1114 #ifdef DEBUG_USB_HOST
1115 Notify(
PSTR(
"\r\nWrote Sensitivity Block 1"), 0x80);
1119 writeSensitivityBlock2();
1120 #ifdef DEBUG_USB_HOST
1121 Notify(
PSTR(
"\r\nWrote Sensitivity Block 2"), 0x80);
1125 uint8_t mode_num = 0x03;
1126 setWiiModeNumber(mode_num);
1127 #ifdef DEBUG_USB_HOST
1128 Notify(
PSTR(
"\r\nSet Wii Mode Number To 0x"), 0x80);
1129 D_PrintHex<uint8_t > (mode_num, 0x80);
1134 #ifdef DEBUG_USB_HOST
1135 Notify(
PSTR(
"\r\nWrote Hex Number 0x08"), 0x80);
1139 setReportMode(
false, 0x33);
1141 #ifdef DEBUG_USB_HOST
1142 Notify(
PSTR(
"\r\nSet Report Mode to 0x33"), 0x80);
1147 #ifdef DEBUG_USB_HOST
1152 void WII::enableIRCamera1() {
1156 cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01);
1157 HID_Command(cmd_buf, 3);
1160 void WII::enableIRCamera2() {
1164 cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01);
1165 HID_Command(cmd_buf, 3);
1168 void WII::writeSensitivityBlock1() {
1180 writeData(0xB00000, 9, buf);
1183 void WII::writeSensitivityBlock2() {
1188 writeData(0xB0001A, 2, buf);
1191 void WII::write0x08Value() {
1193 writeData(0xb00030, 1, &cmd);
1196 void WII::setWiiModeNumber(uint8_t mode_number) {
1197 writeData(0xb00033, 1, &mode_number);
#define L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE
#define pgm_read_dword(addr)
#define wii_clear_flag(flag)
#define L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS
#define L2CAP_INTERRUPT_CONFIG_REQUEST
#define L2CAP_INTERRUPT_SETUP
void l2cap_connection_response(uint16_t handle, uint8_t rxid, uint8_t *dcid, uint8_t *scid, uint8_t result)
void l2cap_connection_request(uint16_t handle, uint8_t rxid, uint8_t *scid, uint16_t psm)
#define L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST
void setLedToggle(LEDEnum a)
void setLedRaw(uint8_t value)
uint8_t getAnalogHat(HatEnum a)
#define WII_FLAG_NUNCHUCK_CONNECTED
void l2cap_disconnection_request(uint16_t handle, uint8_t rxid, uint8_t *dcid, uint8_t *scid)
void ACLData(uint8_t *ACLData)
uint8_t getBatteryLevel()
#define wii_set_flag(flag)
#define L2CAP_CONTROL_SUCCESS
#define pgm_read_byte(addr)
#define L2CAP_CONTROL_CONFIG_REQUEST
void l2cap_disconnection_response(uint16_t handle, uint8_t rxid, uint8_t *dcid, uint8_t *scid)
#define L2CAP_CONTROL_CONNECT_REQUEST
WII(BTD *p, bool pair=false)
#define WII_CHECK_EXTENSION_STATE
void hci_disconnect(uint16_t handle)
#define L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE
#define WII_FLAG_MOTION_PLUS_CONNECTED
bool getButtonClick(ButtonEnum b)
bool wiiUProControllerConnected
void(* pFuncOnInit)(void)
#define l2cap_check_flag(flag)
#define L2CAP_CMD_CONFIG_REQUEST
#define L2CAP_FLAG_CONTROL_CONNECTED
#define L2CAP_CMD_DISCONNECT_REQUEST
#define L2CAP_CONTROL_DISCONNECT
const uint32_t WII_BUTTONS[]
#define L2CAP_FLAG_CONNECTION_CONTROL_REQUEST
#define WII_CHECK_MOTION_PLUS_STATE
bool l2capConnectionClaimed
const uint32_t WII_PROCONTROLLER_BUTTONS[]
#define L2CAP_CMD_DISCONNECT_RESPONSE
#define L2CAP_CMD_CONNECTION_RESPONSE
#define L2CAP_CMD_CONFIG_RESPONSE
uint32_t l2cap_event_flag
#define wii_check_flag(flag)
#define WII_INIT_MOTION_PLUS_STATE
void L2CAP_Command(uint16_t handle, uint8_t *data, uint8_t nbytes, uint8_t channelLow=0x01, uint8_t channelHigh=0x00)
void l2cap_config_response(uint16_t handle, uint8_t rxid, uint8_t *scid)
#define L2CAP_FLAG_INTERRUPT_CONNECTED
#define l2cap_set_flag(flag)
void l2cap_config_request(uint16_t handle, uint8_t rxid, uint8_t *dcid)
bool getButtonPress(ButtonEnum b)
#define L2CAP_FLAG_CONFIG_CONTROL_SUCCESS
#define L2CAP_CMD_CONNECTION_REQUEST
bool checkHciHandle(uint8_t *buf, uint16_t handle)
#define L2CAP_INTERRUPT_CONNECT_REQUEST
#define L2CAP_INTERRUPT_DISCONNECT
#define L2CAP_CMD_COMMAND_REJECT