input: implement HidDevice::close

Preparing for further ps move additions down the line.
This commit is contained in:
Megamouse 2024-06-30 11:32:44 +02:00
parent eab1c1260c
commit 289b70d276
6 changed files with 23 additions and 20 deletions

View file

@ -527,8 +527,7 @@ void ds4_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p
if (!GetCalibrationData(device))
{
ds4_log.error("check_add_device: GetCalibrationData failed!");
hid_close(hidDevice);
device->hidDevice = nullptr;
device->close();
return;
}
@ -553,8 +552,7 @@ void ds4_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p
if (hid_set_nonblocking(hidDevice, 1) == -1)
{
ds4_log.error("check_add_device: hid_set_nonblocking failed! Reason: %s", hid_error(hidDevice));
hid_close(hidDevice);
device->hidDevice = nullptr;
device->close();
return;
}
@ -790,8 +788,7 @@ PadHandlerBase::connection ds4_pad_handler::update_connection(const std::shared_
if (get_data(ds4_dev) == DataStatus::ReadError)
{
// this also can mean disconnected, either way deal with it on next loop and reconnect
hid_close(ds4_dev->hidDevice);
ds4_dev->hidDevice = nullptr;
ds4_dev->close();
return connection::no_data;
}