Minor DS4 Bluetooth fix (#3140)

* Fix DS4 input not working after controller restart (bluetooth)

* Fix bad hid_free_enumeration logic

* Tabbing

* Proper way of telling DS4 to send 0x11 reports

* Dead code removal
This commit is contained in:
praydog 2017-08-10 14:41:13 -07:00 committed by Ivan
parent 69a5f3d58b
commit 6136abd0f8
1 changed files with 15 additions and 8 deletions

View File

@ -616,6 +616,7 @@ void ds4_thread::on_init(const std::shared_ptr<void>& _this)
for (auto pid : ds4Pids)
{
hid_device_info* devInfo = hid_enumerate(DS4_VID, pid);
hid_device_info* head = devInfo;
while (devInfo)
{
@ -628,6 +629,8 @@ void ds4_thread::on_init(const std::shared_ptr<void>& _this)
devInfo = devInfo->next;
}
hid_free_enumeration(head);
}
if (controllers.size() == 0)
@ -715,13 +718,6 @@ void ds4_thread::on_task()
if (dev)
{
hid_set_nonblocking(dev, 1);
if (controller.second.btCon)
{
// We already have calibration data, but we still need this to kick BT into sending correct 0x11 reports
std::array<u8, 64> buf{};
buf[0] = 0x2;
hid_get_feature_report(dev, buf.data(), buf.size());
}
controller.second.hidDevice = dev;
}
else
@ -746,6 +742,16 @@ void ds4_thread::on_task()
if (res == 0)
continue;
// bt controller sends this until 0x02 feature report is sent back (happens on controller init/restart)
if (controller.second.btCon && buf[0] == 0x1)
{
// tells controller to send 0x11 reports
std::array<u8, 64> buf{};
buf[0] = 0x2;
hid_get_feature_report(controller.second.hidDevice, buf.data(), buf.size());
continue;
}
int offset = 0;
// check report and set offset
if (controller.second.btCon && buf[0] == 0x11 && res == 78)
@ -788,4 +794,5 @@ void ds4_thread::on_task()
}
std::this_thread::sleep_for((online > 0) ? THREAD_SLEEP : THREAD_SLEEP_INACTIVE);
}
}
}