Move wstring to string conversion to StringUtils.cpp and update most HID get serial number functions to use it
This commit is contained in:
parent
366fda30f5
commit
b4d15b9545
159 changed files with 623 additions and 930 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ private:
|
|||
hid_device* dev;
|
||||
|
||||
std::string device_location;
|
||||
std::string serial;
|
||||
std::string manufacturer;
|
||||
std::string product;
|
||||
std::string device_model;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue