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();
367 bool activeConnection;
371 uint16_t l2cap_event_flag;
373 uint32_t ButtonState;
374 uint32_t OldButtonState;
375 uint32_t ButtonClickState;
376 uint16_t hatValues[4];
378 uint8_t HIDBuffer[3];
380 uint16_t stateCounter;
381 bool unknownExtensionConnected;
382 bool extensionConnected;
385 uint8_t control_scid[2];
386 uint8_t control_dcid[2];
387 uint8_t interrupt_scid[2];
388 uint8_t interrupt_dcid[2];
392 void HID_Command(uint8_t* data, uint8_t nbytes);
393 void setReportMode(
bool continuous, uint8_t mode);
394 void statusRequest();
396 void writeData(uint32_t offset, uint8_t size, uint8_t* data);
397 void initExtension1();
398 void initExtension2();
400 void readData(uint32_t offset, uint16_t size,
bool EEPROM);
401 void readExtensionType();
404 void checkMotionPresent();
405 void initMotionPlus();
406 void activateMotionPlus();
411 bool activateNunchuck;
412 bool motionValuesReset;
416 uint8_t batteryLevel;
420 void enableIRCamera1();
421 void enableIRCamera2();
422 void writeSensitivityBlock1();
423 void writeSensitivityBlock2();
424 void write0x08Value();
425 void setWiiModeNumber(uint8_t mode_number);
427 uint16_t IR_object_x1;
428 uint16_t IR_object_y1;
429 uint8_t IR_object_s1;
430 uint16_t IR_object_x2;
431 uint16_t IR_object_y2;
432 uint8_t IR_object_s2;
433 uint16_t IR_object_x3;
434 uint16_t IR_object_y3;
435 uint8_t IR_object_s3;
436 uint16_t IR_object_x4;
437 uint16_t IR_object_y4;
438 uint8_t IR_object_s4;