input: log send_output_report hid error

Maybe helps to figure out some issues
This commit is contained in:
Megamouse 2024-08-16 23:46:31 +02:00
parent bd5fd66408
commit 9a071746ed
4 changed files with 69 additions and 27 deletions

View File

@ -75,7 +75,11 @@ ds3_pad_handler::~ds3_pad_handler()
// Disable blinking and vibration
controller.second->large_motor = 0;
controller.second->small_motor = 0;
send_output_report(controller.second.get());
if (send_output_report(controller.second.get()) == -1)
{
ds3_log.error("~ds3_pad_handler: send_output_report failed! error=%s", hid_error(controller.second->hidDevice));
}
}
}
}
@ -106,7 +110,10 @@ void ds3_pad_handler::SetPadData(const std::string& padId, u8 player_id, u8 larg
device->config->player_led_enabled.set(player_led);
// Start/Stop the engines :)
send_output_report(device.get());
if (send_output_report(device.get()) == -1)
{
ds3_log.error("SetPadData: send_output_report failed! error=%s", hid_error(device->hidDevice));
}
}
int ds3_pad_handler::send_output_report(ds3_device* ds3dev)
@ -593,9 +600,13 @@ void ds3_pad_handler::apply_pad_data(const pad_ensemble& binding)
if (dev->new_output_data)
{
if (send_output_report(dev) >= 0)
if (const int res = send_output_report(dev); res >= 0)
{
dev->new_output_data = false;
}
else if (res == -1)
{
ds3_log.error("apply_pad_data: send_output_report failed! error=%s", hid_error(dev->hidDevice));
}
}
}

View File

@ -126,6 +126,26 @@ ds4_pad_handler::ds4_pad_handler()
m_thumb_threshold = thumb_max / 2;
}
ds4_pad_handler::~ds4_pad_handler()
{
for (auto& controller : m_controllers)
{
if (controller.second && controller.second->hidDevice)
{
// Disable blinking and vibration
controller.second->small_motor = 0;
controller.second->large_motor = 0;
controller.second->led_delay_on = 0;
controller.second->led_delay_off = 0;
if (send_output_report(controller.second.get()) == -1)
{
ds4_log.error("~ds4_pad_handler: send_output_report failed! error=%s", hid_error(controller.second->hidDevice));
}
}
}
}
void ds4_pad_handler::init_config(cfg_pad* cfg)
{
if (!cfg) return;
@ -224,7 +244,10 @@ void ds4_pad_handler::SetPadData(const std::string& padId, u8 player_id, u8 larg
}
// Start/Stop the engines :)
send_output_report(device.get());
if (send_output_report(device.get()) == -1)
{
ds4_log.error("SetPadData: send_output_report failed! error=%s", hid_error(device->hidDevice));
}
}
std::unordered_map<u64, u16> ds4_pad_handler::get_button_values(const std::shared_ptr<PadDevice>& device)
@ -614,22 +637,6 @@ void ds4_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p
ds4_log.notice("Added device: bluetooth=%d, serial='%s', hw_version: 0x%x, fw_version: 0x%x, path='%s'", device->bt_controller, serial, hw_version, fw_version, device->path);
}
ds4_pad_handler::~ds4_pad_handler()
{
for (auto& controller : m_controllers)
{
if (controller.second && controller.second->hidDevice)
{
// Disable blinking and vibration
controller.second->small_motor = 0;
controller.second->large_motor = 0;
controller.second->led_delay_on = 0;
controller.second->led_delay_off = 0;
send_output_report(controller.second.get());
}
}
}
int ds4_pad_handler::send_output_report(DS4Device* device)
{
if (!device || !device->hidDevice)
@ -961,9 +968,13 @@ void ds4_pad_handler::apply_pad_data(const pad_ensemble& binding)
if (ds4_dev->new_output_data)
{
if (send_output_report(ds4_dev) >= 0)
if (const int res = send_output_report(ds4_dev); res >= 0)
{
ds4_dev->new_output_data = false;
}
else if (res == -1)
{
ds4_log.error("apply_pad_data: send_output_report failed! error=%s", hid_error(ds4_dev->hidDevice));
}
}
}

View File

@ -802,7 +802,10 @@ dualsense_pad_handler::~dualsense_pad_handler()
// Turns off the lights (disabled due to user complaints)
//controller.second->release_leds = true;
send_output_report(controller.second.get());
if (send_output_report(controller.second.get()) == -1)
{
dualsense_log.error("~dualsense_pad_handler: send_output_report failed! Reason: %s", hid_error(controller.second->hidDevice));
}
}
}
}
@ -1008,10 +1011,14 @@ void dualsense_pad_handler::apply_pad_data(const pad_ensemble& binding)
if (dualsense_dev->new_output_data)
{
if (send_output_report(dualsense_dev) >= 0)
if (const int res = send_output_report(dualsense_dev); res >= 0)
{
dualsense_dev->new_output_data = false;
}
else if (res == -1)
{
dualsense_log.error("apply_pad_data: send_output_report failed! error=%s", hid_error(dualsense_dev->hidDevice));
}
}
}
@ -1050,11 +1057,17 @@ void dualsense_pad_handler::SetPadData(const std::string& padId, u8 player_id, u
if (device->init_lightbar)
{
// Initialize first
send_output_report(device.get());
if (send_output_report(device.get()) == -1)
{
dualsense_log.error("SetPadData: send_output_report failed! Reason: %s", hid_error(device->hidDevice));
}
}
// Start/Stop the engines :)
send_output_report(device.get());
if (send_output_report(device.get()) == -1)
{
dualsense_log.error("SetPadData: send_output_report failed! Reason: %s", hid_error(device->hidDevice));
}
}
u32 dualsense_pad_handler::get_battery_level(const std::string& padId)

View File

@ -358,10 +358,14 @@ void skateboard_pad_handler::apply_pad_data(const pad_ensemble& binding)
if (dev->new_output_data)
{
if (send_output_report(dev) >= 0)
if (const int res = send_output_report(dev); res >= 0)
{
dev->new_output_data = false;
}
else if (res == -1)
{
skateboard_log.error("apply_pad_data: send_output_report failed! error=%s", hid_error(dev->hidDevice));
}
}
}
@ -377,5 +381,8 @@ void skateboard_pad_handler::SetPadData(const std::string& padId, u8 player_id,
ensure(device->config);
// Disabled until needed
//send_output_report(device.get());
//if (send_output_report(device.get()) == -1)
//{
// skateboard_log.error("SetPadData: send_output_report failed! Reason: %s", hid_error(device->hidDevice));
//}
}