mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-03-30 03:41:14 -04:00
Move wstring to string conversion to StringUtils.cpp and update most HID get serial number functions to use it
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <cstring>
|
||||
#include "LightSaltController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
static const int mode_map[LIGHTSALT_MODE_MAXIMUM][6] =
|
||||
{
|
||||
@@ -41,16 +42,6 @@ LightSaltController::LightSaltController(hid_device* dev_handle, const hid_devic
|
||||
dev = dev_handle;
|
||||
device_location = info.path;
|
||||
|
||||
if(hid_get_serial_number_string(dev, usb_string, 128) == 0)
|
||||
{
|
||||
std::wstring tmp_wstring = usb_string;
|
||||
serial = std::string(tmp_wstring.begin(), tmp_wstring.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
serial = "";
|
||||
}
|
||||
|
||||
if(hid_get_manufacturer_string(dev, usb_string, 128) == 0)
|
||||
{
|
||||
std::wstring tmp_wstring = usb_string;
|
||||
@@ -98,7 +89,15 @@ std::string LightSaltController::GetDeviceLocation()
|
||||
|
||||
std::string LightSaltController::GetSerial()
|
||||
{
|
||||
return(serial);
|
||||
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 LightSaltController::GetManufacturer()
|
||||
|
||||
Reference in New Issue
Block a user