From 792ac5ed6439c4c2d421a58efa179d869b337bd2 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 15 Oct 2021 00:12:15 +0200 Subject: [PATCH] DS4: add version check --- rpcs3/Input/ds4_pad_handler.cpp | 19 ++++++++++++++++++- rpcs3/Input/dualsense_pad_handler.cpp | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/rpcs3/Input/ds4_pad_handler.cpp b/rpcs3/Input/ds4_pad_handler.cpp index d255fa8505..3f459a81ad 100644 --- a/rpcs3/Input/ds4_pad_handler.cpp +++ b/rpcs3/Input/ds4_pad_handler.cpp @@ -18,6 +18,7 @@ namespace constexpr u32 DS4_FEATURE_REPORT_0x05_SIZE = 41; constexpr u32 DS4_FEATURE_REPORT_0x12_SIZE = 16; constexpr u32 DS4_FEATURE_REPORT_0x81_SIZE = 7; + constexpr u32 DS4_FEATURE_REPORT_0xA3_SIZE = 49; constexpr u32 DS4_INPUT_REPORT_0x11_SIZE = 78; constexpr u32 DS4_OUTPUT_REPORT_0x05_SIZE = 32; constexpr u32 DS4_OUTPUT_REPORT_0x11_SIZE = 78; @@ -568,6 +569,22 @@ void ds4_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p return; } + u32 hw_version{}; + u32 fw_version{}; + + buf[0] = 0xA3; + + res = hid_get_feature_report(hidDevice, buf.data(), DS4_FEATURE_REPORT_0xA3_SIZE); + if (res <= 0) + { + ds4_log.error("check_add_device: hid_get_feature_report 0xA3 failed! Could not retrieve firmware version! result=%d, error=%s", res, hid_error(hidDevice)); + } + else + { + hw_version = read_u32(&buf[35]); + fw_version = read_u32(&buf[41]); + } + if (hid_set_nonblocking(hidDevice, 1) == -1) { ds4_log.error("check_add_device: hid_set_nonblocking failed! Reason: %s", hid_error(hidDevice)); @@ -581,7 +598,7 @@ void ds4_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p send_output_report(device); - ds4_log.notice("Added device: bluetooth=%d, serial='%s', path='%s'", device->bt_controller, serial, device->path); + 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() diff --git a/rpcs3/Input/dualsense_pad_handler.cpp b/rpcs3/Input/dualsense_pad_handler.cpp index 93a90b00af..e86eb14aa7 100644 --- a/rpcs3/Input/dualsense_pad_handler.cpp +++ b/rpcs3/Input/dualsense_pad_handler.cpp @@ -24,6 +24,7 @@ namespace constexpr u32 DUALSENSE_ACC_RES_PER_G = 8192; constexpr u32 DUALSENSE_GYRO_RES_PER_DEG_S = 1024; constexpr u32 DUALSENSE_CALIBRATION_REPORT_SIZE = 41; + constexpr u32 DUALSENSE_VERSION_REPORT_SIZE = 64; constexpr u32 DUALSENSE_BLUETOOTH_REPORT_SIZE = 78; constexpr u32 DUALSENSE_USB_REPORT_SIZE = 63; constexpr u32 DUALSENSE_COMMON_REPORT_SIZE = 47; @@ -219,7 +220,7 @@ void dualsense_pad_handler::check_add_device(hid_device* hidDevice, std::string_ buf[0] = 0x20; - res = hid_get_feature_report(hidDevice, buf.data(), 64); + res = hid_get_feature_report(hidDevice, buf.data(), DUALSENSE_VERSION_REPORT_SIZE); if (res == 65) { hw_version = read_u32(&buf[24]);