From 32d9211e7d74770802fdaac33ef4db3eb2d1bbed Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Tue, 30 Jul 2024 00:24:45 -0500 Subject: [PATCH] Fix wstring to string conversion warnings in AlienwareAW510KController.cpp --- .../AlienwareAW510KController.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Controllers/AlienwareKeyboardController/AlienwareAW510KController/AlienwareAW510KController.cpp b/Controllers/AlienwareKeyboardController/AlienwareAW510KController/AlienwareAW510KController.cpp index eee3f103..0d46e8cc 100644 --- a/Controllers/AlienwareKeyboardController/AlienwareAW510KController/AlienwareAW510KController.cpp +++ b/Controllers/AlienwareKeyboardController/AlienwareAW510KController/AlienwareAW510KController.cpp @@ -11,6 +11,7 @@ #include #include "AlienwareAW510KController.h" +#include "StringUtils.h" AlienwareAW510KController::AlienwareAW510KController(hid_device* dev_handle, const char* path) { @@ -33,12 +34,14 @@ std::string AlienwareAW510KController::GetDeviceLocation() std::string AlienwareAW510KController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); - std::wstring return_wstring = serial_string; - std::string return_string(return_wstring.begin(), return_wstring.end()); + if(ret != 0) + { + return(""); + } - return(return_string); + return(StringUtils::wstring_to_string(serial_string)); } void AlienwareAW510KController::SendCommit()