Fix coolermaster rescan crash

This commit is contained in:
Tam D 2024-01-07 21:45:18 +00:00 committed by Adam Honse
parent 477fabd381
commit f5bbd49e78
2 changed files with 13 additions and 18 deletions

View file

@ -10,24 +10,22 @@
CMKeyboardAbstractController::CMKeyboardAbstractController(hid_device* dev_handle, hid_device_info* dev_info)
{
const uint8_t sz = HID_MAX_STR;
wchar_t tmp[sz];
wchar_t tmp[HID_MAX_STR];
m_pDev = dev_handle;
m_productId = dev_info->product_id;
m_sLocation = dev_info->path;
m_pDev = dev_handle;
m_productId = dev_info->product_id;
m_sLocation = dev_info->path;
hid_get_manufacturer_string(m_pDev, tmp, sz);
std::wstring wName = std::wstring(tmp);
m_vendorName = std::string(wName.begin(), wName.end());
hid_get_manufacturer_string(m_pDev, tmp, HID_MAX_STR);
std::wstring wVendorName = std::wstring(tmp);
m_vendorName = std::string(wVendorName.begin(), wVendorName.end());
hid_get_product_string(m_pDev, tmp, sz);
wName = std::wstring(tmp);
m_deviceName = std::string(wName.begin(), wName.end());
hid_get_product_string(m_pDev, tmp, HID_MAX_STR);
std::wstring wDeviceName = std::wstring(tmp);
m_deviceName = std::string(wDeviceName.begin(), wDeviceName.end());
m_serialNumber = m_deviceName;
m_serialNumber = m_deviceName;
bool bNotFound = true;
bool bNotFound = true;
for(uint16_t i = 0; i < COOLERMASTER_KEYBOARD_DEVICE_COUNT; i++)
{