Преглед изворни кода

Get PS4 to connect when not binding.

Hopefully did not break other things...

Find that the PS4 requires you to ask to connect versus some/most other devices will do the request...

Also found issue without printing, where adding a delay(1) in a couple of places appears to help when Serial1 printing is not on
main
Kurt Eckhardt пре 5 година
родитељ
комит
6e750a94ab
3 измењених фајлова са 23 додато и 9 уклоњено
  1. +4
    -4
      USBHost_t36.h
  2. +15
    -3
      bluetooth.cpp
  3. +4
    -2
      joystick.cpp

+ 4
- 4
USBHost_t36.h Прегледај датотеку

@@ -555,8 +555,9 @@ private:
BTHIDInput *next = NULL;
friend class BluetoothController;
protected:
strbuf_t *btstrbuf;
uint8_t needs_connect_to_device = false;
Device_t *btdevice = NULL;

};


@@ -1637,10 +1638,9 @@ public:
// BUGBUG version to allow some of the controlled objects to call?

void sendL2CapCommand(uint8_t* data, uint8_t nbytes, uint8_t channelLow = 0x01, uint8_t channelHigh = 0x00) {
//sendL2CapCommand(device_connection_handle_, data, nbytes, control_scid_ & 0xff, control_scid_ >> 8);

USBHDBGSerial.printf("sendL2CapCommand: %x %d %x %x : control: %x\n", (uint32_t)data, nbytes, channelLow, channelHigh, control_scid_);
sendL2CapCommand (device_connection_handle_, data, nbytes, channelLow, channelHigh);
}
}

protected:
virtual bool claim(Device_t *device, int type, const uint8_t *descriptors, uint32_t len);

+ 15
- 3
bluetooth.cpp Прегледај датотеку

@@ -29,8 +29,9 @@

#define print USBHost::print_
#define println USBHost::println_//#define DEBUG_BT

//#define DEBUG_BT
#define DEBUG_BT_VERBOSE
//#define DEBUG_BT_VERBOSE

#ifndef DEBUG_BT
#undef DEBUG_BT_VERBOSE
@@ -701,6 +702,11 @@ void BluetoothController::handle_hci_connection_complete() {
if (do_pair_device_) {
sendHCIAuthenticationRequested();
pending_control_ = PC_AUTHENTICATION_REQUESTED;
} else if (device_driver_ && device_driver_->needs_connect_to_device) {
DBGPrintf(" Needs connect to device(PS4?)\n");
// The PS4 requires a connection request to it.
delay(1);
sendl2cap_ConnectionRequest(device_connection_handle_, connection_rxid_, control_dcid_, HID_CTRL_PSM);
}
}

@@ -1128,6 +1134,7 @@ void BluetoothController::tx_data(const Transfer_t *transfer)
#endif
switch (pending_control_tx_) {
case STATE_TX_SEND_CONNECT_INT:
delay(1);
connection_rxid_++;
sendl2cap_ConnectionRequest(device_connection_handle_, connection_rxid_, interrupt_dcid_, HID_INTR_PSM);
pending_control_tx_ = 0;
@@ -1263,10 +1270,15 @@ void BluetoothController::process_l2cap_config_response(uint8_t *data) {
// Set HID Boot mode
setHIDProtocol(HID_BOOT_PROTOCOL); //
//setHIDProtocol(HID_RPT_PROTOCOL); //HID_RPT_PROTOCOL
if (do_pair_device_)
if (do_pair_device_) {
pending_control_tx_ = STATE_TX_SEND_CONNECT_INT;
else
} else if (device_driver_ && device_driver_->needs_connect_to_device) {
DBGPrintf(" Needs connect to device INT(PS4?)\n");
// The PS4 requires a connection request to it.
pending_control_tx_ = STATE_TX_SEND_CONNECT_INT;
} else {
pending_control_ = 0;
}
} else if (scid == interrupt_dcid_) {
// Enable SCan to page mode
sendHCIWriteScanEnable(2);

+ 4
- 2
joystick.cpp Прегледај датотеку

@@ -235,7 +235,7 @@ bool JoystickController::transmitPS4UserFeedbackMsg() {

// 9, 10 flash ON, OFF times in 100ths of sedond? 2.5 seconds = 255
USBHDBGSerial.printf("Joystick update Rumble/LEDs\n");
btdriver_->sendL2CapCommand(packet, sizeof(packet), 0x42, 0x00);
btdriver_->sendL2CapCommand(packet, sizeof(packet), 0x41, 0x00);

return true;
}
@@ -702,7 +702,7 @@ bool JoystickController::process_bluetooth_HID_data(const uint8_t *data, uint16_
axis[i] = data[i];
}
mask <<= 1; // shift down the mask.
//USBHDBGSerial.printf("%02x ", axisPS4[i]);
//USBHDBGSerial.printf("%02x ", axis[i]);
}
//USBHDBGSerial.printf("\n");
joystickEvent = true;
@@ -717,6 +717,7 @@ void JoystickController::remoteNameComplete(const uint8_t *remoteName)

if (strncmp((const char *)remoteName, "Wireless Controller", 19) == 0) {
USBHDBGSerial.printf(" JoystickController::remoteNameComplete %s - set to PS4\n", remoteName);
needs_connect_to_device = true; // We need to force this.
joystickType = PS4;
}

@@ -727,6 +728,7 @@ void JoystickController::release_bluetooth()
btdevice = nullptr; // remember this way
btdriver_ = nullptr;
connected_ = false;
needs_connect_to_device = false;

}


Loading…
Откажи
Сачувај