From b5638eee126234ebfe8eb7fe240d7b732f5d5dc3 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 28 Jul 2024 18:30:53 -0500 Subject: [PATCH] Use wstring_to_string function for device name string on CorsairPeripheralV2Controller.cpp --- .../CorsairPeripheralV2Controller.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Controller.cpp b/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Controller.cpp index 2a9a0639..b078cc0b 100644 --- a/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Controller.cpp +++ b/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Controller.cpp @@ -16,19 +16,19 @@ using namespace std::chrono_literals; CorsairPeripheralV2Controller::CorsairPeripheralV2Controller(hid_device* dev_handle, const char* path, std::string /*name*/) { - const uint8_t sz = HID_MAX_STR; - wchar_t tmp[sz]; - dev = dev_handle; location = path; - hid_get_manufacturer_string(dev, tmp, sz); - std::wstring wName = std::wstring(tmp); - device_name = std::string(wName.begin(), wName.end()); + /*---------------------------------------------------------*\ + | Get device name from HID manufacturer and product strings | + \*---------------------------------------------------------*/ + wchar_t name_string[HID_MAX_STR]; - hid_get_product_string(dev, tmp, sz); - wName = std::wstring(tmp); - device_name.append(" ").append(std::string(wName.begin(), wName.end())); + hid_get_manufacturer_string(dev, name_string, HID_MAX_STR); + device_name = StringUtils::wstring_to_string(name_string); + + hid_get_product_string(dev, name_string, HID_MAX_STR); + device_name.append(" ").append(StringUtils::wstring_to_string(name_string)); /*---------------------------------------------------------*\ | Get PID |