34 #define L2CAP_CONTROL_SUCCESS 1
35 #define L2CAP_INTERRUPT_SETUP 2
38 #define L2CAP_CONTROL_CONNECT_REQUEST 3
39 #define L2CAP_CONTROL_CONFIG_REQUEST 4
40 #define L2CAP_INTERRUPT_CONNECT_REQUEST 5
42 #define L2CAP_INTERRUPT_CONFIG_REQUEST 6
44 #define L2CAP_CHECK_MOTION_PLUS_STATE 7
45 #define L2CAP_CHECK_EXTENSION_STATE 8
46 #define L2CAP_INIT_MOTION_PLUS_STATE 9
47 #define L2CAP_LED_STATE 10
50 #define L2CAP_INTERRUPT_DISCONNECT 12
51 #define L2CAP_CONTROL_DISCONNECT 13
54 #define L2CAP_FLAG_CONTROL_CONNECTED 0x001
55 #define L2CAP_FLAG_INTERRUPT_CONNECTED 0x002
56 #define L2CAP_FLAG_CONFIG_CONTROL_SUCCESS 0x004
57 #define L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS 0x008
58 #define L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE 0x040
59 #define L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE 0x080
60 #define L2CAP_FLAG_CONNECTION_CONTROL_REQUEST 0x100
61 #define L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST 0x200
64 #define l2cap_connected_control_flag (l2cap_event_flag & L2CAP_FLAG_CONTROL_CONNECTED)
65 #define l2cap_connected_interrupt_flag (l2cap_event_flag & L2CAP_FLAG_INTERRUPT_CONNECTED)
66 #define l2cap_config_success_control_flag (l2cap_event_flag & L2CAP_FLAG_CONFIG_CONTROL_SUCCESS)
67 #define l2cap_config_success_interrupt_flag (l2cap_event_flag & L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS)
68 #define l2cap_disconnect_response_control_flag (l2cap_event_flag & L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE)
69 #define l2cap_disconnect_response_interrupt_flag (l2cap_event_flag & L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE)
70 #define l2cap_connection_request_control_flag (l2cap_event_flag & L2CAP_FLAG_CONNECTION_CONTROL_REQUEST)
71 #define l2cap_connection_request_interrupt_flag (l2cap_event_flag & L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST)
74 #define WII_FLAG_MOTION_PLUS_CONNECTED 0x400
75 #define WII_FLAG_NUNCHUCK_CONNECTED 0x800
77 #define motion_plus_connected_flag (l2cap_event_flag & WII_FLAG_MOTION_PLUS_CONNECTED)
78 #define nunchuck_connected_flag (l2cap_event_flag & WII_FLAG_NUNCHUCK_CONNECTED)
89 WII(
BTD *p,
bool pair=
false);
164 uint16_t getIRx1() {
return IR_object_x1; };
165 uint16_t getIRy1() {
return IR_object_y1; };
166 uint8_t getIRs1() {
return IR_object_s1; };
168 uint16_t getIRx2() {
return IR_object_x2; };
169 uint16_t getIRy2() {
return IR_object_y2; };
170 uint8_t getIRs2() {
return IR_object_s2; };
172 uint16_t getIRx3() {
return IR_object_x3; };
173 uint16_t getIRy3() {
return IR_object_y3; };
174 uint8_t getIRs3() {
return IR_object_s3; };
176 uint16_t getIRx4() {
return IR_object_x4; };
177 uint16_t getIRy4() {
return IR_object_y4; };
178 uint8_t getIRs4() {
return IR_object_s4; };
180 bool isIRCameraEnabled() {
return (wiiState & 0x08); };
191 bool activeConnection;
195 uint16_t l2cap_event_flag;
197 uint32_t ButtonState;
198 uint32_t OldButtonState;
199 uint32_t ButtonClickState;
200 uint8_t hatValues[2];
202 uint8_t HIDBuffer[3];
204 uint16_t stateCounter;
205 bool unknownExtensionConnected;
206 bool extensionConnected;
209 uint8_t control_scid[2];
210 uint8_t control_dcid[2];
211 uint8_t interrupt_scid[2];
212 uint8_t interrupt_dcid[2];
216 void HID_Command(uint8_t* data, uint8_t nbytes);
217 void setReportMode(
bool continuous, uint8_t mode);
218 void statusRequest();
220 void writeData(uint32_t offset, uint8_t size, uint8_t* data);
221 void initExtension1();
222 void initExtension2();
224 void readData(uint32_t offset, uint16_t size,
bool EEPROM);
225 void readExtensionType();
228 void checkMotionPresent();
229 void initMotionPlus();
230 void activateMotionPlus();
235 bool activateNunchuck;
236 bool motionValuesReset;
240 uint8_t batteryLevel;
244 void enableIRCamera1();
245 void enableIRCamera2();
246 void writeSensitivityBlock1();
247 void writeSensitivityBlock2();
248 void write0x08Value();
249 void setWiiModeNumber(uint8_t mode_number);
251 uint16_t IR_object_x1;
252 uint16_t IR_object_y1;
253 uint8_t IR_object_s1;
254 uint16_t IR_object_x2;
255 uint16_t IR_object_y2;
256 uint8_t IR_object_s2;
257 uint16_t IR_object_x3;
258 uint16_t IR_object_y3;
259 uint8_t IR_object_s3;
260 uint16_t IR_object_x4;
261 uint16_t IR_object_y4;
262 uint8_t IR_object_s4;