From 9a071746edd0d0827d1783f7e9fc1fd1262aae10 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 16 Aug 2024 23:46:31 +0200 Subject: [PATCH] input: log send_output_report hid error Maybe helps to figure out some issues --- rpcs3/Input/ds3_pad_handler.cpp | 17 ++++++++-- rpcs3/Input/ds4_pad_handler.cpp | 47 ++++++++++++++++---------- rpcs3/Input/dualsense_pad_handler.cpp | 21 +++++++++--- rpcs3/Input/skateboard_pad_handler.cpp | 11 ++++-- 4 files changed, 69 insertions(+), 27 deletions(-) diff --git a/rpcs3/Input/ds3_pad_handler.cpp b/rpcs3/Input/ds3_pad_handler.cpp index 7b689e2c23..68f31d2aa8 100644 --- a/rpcs3/Input/ds3_pad_handler.cpp +++ b/rpcs3/Input/ds3_pad_handler.cpp @@ -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)); + } } } diff --git a/rpcs3/Input/ds4_pad_handler.cpp b/rpcs3/Input/ds4_pad_handler.cpp index 50ede0a091..dcf5ee2f41 100644 --- a/rpcs3/Input/ds4_pad_handler.cpp +++ b/rpcs3/Input/ds4_pad_handler.cpp @@ -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 ds4_pad_handler::get_button_values(const std::shared_ptr& 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)); + } } } diff --git a/rpcs3/Input/dualsense_pad_handler.cpp b/rpcs3/Input/dualsense_pad_handler.cpp index ddcdbf1544..67ae346d6d 100644 --- a/rpcs3/Input/dualsense_pad_handler.cpp +++ b/rpcs3/Input/dualsense_pad_handler.cpp @@ -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) diff --git a/rpcs3/Input/skateboard_pad_handler.cpp b/rpcs3/Input/skateboard_pad_handler.cpp index 4f32ec848d..20fafa739b 100644 --- a/rpcs3/Input/skateboard_pad_handler.cpp +++ b/rpcs3/Input/skateboard_pad_handler.cpp @@ -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)); + //} }