mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-09 00:17:38 -04:00
Fix wstring to string conversion in CoolerMaster controllers
This commit is contained in:
@@ -12,24 +12,14 @@
|
||||
|
||||
#include <cstring>
|
||||
#include "CMMMController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
CMMMController::CMMMController(hid_device* dev_handle, char *_path, uint16_t pid) : product_id(pid)
|
||||
{
|
||||
const int szTemp = HID_MAX_STR;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
dev = dev_handle;
|
||||
location = _path;
|
||||
current_speed = CM_MM_SPEED_3;
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
std::wstring wName = std::wstring(tmpName);
|
||||
vendor = std::string(wName.begin(), wName.end());
|
||||
|
||||
hid_get_indexed_string(dev, 2, tmpName, szTemp);
|
||||
wName = std::wstring(tmpName);
|
||||
serial = std::string(wName.begin(), wName.end());
|
||||
|
||||
if(product_id == CM_MM530_PID || product_id == CM_MM531_PID)
|
||||
{
|
||||
command_code = CM_MM5XX_COMMAND;
|
||||
@@ -125,12 +115,28 @@ void CMMMController::GetModeStatus()
|
||||
|
||||
std::string CMMMController::GetDeviceVendor()
|
||||
{
|
||||
return vendor;
|
||||
wchar_t vendor_string[HID_MAX_STR];
|
||||
int ret = hid_get_manufacturer_string(dev, vendor_string, HID_MAX_STR);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(vendor_string));
|
||||
}
|
||||
|
||||
std::string CMMMController::GetSerial()
|
||||
{
|
||||
return serial;
|
||||
wchar_t serial_string[HID_MAX_STR];
|
||||
int ret = hid_get_indexed_string(dev, 2, serial_string, HID_MAX_STR);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
std::string CMMMController::GetLocation()
|
||||
|
||||
Reference in New Issue
Block a user