mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 06:51:26 +12:00
input: implement HidDevice::close
Preparing for further ps move additions down the line.
This commit is contained in:
parent
eab1c1260c
commit
289b70d276
6 changed files with 23 additions and 20 deletions
|
@ -519,8 +519,7 @@ PadHandlerBase::connection ds3_pad_handler::update_connection(const std::shared_
|
||||||
if (get_data(dev) == DataStatus::ReadError)
|
if (get_data(dev) == DataStatus::ReadError)
|
||||||
{
|
{
|
||||||
// this also can mean disconnected, either way deal with it on next loop and reconnect
|
// this also can mean disconnected, either way deal with it on next loop and reconnect
|
||||||
hid_close(dev->hidDevice);
|
dev->close();
|
||||||
dev->hidDevice = nullptr;
|
|
||||||
|
|
||||||
return connection::no_data;
|
return connection::no_data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -527,8 +527,7 @@ void ds4_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p
|
||||||
if (!GetCalibrationData(device))
|
if (!GetCalibrationData(device))
|
||||||
{
|
{
|
||||||
ds4_log.error("check_add_device: GetCalibrationData failed!");
|
ds4_log.error("check_add_device: GetCalibrationData failed!");
|
||||||
hid_close(hidDevice);
|
device->close();
|
||||||
device->hidDevice = nullptr;
|
|
||||||
return;
|
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)
|
if (hid_set_nonblocking(hidDevice, 1) == -1)
|
||||||
{
|
{
|
||||||
ds4_log.error("check_add_device: hid_set_nonblocking failed! Reason: %s", hid_error(hidDevice));
|
ds4_log.error("check_add_device: hid_set_nonblocking failed! Reason: %s", hid_error(hidDevice));
|
||||||
hid_close(hidDevice);
|
device->close();
|
||||||
device->hidDevice = nullptr;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -790,8 +788,7 @@ PadHandlerBase::connection ds4_pad_handler::update_connection(const std::shared_
|
||||||
if (get_data(ds4_dev) == DataStatus::ReadError)
|
if (get_data(ds4_dev) == DataStatus::ReadError)
|
||||||
{
|
{
|
||||||
// this also can mean disconnected, either way deal with it on next loop and reconnect
|
// this also can mean disconnected, either way deal with it on next loop and reconnect
|
||||||
hid_close(ds4_dev->hidDevice);
|
ds4_dev->close();
|
||||||
ds4_dev->hidDevice = nullptr;
|
|
||||||
|
|
||||||
return connection::no_data;
|
return connection::no_data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,8 +155,7 @@ void dualsense_pad_handler::check_add_device(hid_device* hidDevice, std::string_
|
||||||
if (!get_calibration_data(device))
|
if (!get_calibration_data(device))
|
||||||
{
|
{
|
||||||
dualsense_log.error("check_add_device: get_calibration_data failed!");
|
dualsense_log.error("check_add_device: get_calibration_data failed!");
|
||||||
hid_close(hidDevice);
|
device->close();
|
||||||
device->hidDevice = nullptr;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,8 +181,7 @@ void dualsense_pad_handler::check_add_device(hid_device* hidDevice, std::string_
|
||||||
if (hid_set_nonblocking(hidDevice, 1) == -1)
|
if (hid_set_nonblocking(hidDevice, 1) == -1)
|
||||||
{
|
{
|
||||||
dualsense_log.error("check_add_device: hid_set_nonblocking failed! Reason: %s", hid_error(hidDevice));
|
dualsense_log.error("check_add_device: hid_set_nonblocking failed! Reason: %s", hid_error(hidDevice));
|
||||||
hid_close(hidDevice);
|
device->close();
|
||||||
device->hidDevice = nullptr;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,8 +567,7 @@ PadHandlerBase::connection dualsense_pad_handler::update_connection(const std::s
|
||||||
if (get_data(dualsense_dev) == DataStatus::ReadError)
|
if (get_data(dualsense_dev) == DataStatus::ReadError)
|
||||||
{
|
{
|
||||||
// this also can mean disconnected, either way deal with it on next loop and reconnect
|
// this also can mean disconnected, either way deal with it on next loop and reconnect
|
||||||
hid_close(dualsense_dev->hidDevice);
|
dualsense_dev->close();
|
||||||
dualsense_dev->hidDevice = nullptr;
|
|
||||||
|
|
||||||
return connection::no_data;
|
return connection::no_data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,15 @@ LOG_CHANNEL(hid_log, "HID");
|
||||||
static std::mutex s_hid_mutex; // hid_pad_handler is created by pad_thread and pad_settings_dialog
|
static std::mutex s_hid_mutex; // hid_pad_handler is created by pad_thread and pad_settings_dialog
|
||||||
static u8 s_hid_instances{0};
|
static u8 s_hid_instances{0};
|
||||||
|
|
||||||
|
void HidDevice::close()
|
||||||
|
{
|
||||||
|
if (hidDevice)
|
||||||
|
{
|
||||||
|
hid_close(hidDevice);
|
||||||
|
hidDevice = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <class Device>
|
template <class Device>
|
||||||
hid_pad_handler<Device>::hid_pad_handler(pad_handler type, std::vector<id_pair> ids)
|
hid_pad_handler<Device>::hid_pad_handler(pad_handler type, std::vector<id_pair> ids)
|
||||||
: PadHandlerBase(type), m_ids(std::move(ids))
|
: PadHandlerBase(type), m_ids(std::move(ids))
|
||||||
|
@ -40,9 +49,9 @@ hid_pad_handler<Device>::~hid_pad_handler()
|
||||||
|
|
||||||
for (auto& controller : m_controllers)
|
for (auto& controller : m_controllers)
|
||||||
{
|
{
|
||||||
if (controller.second && controller.second->hidDevice)
|
if (controller.second)
|
||||||
{
|
{
|
||||||
hid_close(controller.second->hidDevice);
|
controller.second->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +179,7 @@ void hid_pad_handler<Device>::update_devices()
|
||||||
{
|
{
|
||||||
if (controller.second && !controller.second->path.empty() && !m_new_enumerated_devices.contains(controller.second->path))
|
if (controller.second && !controller.second->path.empty() && !m_new_enumerated_devices.contains(controller.second->path))
|
||||||
{
|
{
|
||||||
hid_close(controller.second->hidDevice);
|
controller.second->close();
|
||||||
cfg_pad* config = controller.second->config;
|
cfg_pad* config = controller.second->config;
|
||||||
controller.second.reset(new Device());
|
controller.second.reset(new Device());
|
||||||
controller.second->config = config;
|
controller.second->config = config;
|
||||||
|
|
|
@ -30,6 +30,8 @@ enum CalibIndex
|
||||||
class HidDevice : public PadDevice
|
class HidDevice : public PadDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
void close();
|
||||||
|
|
||||||
hid_device* hidDevice{nullptr};
|
hid_device* hidDevice{nullptr};
|
||||||
std::string path;
|
std::string path;
|
||||||
bool new_output_data{true};
|
bool new_output_data{true};
|
||||||
|
|
|
@ -204,7 +204,7 @@ skateboard_pad_handler::DataStatus skateboard_pad_handler::get_data(skateboard_d
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
{
|
{
|
||||||
// looks like controller disconnected or read error
|
// looks like controller disconnected or read error
|
||||||
skateboard_log.error("get_data ReadError", device->path);
|
skateboard_log.error("get_data ReadError: %s", hid_error(device->hidDevice));
|
||||||
return DataStatus::ReadError;
|
return DataStatus::ReadError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,8 +254,7 @@ PadHandlerBase::connection skateboard_pad_handler::update_connection(const std::
|
||||||
if (get_data(skateboard_dev) == DataStatus::ReadError)
|
if (get_data(skateboard_dev) == DataStatus::ReadError)
|
||||||
{
|
{
|
||||||
// this also can mean disconnected, either way deal with it on next loop and reconnect
|
// this also can mean disconnected, either way deal with it on next loop and reconnect
|
||||||
hid_close(skateboard_dev->hidDevice);
|
skateboard_dev->close();
|
||||||
skateboard_dev->hidDevice = nullptr;
|
|
||||||
|
|
||||||
return connection::no_data;
|
return connection::no_data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue