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
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <cstring>
|
||||
#include "EVisionKeyboardController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
EVisionKeyboardController::EVisionKeyboardController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
|
|
@ -39,10 +40,7 @@ std::string EVisionKeyboardController::GetSerialString()
|
|||
return("");
|
||||
}
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
void EVisionKeyboardController::SetKeyboardColors
|
||||
|
|
@ -64,7 +62,7 @@ void EVisionKeyboardController::SetKeyboardColors
|
|||
{
|
||||
packet_size = size;
|
||||
}
|
||||
|
||||
|
||||
SendKeyboardData
|
||||
(
|
||||
&color_data[packet_offset],
|
||||
|
|
@ -149,7 +147,7 @@ void EVisionKeyboardController::SendKeyboardBegin()
|
|||
usb_buf[0x01] = EVISION_KB_COMMAND_BEGIN;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = EVISION_KB_COMMAND_BEGIN;
|
||||
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
@ -175,7 +173,7 @@ void EVisionKeyboardController::SendKeyboardEnd()
|
|||
usb_buf[0x01] = EVISION_KB_COMMAND_END;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = EVISION_KB_COMMAND_END;
|
||||
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
@ -211,7 +209,7 @@ void EVisionKeyboardController::SendKeyboardData
|
|||
| Copy in data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x08], data, data_size);
|
||||
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Compute Checksum |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <cstring>
|
||||
#include "LogManager.h"
|
||||
#include "EVisionV2KeyboardController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#define BLANK_SPACE 6
|
||||
#define query_check_buffer(c) \
|
||||
|
|
@ -102,20 +103,15 @@ std::string EVisionV2KeyboardController::GetDeviceName()
|
|||
|
||||
std::string EVisionV2KeyboardController::GetSerial()
|
||||
{
|
||||
const uint8_t sz = HID_MAX_STR;
|
||||
wchar_t tmp[sz];
|
||||
|
||||
int ret = hid_get_serial_number_string(dev, tmp, sz);
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
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 EVisionV2KeyboardController::GetLocation()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue