Adding status check for GetSerial() for the EVGA Keyboard to resolve #2531

* Adding status check for `hid_get_serial_number_string()` to ensure serial string is valid.
This commit is contained in:
Chris 2022-06-15 17:40:24 +10:00
parent 0282f761cd
commit 7900e52291

View file

@ -89,7 +89,13 @@ std::string EVGAKeyboardController::GetSerial()
const uint8_t sz = HID_MAX_STR;
wchar_t tmp[sz];
hid_get_serial_number_string(dev, tmp, sz);
int ret = hid_get_serial_number_string(dev, tmp, sz);
if (ret != 0)
{
return("");
}
std::wstring w_tmp = std::wstring(tmp);
std::string serial = std::string(w_tmp.begin(), w_tmp.end());