Merge remote branch 'origin' into xxxajk

This commit is contained in:
Andrew J. Kroll 2013-08-19 06:53:47 -04:00
commit 0e6cc53df5
26 changed files with 103 additions and 60 deletions

15
BTD.cpp
View file

@ -187,9 +187,14 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
// First interface in the configuration must have Bluetooth assigned Class/Subclass/Protocol // First interface in the configuration must have Bluetooth assigned Class/Subclass/Protocol
// And 3 endpoints - interrupt-IN, bulk-IN, bulk-OUT, not necessarily in this order // And 3 endpoints - interrupt-IN, bulk-IN, bulk-OUT, not necessarily in this order
for (uint8_t i = 0; i < num_of_conf; i++) { for (uint8_t i = 0; i < num_of_conf; i++) {
ConfigDescParser<USB_CLASS_WIRELESS_CTRL, WI_SUBCLASS_RF, WI_PROTOCOL_BT, CP_MASK_COMPARE_ALL> confDescrParser(this); if (VID == IOGEAR_GBU521_VID && PID == IOGEAR_GBU521_PID) {
rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); ConfigDescParser<USB_CLASS_VENDOR_SPECIFIC, WI_SUBCLASS_RF, WI_PROTOCOL_BT, CP_MASK_COMPARE_ALL> confDescrParser(this); // Needed for the IOGEAR GBU521
if (rcode) rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser);
} else {
ConfigDescParser<USB_CLASS_WIRELESS_CTRL, WI_SUBCLASS_RF, WI_PROTOCOL_BT, CP_MASK_COMPARE_ALL> confDescrParser(this);
rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser);
}
if (rcode) // Check error code
goto FailGetConfDescr; goto FailGetConfDescr;
if (bNumEP >= BTD_MAX_ENDPOINTS) // All endpoints extracted if (bNumEP >= BTD_MAX_ENDPOINTS) // All endpoints extracted
break; break;
@ -342,7 +347,7 @@ void BTD::HCI_event_task() {
/* check the event pipe*/ /* check the event pipe*/
uint16_t MAX_BUFFER_SIZE = BULK_MAXPKTSIZE; // Request more than 16 bytes anyway, the inTransfer routine will take care of this uint16_t MAX_BUFFER_SIZE = BULK_MAXPKTSIZE; // Request more than 16 bytes anyway, the inTransfer routine will take care of this
uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[ BTD_EVENT_PIPE ].epAddr, &MAX_BUFFER_SIZE, hcibuf); // input on endpoint 1 uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[ BTD_EVENT_PIPE ].epAddr, &MAX_BUFFER_SIZE, hcibuf); // input on endpoint 1
if (!rcode) // Check for errors if (!rcode || rcode == hrNAK) // Check for errors
{ {
switch (hcibuf[0]) //switch on event type switch (hcibuf[0]) //switch on event type
{ {
@ -527,7 +532,7 @@ void BTD::HCI_event_task() {
} // switch } // switch
} }
#ifdef EXTRADEBUG #ifdef EXTRADEBUG
else if (rcode != hrNAK) { else {
Notify(PSTR("\r\nHCI event error: "), 0x80); Notify(PSTR("\r\nHCI event error: "), 0x80);
D_PrintHex<uint8_t > (rcode, 0x80); D_PrintHex<uint8_t > (rcode, 0x80);
} }

15
BTD.h
View file

@ -22,13 +22,16 @@
#include "confdescparser.h" #include "confdescparser.h"
//PID and VID of the Sony PS3 devices //PID and VID of the Sony PS3 devices
#define PS3_VID 0x054C // Sony Corporation #define PS3_VID 0x054C // Sony Corporation
#define PS3_PID 0x0268 // PS3 Controller DualShock 3 #define PS3_PID 0x0268 // PS3 Controller DualShock 3
#define PS3NAVIGATION_PID 0x042F // Navigation controller #define PS3NAVIGATION_PID 0x042F // Navigation controller
#define PS3MOVE_PID 0x03D5 // Motion controller #define PS3MOVE_PID 0x03D5 // Motion controller
#define IOGEAR_GBU521_VID 0x0A5C // The IOGEAR GBU521 dongle does not presents itself correctly, so we have to check for it manually
#define IOGEAR_GBU521_PID 0x21E8
/* Bluetooth dongle data taken from descriptors */ /* Bluetooth dongle data taken from descriptors */
#define BULK_MAXPKTSIZE 64 // max size for ACL data #define BULK_MAXPKTSIZE 64 // max size for ACL data
// Used in control endpoint header for HCI Commands // Used in control endpoint header for HCI Commands
#define bmREQ_HCI_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE #define bmREQ_HCI_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE
@ -209,7 +212,7 @@ public:
* @return Returns true if the device's VID and PID matches this driver. * @return Returns true if the device's VID and PID matches this driver.
*/ */
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
return (vid == PS3_VID && (pid == PS3_PID || pid == PS3NAVIGATION_PID || pid == PS3MOVE_PID)); return ((vid == PS3_VID || vid == IOGEAR_GBU521_VID) && (pid == PS3_PID || pid == PS3NAVIGATION_PID || pid == PS3MOVE_PID || pid == IOGEAR_GBU521_PID));
}; };
/**@}*/ /**@}*/

View file

@ -55,7 +55,7 @@ Documentation for the library can be found at the following link: <http://felis.
### Enable debugging ### Enable debugging
By default serial debugging is disabled. To turn it on uncomment ```DEBUG_USB_HOST``` in [message.h](message.h). By default serial debugging is disabled. To turn it on uncomment ```#define DEBUG_USB_HOST``` in [message.h](message.h).
### Arduino ADK ### Arduino ADK
To use this library with the official [Arduino ADK](http://arduino.cc/en/Main/ArduinoBoardADK) uncomment the following line in [avrpins.h](avrpins.h): To use this library with the official [Arduino ADK](http://arduino.cc/en/Main/ArduinoBoardADK) uncomment the following line in [avrpins.h](avrpins.h):

View file

@ -452,9 +452,9 @@ void USB::Task(void) //USB state machine
lowspeed = false; lowspeed = false;
break; break;
case LSHOST: case LSHOST:
// if ((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) {
lowspeed = true; lowspeed = true;
// } //intentional fallthrough
case FSHOST: //attached case FSHOST: //attached
if ((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) { if ((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) {
delay = millis() + USB_SETTLE_DELAY; delay = millis() + USB_SETTLE_DELAY;

10
Wii.cpp
View file

@ -357,7 +357,10 @@ void WII::ACLData(uint8_t* l2capinbuf) {
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;
setReportMode(false, 0x35); // Also read the extension #ifdef WIICAMERA
if (!isIRCameraEnabled()) // Don't activate the Motion Plus if we are trying to initialize the IR camera
#endif
setReportMode(false, 0x35); // Also read the extension
} 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_USB_HOST #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);
@ -365,7 +368,10 @@ void WII::ACLData(uint8_t* l2capinbuf) {
activateNunchuck = false; activateNunchuck = false;
motionPlusConnected = true; motionPlusConnected = true;
nunchuckConnected = true; nunchuckConnected = true;
setReportMode(false, 0x35); // Also read the extension #ifdef WIICAMERA
if (!isIRCameraEnabled()) // Don't activate the Motion Plus if we are trying to initialize the IR camera
#endif
setReportMode(false, 0x35); // Also read the extension
} 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_USB_HOST #ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nInactive Wii Motion Plus"), 0x80); Notify(PSTR("\r\nInactive Wii Motion Plus"), 0x80);

12
adk.cpp
View file

@ -335,16 +335,16 @@ uint8_t ADK::SndData(uint16_t nbytes, uint8_t *dataptr) {
void ADK::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) { void ADK::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
Notify(PSTR("Endpoint descriptor:"), 0x80); Notify(PSTR("Endpoint descriptor:"), 0x80);
Notify(PSTR("\r\nLength:\t\t"), 0x80); Notify(PSTR("\r\nLength:\t\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80); PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
Notify(PSTR("\r\nType:\t\t"), 0x80); Notify(PSTR("\r\nType:\t\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80); PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
Notify(PSTR("\r\nAddress:\t"), 0x80); Notify(PSTR("\r\nAddress:\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80); PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
Notify(PSTR("\r\nAttributes:\t"), 0x80); Notify(PSTR("\r\nAttributes:\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80); PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80); PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80); PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
Notify(PSTR("\r\n"), 0x80); Notify(PSTR("\r\n"), 0x80);
} }

View file

@ -334,16 +334,16 @@ uint8_t ACM::SendBreak(uint16_t duration) {
void ACM::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) { void ACM::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
Notify(PSTR("Endpoint descriptor:"), 0x80); Notify(PSTR("Endpoint descriptor:"), 0x80);
Notify(PSTR("\r\nLength:\t\t"), 0x80); Notify(PSTR("\r\nLength:\t\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80); PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
Notify(PSTR("\r\nType:\t\t"), 0x80); Notify(PSTR("\r\nType:\t\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80); PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
Notify(PSTR("\r\nAddress:\t"), 0x80); Notify(PSTR("\r\nAddress:\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80); PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
Notify(PSTR("\r\nAttributes:\t"), 0x80); Notify(PSTR("\r\nAttributes:\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80); PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80); PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80); PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
Notify(PSTR("\r\n"), 0x80); Notify(PSTR("\r\n"), 0x80);
} }

View file

@ -326,16 +326,16 @@ uint8_t FTDI::SndData(uint16_t nbytes, uint8_t *dataptr) {
void FTDI::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) { void FTDI::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
Notify(PSTR("Endpoint descriptor:"), 0x80); Notify(PSTR("Endpoint descriptor:"), 0x80);
Notify(PSTR("\r\nLength:\t\t"), 0x80); Notify(PSTR("\r\nLength:\t\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80); PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
Notify(PSTR("\r\nType:\t\t"), 0x80); Notify(PSTR("\r\nType:\t\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80); PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
Notify(PSTR("\r\nAddress:\t"), 0x80); Notify(PSTR("\r\nAddress:\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80); PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
Notify(PSTR("\r\nAttributes:\t"), 0x80); Notify(PSTR("\r\nAttributes:\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80); PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80); PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80); PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
Notify(PSTR("\r\n"), 0x80); Notify(PSTR("\r\n"), 0x80);
} }

View file

@ -175,19 +175,19 @@ template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTO
void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) { void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) {
Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80); Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80);
Notify(PSTR("bDescLength:\t\t"), 0x80); Notify(PSTR("bDescLength:\t\t"), 0x80);
D_PrintHex<uint8_t > (pDesc->bLength, 0x80); PrintHex<uint8_t > (pDesc->bLength, 0x80);
Notify(PSTR("\r\nbDescriptorType:\t"), 0x80); Notify(PSTR("\r\nbDescriptorType:\t"), 0x80);
D_PrintHex<uint8_t > (pDesc->bDescriptorType, 0x80); PrintHex<uint8_t > (pDesc->bDescriptorType, 0x80);
Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80); Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80);
D_PrintHex<uint16_t > (pDesc->bcdHID, 0x80); PrintHex<uint16_t > (pDesc->bcdHID, 0x80);
Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80); Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80);
D_PrintHex<uint8_t > (pDesc->bCountryCode, 0x80); PrintHex<uint8_t > (pDesc->bCountryCode, 0x80);
Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80); Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80);
D_PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80); PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
//Notify(PSTR("\r\nbDescrType:\t\t")); //Notify(PSTR("\r\nbDescrType:\t\t"));
//PrintHex<uint8_t>(pDesc->bDescrType); //PrintHex<uint8_t>(pDesc->bDescrType);
@ -199,10 +199,10 @@ void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::PrintHidDescrip
HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType); HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType);
Notify(PSTR("\r\nbDescrType:\t\t"), 0x80); Notify(PSTR("\r\nbDescrType:\t\t"), 0x80);
D_PrintHex<uint8_t > (pLT[i].bDescrType, 0x80); PrintHex<uint8_t > (pLT[i].bDescrType, 0x80);
Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80); Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80);
D_PrintHex<uint16_t > (pLT[i].wDescriptorLength, 0x80); PrintHex<uint16_t > (pLT[i].wDescriptorLength, 0x80);
} }
Notify(PSTR("\r\n"), 0x80); Notify(PSTR("\r\n"), 0x80);
} }

View file

@ -5,7 +5,10 @@
*/ */
#include <PS3BT.h> #include <PS3BT.h>
#include <usbhub.h>
USB Usb; USB Usb;
USBHub Hub1(&Usb); // Some dongles have a hub inside
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
/* You can create the instance of the class in two ways */ /* You can create the instance of the class in two ways */
PS3BT PS3(&Btd); // This will just create the instance PS3BT PS3(&Btd); // This will just create the instance

View file

@ -6,7 +6,10 @@
*/ */
#include <PS3BT.h> #include <PS3BT.h>
#include <usbhub.h>
USB Usb; USB Usb;
USBHub Hub1(&Usb); // Some dongles have a hub inside
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
PS3BT *PS3[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM! PS3BT *PS3[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM!
const uint8_t length = sizeof(PS3)/sizeof(PS3[0]); // Get the lenght of the array const uint8_t length = sizeof(PS3)/sizeof(PS3[0]); // Get the lenght of the array

View file

@ -11,7 +11,10 @@
#include <PS3BT.h> #include <PS3BT.h>
#include <SPP.h> #include <SPP.h>
#include <usbhub.h>
USB Usb; USB Usb;
USBHub Hub1(&Usb); // Some dongles have a hub inside
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
/* You can create the instances of the bluetooth services in two ways */ /* You can create the instances of the bluetooth services in two ways */

View file

@ -5,7 +5,10 @@
*/ */
#include <SPP.h> #include <SPP.h>
#include <usbhub.h>
USB Usb; USB Usb;
USBHub Hub1(&Usb); // Some dongles have a hub inside
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
/* You can create the instance of the class in two ways */ /* You can create the instance of the class in two ways */
SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the pin to "1234" SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the pin to "1234"

View file

@ -5,7 +5,10 @@
*/ */
#include <SPP.h> #include <SPP.h>
#include <usbhub.h>
USB Usb; USB Usb;
USBHub Hub1(&Usb); // Some dongles have a hub inside
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
SPP* SerialBT[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM! SPP* SerialBT[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM!
const uint8_t length = sizeof(SerialBT)/sizeof(SerialBT[0]); // Get the lenght of the array const uint8_t length = sizeof(SerialBT)/sizeof(SerialBT[0]); // Get the lenght of the array

View file

@ -5,7 +5,10 @@
*/ */
#include <Wii.h> #include <Wii.h>
#include <usbhub.h>
USB Usb; USB Usb;
USBHub Hub1(&Usb); // Some dongles have a hub inside
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
/* You can create the instance of the class in two ways */ /* You can create the instance of the class in two ways */
WII Wii(&Btd,PAIR); // This will start an inquiry and then pair with your Wiimote - you only have to do this once WII Wii(&Btd,PAIR); // This will start an inquiry and then pair with your Wiimote - you only have to do this once

View file

@ -12,10 +12,14 @@ Otherwise, wire up a IR LED yourself.
*/ */
#include <Wii.h> #include <Wii.h>
#include <usbhub.h>
#ifndef WIICAMERA // Used to check if WIICAMERA is defined #ifndef WIICAMERA // Used to check if WIICAMERA is defined
#error "Uncomment WIICAMERA in Wii.h to use this example" #error "Uncomment WIICAMERA in Wii.h to use this example"
#endif #endif
USB Usb; USB Usb;
USBHub Hub1(&Usb); // Some dongles have a hub inside
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
/* You can create the instance of the class in two ways */ /* You can create the instance of the class in two ways */
WII Wii(&Btd,PAIR); // This will start an inquiry and then pair with your Wiimote - you only have to do this once WII Wii(&Btd,PAIR); // This will start an inquiry and then pair with your Wiimote - you only have to do this once

View file

@ -6,7 +6,10 @@
*/ */
#include <Wii.h> #include <Wii.h>
#include <usbhub.h>
USB Usb; USB Usb;
USBHub Hub1(&Usb); // Some dongles have a hub inside
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
WII *Wii[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM! WII *Wii[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM!
const uint8_t length = sizeof(Wii)/sizeof(Wii[0]); // Get the lenght of the array const uint8_t length = sizeof(Wii)/sizeof(Wii[0]); // Get the lenght of the array

View file

@ -5,7 +5,10 @@
*/ */
#include <Wii.h> #include <Wii.h>
#include <usbhub.h>
USB Usb; USB Usb;
USBHub Hub1(&Usb); // Some dongles have a hub inside
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
/* You can create the instance of the class in two ways */ /* You can create the instance of the class in two ways */
WII Wii(&Btd,PAIR); // This will start an inquiry and then pair with your Wiimote - you only have to do this once WII Wii(&Btd,PAIR); // This will start an inquiry and then pair with your Wiimote - you only have to do this once

View file

@ -37,7 +37,7 @@ void KbdRptParser::PrintKey(uint8_t m, uint8_t key)
Serial.print((mod.bmLeftGUI == 1) ? "G" : " "); Serial.print((mod.bmLeftGUI == 1) ? "G" : " ");
Serial.print(" >"); Serial.print(" >");
D_PrintHex<uint8_t>(key, 0x80); PrintHex<uint8_t>(key, 0x80);
Serial.print("< "); Serial.print("< ");
Serial.print((mod.bmRightCtrl == 1) ? "C" : " "); Serial.print((mod.bmRightCtrl == 1) ? "C" : " ");

View file

@ -63,22 +63,22 @@ void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
{ {
Serial.print("X: "); Serial.print("X: ");
D_PrintHex<uint8_t>(evt->X, 0x80); PrintHex<uint8_t>(evt->X, 0x80);
Serial.print("\tY: "); Serial.print("\tY: ");
D_PrintHex<uint8_t>(evt->Y, 0x80); PrintHex<uint8_t>(evt->Y, 0x80);
Serial.print("\tZ: "); Serial.print("\tZ: ");
D_PrintHex<uint8_t>(evt->Z1, 0x80); PrintHex<uint8_t>(evt->Z1, 0x80);
Serial.print("\tZ: "); Serial.print("\tZ: ");
D_PrintHex<uint8_t>(evt->Z2, 0x80); PrintHex<uint8_t>(evt->Z2, 0x80);
Serial.print("\tRz: "); Serial.print("\tRz: ");
D_PrintHex<uint8_t>(evt->Rz, 0x80); PrintHex<uint8_t>(evt->Rz, 0x80);
Serial.println(""); Serial.println("");
} }
void JoystickEvents::OnHatSwitch(uint8_t hat) void JoystickEvents::OnHatSwitch(uint8_t hat)
{ {
Serial.print("Hat Switch: "); Serial.print("Hat Switch: ");
D_PrintHex<uint8_t>(hat, 0x80); PrintHex<uint8_t>(hat, 0x80);
Serial.println(""); Serial.println("");
} }

View file

@ -26,18 +26,18 @@ void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
{ {
Serial.print("X: "); Serial.print("X: ");
D_PrintHex<uint16_t>(evt->x, 0x80); PrintHex<uint16_t>(evt->x, 0x80);
Serial.print(" Y: "); Serial.print(" Y: ");
D_PrintHex<uint16_t>(evt->y, 0x80); PrintHex<uint16_t>(evt->y, 0x80);
Serial.print(" Hat Switch: "); Serial.print(" Hat Switch: ");
D_PrintHex<uint8_t>(evt->hat, 0x80); PrintHex<uint8_t>(evt->hat, 0x80);
Serial.print(" Twist: "); Serial.print(" Twist: ");
D_PrintHex<uint8_t>(evt->twist, 0x80); PrintHex<uint8_t>(evt->twist, 0x80);
Serial.print(" Slider: "); Serial.print(" Slider: ");
D_PrintHex<uint8_t>(evt->slider, 0x80); PrintHex<uint8_t>(evt->slider, 0x80);
Serial.print(" Buttons A: "); Serial.print(" Buttons A: ");
D_PrintHex<uint8_t>(evt->buttons_a, 0x80); PrintHex<uint8_t>(evt->buttons_a, 0x80);
Serial.print(" Buttons B: "); Serial.print(" Buttons B: ");
D_PrintHex<uint8_t>(evt->buttons_b, 0x80); PrintHex<uint8_t>(evt->buttons_b, 0x80);
Serial.println(""); Serial.println("");
} }

View file

@ -27,7 +27,7 @@ void loop() {
Serial.print(Xbox.getButtonPress(L2,i)); Serial.print(Xbox.getButtonPress(L2,i));
Serial.print("\tR2: "); Serial.print("\tR2: ");
Serial.println(Xbox.getButtonPress(R2,i)); Serial.println(Xbox.getButtonPress(R2,i));
Xbox.setRumbleOn(Xbox.getButtonPress(L2,i),Xbox.getButtonPress(R2,i)); Xbox.setRumbleOn(Xbox.getButtonPress(L2,i),Xbox.getButtonPress(R2,i),i);
} }
if(Xbox.getAnalogHat(LeftHatX,i) > 7500 || Xbox.getAnalogHat(LeftHatX,i) < -7500 || Xbox.getAnalogHat(LeftHatY,i) > 7500 || Xbox.getAnalogHat(LeftHatY,i) < -7500 || Xbox.getAnalogHat(RightHatX,i) > 7500 || Xbox.getAnalogHat(RightHatX,i) < -7500 || Xbox.getAnalogHat(RightHatY,i) > 7500 || Xbox.getAnalogHat(RightHatY,i) < -7500) { if(Xbox.getAnalogHat(LeftHatX,i) > 7500 || Xbox.getAnalogHat(LeftHatX,i) < -7500 || Xbox.getAnalogHat(LeftHatY,i) > 7500 || Xbox.getAnalogHat(LeftHatY,i) < -7500 || Xbox.getAnalogHat(RightHatX,i) > 7500 || Xbox.getAnalogHat(RightHatX,i) < -7500 || Xbox.getAnalogHat(RightHatY,i) > 7500 || Xbox.getAnalogHat(RightHatY,i) < -7500) {
if(Xbox.getAnalogHat(LeftHatX,i) > 7500 || Xbox.getAnalogHat(LeftHatX,i) < -7500) { if(Xbox.getAnalogHat(LeftHatX,i) > 7500 || Xbox.getAnalogHat(LeftHatX,i) < -7500) {

@ -1 +1 @@
Subproject commit 76e5edb248b9078916cf46bdd4fd1a9e8201ca64 Subproject commit f379bae02aa3d9c3da558ba2041558b88db95bbb

@ -1 +1 @@
Subproject commit e717f2df099491439877cc0d44a660688685dd54 Subproject commit 071b65b923b2656bb1e1b622de5272b4ed9a4996

@ -1 +1 @@
Subproject commit e5f9968b42fb4970ec037290e5942e83accd4fad Subproject commit 8bcf5f90f8bd967378b6eeebd7fd943f125fbc18

View file

@ -7,6 +7,7 @@
#################################################### ####################################################
USB KEYWORD1 USB KEYWORD1
USBHub KEYWORD1
#################################################### ####################################################
# Syntax Coloring Map For BTD (Bluetooth) Library # Syntax Coloring Map For BTD (Bluetooth) Library