mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Typos, whitespace and some other cleanup stuff
This commit is contained in:
parent
22efbd4d60
commit
7469ff099e
8 changed files with 38 additions and 37 deletions
8
BTD.cpp
8
BTD.cpp
|
@ -36,7 +36,7 @@ qNextPollTime(0), // Reset NextPollTime
|
|||
pollInterval(0),
|
||||
bPollEnable(false) // Don't start polling before dongle is connected
|
||||
{
|
||||
for(uint8_t i = 0; i < BTD_NUMSERVICES; i++)
|
||||
for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++)
|
||||
btService[i] = NULL;
|
||||
|
||||
Initialize(); // Set all variables, endpoint structs etc. to default values
|
||||
|
@ -293,7 +293,7 @@ void BTD::Initialize() {
|
|||
epInfo[i].epAttribs = 0;
|
||||
epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER;
|
||||
}
|
||||
for(i = 0; i < BTD_NUMSERVICES; i++) {
|
||||
for(i = 0; i < BTD_NUM_SERVICES; i++) {
|
||||
if(btService[i])
|
||||
btService[i]->Reset(); // Reset all Bluetooth services
|
||||
}
|
||||
|
@ -898,7 +898,7 @@ void BTD::ACL_event_task() {
|
|||
|
||||
if(!rcode) { // Check for errors
|
||||
if(length > 0) { // Check if any data was read
|
||||
for(uint8_t i = 0; i < BTD_NUMSERVICES; i++) {
|
||||
for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++) {
|
||||
if(btService[i])
|
||||
btService[i]->ACLData(l2capinbuf);
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ void BTD::ACL_event_task() {
|
|||
D_PrintHex<uint8_t > (rcode, 0x80);
|
||||
}
|
||||
#endif
|
||||
for(uint8_t i = 0; i < BTD_NUMSERVICES; i++)
|
||||
for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++)
|
||||
if(btService[i])
|
||||
btService[i]->Run();
|
||||
}
|
||||
|
|
34
BTD.h
34
BTD.h
|
@ -187,7 +187,7 @@
|
|||
#define WI_PROTOCOL_BT 0x01 // Bluetooth Programming Interface
|
||||
|
||||
#define BTD_MAX_ENDPOINTS 4
|
||||
#define BTD_NUMSERVICES 4 // Max number of Bluetooth services - if you need more than 4 simply increase this number
|
||||
#define BTD_NUM_SERVICES 4 // Max number of Bluetooth services - if you need more than 4 simply increase this number
|
||||
|
||||
#define PAIR 1
|
||||
|
||||
|
@ -237,7 +237,7 @@ public:
|
|||
|
||||
/** @name USBDeviceConfig implementation */
|
||||
/**
|
||||
* Address assignment and basic initilization is done here.
|
||||
* Address assignment and basic initialization is done here.
|
||||
* @param parent Hub number.
|
||||
* @param port Port number on the hub.
|
||||
* @param lowspeed Speed of the device.
|
||||
|
@ -258,7 +258,7 @@ public:
|
|||
*/
|
||||
virtual uint8_t Release();
|
||||
/**
|
||||
* Poll the USB Input endpoins and run the state machines.
|
||||
* Poll the USB Input endpoints and run the state machines.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
virtual uint8_t Poll();
|
||||
|
@ -320,18 +320,18 @@ public:
|
|||
|
||||
/** Disconnects both the L2CAP Channel and the HCI Connection for all Bluetooth services. */
|
||||
void disconnect() {
|
||||
for(uint8_t i = 0; i < BTD_NUMSERVICES; i++)
|
||||
for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++)
|
||||
if(btService[i])
|
||||
btService[i]->disconnect();
|
||||
};
|
||||
|
||||
/**
|
||||
* Register bluetooth dongle members/services.
|
||||
* Register Bluetooth dongle members/services.
|
||||
* @param pService Pointer to BluetoothService class instance.
|
||||
* @return The serice ID on succes or -1 on fail.
|
||||
* @return The service ID on success or -1 on fail.
|
||||
*/
|
||||
int8_t registerServiceClass(BluetoothService *pService) {
|
||||
for(uint8_t i = 0; i < BTD_NUMSERVICES; i++) {
|
||||
for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++) {
|
||||
if(!btService[i]) {
|
||||
btService[i] = pService;
|
||||
return i; // Return ID
|
||||
|
@ -501,7 +501,7 @@ public:
|
|||
pairWithWii = true;
|
||||
hci_state = HCI_CHECK_DEVICE_SERVICE;
|
||||
};
|
||||
/** Used to only send the ACL data to the wiimote. */
|
||||
/** Used to only send the ACL data to the Wiimote. */
|
||||
bool connectToWii;
|
||||
/** True if a Wiimote is connecting. */
|
||||
bool incomingWii;
|
||||
|
@ -517,7 +517,7 @@ public:
|
|||
pairWithHIDDevice = true;
|
||||
hci_state = HCI_CHECK_DEVICE_SERVICE;
|
||||
};
|
||||
/** Used to only send the ACL data to the wiimote. */
|
||||
/** Used to only send the ACL data to the Wiimote. */
|
||||
bool connectToHIDDevice;
|
||||
/** True if a Wiimote is connecting. */
|
||||
bool incomingHIDDevice;
|
||||
|
@ -564,7 +564,7 @@ protected:
|
|||
|
||||
private:
|
||||
void Initialize(); // Set all variables, endpoint structs etc. to default values
|
||||
BluetoothService* btService[BTD_NUMSERVICES];
|
||||
BluetoothService *btService[BTD_NUM_SERVICES];
|
||||
|
||||
uint16_t PID, VID; // PID and VID of device connected
|
||||
|
||||
|
@ -575,15 +575,15 @@ private:
|
|||
uint8_t classOfDevice[3]; // Class of device of last device
|
||||
|
||||
/* Variables used by high level HCI task */
|
||||
uint8_t hci_state; //current state of bluetooth hci connection
|
||||
uint16_t hci_counter; // counter used for bluetooth hci reset loops
|
||||
uint16_t hci_num_reset_loops; // this value indicate how many times it should read before trying to reset
|
||||
uint16_t hci_event_flag; // hci flags of received bluetooth events
|
||||
uint8_t hci_state; // Current state of Bluetooth HCI connection
|
||||
uint16_t hci_counter; // Counter used for Bluetooth HCI reset loops
|
||||
uint16_t hci_num_reset_loops; // This value indicate how many times it should read before trying to reset
|
||||
uint16_t hci_event_flag; // HCI flags of received Bluetooth events
|
||||
uint8_t inquiry_counter;
|
||||
|
||||
uint8_t hcibuf[BULK_MAXPKTSIZE]; //General purpose buffer for hci data
|
||||
uint8_t l2capinbuf[BULK_MAXPKTSIZE]; //General purpose buffer for l2cap in data
|
||||
uint8_t l2capoutbuf[14]; //General purpose buffer for l2cap out data
|
||||
uint8_t hcibuf[BULK_MAXPKTSIZE]; // General purpose buffer for HCI data
|
||||
uint8_t l2capinbuf[BULK_MAXPKTSIZE]; // General purpose buffer for L2CAP in data
|
||||
uint8_t l2capoutbuf[14]; // General purpose buffer for L2CAP out data
|
||||
|
||||
/* State machines */
|
||||
void HCI_event_task(); // Poll the HCI event pipe
|
||||
|
|
12
PS4BT.cpp
12
PS4BT.cpp
|
@ -48,9 +48,9 @@ const uint8_t PS4_BUTTONS[] PROGMEM = {
|
|||
|
||||
/** Analog buttons on the controller */
|
||||
const uint8_t PS4_ANALOG_BUTTONS[] PROGMEM = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, // Skip UP_ANALOG, RIGHT_ANALOG, DOWN_ANALOG, LEFT_ANALOG, SELECT, L3, R3 and START
|
||||
0, // L2_ANALOG
|
||||
1, // R2_ANALOG
|
||||
0, 0, 0, 0, 0, 0, 0, 0, // Skip UP, RIGHT, DOWN, LEFT, SHARE, OPTIONS, L3, and R3
|
||||
0, // L2
|
||||
1, // R2
|
||||
};
|
||||
|
||||
bool PS4BT::checkDpad(PS4Buttons ps4Buttons, DPADEnum b) {
|
||||
|
@ -59,7 +59,7 @@ bool PS4BT::checkDpad(PS4Buttons ps4Buttons, DPADEnum b) {
|
|||
|
||||
bool PS4BT::getButtonPress(ButtonEnum b) {
|
||||
uint8_t button = pgm_read_byte(&PS4_BUTTONS[(uint8_t)b]);
|
||||
if (b < 4) // Dpad
|
||||
if (b <= LEFT) // Dpad
|
||||
return checkDpad(ps4Data.btn, (DPADEnum)button);
|
||||
else {
|
||||
uint8_t index = button < 8 ? 0 : button < 16 ? 1 : 2;
|
||||
|
@ -70,7 +70,7 @@ bool PS4BT::getButtonPress(ButtonEnum b) {
|
|||
|
||||
bool PS4BT::getButtonClick(ButtonEnum b) {
|
||||
uint8_t button = pgm_read_byte(&PS4_BUTTONS[(uint8_t)b]);
|
||||
if (b < 4) { // Dpad
|
||||
if (b <= LEFT) { // Dpad
|
||||
if (checkDpad(buttonClickState, (DPADEnum)button)) {
|
||||
buttonClickState.dpad = DPAD_OFF;
|
||||
return true;
|
||||
|
@ -87,7 +87,7 @@ bool PS4BT::getButtonClick(ButtonEnum b) {
|
|||
}
|
||||
|
||||
uint8_t PS4BT::getAnalogButton(ButtonEnum a) {
|
||||
return (uint8_t)(ps4Data.trigger[pgm_read_byte(&PS4_ANALOG_BUTTONS[(uint8_t)a])]);
|
||||
return ps4Data.trigger[pgm_read_byte(&PS4_ANALOG_BUTTONS[(uint8_t)a])];
|
||||
}
|
||||
|
||||
uint8_t PS4BT::getAnalogHat(AnalogHatEnum a) {
|
||||
|
|
|
@ -20,7 +20,7 @@ BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
|
|||
/* You can create the instance of the class in two ways */
|
||||
// This will start an inquiry and then pair with your device - you only have to do this once
|
||||
// If you are using a Bluetooth keyboard, then you should type in the password on the keypad and then press enter
|
||||
BTHID hid(&Btd, PAIR, "0000");
|
||||
BTHID bthid(&Btd, PAIR, "0000");
|
||||
|
||||
// After that you can simply create the instance like so and then press any button on the device
|
||||
//BTHID hid(&Btd);
|
||||
|
@ -36,13 +36,13 @@ void setup() {
|
|||
while (1); // Halt
|
||||
}
|
||||
|
||||
hid.SetReportParser(KEYBOARD_PARSER_ID, (HIDReportParser*)&keyboardPrs);
|
||||
hid.SetReportParser(MOUSE_PARSER_ID, (HIDReportParser*)&mousePrs);
|
||||
bthid.SetReportParser(KEYBOARD_PARSER_ID, (HIDReportParser*)&keyboardPrs);
|
||||
bthid.SetReportParser(MOUSE_PARSER_ID, (HIDReportParser*)&mousePrs);
|
||||
|
||||
// If "Boot Protocol Mode" does not work, then try "Report Protocol Mode"
|
||||
// If that does not work either, then uncomment PRINTREPORT in BTHID.cpp to see the raw report
|
||||
hid.setProtocolMode(HID_BOOT_PROTOCOL); // Boot Protocol Mode
|
||||
//hid.setProtocolMode(HID_RPT_PROTOCOL); // Report Protocol Mode
|
||||
bthid.setProtocolMode(HID_BOOT_PROTOCOL); // Boot Protocol Mode
|
||||
//bthid.setProtocolMode(HID_RPT_PROTOCOL); // Report Protocol Mode
|
||||
|
||||
Serial.print(F("\r\nHID Bluetooth Library Started"));
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ void loop() {
|
|||
if (PS3.getAnalogButton(L2) || PS3.getAnalogButton(R2)) {
|
||||
Serial.print(F("\r\nL2: "));
|
||||
Serial.print(PS3.getAnalogButton(L2));
|
||||
if (!PS3.PS3NavigationConnected) {
|
||||
if (PS3.PS3Connected) {
|
||||
Serial.print(F("\tR2: "));
|
||||
Serial.print(PS3.getAnalogButton(R2));
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ void loop() {
|
|||
if (PS3[i]->getAnalogButton(L2) || PS3[i]->getAnalogButton(R2)) {
|
||||
Serial.print(F("\r\nL2: "));
|
||||
Serial.print(PS3[i]->getAnalogButton(L2));
|
||||
if (!PS3[i]->PS3NavigationConnected) {
|
||||
if (PS3[i]->PS3Connected) {
|
||||
Serial.print(F("\tR2: "));
|
||||
Serial.print(PS3[i]->getAnalogButton(R2));
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ void loop() {
|
|||
output += "\r\n";
|
||||
output += "L2: ";
|
||||
output += PS3.getAnalogButton(L2);
|
||||
if (!PS3.PS3NavigationConnected) {
|
||||
if (PS3.PS3Connected) {
|
||||
output += "\tR2: ";
|
||||
output += PS3.getAnalogButton(R2);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
|
|||
|
||||
/* You can create the instance of the BTHID class in two ways */
|
||||
// This will start an inquiry and then pair with the PS4 controller - you only have to do this once
|
||||
// You will need to hold down the PS and Share button at the same time, the PS4 controller will then start to blink rapidly indicating that it is in paring mode
|
||||
BTHID bthid(&Btd, PAIR);
|
||||
|
||||
// After that you can simply create the instance like so and then press the PS button on the device
|
||||
|
|
Loading…
Reference in a new issue