mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
refactor DEBUG -> DEBUG_USB_HOST
This commit is contained in:
parent
86b575309a
commit
159e8dc46b
17 changed files with 233 additions and 233 deletions
84
BTD.cpp
84
BTD.cpp
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BTD.h"
|
#include "BTD.h"
|
||||||
// To enable serial debugging uncomment "#define DEBUG" in message.h
|
// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
|
|
||||||
const uint8_t BTD::BTD_CONTROL_PIPE = 0;
|
const uint8_t BTD::BTD_CONTROL_PIPE = 0;
|
||||||
|
@ -58,7 +58,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#endif
|
#endif
|
||||||
// check if address has already been assigned to an instance
|
// check if address has already been assigned to an instance
|
||||||
if (bAddress) {
|
if (bAddress) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nAddress in use"), 0x80);
|
Notify(PSTR("\r\nAddress in use"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
|
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
|
||||||
|
@ -68,14 +68,14 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
p = addrPool.GetUsbDevicePtr(0);
|
p = addrPool.GetUsbDevicePtr(0);
|
||||||
|
|
||||||
if (!p) {
|
if (!p) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nAddress not found"), 0x80);
|
Notify(PSTR("\r\nAddress not found"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
|
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p->epinfo) {
|
if (!p->epinfo) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nepinfo is null"), 0x80);
|
Notify(PSTR("\r\nepinfo is null"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_EPINFO_IS_NULL;
|
return USB_ERROR_EPINFO_IS_NULL;
|
||||||
|
@ -113,7 +113,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
p->lowspeed = false;
|
p->lowspeed = false;
|
||||||
addrPool.FreeAddress(bAddress);
|
addrPool.FreeAddress(bAddress);
|
||||||
bAddress = 0;
|
bAddress = 0;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
PrintHex<uint8_t > (rcode, 0x80);
|
||||||
|
@ -145,7 +145,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (rcode)
|
if (rcode)
|
||||||
goto FailSetConfDescr;
|
goto FailSetConfDescr;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
if (PID == PS3_PID || PID == PS3NAVIGATION_PID) {
|
if (PID == PS3_PID || PID == PS3NAVIGATION_PID) {
|
||||||
if (PID == PS3_PID)
|
if (PID == PS3_PID)
|
||||||
Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80);
|
Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80);
|
||||||
|
@ -156,7 +156,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (my_bdaddr[0] == 0x00 && my_bdaddr[1] == 0x00 && my_bdaddr[2] == 0x00 && my_bdaddr[3] == 0x00 && my_bdaddr[4] == 0x00 && my_bdaddr[5] == 0x00) {
|
if (my_bdaddr[0] == 0x00 && my_bdaddr[1] == 0x00 && my_bdaddr[2] == 0x00 && my_bdaddr[3] == 0x00 && my_bdaddr[4] == 0x00 && my_bdaddr[5] == 0x00) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nPlease plug in the dongle before trying to pair with the PS3 Controller\n\rOr set the Bluetooth address in the constructor of the PS3BT class"), 0x80);
|
Notify(PSTR("\r\nPlease plug in the dongle before trying to pair with the PS3 Controller\n\rOr set the Bluetooth address in the constructor of the PS3BT class"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
@ -164,7 +164,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
setBdaddr(my_bdaddr); // Set internal Bluetooth address
|
setBdaddr(my_bdaddr); // Set internal Bluetooth address
|
||||||
else
|
else
|
||||||
setMoveBdaddr(my_bdaddr); // Set internal Bluetooth address
|
setMoveBdaddr(my_bdaddr); // Set internal Bluetooth address
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
|
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
|
||||||
for (int8_t i = 5; i > 0; i--) {
|
for (int8_t i = 5; i > 0; i--) {
|
||||||
PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
||||||
|
@ -214,7 +214,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
watingForConnection = false;
|
watingForConnection = false;
|
||||||
bPollEnable = true;
|
bPollEnable = true;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nBluetooth Dongle Initialized"), 0x80);
|
Notify(PSTR("\r\nBluetooth Dongle Initialized"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -222,37 +222,37 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
#endif
|
#endif
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
FailUnknownDevice:
|
FailUnknownDevice:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailUnknownDevice(VID, PID);
|
NotifyFailUnknownDevice(VID, PID);
|
||||||
#endif
|
#endif
|
||||||
pUsb->setAddr(bAddress, 0, 0); // Reset address
|
pUsb->setAddr(bAddress, 0, 0); // Reset address
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nBTD Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nBTD Init Failed, error code: "), 0x80);
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
|
@ -360,7 +360,7 @@ void BTD::HCI_event_task() {
|
||||||
|
|
||||||
case EV_COMMAND_STATUS:
|
case EV_COMMAND_STATUS:
|
||||||
if (hcibuf[2]) { // show status on serial if not OK
|
if (hcibuf[2]) { // show status on serial if not OK
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHCI Command Failed: "), 0x80);
|
Notify(PSTR("\r\nHCI Command Failed: "), 0x80);
|
||||||
PrintHex<uint8_t > (hcibuf[2], 0x80);
|
PrintHex<uint8_t > (hcibuf[2], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
|
@ -374,7 +374,7 @@ void BTD::HCI_event_task() {
|
||||||
case EV_INQUIRY_COMPLETE:
|
case EV_INQUIRY_COMPLETE:
|
||||||
if (inquiry_counter >= 5) {
|
if (inquiry_counter >= 5) {
|
||||||
inquiry_counter = 0;
|
inquiry_counter = 0;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nCouldn't find Wiimote"), 0x80);
|
Notify(PSTR("\r\nCouldn't find Wiimote"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
connectToWii = false;
|
connectToWii = false;
|
||||||
|
@ -468,18 +468,18 @@ void BTD::HCI_event_task() {
|
||||||
|
|
||||||
case EV_PIN_CODE_REQUEST:
|
case EV_PIN_CODE_REQUEST:
|
||||||
if (pairWithWii) {
|
if (pairWithWii) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nPairing with wiimote"), 0x80);
|
Notify(PSTR("\r\nPairing with wiimote"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_pin_code_request_reply();
|
hci_pin_code_request_reply();
|
||||||
} else if (btdPin != NULL) {
|
} else if (btdPin != NULL) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nBluetooth pin is set too: "), 0x80);
|
Notify(PSTR("\r\nBluetooth pin is set too: "), 0x80);
|
||||||
NotifyStr(btdPin, 0x80);
|
NotifyStr(btdPin, 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_pin_code_request_reply();
|
hci_pin_code_request_reply();
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nNo pin was set"), 0x80);
|
Notify(PSTR("\r\nNo pin was set"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_pin_code_negative_request_reply();
|
hci_pin_code_negative_request_reply();
|
||||||
|
@ -487,7 +487,7 @@ void BTD::HCI_event_task() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EV_LINK_KEY_REQUEST:
|
case EV_LINK_KEY_REQUEST:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nReceived Key Request"), 0x80);
|
Notify(PSTR("\r\nReceived Key Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_link_key_request_negative_reply();
|
hci_link_key_request_negative_reply();
|
||||||
|
@ -495,7 +495,7 @@ void BTD::HCI_event_task() {
|
||||||
|
|
||||||
case EV_AUTHENTICATION_COMPLETE:
|
case EV_AUTHENTICATION_COMPLETE:
|
||||||
if (pairWithWii && !connectToWii) {
|
if (pairWithWii && !connectToWii) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nPairing successful"), 0x80);
|
Notify(PSTR("\r\nPairing successful"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
connectToWii = true; // Only send the ACL data to the Wii service
|
connectToWii = true; // Only send the ACL data to the Wii service
|
||||||
|
@ -549,7 +549,7 @@ void BTD::HCI_task() {
|
||||||
hci_counter++;
|
hci_counter++;
|
||||||
if (hci_cmd_complete) {
|
if (hci_cmd_complete) {
|
||||||
hci_counter = 0;
|
hci_counter = 0;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHCI Reset complete"), 0x80);
|
Notify(PSTR("\r\nHCI Reset complete"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_state = HCI_CLASS_STATE;
|
hci_state = HCI_CLASS_STATE;
|
||||||
|
@ -558,7 +558,7 @@ void BTD::HCI_task() {
|
||||||
hci_num_reset_loops *= 10;
|
hci_num_reset_loops *= 10;
|
||||||
if (hci_num_reset_loops > 2000)
|
if (hci_num_reset_loops > 2000)
|
||||||
hci_num_reset_loops = 2000;
|
hci_num_reset_loops = 2000;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nNo response to HCI Reset"), 0x80);
|
Notify(PSTR("\r\nNo response to HCI Reset"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_state = HCI_INIT_STATE;
|
hci_state = HCI_INIT_STATE;
|
||||||
|
@ -568,7 +568,7 @@ void BTD::HCI_task() {
|
||||||
|
|
||||||
case HCI_CLASS_STATE:
|
case HCI_CLASS_STATE:
|
||||||
if (hci_cmd_complete) {
|
if (hci_cmd_complete) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nWrite class of device"), 0x80);
|
Notify(PSTR("\r\nWrite class of device"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_state = HCI_BDADDR_STATE;
|
hci_state = HCI_BDADDR_STATE;
|
||||||
|
@ -578,7 +578,7 @@ void BTD::HCI_task() {
|
||||||
|
|
||||||
case HCI_BDADDR_STATE:
|
case HCI_BDADDR_STATE:
|
||||||
if (hci_read_bdaddr_complete) {
|
if (hci_read_bdaddr_complete) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nLocal Bluetooth Address: "), 0x80);
|
Notify(PSTR("\r\nLocal Bluetooth Address: "), 0x80);
|
||||||
for (int8_t i = 5; i > 0; i--) {
|
for (int8_t i = 5; i > 0; i--) {
|
||||||
PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
||||||
|
@ -603,7 +603,7 @@ void BTD::HCI_task() {
|
||||||
|
|
||||||
case HCI_SET_NAME_STATE:
|
case HCI_SET_NAME_STATE:
|
||||||
if (hci_cmd_complete) {
|
if (hci_cmd_complete) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nThe name is set to: "), 0x80);
|
Notify(PSTR("\r\nThe name is set to: "), 0x80);
|
||||||
NotifyStr(btdName, 0x80);
|
NotifyStr(btdName, 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -613,7 +613,7 @@ void BTD::HCI_task() {
|
||||||
|
|
||||||
case HCI_CHECK_WII_SERVICE:
|
case HCI_CHECK_WII_SERVICE:
|
||||||
if (pairWithWii) { // Check if it should try to connect to a wiimote
|
if (pairWithWii) { // Check if it should try to connect to a wiimote
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nStarting inquiry\r\nPress 1 & 2 on the Wiimote\r\nOr press sync if you are using a Wii U Pro Controller"), 0x80);
|
Notify(PSTR("\r\nStarting inquiry\r\nPress 1 & 2 on the Wiimote\r\nOr press sync if you are using a Wii U Pro Controller"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_inquiry();
|
hci_inquiry();
|
||||||
|
@ -625,7 +625,7 @@ void BTD::HCI_task() {
|
||||||
case HCI_INQUIRY_STATE:
|
case HCI_INQUIRY_STATE:
|
||||||
if (hci_wii_found) {
|
if (hci_wii_found) {
|
||||||
hci_inquiry_cancel(); // Stop inquiry
|
hci_inquiry_cancel(); // Stop inquiry
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nWiimote found"), 0x80);
|
Notify(PSTR("\r\nWiimote found"), 0x80);
|
||||||
Notify(PSTR("\r\nNow just create the instance like so:"), 0x80);
|
Notify(PSTR("\r\nNow just create the instance like so:"), 0x80);
|
||||||
Notify(PSTR("\r\nWII Wii(&Btd);"), 0x80);
|
Notify(PSTR("\r\nWII Wii(&Btd);"), 0x80);
|
||||||
|
@ -641,7 +641,7 @@ void BTD::HCI_task() {
|
||||||
|
|
||||||
case HCI_CONNECT_WII_STATE:
|
case HCI_CONNECT_WII_STATE:
|
||||||
if (hci_cmd_complete) {
|
if (hci_cmd_complete) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nConnecting to Wiimote"), 0x80);
|
Notify(PSTR("\r\nConnecting to Wiimote"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_connect();
|
hci_connect();
|
||||||
|
@ -652,13 +652,13 @@ void BTD::HCI_task() {
|
||||||
case HCI_CONNECTED_WII_STATE:
|
case HCI_CONNECTED_WII_STATE:
|
||||||
if (hci_connect_event) {
|
if (hci_connect_event) {
|
||||||
if (hci_connect_complete) {
|
if (hci_connect_complete) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nConnected to Wiimote"), 0x80);
|
Notify(PSTR("\r\nConnected to Wiimote"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_authentication_request(); // This will start the pairing with the wiimote
|
hci_authentication_request(); // This will start the pairing with the wiimote
|
||||||
hci_state = HCI_SCANNING_STATE;
|
hci_state = HCI_SCANNING_STATE;
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nTrying to connect one more time..."), 0x80);
|
Notify(PSTR("\r\nTrying to connect one more time..."), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_connect(); // Try to connect one more time
|
hci_connect(); // Try to connect one more time
|
||||||
|
@ -668,7 +668,7 @@ void BTD::HCI_task() {
|
||||||
|
|
||||||
case HCI_SCANNING_STATE:
|
case HCI_SCANNING_STATE:
|
||||||
if (!connectToWii && !pairWithWii) {
|
if (!connectToWii && !pairWithWii) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nWait For Incoming Connection Request"), 0x80);
|
Notify(PSTR("\r\nWait For Incoming Connection Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_write_scan_enable();
|
hci_write_scan_enable();
|
||||||
|
@ -680,7 +680,7 @@ void BTD::HCI_task() {
|
||||||
case HCI_CONNECT_IN_STATE:
|
case HCI_CONNECT_IN_STATE:
|
||||||
if (hci_incoming_connect_request) {
|
if (hci_incoming_connect_request) {
|
||||||
watingForConnection = false;
|
watingForConnection = false;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nIncoming Connection Request"), 0x80);
|
Notify(PSTR("\r\nIncoming Connection Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_remote_name();
|
hci_remote_name();
|
||||||
|
@ -691,7 +691,7 @@ void BTD::HCI_task() {
|
||||||
|
|
||||||
case HCI_REMOTE_NAME_STATE:
|
case HCI_REMOTE_NAME_STATE:
|
||||||
if (hci_remote_name_complete) {
|
if (hci_remote_name_complete) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nRemote Name: "), 0x80);
|
Notify(PSTR("\r\nRemote Name: "), 0x80);
|
||||||
for (uint8_t i = 0; i < 30; i++) {
|
for (uint8_t i = 0; i < 30; i++) {
|
||||||
if (remote_name[i] == NULL)
|
if (remote_name[i] == NULL)
|
||||||
|
@ -701,16 +701,16 @@ void BTD::HCI_task() {
|
||||||
#endif
|
#endif
|
||||||
if (strncmp((const char*)remote_name, "Nintendo", 8) == 0) {
|
if (strncmp((const char*)remote_name, "Nintendo", 8) == 0) {
|
||||||
incomingWii = true;
|
incomingWii = true;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nWiimote is connecting"), 0x80);
|
Notify(PSTR("\r\nWiimote is connecting"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
if (strncmp((const char*)remote_name, "Nintendo RVL-CNT-01-TR", 22) == 0) {
|
if (strncmp((const char*)remote_name, "Nintendo RVL-CNT-01-TR", 22) == 0) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR(" with Motion Plus Inside"), 0x80);
|
Notify(PSTR(" with Motion Plus Inside"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
motionPlusInside = true;
|
motionPlusInside = true;
|
||||||
} else if (strncmp((const char*)remote_name, "Nintendo RVL-CNT-01-UC", 22) == 0) {
|
} else if (strncmp((const char*)remote_name, "Nintendo RVL-CNT-01-UC", 22) == 0) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR(" - Wii U Pro Controller"), 0x80);
|
Notify(PSTR(" - Wii U Pro Controller"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
motionPlusInside = true;
|
motionPlusInside = true;
|
||||||
|
@ -731,7 +731,7 @@ void BTD::HCI_task() {
|
||||||
|
|
||||||
case HCI_CONNECTED_STATE:
|
case HCI_CONNECTED_STATE:
|
||||||
if (hci_connect_complete) {
|
if (hci_connect_complete) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nConnected to Device: "), 0x80);
|
Notify(PSTR("\r\nConnected to Device: "), 0x80);
|
||||||
for (int8_t i = 5; i > 0; i--) {
|
for (int8_t i = 5; i > 0; i--) {
|
||||||
PrintHex<uint8_t > (disc_bdaddr[i], 0x80);
|
PrintHex<uint8_t > (disc_bdaddr[i], 0x80);
|
||||||
|
@ -759,7 +759,7 @@ void BTD::HCI_task() {
|
||||||
|
|
||||||
case HCI_DISCONNECT_STATE:
|
case HCI_DISCONNECT_STATE:
|
||||||
if (hci_disconnect_complete) {
|
if (hci_disconnect_complete) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHCI Disconnected from Device"), 0x80);
|
Notify(PSTR("\r\nHCI Disconnected from Device"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_event_flag = 0; // Clear all flags
|
hci_event_flag = 0; // Clear all flags
|
||||||
|
@ -957,7 +957,7 @@ void BTD::hci_pin_code_request_reply() {
|
||||||
if (pairWithWii) {
|
if (pairWithWii) {
|
||||||
hcibuf[9] = 6; // Pin length is the length of the Bluetooth address
|
hcibuf[9] = 6; // Pin length is the length of the Bluetooth address
|
||||||
if (wiiUProController) {
|
if (wiiUProController) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nParing with Wii U Pro Controller"), 0x80);
|
Notify(PSTR("\r\nParing with Wii U Pro Controller"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
for (uint8_t i = 0; i < 6; i++)
|
for (uint8_t i = 0; i < 6; i++)
|
||||||
|
@ -1083,7 +1083,7 @@ void BTD::L2CAP_Command(uint16_t handle, uint8_t* data, uint8_t nbytes, uint8_t
|
||||||
uint8_t rcode = pUsb->outTransfer(bAddress, epInfo[ BTD_DATAOUT_PIPE ].epAddr, (8 + nbytes), buf);
|
uint8_t rcode = pUsb->outTransfer(bAddress, epInfo[ BTD_DATAOUT_PIPE ].epAddr, (8 + nbytes), buf);
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
delay(100); // This small delay prevents it from overflowing if it fails
|
delay(100); // This small delay prevents it from overflowing if it fails
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nError sending L2CAP message: 0x"), 0x80);
|
Notify(PSTR("\r\nError sending L2CAP message: 0x"), 0x80);
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
PrintHex<uint8_t > (rcode, 0x80);
|
||||||
Notify(PSTR(" - Channel ID: "), 0x80);
|
Notify(PSTR(" - Channel ID: "), 0x80);
|
||||||
|
|
34
PS3BT.cpp
34
PS3BT.cpp
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PS3BT.h"
|
#include "PS3BT.h"
|
||||||
// To enable serial debugging uncomment "#define DEBUG" in message.h
|
// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
//#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers
|
//#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
l2cap_state = L2CAP_WAIT;
|
l2cap_state = L2CAP_WAIT;
|
||||||
for (uint8_t i = 0; i < 30; i++)
|
for (uint8_t i = 0; i < 30; i++)
|
||||||
remote_name[i] = pBtd->remote_name[i]; // Store the remote name for the connection
|
remote_name[i] = pBtd->remote_name[i]; // Store the remote name for the connection
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
if (pBtd->hci_version < 3) { // Check the HCI Version of the Bluetooth dongle
|
if (pBtd->hci_version < 3) { // Check the HCI Version of the Bluetooth dongle
|
||||||
Notify(PSTR("\r\nYour dongle may not support reading the analog buttons, sensors and status\r\nYour HCI Version is: "), 0x80);
|
Notify(PSTR("\r\nYour dongle may not support reading the analog buttons, sensors and status\r\nYour HCI Version is: "), 0x80);
|
||||||
Notify(pBtd->hci_version, 0x80);
|
Notify(pBtd->hci_version, 0x80);
|
||||||
|
@ -270,7 +270,7 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
l2capinbuf[i] = ACLData[i];
|
l2capinbuf[i] = ACLData[i];
|
||||||
if ((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001) { //l2cap_control - Channel ID for ACL-U
|
if ((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001) { //l2cap_control - Channel ID for ACL-U
|
||||||
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
|
@ -330,14 +330,14 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
}
|
}
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) {
|
||||||
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnect Request: Control Channel"), 0x80);
|
Notify(PSTR("\r\nDisconnect Request: Control Channel"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
pBtd->l2cap_disconnection_response(hci_handle, identifier, control_dcid, control_scid);
|
pBtd->l2cap_disconnection_response(hci_handle, identifier, control_dcid, control_scid);
|
||||||
Reset();
|
Reset();
|
||||||
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"), 0x80);
|
Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
|
@ -397,7 +397,7 @@ void PS3BT::L2CAP_task() {
|
||||||
switch (l2cap_state) {
|
switch (l2cap_state) {
|
||||||
case L2CAP_WAIT:
|
case L2CAP_WAIT:
|
||||||
if (l2cap_connection_request_control_flag) {
|
if (l2cap_connection_request_control_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHID Control Incoming Connection Request"), 0x80);
|
Notify(PSTR("\r\nHID Control Incoming Connection Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, PENDING);
|
pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, PENDING);
|
||||||
|
@ -411,7 +411,7 @@ void PS3BT::L2CAP_task() {
|
||||||
break;
|
break;
|
||||||
case L2CAP_CONTROL_REQUEST:
|
case L2CAP_CONTROL_REQUEST:
|
||||||
if (l2cap_config_request_control_flag) {
|
if (l2cap_config_request_control_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHID Control Configuration Request"), 0x80);
|
Notify(PSTR("\r\nHID Control Configuration Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_config_response(hci_handle, identifier, control_scid);
|
pBtd->l2cap_config_response(hci_handle, identifier, control_scid);
|
||||||
|
@ -421,7 +421,7 @@ void PS3BT::L2CAP_task() {
|
||||||
|
|
||||||
case L2CAP_CONTROL_SUCCESS:
|
case L2CAP_CONTROL_SUCCESS:
|
||||||
if (l2cap_config_success_control_flag) {
|
if (l2cap_config_success_control_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80);
|
Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
l2cap_state = L2CAP_INTERRUPT_SETUP;
|
l2cap_state = L2CAP_INTERRUPT_SETUP;
|
||||||
|
@ -429,7 +429,7 @@ void PS3BT::L2CAP_task() {
|
||||||
break;
|
break;
|
||||||
case L2CAP_INTERRUPT_SETUP:
|
case L2CAP_INTERRUPT_SETUP:
|
||||||
if (l2cap_connection_request_interrupt_flag) {
|
if (l2cap_connection_request_interrupt_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHID Interrupt Incoming Connection Request"), 0x80);
|
Notify(PSTR("\r\nHID Interrupt Incoming Connection Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, PENDING);
|
pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, PENDING);
|
||||||
|
@ -444,7 +444,7 @@ void PS3BT::L2CAP_task() {
|
||||||
break;
|
break;
|
||||||
case L2CAP_INTERRUPT_REQUEST:
|
case L2CAP_INTERRUPT_REQUEST:
|
||||||
if (l2cap_config_request_interrupt_flag) {
|
if (l2cap_config_request_interrupt_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHID Interrupt Configuration Request"), 0x80);
|
Notify(PSTR("\r\nHID Interrupt Configuration Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_config_response(hci_handle, identifier, interrupt_scid);
|
pBtd->l2cap_config_response(hci_handle, identifier, interrupt_scid);
|
||||||
|
@ -453,7 +453,7 @@ void PS3BT::L2CAP_task() {
|
||||||
break;
|
break;
|
||||||
case L2CAP_INTERRUPT_SUCCESS:
|
case L2CAP_INTERRUPT_SUCCESS:
|
||||||
if (l2cap_config_success_interrupt_flag) {
|
if (l2cap_config_success_interrupt_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHID Interrupt Successfully Configured"), 0x80);
|
Notify(PSTR("\r\nHID Interrupt Successfully Configured"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
if (remote_name[0] == 'M') { // First letter in Motion Controller ('M')
|
if (remote_name[0] == 'M') { // First letter in Motion Controller ('M')
|
||||||
|
@ -473,7 +473,7 @@ void PS3BT::L2CAP_task() {
|
||||||
|
|
||||||
case L2CAP_INTERRUPT_DISCONNECT:
|
case L2CAP_INTERRUPT_DISCONNECT:
|
||||||
if (l2cap_disconnect_response_interrupt_flag) {
|
if (l2cap_disconnect_response_interrupt_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80);
|
Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
identifier++;
|
identifier++;
|
||||||
|
@ -484,7 +484,7 @@ void PS3BT::L2CAP_task() {
|
||||||
|
|
||||||
case L2CAP_CONTROL_DISCONNECT:
|
case L2CAP_CONTROL_DISCONNECT:
|
||||||
if (l2cap_disconnect_response_control_flag) {
|
if (l2cap_disconnect_response_control_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnected Control Channel"), 0x80);
|
Notify(PSTR("\r\nDisconnected Control Channel"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->hci_disconnect(hci_handle);
|
pBtd->hci_disconnect(hci_handle);
|
||||||
|
@ -517,20 +517,20 @@ void PS3BT::Run() {
|
||||||
if (millis() - timer > 1000) { // loop 1 second before sending the command
|
if (millis() - timer > 1000) { // loop 1 second before sending the command
|
||||||
if (remote_name[0] == 'P') { // First letter in PLAYSTATION(R)3 Controller ('P')
|
if (remote_name[0] == 'P') { // First letter in PLAYSTATION(R)3 Controller ('P')
|
||||||
setLedOn(LED1);
|
setLedOn(LED1);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDualshock 3 Controller Enabled\r\n"), 0x80);
|
Notify(PSTR("\r\nDualshock 3 Controller Enabled\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PS3Connected = true;
|
PS3Connected = true;
|
||||||
} else if (remote_name[0] == 'N') { // First letter in Navigation Controller ('N')
|
} else if (remote_name[0] == 'N') { // First letter in Navigation Controller ('N')
|
||||||
setLedOn(LED1); // This just turns LED constantly on, on the Navigation controller
|
setLedOn(LED1); // This just turns LED constantly on, on the Navigation controller
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nNavigation Controller Enabled\r\n"), 0x80);
|
Notify(PSTR("\r\nNavigation Controller Enabled\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PS3NavigationConnected = true;
|
PS3NavigationConnected = true;
|
||||||
} else if (remote_name[0] == 'M') { // First letter in Motion Controller ('M')
|
} else if (remote_name[0] == 'M') { // First letter in Motion Controller ('M')
|
||||||
moveSetBulb(Red);
|
moveSetBulb(Red);
|
||||||
timerBulbRumble = millis();
|
timerBulbRumble = millis();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nMotion Controller Enabled\r\n"), 0x80);
|
Notify(PSTR("\r\nMotion Controller Enabled\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PS3MoveConnected = true;
|
PS3MoveConnected = true;
|
||||||
|
@ -650,7 +650,7 @@ void PS3BT::moveSetBulb(Colors color) { //Use this to set the Color using the pr
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS3BT::moveSetRumble(uint8_t rumble) {
|
void PS3BT::moveSetRumble(uint8_t rumble) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
if (rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100)
|
if (rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100)
|
||||||
Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80);
|
Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
|
30
PS3USB.cpp
30
PS3USB.cpp
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PS3USB.h"
|
#include "PS3USB.h"
|
||||||
// To enable serial debugging uncomment "#define DEBUG" in message.h
|
// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
//#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers
|
//#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#endif
|
#endif
|
||||||
// check if address has already been assigned to an instance
|
// check if address has already been assigned to an instance
|
||||||
if (bAddress) {
|
if (bAddress) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nAddress in use"), 0x80);
|
Notify(PSTR("\r\nAddress in use"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
|
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
|
||||||
|
@ -68,14 +68,14 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
p = addrPool.GetUsbDevicePtr(0);
|
p = addrPool.GetUsbDevicePtr(0);
|
||||||
|
|
||||||
if (!p) {
|
if (!p) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nAddress not found"), 0x80);
|
Notify(PSTR("\r\nAddress not found"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
|
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p->epinfo) {
|
if (!p->epinfo) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nepinfo is null"), 0x80);
|
Notify(PSTR("\r\nepinfo is null"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_EPINFO_IS_NULL;
|
return USB_ERROR_EPINFO_IS_NULL;
|
||||||
|
@ -118,7 +118,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
p->lowspeed = false;
|
p->lowspeed = false;
|
||||||
addrPool.FreeAddress(bAddress);
|
addrPool.FreeAddress(bAddress);
|
||||||
bAddress = 0;
|
bAddress = 0;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
PrintHex<uint8_t > (rcode, 0x80);
|
||||||
|
@ -173,12 +173,12 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
if (PID == PS3_PID || PID == PS3NAVIGATION_PID) {
|
if (PID == PS3_PID || PID == PS3NAVIGATION_PID) {
|
||||||
if (PID == PS3_PID) {
|
if (PID == PS3_PID) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80);
|
Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PS3Connected = true;
|
PS3Connected = true;
|
||||||
} else { // must be a navigation controller
|
} else { // must be a navigation controller
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nNavigation Controller Connected"), 0x80);
|
Notify(PSTR("\r\nNavigation Controller Connected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PS3NavigationConnected = true;
|
PS3NavigationConnected = true;
|
||||||
|
@ -195,7 +195,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
for (uint8_t i = 6; i < 10; i++)
|
for (uint8_t i = 6; i < 10; i++)
|
||||||
readBuf[i] = 0x7F; // Set the analog joystick values to center position
|
readBuf[i] = 0x7F; // Set the analog joystick values to center position
|
||||||
} else { // must be a Motion controller
|
} else { // must be a Motion controller
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nMotion Controller Connected"), 0x80);
|
Notify(PSTR("\r\nMotion Controller Connected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PS3MoveConnected = true;
|
PS3MoveConnected = true;
|
||||||
|
@ -205,7 +205,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
writeBuf[0] = 0x02; // Set report ID, this is needed for Move commands to work
|
writeBuf[0] = 0x02; // Set report ID, this is needed for Move commands to work
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
|
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
|
||||||
for (int8_t i = 5; i > 0; i--) {
|
for (int8_t i = 5; i > 0; i--) {
|
||||||
PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
||||||
|
@ -221,29 +221,29 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
#endif
|
#endif
|
||||||
goto Fail;
|
goto Fail;
|
||||||
FailUnknownDevice:
|
FailUnknownDevice:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailUnknownDevice(VID, PID);
|
NotifyFailUnknownDevice(VID, PID);
|
||||||
#endif
|
#endif
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
Fail:
|
Fail:
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
|
@ -513,7 +513,7 @@ void PS3USB::moveSetBulb(Colors color) { //Use this to set the Color using the p
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS3USB::moveSetRumble(uint8_t rumble) {
|
void PS3USB::moveSetRumble(uint8_t rumble) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
if (rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100)
|
if (rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100)
|
||||||
Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80);
|
Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
|
50
SPP.cpp
50
SPP.cpp
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SPP.h"
|
#include "SPP.h"
|
||||||
// To enable serial debugging uncomment "#define DEBUG" in message.h
|
// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
//#define PRINTREPORT // Uncomment to print the report sent to the Arduino
|
//#define PRINTREPORT // Uncomment to print the report sent to the Arduino
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
if (((l2capinbuf[0] | (l2capinbuf[1] << 8)) == (hci_handle | 0x2000))) { // acl_handle_ok
|
if (((l2capinbuf[0] | (l2capinbuf[1] << 8)) == (hci_handle | 0x2000))) { // acl_handle_ok
|
||||||
if ((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001) { //l2cap_control - Channel ID for ACL-U
|
if ((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001) { //l2cap_control - Channel ID for ACL-U
|
||||||
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
|
@ -178,7 +178,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_RESPONSE;
|
l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_RESPONSE;
|
||||||
}
|
}
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_INFORMATION_REQUEST) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_INFORMATION_REQUEST) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nInformation request"), 0x80);
|
Notify(PSTR("\r\nInformation request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
|
@ -252,7 +252,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
PrintHex<uint8_t > (rfcommPfBit, 0x80);
|
PrintHex<uint8_t > (rfcommPfBit, 0x80);
|
||||||
#endif
|
#endif
|
||||||
if (rfcommChannelType == RFCOMM_DISC) {
|
if (rfcommChannelType == RFCOMM_DISC) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nReceived Disconnect RFCOMM Command on channel: "), 0x80);
|
Notify(PSTR("\r\nReceived Disconnect RFCOMM Command on channel: "), 0x80);
|
||||||
PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
|
PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -282,7 +282,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
Notifyc(l2capinbuf[i + 11 + offset], 0x80);
|
Notifyc(l2capinbuf[i + 11 + offset], 0x80);
|
||||||
#endif
|
#endif
|
||||||
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command
|
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80);
|
Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
rfcommbuf[0] = BT_RFCOMM_RPN_RSP; // Command
|
rfcommbuf[0] = BT_RFCOMM_RPN_RSP; // Command
|
||||||
|
@ -297,7 +297,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
rfcommbuf[9] = l2capinbuf[20]; // Number of Frames
|
rfcommbuf[9] = l2capinbuf[20]; // Number of Frames
|
||||||
sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); // UIH Remote Port Negotiation Response
|
sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); // UIH Remote Port Negotiation Response
|
||||||
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_CMD) { // UIH Modem Status Command
|
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_CMD) { // UIH Modem Status Command
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80);
|
Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
rfcommbuf[0] = BT_RFCOMM_MSC_RSP; // UIH Modem Status Response
|
rfcommbuf[0] = BT_RFCOMM_MSC_RSP; // UIH Modem Status Response
|
||||||
|
@ -308,12 +308,12 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (rfcommChannelType == RFCOMM_SABM) { // SABM Command - this is sent twice: once for channel 0 and then for the channel to establish
|
if (rfcommChannelType == RFCOMM_SABM) { // SABM Command - this is sent twice: once for channel 0 and then for the channel to establish
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nReceived SABM Command"), 0x80);
|
Notify(PSTR("\r\nReceived SABM Command"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
sendRfcomm(rfcommChannel, rfcommDirection, rfcommCommandResponse, RFCOMM_UA, rfcommPfBit, rfcommbuf, 0x00); // UA Command
|
sendRfcomm(rfcommChannel, rfcommDirection, rfcommCommandResponse, RFCOMM_UA, rfcommPfBit, rfcommbuf, 0x00); // UA Command
|
||||||
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_PN_CMD) { // UIH Parameter Negotiation Command
|
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_PN_CMD) { // UIH Parameter Negotiation Command
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nReceived UIH Parameter Negotiation Command"), 0x80);
|
Notify(PSTR("\r\nReceived UIH Parameter Negotiation Command"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
rfcommbuf[0] = BT_RFCOMM_PN_RSP; // UIH Parameter Negotiation Response
|
rfcommbuf[0] = BT_RFCOMM_PN_RSP; // UIH Parameter Negotiation Response
|
||||||
|
@ -328,7 +328,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
rfcommbuf[9] = 0x00; // Number of Frames
|
rfcommbuf[9] = 0x00; // Number of Frames
|
||||||
sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A);
|
sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A);
|
||||||
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_CMD) { // UIH Modem Status Command
|
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_CMD) { // UIH Modem Status Command
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80);
|
Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
rfcommbuf[0] = BT_RFCOMM_MSC_RSP; // UIH Modem Status Response
|
rfcommbuf[0] = BT_RFCOMM_MSC_RSP; // UIH Modem Status Response
|
||||||
|
@ -338,7 +338,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x04);
|
sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x04);
|
||||||
|
|
||||||
delay(1);
|
delay(1);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSend UIH Modem Status Command"), 0x80);
|
Notify(PSTR("\r\nSend UIH Modem Status Command"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
rfcommbuf[0] = BT_RFCOMM_MSC_CMD; // UIH Modem Status Command
|
rfcommbuf[0] = BT_RFCOMM_MSC_CMD; // UIH Modem Status Command
|
||||||
|
@ -349,7 +349,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x04);
|
sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x04);
|
||||||
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_RSP) { // UIH Modem Status Response
|
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_RSP) { // UIH Modem Status Response
|
||||||
if (!creditSent) {
|
if (!creditSent) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSend UIH Command with credit"), 0x80);
|
Notify(PSTR("\r\nSend UIH Command with credit"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
sendRfcommCredit(rfcommChannelConnection, rfcommDirection, 0, RFCOMM_UIH, 0x10, sizeof (rfcommDataBuffer)); // Send credit
|
sendRfcommCredit(rfcommChannelConnection, rfcommDirection, 0, RFCOMM_UIH, 0x10, sizeof (rfcommDataBuffer)); // Send credit
|
||||||
|
@ -358,11 +358,11 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
waitForLastCommand = true;
|
waitForLastCommand = true;
|
||||||
}
|
}
|
||||||
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[10] == 0x01) { // UIH Command with credit
|
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[10] == 0x01) { // UIH Command with credit
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nReceived UIH Command with credit"), 0x80);
|
Notify(PSTR("\r\nReceived UIH Command with credit"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command
|
} else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80);
|
Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
rfcommbuf[0] = BT_RFCOMM_RPN_RSP; // Command
|
rfcommbuf[0] = BT_RFCOMM_RPN_RSP; // Command
|
||||||
|
@ -376,7 +376,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
rfcommbuf[8] = l2capinbuf[19]; // MaxRatransm.
|
rfcommbuf[8] = l2capinbuf[19]; // MaxRatransm.
|
||||||
rfcommbuf[9] = l2capinbuf[20]; // Number of Frames
|
rfcommbuf[9] = l2capinbuf[20]; // Number of Frames
|
||||||
sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); // UIH Remote Port Negotiation Response
|
sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); // UIH Remote Port Negotiation Response
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nRFCOMM Connection is now established\r\n"), 0x80);
|
Notify(PSTR("\r\nRFCOMM Connection is now established\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
waitForLastCommand = false;
|
waitForLastCommand = false;
|
||||||
|
@ -384,7 +384,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
connected = true; // The RFCOMM channel is now established
|
connected = true; // The RFCOMM channel is now established
|
||||||
sppIndex = 0;
|
sppIndex = 0;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
else if (rfcommChannelType != RFCOMM_DISC) {
|
else if (rfcommChannelType != RFCOMM_DISC) {
|
||||||
Notify(PSTR("\r\nUnsupported RFCOMM Data - ChannelType: "), 0x80);
|
Notify(PSTR("\r\nUnsupported RFCOMM Data - ChannelType: "), 0x80);
|
||||||
PrintHex<uint8_t > (rfcommChannelType, 0x80);
|
PrintHex<uint8_t > (rfcommChannelType, 0x80);
|
||||||
|
@ -409,7 +409,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
|
|
||||||
void SPP::Run() {
|
void SPP::Run() {
|
||||||
if (waitForLastCommand && (millis() - timer) > 100) { // We will only wait 100ms and see if the UIH Remote Port Negotiation Command is send, as some deviced don't send it
|
if (waitForLastCommand && (millis() - timer) > 100) { // We will only wait 100ms and see if the UIH Remote Port Negotiation Command is send, as some deviced don't send it
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nRFCOMM Connection is now established - Automatic\r\n"), 0x80);
|
Notify(PSTR("\r\nRFCOMM Connection is now established - Automatic\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
creditSent = false;
|
creditSent = false;
|
||||||
|
@ -425,7 +425,7 @@ void SPP::SDP_task() {
|
||||||
case L2CAP_SDP_WAIT:
|
case L2CAP_SDP_WAIT:
|
||||||
if (l2cap_connection_request_sdp_flag) {
|
if (l2cap_connection_request_sdp_flag) {
|
||||||
l2cap_event_flag &= ~L2CAP_FLAG_CONNECTION_SDP_REQUEST; // Clear flag
|
l2cap_event_flag &= ~L2CAP_FLAG_CONNECTION_SDP_REQUEST; // Clear flag
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSDP Incoming Connection Request"), 0x80);
|
Notify(PSTR("\r\nSDP Incoming Connection Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_connection_response(hci_handle, identifier, sdp_dcid, sdp_scid, PENDING);
|
pBtd->l2cap_connection_response(hci_handle, identifier, sdp_dcid, sdp_scid, PENDING);
|
||||||
|
@ -440,7 +440,7 @@ void SPP::SDP_task() {
|
||||||
case L2CAP_SDP_REQUEST:
|
case L2CAP_SDP_REQUEST:
|
||||||
if (l2cap_config_request_sdp_flag) {
|
if (l2cap_config_request_sdp_flag) {
|
||||||
l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_SDP_REQUEST; // Clear flag
|
l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_SDP_REQUEST; // Clear flag
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSDP Configuration Request"), 0x80);
|
Notify(PSTR("\r\nSDP Configuration Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_config_response(hci_handle, identifier, sdp_scid);
|
pBtd->l2cap_config_response(hci_handle, identifier, sdp_scid);
|
||||||
|
@ -450,7 +450,7 @@ void SPP::SDP_task() {
|
||||||
case L2CAP_SDP_SUCCESS:
|
case L2CAP_SDP_SUCCESS:
|
||||||
if (l2cap_config_success_sdp_flag) {
|
if (l2cap_config_success_sdp_flag) {
|
||||||
l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_SDP_SUCCESS; // Clear flag
|
l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_SDP_SUCCESS; // Clear flag
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSDP Successfully Configured"), 0x80);
|
Notify(PSTR("\r\nSDP Successfully Configured"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
firstMessage = true; // Reset bool
|
firstMessage = true; // Reset bool
|
||||||
|
@ -462,7 +462,7 @@ void SPP::SDP_task() {
|
||||||
if (l2cap_disconnect_request_sdp_flag) {
|
if (l2cap_disconnect_request_sdp_flag) {
|
||||||
l2cap_event_flag &= ~L2CAP_FLAG_DISCONNECT_SDP_REQUEST; // Clear flag
|
l2cap_event_flag &= ~L2CAP_FLAG_DISCONNECT_SDP_REQUEST; // Clear flag
|
||||||
SDPConnected = false;
|
SDPConnected = false;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnected SDP Channel"), 0x80);
|
Notify(PSTR("\r\nDisconnected SDP Channel"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_disconnection_response(hci_handle, identifier, sdp_dcid, sdp_scid);
|
pBtd->l2cap_disconnection_response(hci_handle, identifier, sdp_dcid, sdp_scid);
|
||||||
|
@ -472,7 +472,7 @@ void SPP::SDP_task() {
|
||||||
break;
|
break;
|
||||||
case L2CAP_DISCONNECT_RESPONSE: // This is for both disconnection response from the RFCOMM and SDP channel if they were connected
|
case L2CAP_DISCONNECT_RESPONSE: // This is for both disconnection response from the RFCOMM and SDP channel if they were connected
|
||||||
if (l2cap_disconnect_response_flag) {
|
if (l2cap_disconnect_response_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnected L2CAP Connection"), 0x80);
|
Notify(PSTR("\r\nDisconnected L2CAP Connection"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
RFCOMMConnected = false;
|
RFCOMMConnected = false;
|
||||||
|
@ -492,7 +492,7 @@ void SPP::RFCOMM_task() {
|
||||||
case L2CAP_RFCOMM_WAIT:
|
case L2CAP_RFCOMM_WAIT:
|
||||||
if (l2cap_connection_request_rfcomm_flag) {
|
if (l2cap_connection_request_rfcomm_flag) {
|
||||||
l2cap_event_flag &= ~L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST; // Clear flag
|
l2cap_event_flag &= ~L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST; // Clear flag
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nRFCOMM Incoming Connection Request"), 0x80);
|
Notify(PSTR("\r\nRFCOMM Incoming Connection Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_connection_response(hci_handle, identifier, rfcomm_dcid, rfcomm_scid, PENDING);
|
pBtd->l2cap_connection_response(hci_handle, identifier, rfcomm_dcid, rfcomm_scid, PENDING);
|
||||||
|
@ -507,7 +507,7 @@ void SPP::RFCOMM_task() {
|
||||||
case L2CAP_RFCOMM_REQUEST:
|
case L2CAP_RFCOMM_REQUEST:
|
||||||
if (l2cap_config_request_rfcomm_flag) {
|
if (l2cap_config_request_rfcomm_flag) {
|
||||||
l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_RFCOMM_REQUEST; // Clear flag
|
l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_RFCOMM_REQUEST; // Clear flag
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nRFCOMM Configuration Request"), 0x80);
|
Notify(PSTR("\r\nRFCOMM Configuration Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_config_response(hci_handle, identifier, rfcomm_scid);
|
pBtd->l2cap_config_response(hci_handle, identifier, rfcomm_scid);
|
||||||
|
@ -517,7 +517,7 @@ void SPP::RFCOMM_task() {
|
||||||
case L2CAP_RFCOMM_SUCCESS:
|
case L2CAP_RFCOMM_SUCCESS:
|
||||||
if (l2cap_config_success_rfcomm_flag) {
|
if (l2cap_config_success_rfcomm_flag) {
|
||||||
l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS; // Clear flag
|
l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS; // Clear flag
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nRFCOMM Successfully Configured"), 0x80);
|
Notify(PSTR("\r\nRFCOMM Successfully Configured"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
rfcommAvailable = 0; // Reset number of bytes available
|
rfcommAvailable = 0; // Reset number of bytes available
|
||||||
|
@ -531,7 +531,7 @@ void SPP::RFCOMM_task() {
|
||||||
l2cap_event_flag &= ~L2CAP_FLAG_DISCONNECT_RFCOMM_REQUEST; // Clear flag
|
l2cap_event_flag &= ~L2CAP_FLAG_DISCONNECT_RFCOMM_REQUEST; // Clear flag
|
||||||
RFCOMMConnected = false;
|
RFCOMMConnected = false;
|
||||||
connected = false;
|
connected = false;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnected RFCOMM Channel"), 0x80);
|
Notify(PSTR("\r\nDisconnected RFCOMM Channel"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_disconnection_response(hci_handle, identifier, rfcomm_dcid, rfcomm_scid);
|
pBtd->l2cap_disconnection_response(hci_handle, identifier, rfcomm_dcid, rfcomm_scid);
|
||||||
|
|
102
Wii.cpp
102
Wii.cpp
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Wii.h"
|
#include "Wii.h"
|
||||||
// To enable serial debugging uncomment "#define DEBUG" in message.h
|
// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
//#define PRINTREPORT // Uncomment to print the report send by the Wii controllers
|
//#define PRINTREPORT // Uncomment to print the report send by the Wii controllers
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ void WII::Reset() {
|
||||||
|
|
||||||
void WII::disconnect() { // Use this void to disconnect any of the controllers
|
void WII::disconnect() { // Use this void to disconnect any of the controllers
|
||||||
if (motionPlusConnected && !pBtd->motionPlusInside) { // Disable the Motion Plus extension
|
if (motionPlusConnected && !pBtd->motionPlusInside) { // Disable the Motion Plus extension
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDeactivating Motion Plus"), 0x80);
|
Notify(PSTR("\r\nDeactivating Motion Plus"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
initExtension1(); // This will disable the Motion Plus extension
|
initExtension1(); // This will disable the Motion Plus extension
|
||||||
|
@ -144,7 +144,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
if ((l2capinbuf[0] | (l2capinbuf[1] << 8)) == (hci_handle | 0x2000)) { // acl_handle_ok or it's a new connection
|
if ((l2capinbuf[0] | (l2capinbuf[1] << 8)) == (hci_handle | 0x2000)) { // acl_handle_ok or it's a new connection
|
||||||
if ((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001) { //l2cap_control - Channel ID for ACL-U
|
if ((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001) { //l2cap_control - Channel ID for ACL-U
|
||||||
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
|
@ -220,14 +220,14 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
}
|
}
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) {
|
||||||
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnect Request: Control Channel"), 0x80);
|
Notify(PSTR("\r\nDisconnect Request: Control Channel"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
pBtd->l2cap_disconnection_response(hci_handle, identifier, control_dcid, control_scid);
|
pBtd->l2cap_disconnection_response(hci_handle, identifier, control_dcid, control_scid);
|
||||||
Reset();
|
Reset();
|
||||||
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
} else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"), 0x80);
|
Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
|
@ -294,12 +294,12 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
wiiState = l2capinbuf[12]; // (0x01: Battery is nearly empty), (0x02: An Extension Controller is connected), (0x04: Speaker enabled), (0x08: IR enabled), (0x10: LED1, 0x20: LED2, 0x40: LED3, 0x80: LED4)
|
wiiState = l2capinbuf[12]; // (0x01: Battery is nearly empty), (0x02: An Extension Controller is connected), (0x04: Speaker enabled), (0x08: IR enabled), (0x10: LED1, 0x20: LED2, 0x40: LED3, 0x80: LED4)
|
||||||
batteryLevel = l2capinbuf[15]; // Update battery level
|
batteryLevel = l2capinbuf[15]; // Update battery level
|
||||||
if (l2capinbuf[12] & 0x01) {
|
if (l2capinbuf[12] & 0x01) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nWARNING: Battery is nearly empty"), 0x80);
|
Notify(PSTR("\r\nWARNING: Battery is nearly empty"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (l2capinbuf[12] & 0x02) { // Check if a extension is connected
|
if (l2capinbuf[12] & 0x02) { // Check if a extension is connected
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
if (!unknownExtensionConnected)
|
if (!unknownExtensionConnected)
|
||||||
Notify(PSTR("\r\nExtension connected"), 0x80);
|
Notify(PSTR("\r\nExtension connected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -309,11 +309,11 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
#endif
|
#endif
|
||||||
setReportMode(false, 0x35); // Also read the extension
|
setReportMode(false, 0x35); // Also read the extension
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nExtension disconnected"), 0x80);
|
Notify(PSTR("\r\nExtension disconnected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
if (motionPlusConnected) {
|
if (motionPlusConnected) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR(" - from Motion Plus"), 0x80);
|
Notify(PSTR(" - from Motion Plus"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
l2cap_event_flag &= ~WII_FLAG_NUNCHUCK_CONNECTED;
|
l2cap_event_flag &= ~WII_FLAG_NUNCHUCK_CONNECTED;
|
||||||
|
@ -321,7 +321,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
nunchuckConnected = false;
|
nunchuckConnected = false;
|
||||||
//else if(classicControllerConnected)
|
//else if(classicControllerConnected)
|
||||||
} else if (nunchuckConnected) {
|
} else if (nunchuckConnected) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR(" - Nunchuck"), 0x80);
|
Notify(PSTR(" - Nunchuck"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
nunchuckConnected = false; // It must be the Nunchuck controller then
|
nunchuckConnected = false; // It must be the Nunchuck controller then
|
||||||
|
@ -337,40 +337,40 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
if ((l2capinbuf[12] & 0x0F) == 0) { // No error
|
if ((l2capinbuf[12] & 0x0F) == 0) { // No error
|
||||||
// See: http://wiibrew.org/wiki/Wiimote/Extension_Controllers
|
// See: http://wiibrew.org/wiki/Wiimote/Extension_Controllers
|
||||||
if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x00 && l2capinbuf[20] == 0x00) {
|
if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x00 && l2capinbuf[20] == 0x00) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nNunchuck connected"), 0x80);
|
Notify(PSTR("\r\nNunchuck connected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
l2cap_event_flag |= WII_FLAG_NUNCHUCK_CONNECTED;
|
l2cap_event_flag |= WII_FLAG_NUNCHUCK_CONNECTED;
|
||||||
} else if (l2capinbuf[16] == 0x00 && (l2capinbuf[17] == 0xA6 || l2capinbuf[17] == 0xA4) && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x00 && l2capinbuf[20] == 0x05) {
|
} else if (l2capinbuf[16] == 0x00 && (l2capinbuf[17] == 0xA6 || l2capinbuf[17] == 0xA4) && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x00 && l2capinbuf[20] == 0x05) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nMotion Plus connected"), 0x80);
|
Notify(PSTR("\r\nMotion Plus connected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
l2cap_event_flag |= WII_FLAG_MOTION_PLUS_CONNECTED;
|
l2cap_event_flag |= WII_FLAG_MOTION_PLUS_CONNECTED;
|
||||||
} else if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x04 && l2capinbuf[20] == 0x05) {
|
} else if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x04 && l2capinbuf[20] == 0x05) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nMotion Plus activated in normal mode"), 0x80);
|
Notify(PSTR("\r\nMotion Plus activated in normal mode"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
motionPlusConnected = true;
|
motionPlusConnected = true;
|
||||||
} else if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x05 && l2capinbuf[20] == 0x05) {
|
} else if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x05 && l2capinbuf[20] == 0x05) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nMotion Plus activated in Nunchuck pass-through mode"), 0x80);
|
Notify(PSTR("\r\nMotion Plus activated in Nunchuck pass-through mode"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
activateNunchuck = false;
|
activateNunchuck = false;
|
||||||
motionPlusConnected = true;
|
motionPlusConnected = true;
|
||||||
nunchuckConnected = true;
|
nunchuckConnected = true;
|
||||||
} 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) {
|
} 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) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nInactive Wii Motion Plus"), 0x80);
|
Notify(PSTR("\r\nInactive Wii Motion Plus"), 0x80);
|
||||||
Notify(PSTR("\r\nPlease unplug the Motion Plus, disconnect the Wiimote and then replug the Motion Plus Extension"), 0x80);
|
Notify(PSTR("\r\nPlease unplug the Motion Plus, disconnect the Wiimote and then replug the Motion Plus Extension"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
stateCounter = 300; // Skip the rest in "L2CAP_CHECK_MOTION_PLUS_STATE"
|
stateCounter = 300; // Skip the rest in "L2CAP_CHECK_MOTION_PLUS_STATE"
|
||||||
} else if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x01 && l2capinbuf[20] == 0x20) {
|
} else if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x01 && l2capinbuf[20] == 0x20) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nWii U Pro Controller connected"), 0x80);
|
Notify(PSTR("\r\nWii U Pro Controller connected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
wiiUProControllerConnected = true;
|
wiiUProControllerConnected = true;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
else {
|
else {
|
||||||
Notify(PSTR("\r\nUnknown Device: "), 0x80);
|
Notify(PSTR("\r\nUnknown Device: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
|
@ -392,7 +392,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 0x22: // Acknowledge output report, return function result
|
case 0x22: // Acknowledge output report, return function result
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
if (l2capinbuf[13] != 0x00) { // Check if there is an error
|
if (l2capinbuf[13] != 0x00) { // Check if there is an error
|
||||||
Notify(PSTR("\r\nCommand failed: "), 0x80);
|
Notify(PSTR("\r\nCommand failed: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
||||||
|
@ -496,7 +496,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
if ((micros() - timer) > 1000000) { // Loop for 1 sec before resetting the values
|
if ((micros() - timer) > 1000000) { // Loop for 1 sec before resetting the values
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nThe gyro values has been reset"), 0x80);
|
Notify(PSTR("\r\nThe gyro values has been reset"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
gyroYawZero = (l2capinbuf[15] | ((l2capinbuf[18] & 0xFC) << 6));
|
gyroYawZero = (l2capinbuf[15] | ((l2capinbuf[18] & 0xFC) << 6));
|
||||||
|
@ -531,7 +531,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
if (!extensionConnected) {
|
if (!extensionConnected) {
|
||||||
extensionConnected = true;
|
extensionConnected = true;
|
||||||
unknownExtensionConnected = true;
|
unknownExtensionConnected = true;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nExtension connected to Motion Plus"), 0x80);
|
Notify(PSTR("\r\nExtension connected to Motion Plus"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
if (extensionConnected && !unknownExtensionConnected) {
|
if (extensionConnected && !unknownExtensionConnected) {
|
||||||
extensionConnected = false;
|
extensionConnected = false;
|
||||||
unknownExtensionConnected = true;
|
unknownExtensionConnected = true;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nExtension disconnected from Motion Plus"), 0x80);
|
Notify(PSTR("\r\nExtension disconnected from Motion Plus"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
nunchuckConnected = false; // There is no extension connected to the Motion Plus if this report is sent
|
nunchuckConnected = false; // There is no extension connected to the Motion Plus if this report is sent
|
||||||
|
@ -564,7 +564,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
hatValues[RightHatY] = (l2capinbuf[21] | l2capinbuf[22] << 8);
|
hatValues[RightHatY] = (l2capinbuf[21] | l2capinbuf[22] << 8);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
default:
|
default:
|
||||||
Notify(PSTR("\r\nUnknown Report type: "), 0x80);
|
Notify(PSTR("\r\nUnknown Report type: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[9], 0x80);
|
PrintHex<uint8_t > (l2capinbuf[9], 0x80);
|
||||||
|
@ -583,7 +583,7 @@ void WII::L2CAP_task() {
|
||||||
/* These states are used if the Wiimote is the host */
|
/* These states are used if the Wiimote is the host */
|
||||||
case L2CAP_CONTROL_SUCCESS:
|
case L2CAP_CONTROL_SUCCESS:
|
||||||
if (l2cap_config_success_control_flag) {
|
if (l2cap_config_success_control_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80);
|
Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
l2cap_state = L2CAP_INTERRUPT_SETUP;
|
l2cap_state = L2CAP_INTERRUPT_SETUP;
|
||||||
|
@ -592,7 +592,7 @@ void WII::L2CAP_task() {
|
||||||
|
|
||||||
case L2CAP_INTERRUPT_SETUP:
|
case L2CAP_INTERRUPT_SETUP:
|
||||||
if (l2cap_connection_request_interrupt_flag) {
|
if (l2cap_connection_request_interrupt_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHID Interrupt Incoming Connection Request"), 0x80);
|
Notify(PSTR("\r\nHID Interrupt Incoming Connection Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, PENDING);
|
pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, PENDING);
|
||||||
|
@ -609,7 +609,7 @@ void WII::L2CAP_task() {
|
||||||
/* These states are used if the Arduino is the host */
|
/* These states are used if the Arduino is the host */
|
||||||
case L2CAP_CONTROL_CONNECT_REQUEST:
|
case L2CAP_CONTROL_CONNECT_REQUEST:
|
||||||
if (l2cap_connected_control_flag) {
|
if (l2cap_connected_control_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSend HID Control Config Request"), 0x80);
|
Notify(PSTR("\r\nSend HID Control Config Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
identifier++;
|
identifier++;
|
||||||
|
@ -620,7 +620,7 @@ void WII::L2CAP_task() {
|
||||||
|
|
||||||
case L2CAP_CONTROL_CONFIG_REQUEST:
|
case L2CAP_CONTROL_CONFIG_REQUEST:
|
||||||
if (l2cap_config_success_control_flag) {
|
if (l2cap_config_success_control_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSend HID Interrupt Connection Request"), 0x80);
|
Notify(PSTR("\r\nSend HID Interrupt Connection Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
identifier++;
|
identifier++;
|
||||||
|
@ -631,7 +631,7 @@ void WII::L2CAP_task() {
|
||||||
|
|
||||||
case L2CAP_INTERRUPT_CONNECT_REQUEST:
|
case L2CAP_INTERRUPT_CONNECT_REQUEST:
|
||||||
if (l2cap_connected_interrupt_flag) {
|
if (l2cap_connected_interrupt_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSend HID Interrupt Config Request"), 0x80);
|
Notify(PSTR("\r\nSend HID Interrupt Config Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
identifier++;
|
identifier++;
|
||||||
|
@ -642,7 +642,7 @@ void WII::L2CAP_task() {
|
||||||
|
|
||||||
case L2CAP_INTERRUPT_CONFIG_REQUEST:
|
case L2CAP_INTERRUPT_CONFIG_REQUEST:
|
||||||
if (l2cap_config_success_interrupt_flag) { // Now the HID channels is established
|
if (l2cap_config_success_interrupt_flag) { // Now the HID channels is established
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHID Channels Established"), 0x80);
|
Notify(PSTR("\r\nHID Channels Established"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->connectToWii = false;
|
pBtd->connectToWii = false;
|
||||||
|
@ -657,7 +657,7 @@ void WII::L2CAP_task() {
|
||||||
|
|
||||||
case L2CAP_INTERRUPT_DISCONNECT:
|
case L2CAP_INTERRUPT_DISCONNECT:
|
||||||
if (l2cap_disconnect_response_interrupt_flag) {
|
if (l2cap_disconnect_response_interrupt_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80);
|
Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
identifier++;
|
identifier++;
|
||||||
|
@ -668,7 +668,7 @@ void WII::L2CAP_task() {
|
||||||
|
|
||||||
case L2CAP_CONTROL_DISCONNECT:
|
case L2CAP_CONTROL_DISCONNECT:
|
||||||
if (l2cap_disconnect_response_control_flag) {
|
if (l2cap_disconnect_response_control_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnected Control Channel"), 0x80);
|
Notify(PSTR("\r\nDisconnected Control Channel"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->hci_disconnect(hci_handle);
|
pBtd->hci_disconnect(hci_handle);
|
||||||
|
@ -686,7 +686,7 @@ void WII::Run() {
|
||||||
if (pBtd->connectToWii && !pBtd->l2capConnectionClaimed && !wiimoteConnected && !activeConnection) {
|
if (pBtd->connectToWii && !pBtd->l2capConnectionClaimed && !wiimoteConnected && !activeConnection) {
|
||||||
pBtd->l2capConnectionClaimed = true;
|
pBtd->l2capConnectionClaimed = true;
|
||||||
activeConnection = true;
|
activeConnection = true;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSend HID Control Connection Request"), 0x80);
|
Notify(PSTR("\r\nSend HID Control Connection Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection
|
hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection
|
||||||
|
@ -695,7 +695,7 @@ void WII::Run() {
|
||||||
pBtd->l2cap_connection_request(hci_handle, identifier, control_dcid, HID_CTRL_PSM);
|
pBtd->l2cap_connection_request(hci_handle, identifier, control_dcid, HID_CTRL_PSM);
|
||||||
l2cap_state = L2CAP_CONTROL_CONNECT_REQUEST;
|
l2cap_state = L2CAP_CONTROL_CONNECT_REQUEST;
|
||||||
} else if (l2cap_connection_request_control_flag) {
|
} else if (l2cap_connection_request_control_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHID Control Incoming Connection Request"), 0x80);
|
Notify(PSTR("\r\nHID Control Incoming Connection Request"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, PENDING);
|
pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, PENDING);
|
||||||
|
@ -709,7 +709,7 @@ void WII::Run() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L2CAP_CHECK_MOTION_PLUS_STATE:
|
case L2CAP_CHECK_MOTION_PLUS_STATE:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
if (stateCounter == 0) // Only print onnce
|
if (stateCounter == 0) // Only print onnce
|
||||||
Notify(PSTR("\r\nChecking if a Motion Plus is connected"), 0x80);
|
Notify(PSTR("\r\nChecking if a Motion Plus is connected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -722,14 +722,14 @@ void WII::Run() {
|
||||||
timer = micros();
|
timer = micros();
|
||||||
|
|
||||||
if (unknownExtensionConnected) {
|
if (unknownExtensionConnected) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nA extension is also connected"), 0x80);
|
Notify(PSTR("\r\nA extension is also connected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
activateNunchuck = true; // For we will just set this to true as this the only extension supported so far
|
activateNunchuck = true; // For we will just set this to true as this the only extension supported so far
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (stateCounter == 601) { // We will try three times to check for the motion plus
|
} else if (stateCounter == 601) { // We will try three times to check for the motion plus
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nNo Motion Plus was detected"), 0x80);
|
Notify(PSTR("\r\nNo Motion Plus was detected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
stateCounter = 0;
|
stateCounter = 0;
|
||||||
|
@ -738,7 +738,7 @@ void WII::Run() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L2CAP_CHECK_EXTENSION_STATE: // This is used to check if there is anything plugged in to the extension port
|
case L2CAP_CHECK_EXTENSION_STATE: // This is used to check if there is anything plugged in to the extension port
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
if (stateCounter == 0) // Only print onnce
|
if (stateCounter == 0) // Only print onnce
|
||||||
Notify(PSTR("\r\nChecking if there is any extension connected"), 0x80);
|
Notify(PSTR("\r\nChecking if there is any extension connected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -785,7 +785,7 @@ void WII::Run() {
|
||||||
|
|
||||||
case L2CAP_DONE:
|
case L2CAP_DONE:
|
||||||
if (unknownExtensionConnected) {
|
if (unknownExtensionConnected) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
if (stateCounter == 0) // Only print once
|
if (stateCounter == 0) // Only print once
|
||||||
Notify(PSTR("\r\nChecking extension port"), 0x80);
|
Notify(PSTR("\r\nChecking extension port"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -803,7 +803,7 @@ void WII::Run() {
|
||||||
readExtensionType();
|
readExtensionType();
|
||||||
else if (stateCounter == 250) {
|
else if (stateCounter == 250) {
|
||||||
if (nunchuck_connected_flag) {
|
if (nunchuck_connected_flag) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nNunchuck was reconnected"), 0x80);
|
Notify(PSTR("\r\nNunchuck was reconnected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
activateNunchuck = true;
|
activateNunchuck = true;
|
||||||
|
@ -813,7 +813,7 @@ void WII::Run() {
|
||||||
stateCounter = 449;
|
stateCounter = 449;
|
||||||
} else if (stateCounter == 300) {
|
} else if (stateCounter == 300) {
|
||||||
if (motionPlusConnected) {
|
if (motionPlusConnected) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nReactivating the Motion Plus"), 0x80);
|
Notify(PSTR("\r\nReactivating the Motion Plus"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
initMotionPlus();
|
initMotionPlus();
|
||||||
|
@ -967,19 +967,19 @@ void WII::initMotionPlus() {
|
||||||
void WII::activateMotionPlus() {
|
void WII::activateMotionPlus() {
|
||||||
uint8_t buf[1];
|
uint8_t buf[1];
|
||||||
if (pBtd->wiiUProController) {
|
if (pBtd->wiiUProController) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nActivating Wii U Pro Controller"), 0x80);
|
Notify(PSTR("\r\nActivating Wii U Pro Controller"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
buf[0] = 0x00; // It seems like you can send anything but 0x04, 0x05, and 0x07
|
buf[0] = 0x00; // It seems like you can send anything but 0x04, 0x05, and 0x07
|
||||||
} else if (activateNunchuck) {
|
} else if (activateNunchuck) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nActivating Motion Plus in pass-through mode"), 0x80);
|
Notify(PSTR("\r\nActivating Motion Plus in pass-through mode"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
buf[0] = 0x05; // Activate nunchuck pass-through mode
|
buf[0] = 0x05; // Activate nunchuck pass-through mode
|
||||||
} //else if(classicControllerConnected && extensionConnected)
|
} //else if(classicControllerConnected && extensionConnected)
|
||||||
//buf[0] = 0x07;
|
//buf[0] = 0x07;
|
||||||
else {
|
else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nActivating Motion Plus in normal mode"), 0x80);
|
Notify(PSTR("\r\nActivating Motion Plus in normal mode"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
buf[0] = 0x04; // Don't use any extension
|
buf[0] = 0x04; // Don't use any extension
|
||||||
|
@ -1071,58 +1071,58 @@ uint16_t WII::getAnalogHat(AnalogHat a) {
|
||||||
void WII::IRinitialize() { // Turns on and initialises the IR camera
|
void WII::IRinitialize() { // Turns on and initialises the IR camera
|
||||||
|
|
||||||
enableIRCamera1();
|
enableIRCamera1();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nEnable IR Camera1 Complete"), 0x80);
|
Notify(PSTR("\r\nEnable IR Camera1 Complete"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
delay(80);
|
delay(80);
|
||||||
|
|
||||||
enableIRCamera2();
|
enableIRCamera2();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nEnable IR Camera2 Complete"), 0x80);
|
Notify(PSTR("\r\nEnable IR Camera2 Complete"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
delay(80);
|
delay(80);
|
||||||
|
|
||||||
write0x08Value();
|
write0x08Value();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nWrote hex number 0x08"), 0x80);
|
Notify(PSTR("\r\nWrote hex number 0x08"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
delay(80);
|
delay(80);
|
||||||
|
|
||||||
writeSensitivityBlock1();
|
writeSensitivityBlock1();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nWrote Sensitivity Block 1"), 0x80);
|
Notify(PSTR("\r\nWrote Sensitivity Block 1"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
delay(80);
|
delay(80);
|
||||||
|
|
||||||
writeSensitivityBlock2();
|
writeSensitivityBlock2();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nWrote Sensitivity Block 2"), 0x80);
|
Notify(PSTR("\r\nWrote Sensitivity Block 2"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
delay(80);
|
delay(80);
|
||||||
|
|
||||||
uint8_t mode_num = 0x03;
|
uint8_t mode_num = 0x03;
|
||||||
setWiiModeNumber(mode_num); // Change input for whatever mode you want i.e. 0x01, 0x03, or 0x05
|
setWiiModeNumber(mode_num); // Change input for whatever mode you want i.e. 0x01, 0x03, or 0x05
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSet Wii Mode Number To 0x"), 0x80);
|
Notify(PSTR("\r\nSet Wii Mode Number To 0x"), 0x80);
|
||||||
PrintHex<uint8_t > (mode_num, 0x80);
|
PrintHex<uint8_t > (mode_num, 0x80);
|
||||||
#endif
|
#endif
|
||||||
delay(80);
|
delay(80);
|
||||||
|
|
||||||
write0x08Value();
|
write0x08Value();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nWrote Hex Number 0x08"), 0x80);
|
Notify(PSTR("\r\nWrote Hex Number 0x08"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
delay(80);
|
delay(80);
|
||||||
|
|
||||||
setReportMode(false, 0x33);
|
setReportMode(false, 0x33);
|
||||||
//setReportMode(false, 0x3f); // For full reporting mode, doesn't work yet
|
//setReportMode(false, 0x3f); // For full reporting mode, doesn't work yet
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSet Report Mode to 0x33"), 0x80);
|
Notify(PSTR("\r\nSet Report Mode to 0x33"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
delay(80);
|
delay(80);
|
||||||
|
|
||||||
statusRequest(); // Used to update wiiState - call isIRCameraEnabled() afterwards to check if it actually worked
|
statusRequest(); // Used to update wiiState - call isIRCameraEnabled() afterwards to check if it actually worked
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nIR Initialized"), 0x80);
|
Notify(PSTR("\r\nIR Initialized"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
30
XBOXRECV.cpp
30
XBOXRECV.cpp
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "XBOXRECV.h"
|
#include "XBOXRECV.h"
|
||||||
// To enable serial debugging uncomment "#define DEBUG" in message.h
|
// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
|
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#endif
|
#endif
|
||||||
// check if address has already been assigned to an instance
|
// check if address has already been assigned to an instance
|
||||||
if (bAddress) {
|
if (bAddress) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nAddress in use"), 0x80);
|
Notify(PSTR("\r\nAddress in use"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
|
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
|
||||||
|
@ -62,14 +62,14 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
p = addrPool.GetUsbDevicePtr(0);
|
p = addrPool.GetUsbDevicePtr(0);
|
||||||
|
|
||||||
if (!p) {
|
if (!p) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nAddress not found"), 0x80);
|
Notify(PSTR("\r\nAddress not found"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
|
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p->epinfo) {
|
if (!p->epinfo) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nepinfo is null"), 0x80);
|
Notify(PSTR("\r\nepinfo is null"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_EPINFO_IS_NULL;
|
return USB_ERROR_EPINFO_IS_NULL;
|
||||||
|
@ -97,7 +97,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (VID != XBOX_VID && VID != MADCATZ_VID) // We just check if it's a xbox receiver using the Vendor ID
|
if (VID != XBOX_VID && VID != MADCATZ_VID) // We just check if it's a xbox receiver using the Vendor ID
|
||||||
goto FailUnknownDevice;
|
goto FailUnknownDevice;
|
||||||
else if (PID != XBOX_WIRELESS_RECEIVER_PID && PID != XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID) {
|
else if (PID != XBOX_WIRELESS_RECEIVER_PID && PID != XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nYou'll need a wireless receiver for this libary to work"), 0x80);
|
Notify(PSTR("\r\nYou'll need a wireless receiver for this libary to work"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
goto FailUnknownDevice;
|
goto FailUnknownDevice;
|
||||||
|
@ -118,7 +118,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
p->lowspeed = false;
|
p->lowspeed = false;
|
||||||
addrPool.FreeAddress(bAddress);
|
addrPool.FreeAddress(bAddress);
|
||||||
bAddress = 0;
|
bAddress = 0;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
PrintHex<uint8_t > (rcode, 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -209,7 +209,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (rcode)
|
if (rcode)
|
||||||
goto FailSetConfDescr;
|
goto FailSetConfDescr;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nXbox Wireless Receiver Connected\r\n"), 0x80);
|
Notify(PSTR("\r\nXbox Wireless Receiver Connected\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
XboxReceiverConnected = true;
|
XboxReceiverConnected = true;
|
||||||
|
@ -218,31 +218,31 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
#endif
|
#endif
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
FailUnknownDevice:
|
FailUnknownDevice:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailUnknownDevice(VID,PID);
|
NotifyFailUnknownDevice(VID,PID);
|
||||||
#endif
|
#endif
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
|
@ -304,12 +304,12 @@ void XBOXRECV::readReport(uint8_t controller) {
|
||||||
// This report is send when a controller is connected and disconnected
|
// This report is send when a controller is connected and disconnected
|
||||||
if (readBuf[0] == 0x08 && readBuf[1] != Xbox360Connected[controller]) {
|
if (readBuf[0] == 0x08 && readBuf[1] != Xbox360Connected[controller]) {
|
||||||
Xbox360Connected[controller] = readBuf[1];
|
Xbox360Connected[controller] = readBuf[1];
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("Controller "), 0x80);
|
Notify(PSTR("Controller "), 0x80);
|
||||||
Notify(controller, 0x80);
|
Notify(controller, 0x80);
|
||||||
#endif
|
#endif
|
||||||
if (Xbox360Connected[controller]) {
|
if (Xbox360Connected[controller]) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
char* str = 0;
|
char* str = 0;
|
||||||
switch (readBuf[1]) {
|
switch (readBuf[1]) {
|
||||||
case 0x80: str = PSTR(" as controller\r\n");
|
case 0x80: str = PSTR(" as controller\r\n");
|
||||||
|
@ -335,7 +335,7 @@ void XBOXRECV::readReport(uint8_t controller) {
|
||||||
}
|
}
|
||||||
setLedOn(led, controller);
|
setLedOn(led, controller);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
else
|
else
|
||||||
Notify(PSTR(": disconnected\r\n"), 0x80);
|
Notify(PSTR(": disconnected\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
|
26
XBOXUSB.cpp
26
XBOXUSB.cpp
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "XBOXUSB.h"
|
#include "XBOXUSB.h"
|
||||||
// To enable serial debugging uncomment "#define DEBUG" in message.h
|
// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
|
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#endif
|
#endif
|
||||||
// check if address has already been assigned to an instance
|
// check if address has already been assigned to an instance
|
||||||
if (bAddress) {
|
if (bAddress) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nAddress in use"), 0x80);
|
Notify(PSTR("\r\nAddress in use"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
|
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
|
||||||
|
@ -60,14 +60,14 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
p = addrPool.GetUsbDevicePtr(0);
|
p = addrPool.GetUsbDevicePtr(0);
|
||||||
|
|
||||||
if (!p) {
|
if (!p) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nAddress not found"), 0x80);
|
Notify(PSTR("\r\nAddress not found"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
|
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p->epinfo) {
|
if (!p->epinfo) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nepinfo is null"), 0x80);
|
Notify(PSTR("\r\nepinfo is null"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
return USB_ERROR_EPINFO_IS_NULL;
|
return USB_ERROR_EPINFO_IS_NULL;
|
||||||
|
@ -95,12 +95,12 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID) // We just check if it's a xbox controller using the Vendor ID
|
if (VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID) // We just check if it's a xbox controller using the Vendor ID
|
||||||
goto FailUnknownDevice;
|
goto FailUnknownDevice;
|
||||||
if (PID == XBOX_WIRELESS_PID) {
|
if (PID == XBOX_WIRELESS_PID) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nYou have plugged in a wireless Xbox 360 controller - it doesn't support USB communication"), 0x80);
|
Notify(PSTR("\r\nYou have plugged in a wireless Xbox 360 controller - it doesn't support USB communication"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
goto FailUnknownDevice;
|
goto FailUnknownDevice;
|
||||||
} else if (PID == XBOX_WIRELESS_RECEIVER_PID || PID == XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID) {
|
} else if (PID == XBOX_WIRELESS_RECEIVER_PID || PID == XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nThis library only supports Xbox 360 controllers via USB"), 0x80);
|
Notify(PSTR("\r\nThis library only supports Xbox 360 controllers via USB"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
goto FailUnknownDevice;
|
goto FailUnknownDevice;
|
||||||
|
@ -121,7 +121,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
p->lowspeed = false;
|
p->lowspeed = false;
|
||||||
addrPool.FreeAddress(bAddress);
|
addrPool.FreeAddress(bAddress);
|
||||||
bAddress = 0;
|
bAddress = 0;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
PrintHex<uint8_t > (rcode, 0x80);
|
||||||
|
@ -173,7 +173,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (rcode)
|
if (rcode)
|
||||||
goto FailSetConfDescr;
|
goto FailSetConfDescr;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nXbox 360 Controller Connected\r\n"), 0x80);
|
Notify(PSTR("\r\nXbox 360 Controller Connected\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
setLedOn(LED1);
|
setLedOn(LED1);
|
||||||
|
@ -183,30 +183,30 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
FailUnknownDevice:
|
FailUnknownDevice:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailUnknownDevice(VID, PID);
|
NotifyFailUnknownDevice(VID, PID);
|
||||||
#endif
|
#endif
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
|
|
14
adk.cpp
14
adk.cpp
|
@ -227,43 +227,43 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailGetProto:
|
FailGetProto:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("\r\ngetProto:");
|
USBTRACE("\r\ngetProto:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSwAcc:
|
FailSwAcc:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("\r\nswAcc:");
|
USBTRACE("\r\nswAcc:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SwAttempt:
|
SwAttempt:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("\r\nAccessory mode switch attempt");
|
USBTRACE("\r\nAccessory mode switch attempt");
|
||||||
#endif
|
#endif
|
||||||
//FailOnInit:
|
//FailOnInit:
|
||||||
|
|
12
cdcacm.cpp
12
cdcacm.cpp
|
@ -183,36 +183,36 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailOnInit:
|
FailOnInit:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("OnInit:");
|
USBTRACE("OnInit:");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
Release();
|
Release();
|
||||||
|
|
12
cdcftdi.cpp
12
cdcftdi.cpp
|
@ -178,36 +178,36 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailOnInit:
|
FailOnInit:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("OnInit:");
|
USBTRACE("OnInit:");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
Release();
|
Release();
|
||||||
|
|
|
@ -155,36 +155,36 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailOnInit:
|
FailOnInit:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("OnInit:");
|
USBTRACE("OnInit:");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
Release();
|
Release();
|
||||||
|
|
14
hidboot.h
14
hidboot.h
|
@ -393,42 +393,42 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Init(uint8_t parent, uint8_t port, bool lowspeed
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetProtocol:
|
FailSetProtocol:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("SetProto:");
|
USBTRACE("SetProto:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetIdle:
|
FailSetIdle:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("SetIdle:");
|
USBTRACE("SetIdle:");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
Release();
|
Release();
|
||||||
|
|
|
@ -221,37 +221,37 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
FailSetIdle:
|
FailSetIdle:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("SetIdle:");
|
USBTRACE("SetIdle:");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
Release();
|
Release();
|
||||||
|
|
|
@ -174,7 +174,7 @@ uint8_t BulkOnly::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetDevDescr(rcode);
|
NotifyFailGetDevDescr(rcode);
|
||||||
#endif
|
#endif
|
||||||
rcode = USB_ERROR_FailGetDevDescr;
|
rcode = USB_ERROR_FailGetDevDescr;
|
||||||
|
@ -362,42 +362,42 @@ uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailOnInit:
|
FailOnInit:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("OnInit:");
|
USBTRACE("OnInit:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailGetMaxLUN:
|
FailGetMaxLUN:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("GetMaxLUN:");
|
USBTRACE("GetMaxLUN:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailInvalidSectorSize:
|
FailInvalidSectorSize:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("Sector Size is NOT VALID: ");
|
USBTRACE("Sector Size is NOT VALID: ");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
Release();
|
Release();
|
||||||
|
|
|
@ -63,7 +63,7 @@ void E_Notify(double d, int lvl) {
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
void NotifyFailGetDevDescr(void) {
|
void NotifyFailGetDevDescr(void) {
|
||||||
Notify(PSTR("\r\ngetDevDescr"), 0x80);
|
Notify(PSTR("\r\ngetDevDescr"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ e-mail : support@circuitsathome.com
|
||||||
#define __MESSAGE_H__
|
#define __MESSAGE_H__
|
||||||
|
|
||||||
// uncomment to activate
|
// uncomment to activate
|
||||||
//#define DEBUG
|
//#define DEBUG_USB_HOST
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
@ -31,7 +31,7 @@ void E_Notify(uint8_t b, int lvl);
|
||||||
void E_NotifyStr(char const * msg, int lvl);
|
void E_NotifyStr(char const * msg, int lvl);
|
||||||
void E_Notifyc(char c, int lvl);
|
void E_Notifyc(char c, int lvl);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
#define Notify E_Notify
|
#define Notify E_Notify
|
||||||
#define NotifyStr E_NotifyStr
|
#define NotifyStr E_NotifyStr
|
||||||
#define Notifyc E_Notifyc
|
#define Notifyc E_Notifyc
|
||||||
|
@ -61,7 +61,7 @@ void NotifyFail(uint8_t rcode);
|
||||||
|
|
||||||
template <class ERROR_TYPE>
|
template <class ERROR_TYPE>
|
||||||
void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
|
void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(msg, level);
|
Notify(msg, level);
|
||||||
Notify(PSTR(": "), level);
|
Notify(PSTR(": "), level);
|
||||||
PrintHex<ERROR_TYPE > (rcode, level);
|
PrintHex<ERROR_TYPE > (rcode, level);
|
||||||
|
@ -71,7 +71,7 @@ void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
|
||||||
|
|
||||||
template <class ERROR_TYPE>
|
template <class ERROR_TYPE>
|
||||||
void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
|
void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(msg, 0x80);
|
Notify(msg, 0x80);
|
||||||
Notify(PSTR(": "), 0x80);
|
Notify(PSTR(": "), 0x80);
|
||||||
PrintHex<ERROR_TYPE > (rcode, 0x80);
|
PrintHex<ERROR_TYPE > (rcode, 0x80);
|
||||||
|
|
|
@ -27,7 +27,7 @@ void E_Notifyc(char c, int lvl);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PrintHex(T val, int lvl) {
|
void PrintHex(T val, int lvl) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
int num_nibbles = sizeof(T) * 2;
|
int num_nibbles = sizeof(T) * 2;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -40,7 +40,7 @@ void PrintHex(T val, int lvl) {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PrintBin(T val, int lvl) {
|
void PrintBin(T val, int lvl) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
for(T mask = (((T) 1) << ((sizeof(T) << 3) - 1)); mask; mask >>= 1)
|
for(T mask = (((T) 1) << ((sizeof(T) << 3) - 1)); mask; mask >>= 1)
|
||||||
if(val & mask)
|
if(val & mask)
|
||||||
E_Notifyc('1', lvl);
|
E_Notifyc('1', lvl);
|
||||||
|
@ -51,7 +51,7 @@ void PrintBin(T val, int lvl) {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void SerialPrintHex(T val) {
|
void SerialPrintHex(T val) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
int num_nibbles = sizeof(T) * 2;
|
int num_nibbles = sizeof(T) * 2;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -64,7 +64,7 @@ void SerialPrintHex(T val) {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PrintHex2(Print *prn, T val) {
|
void PrintHex2(Print *prn, T val) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_USB_HOST
|
||||||
T mask = (((T) 1) << (((sizeof(T) << 1) - 1) << 2));
|
T mask = (((T) 1) << (((sizeof(T) << 1) - 1) << 2));
|
||||||
|
|
||||||
while(mask > 1) {
|
while(mask > 1) {
|
||||||
|
|
Loading…
Reference in a new issue