Fix wstring to string conversion warnings in GigabyteAorusLaptopControllercpp

This commit is contained in:
Adam Honse 2024-07-29 22:49:56 -05:00
parent 2805476fb8
commit 2225ca0ec4
2 changed files with 10 additions and 15 deletions

View file

@ -12,6 +12,7 @@
#include <cmath> #include <cmath>
#include <string.h> #include <string.h>
#include "GigabyteAorusLaptopController.h" #include "GigabyteAorusLaptopController.h"
#include "StringUtils.h"
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Indexed colors mapping | | Indexed colors mapping |
@ -36,19 +37,6 @@ GigabyteAorusLaptopController::GigabyteAorusLaptopController(hid_device* dev_han
dev = dev_handle; dev = dev_handle;
location = info.path; location = info.path;
version = ""; version = "";
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
serial_number = "";
}
else
{
std::wstring return_wstring = serial_string;
serial_number = std::string(return_wstring.begin(), return_wstring.end());
}
} }
GigabyteAorusLaptopController::~GigabyteAorusLaptopController() GigabyteAorusLaptopController::~GigabyteAorusLaptopController()
@ -63,7 +51,15 @@ std::string GigabyteAorusLaptopController::GetDeviceLocation()
std::string GigabyteAorusLaptopController::GetSerialString() std::string GigabyteAorusLaptopController::GetSerialString()
{ {
return(serial_number); wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
return(StringUtils::wstring_to_string(serial_string));
} }
std::string GigabyteAorusLaptopController::GetFirmwareVersion() std::string GigabyteAorusLaptopController::GetFirmwareVersion()

View file

@ -69,6 +69,5 @@ private:
unsigned char GetColourIndex(unsigned char red, unsigned char green, unsigned char blue); unsigned char GetColourIndex(unsigned char red, unsigned char green, unsigned char blue);
std::string location; std::string location;
std::string serial_number;
std::string version; std::string version;
}; };