From c8e7530e372a014883e4bbaaf1c91e9f3430a881 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 5 Mar 2021 19:14:50 +0100 Subject: [PATCH] dualsense: get hardware and firmware version --- rpcs3/Input/dualsense_pad_handler.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/rpcs3/Input/dualsense_pad_handler.cpp b/rpcs3/Input/dualsense_pad_handler.cpp index cc94cabda8..9a6ae134fc 100644 --- a/rpcs3/Input/dualsense_pad_handler.cpp +++ b/rpcs3/Input/dualsense_pad_handler.cpp @@ -174,7 +174,7 @@ void dualsense_pad_handler::check_add_device(hid_device* hidDevice, std::string_ std::string serial; - std::array buf{}; + std::array buf{}; buf[0] = 0x09; // This will give us the bluetooth mac address of the device, regardless if we are on wired or bluetooth. @@ -204,6 +204,20 @@ void dualsense_pad_handler::check_add_device(hid_device* hidDevice, std::string_ return; } + u32 hw_version{}; + u32 fw_version{}; + + buf[0] = 0x20; + if (hid_get_feature_report(hidDevice, buf.data(), 64) == 65) + { + hw_version = read_u32(&buf[24]); + fw_version = read_u32(&buf[28]); + } + else + { + dualsense_log.error("Could not retrieve firmware version"); + } + if (hid_set_nonblocking(hidDevice, 1) == -1) { dualsense_log.error("check_add_device: hid_set_nonblocking failed! Reason: %s", hid_error(hidDevice)); @@ -221,7 +235,7 @@ void dualsense_pad_handler::check_add_device(hid_device* hidDevice, std::string_ // Get bluetooth information get_data(device); - dualsense_log.notice("Added device: bluetooth=%d, data_mode=%s, serial='%s', path='%s'", device->bt_controller, device->data_mode, serial, device->path); + dualsense_log.notice("Added device: bluetooth=%d, data_mode=%s, serial='%s', hw_version: 0x%x, fw_version: 0x%x, path='%s'", device->bt_controller, device->data_mode, serial, hw_version, fw_version, device->path); } void dualsense_pad_handler::init_config(pad_config* cfg, const std::string& name)