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();
329 bool activeConnection;
333 uint16_t l2cap_event_flag;
335 uint32_t ButtonState;
336 uint32_t OldButtonState;
337 uint32_t ButtonClickState;
338 uint16_t hatValues[4];
340 uint8_t HIDBuffer[3];
342 uint16_t stateCounter;
343 bool unknownExtensionConnected;
344 bool extensionConnected;
347 uint8_t control_scid[2];
348 uint8_t control_dcid[2];
349 uint8_t interrupt_scid[2];
350 uint8_t interrupt_dcid[2];
354 void HID_Command(uint8_t* data, uint8_t nbytes);
355 void setReportMode(
bool continuous, uint8_t mode);
356 void statusRequest();
358 void writeData(uint32_t offset, uint8_t size, uint8_t* data);
359 void initExtension1();
360 void initExtension2();
362 void readData(uint32_t offset, uint16_t size,
bool EEPROM);
363 void readExtensionType();
366 void checkMotionPresent();
367 void initMotionPlus();
368 void activateMotionPlus();
373 bool activateNunchuck;
374 bool motionValuesReset;
378 uint8_t batteryLevel;
382 void enableIRCamera1();
383 void enableIRCamera2();
384 void writeSensitivityBlock1();
385 void writeSensitivityBlock2();
386 void write0x08Value();
387 void setWiiModeNumber(uint8_t mode_number);
389 uint16_t IR_object_x1;
390 uint16_t IR_object_y1;
391 uint8_t IR_object_s1;
392 uint16_t IR_object_x2;
393 uint16_t IR_object_y2;
394 uint8_t IR_object_s2;
395 uint16_t IR_object_x3;
396 uint16_t IR_object_y3;
397 uint8_t IR_object_s3;
398 uint16_t IR_object_x4;
399 uint16_t IR_object_y4;
400 uint8_t IR_object_s4;