35 #define L2CAP_CONTROL_SUCCESS 1
36 #define L2CAP_INTERRUPT_SETUP 2
39 #define L2CAP_CONTROL_CONNECT_REQUEST 3
40 #define L2CAP_CONTROL_CONFIG_REQUEST 4
41 #define L2CAP_INTERRUPT_CONNECT_REQUEST 5
43 #define L2CAP_INTERRUPT_CONFIG_REQUEST 6
45 #define L2CAP_CHECK_MOTION_PLUS_STATE 7
46 #define L2CAP_CHECK_EXTENSION_STATE 8
47 #define L2CAP_INIT_MOTION_PLUS_STATE 9
48 #define L2CAP_LED_STATE 10
51 #define L2CAP_INTERRUPT_DISCONNECT 12
52 #define L2CAP_CONTROL_DISCONNECT 13
55 #define L2CAP_FLAG_CONTROL_CONNECTED 0x001
56 #define L2CAP_FLAG_INTERRUPT_CONNECTED 0x002
57 #define L2CAP_FLAG_CONFIG_CONTROL_SUCCESS 0x004
58 #define L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS 0x008
59 #define L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE 0x040
60 #define L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE 0x080
61 #define L2CAP_FLAG_CONNECTION_CONTROL_REQUEST 0x100
62 #define L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST 0x200
65 #define l2cap_connected_control_flag (l2cap_event_flag & L2CAP_FLAG_CONTROL_CONNECTED)
66 #define l2cap_connected_interrupt_flag (l2cap_event_flag & L2CAP_FLAG_INTERRUPT_CONNECTED)
67 #define l2cap_config_success_control_flag (l2cap_event_flag & L2CAP_FLAG_CONFIG_CONTROL_SUCCESS)
68 #define l2cap_config_success_interrupt_flag (l2cap_event_flag & L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS)
69 #define l2cap_disconnect_response_control_flag (l2cap_event_flag & L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE)
70 #define l2cap_disconnect_response_interrupt_flag (l2cap_event_flag & L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE)
71 #define l2cap_connection_request_control_flag (l2cap_event_flag & L2CAP_FLAG_CONNECTION_CONTROL_REQUEST)
72 #define l2cap_connection_request_interrupt_flag (l2cap_event_flag & L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST)
75 #define WII_FLAG_MOTION_PLUS_CONNECTED 0x400
76 #define WII_FLAG_NUNCHUCK_CONNECTED 0x800
78 #define motion_plus_connected_flag (l2cap_event_flag & WII_FLAG_MOTION_PLUS_CONNECTED)
79 #define nunchuck_connected_flag (l2cap_event_flag & WII_FLAG_NUNCHUCK_CONNECTED)
104 WII(
BTD *p,
bool pair =
false);
115 virtual void Reset();
410 return(wiiState & 0x08);
423 bool activeConnection;
427 uint16_t l2cap_event_flag;
429 uint32_t ButtonState;
430 uint32_t OldButtonState;
431 uint32_t ButtonClickState;
432 uint16_t hatValues[4];
434 uint8_t HIDBuffer[3];
436 uint16_t stateCounter;
437 bool unknownExtensionConnected;
438 bool extensionConnected;
441 uint8_t control_scid[2];
442 uint8_t control_dcid[2];
443 uint8_t interrupt_scid[2];
444 uint8_t interrupt_dcid[2];
448 void HID_Command(uint8_t* data, uint8_t nbytes);
449 void setReportMode(
bool continuous, uint8_t mode);
451 void writeData(uint32_t offset, uint8_t size, uint8_t* data);
452 void initExtension1();
453 void initExtension2();
455 void readData(uint32_t offset, uint16_t size,
bool EEPROM);
456 void readExtensionType();
459 void checkMotionPresent();
460 void initMotionPlus();
461 void activateMotionPlus();
466 bool activateNunchuck;
467 bool motionValuesReset;
471 uint8_t batteryLevel;
475 void enableIRCamera1();
476 void enableIRCamera2();
477 void writeSensitivityBlock1();
478 void writeSensitivityBlock2();
479 void write0x08Value();
480 void setWiiModeNumber(uint8_t mode_number);
482 uint16_t IR_object_x1;
483 uint16_t IR_object_y1;
484 uint8_t IR_object_s1;
485 uint16_t IR_object_x2;
486 uint16_t IR_object_y2;
487 uint8_t IR_object_s2;
488 uint16_t IR_object_x3;
489 uint16_t IR_object_y3;
490 uint8_t IR_object_s3;
491 uint16_t IR_object_x4;
492 uint16_t IR_object_y4;
493 uint8_t IR_object_s4;