Fix crash when connecting DS3 to Mac

== DETAILS
The OSX HID driver doesn't implement `set_protocol()` and crashes
with an NPE, so we guard it.
This commit is contained in:
Nathan Strong 2021-10-05 23:57:09 -07:00
parent 55bf2b0083
commit 01e96585a3

View File

@ -118,7 +118,9 @@ static void *ds3_pad_init(void *data, uint32_t slot, hid_driver_t *driver)
int errors = 0;
ds3_instance_t *instance = (ds3_instance_t *)calloc(1, sizeof(ds3_instance_t));
driver->set_protocol(data, 1);
if(driver->set_protocol) {
driver->set_protocol(data, 1);
}
if (ds3_send_control_packet(data, slot, driver) < 0)
errors++;