Fix wstring to string conversion warnings in BlinkController.cpp

This commit is contained in:
Adam Honse 2024-07-30 00:02:59 -05:00
parent d1be4288d3
commit 43de81819b
2 changed files with 24 additions and 22 deletions

View file

@ -18,16 +18,16 @@ BlinkController::BlinkController(hid_device* dev_handle, char *_path)
dev = dev_handle;
location = _path;
const int szTemp = 256;
wchar_t tmpName[szTemp];
/*---------------------------------------------------------*\
| Get device name from HID manufacturer and product strings |
\*---------------------------------------------------------*/
wchar_t name_string[HID_MAX_STR];
hid_get_manufacturer_string(dev, tmpName, szTemp);
std::wstring wName = std::wstring(tmpName);
device_name = 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, tmpName, szTemp);
wName = std::wstring(tmpName);
device_name.append(" ").append(std::string(wName.begin(), wName.end()));
hid_get_product_string(dev, name_string, HID_MAX_STR);
device_name.append(" ").append(StringUtils::wstring_to_string(name_string));
}
BlinkController::~BlinkController()
@ -64,22 +64,22 @@ std::string BlinkController::GetLocation()
void BlinkController::SendUpdate(unsigned char led, unsigned char red, unsigned char green, unsigned char blue, unsigned int speed)
{
unsigned char buffer[BLINK_PACKET_SIZE] = { 0x00 };
memset(buffer, 0x00, BLINK_PACKET_SIZE);
unsigned char buffer[BLINK_PACKET_SIZE] = { 0x00 };
memset(buffer, 0x00, BLINK_PACKET_SIZE);
buffer[0x00] = 0x01;
buffer[0x01] = 0x63;
buffer[0x02] = red;
buffer[0x03] = green;
buffer[0x04] = blue;
buffer[0x00] = 0x01;
buffer[0x01] = 0x63;
buffer[0x02] = red;
buffer[0x03] = green;
buffer[0x04] = blue;
if(speed > 0)
{
buffer[0x05] = (speed & 0xff00) >> 8;
buffer[0x06] = speed & 0x00ff;
}
if(speed > 0)
{
buffer[0x05] = (speed & 0xff00) >> 8;
buffer[0x06] = speed & 0x00ff;
}
buffer[0x07] = led;
buffer[0x07] = led;
hid_send_feature_report(dev, buffer, BLINK_PACKET_SIZE);
hid_send_feature_report(dev, buffer, BLINK_PACKET_SIZE);
}

View file

@ -21,6 +21,8 @@
#define BLINK_MODE_DIRECT 1
#define BLINK_MODE_FADE 2
#define HID_MAX_STR 255
class BlinkController
{
public: