Fix wstring to string conversion warning in LianLiStrimerLConnectController.cpp
This commit is contained in:
parent
6548dea9c4
commit
3b61a47ec2
1 changed files with 14 additions and 19 deletions
|
|
@ -10,6 +10,7 @@
|
|||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "LianLiStrimerLConnectController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
static uint8_t speed_data[5] =
|
||||
{
|
||||
|
|
@ -23,19 +24,19 @@ static uint8_t brightness_data[5] =
|
|||
|
||||
LianLiStrimerLConnectController::LianLiStrimerLConnectController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
LianLiStrimerLConnectController::~LianLiStrimerLConnectController()
|
||||
|
|
@ -50,21 +51,15 @@ std::string LianLiStrimerLConnectController::GetDeviceName()
|
|||
|
||||
std::string LianLiStrimerLConnectController::GetSerial()
|
||||
{
|
||||
const uint8_t sz = HID_MAX_STR;
|
||||
wchar_t tmp[sz];
|
||||
wchar_t serial_string[HID_MAX_STR];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, HID_MAX_STR);
|
||||
|
||||
int ret = hid_get_serial_number_string(dev, tmp, sz);
|
||||
|
||||
if (ret != 0)
|
||||
if(ret != 0)
|
||||
{
|
||||
LOG_DEBUG("[%s] Get HID Serial string failed", device_name.c_str());
|
||||
return("");
|
||||
}
|
||||
|
||||
std::wstring w_tmp = std::wstring(tmp);
|
||||
std::string serial = std::string(w_tmp.begin(), w_tmp.end());
|
||||
|
||||
return serial;
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
std::string LianLiStrimerLConnectController::GetLocation()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue