From 22acdd1fed976392698753b349b74233e8e319ed Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 3 Jun 2021 14:52:30 +0900 Subject: [PATCH] Check return code from hid_get_serial_number_string() in GetSerialString() Amended for code style by Adam Honse --- .../AMDWraithPrismController/AMDWraithPrismController.cpp | 7 ++++++- .../ASRockPolychromeUSBController.cpp | 7 ++++++- .../AsusAuraCoreController/AsusAuraCoreController.cpp | 7 ++++++- .../AsusAuraUSBController/AsusAuraKeyboardController.cpp | 7 ++++++- .../AsusAuraUSBController/AsusAuraMouseController.cpp | 7 ++++++- .../AsusAuraUSBController/AsusAuraUSBController.cpp | 7 ++++++- .../CorsairLightingNodeController.cpp | 7 ++++++- .../CorsairPeripheralController.cpp | 7 ++++++- .../CorsairWirelessController.cpp | 7 ++++++- .../DasKeyboardController/DasKeyboardController.cpp | 2 +- .../DuckyKeyboardController/DuckyKeyboardController.cpp | 7 ++++++- .../EVisionKeyboardController.cpp | 7 ++++++- .../GigabyteAorusCPUCoolerController/ATC800Controller.cpp | 7 ++++++- Controllers/HoltekController/HoltekA070Controller.cpp | 7 ++++++- Controllers/HoltekController/HoltekA1FAController.cpp | 7 ++++++- .../HyperXAlloyElite2Controller.cpp | 7 ++++++- .../HyperXAlloyOriginsController.cpp | 7 ++++++- .../HyperXKeyboardController/HyperXKeyboardController.cpp | 7 ++++++- .../HyperXPulsefireDartController.cpp | 7 ++++++- .../HyperXPulsefireFPSProController.cpp | 7 ++++++- .../HyperXPulsefireSurgeController.cpp | 7 ++++++- .../HyperXMousematController/HyperXMousematController.cpp | 7 ++++++- Controllers/LogitechController/LogitechG203LController.cpp | 7 ++++++- Controllers/LogitechController/LogitechG213Controller.cpp | 7 ++++++- Controllers/LogitechController/LogitechG810Controller.cpp | 7 ++++++- Controllers/LogitechController/LogitechG815Controller.cpp | 7 ++++++- Controllers/LogitechController/LogitechG910Controller.cpp | 7 ++++++- .../LogitechController/LogitechGLightsyncController.cpp | 7 ++++++- .../LogitechController/LogitechLightspeedController.cpp | 7 ++++++- Controllers/MSI3ZoneController/MSI3ZoneController.cpp | 7 ++++++- Controllers/NZXTHue2Controller/NZXTHue2Controller.cpp | 7 ++++++- Controllers/NZXTKrakenController/NZXTKrakenController.cpp | 7 ++++++- Controllers/RedragonController/RedragonM711Controller.cpp | 7 ++++++- Controllers/SinowealthController/SinowealthController.cpp | 7 ++++++- .../ThermaltakePoseidonZRGBController.cpp | 7 ++++++- .../ThermaltakeRiingController.cpp | 7 ++++++- .../ZalmanZSyncController/ZalmanZSyncController.cpp | 7 ++++++- 37 files changed, 217 insertions(+), 37 deletions(-) diff --git a/Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp b/Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp index 30cd69af..9bb042f7 100644 --- a/Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp +++ b/Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp @@ -52,7 +52,12 @@ char* AMDWraithPrismController::GetDeviceName() std::string AMDWraithPrismController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBController.cpp b/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBController.cpp index effcc44a..bdcb3e79 100755 --- a/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBController.cpp +++ b/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBController.cpp @@ -54,8 +54,13 @@ std::string PolychromeUSBController::GetDeviceName() std::string PolychromeUSBController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + if(ret != 0) + { + return(""); + } + std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/AsusAuraCoreController/AsusAuraCoreController.cpp b/Controllers/AsusAuraCoreController/AsusAuraCoreController.cpp index f371e914..79550d87 100644 --- a/Controllers/AsusAuraCoreController/AsusAuraCoreController.cpp +++ b/Controllers/AsusAuraCoreController/AsusAuraCoreController.cpp @@ -40,7 +40,12 @@ std::string AuraCoreController::GetDeviceLocation() std::string AuraCoreController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/AsusAuraUSBController/AsusAuraKeyboardController.cpp b/Controllers/AsusAuraUSBController/AsusAuraKeyboardController.cpp index 457b7416..6712ccee 100644 --- a/Controllers/AsusAuraUSBController/AsusAuraKeyboardController.cpp +++ b/Controllers/AsusAuraUSBController/AsusAuraKeyboardController.cpp @@ -30,7 +30,12 @@ std::string AuraKeyboardController::GetDeviceLocation() std::string AuraKeyboardController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/AsusAuraUSBController/AsusAuraMouseController.cpp b/Controllers/AsusAuraUSBController/AsusAuraMouseController.cpp index b83ca37e..24f5e729 100644 --- a/Controllers/AsusAuraUSBController/AsusAuraMouseController.cpp +++ b/Controllers/AsusAuraUSBController/AsusAuraMouseController.cpp @@ -30,7 +30,12 @@ std::string AuraMouseController::GetDeviceLocation() std::string AuraMouseController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/AsusAuraUSBController/AsusAuraUSBController.cpp b/Controllers/AsusAuraUSBController/AsusAuraUSBController.cpp index 4a6905aa..a80722e3 100644 --- a/Controllers/AsusAuraUSBController/AsusAuraUSBController.cpp +++ b/Controllers/AsusAuraUSBController/AsusAuraUSBController.cpp @@ -42,7 +42,12 @@ std::string AuraUSBController::GetDeviceName() std::string AuraUSBController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp b/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp index 0966d7f6..9a8dc70a 100644 --- a/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp +++ b/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp @@ -64,7 +64,12 @@ std::string CorsairLightingNodeController::GetLocationString() std::string CorsairLightingNodeController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp b/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp index 558851d9..69bf5151 100644 --- a/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp +++ b/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp @@ -112,7 +112,12 @@ std::string CorsairPeripheralController::GetName() std::string CorsairPeripheralController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/CorsairWirelessController/CorsairWirelessController.cpp b/Controllers/CorsairWirelessController/CorsairWirelessController.cpp index e485fd76..a7b9d7d4 100644 --- a/Controllers/CorsairWirelessController/CorsairWirelessController.cpp +++ b/Controllers/CorsairWirelessController/CorsairWirelessController.cpp @@ -51,7 +51,12 @@ std::string CorsairWirelessController::GetName() std::string CorsairWirelessController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/DasKeyboardController/DasKeyboardController.cpp b/Controllers/DasKeyboardController/DasKeyboardController.cpp index 582c068f..e36c7038 100644 --- a/Controllers/DasKeyboardController/DasKeyboardController.cpp +++ b/Controllers/DasKeyboardController/DasKeyboardController.cpp @@ -38,7 +38,7 @@ std::string DasKeyboardController::GetSerialString() int err = hid_get_serial_number_string(dev, serial_string, 128); std::string return_string; - if(!err) + if(err == 0) { std::wstring return_wstring = serial_string; return_string = std::string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/DuckyKeyboardController/DuckyKeyboardController.cpp b/Controllers/DuckyKeyboardController/DuckyKeyboardController.cpp index 7c65fb05..a430d934 100644 --- a/Controllers/DuckyKeyboardController/DuckyKeyboardController.cpp +++ b/Controllers/DuckyKeyboardController/DuckyKeyboardController.cpp @@ -31,7 +31,12 @@ std::string DuckyKeyboardController::GetDeviceLocation() std::string DuckyKeyboardController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/EVisionKeyboardController/EVisionKeyboardController.cpp b/Controllers/EVisionKeyboardController/EVisionKeyboardController.cpp index 7d72172d..8d4e5168 100644 --- a/Controllers/EVisionKeyboardController/EVisionKeyboardController.cpp +++ b/Controllers/EVisionKeyboardController/EVisionKeyboardController.cpp @@ -33,7 +33,12 @@ std::string EVisionKeyboardController::GetDeviceLocation() std::string EVisionKeyboardController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/GigabyteAorusCPUCoolerController/ATC800Controller.cpp b/Controllers/GigabyteAorusCPUCoolerController/ATC800Controller.cpp index ec5f73a1..a6480574 100644 --- a/Controllers/GigabyteAorusCPUCoolerController/ATC800Controller.cpp +++ b/Controllers/GigabyteAorusCPUCoolerController/ATC800Controller.cpp @@ -30,7 +30,12 @@ std::string ATC800Controller::GetDeviceLocation() std::string ATC800Controller::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/HoltekController/HoltekA070Controller.cpp b/Controllers/HoltekController/HoltekA070Controller.cpp index 51542888..6bc14141 100644 --- a/Controllers/HoltekController/HoltekA070Controller.cpp +++ b/Controllers/HoltekController/HoltekA070Controller.cpp @@ -29,7 +29,12 @@ std::string HoltekA070Controller::GetDeviceLocation() std::string HoltekA070Controller::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/HoltekController/HoltekA1FAController.cpp b/Controllers/HoltekController/HoltekA1FAController.cpp index 0f4089bd..ae52f70d 100644 --- a/Controllers/HoltekController/HoltekA1FAController.cpp +++ b/Controllers/HoltekController/HoltekA1FAController.cpp @@ -30,7 +30,12 @@ std::string HoltekA1FAController::GetDeviceLocation() std::string HoltekA1FAController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/HyperXKeyboardController/HyperXAlloyElite2Controller.cpp b/Controllers/HyperXKeyboardController/HyperXAlloyElite2Controller.cpp index eadb502f..380a5960 100644 --- a/Controllers/HyperXKeyboardController/HyperXAlloyElite2Controller.cpp +++ b/Controllers/HyperXKeyboardController/HyperXAlloyElite2Controller.cpp @@ -35,7 +35,12 @@ std::string HyperXAlloyElite2Controller::GetDeviceLocation() std::string HyperXAlloyElite2Controller::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/HyperXKeyboardController/HyperXAlloyOriginsController.cpp b/Controllers/HyperXKeyboardController/HyperXAlloyOriginsController.cpp index f020e90d..ed3fc774 100644 --- a/Controllers/HyperXKeyboardController/HyperXAlloyOriginsController.cpp +++ b/Controllers/HyperXKeyboardController/HyperXAlloyOriginsController.cpp @@ -33,7 +33,12 @@ std::string HyperXAlloyOriginsController::GetDeviceLocation() std::string HyperXAlloyOriginsController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp b/Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp index 0647ac3c..5a1eafc3 100644 --- a/Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp +++ b/Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp @@ -46,7 +46,12 @@ std::string HyperXKeyboardController::GetDeviceLocation() std::string HyperXKeyboardController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/HyperXMouseController/HyperXPulsefireDartController.cpp b/Controllers/HyperXMouseController/HyperXPulsefireDartController.cpp index 8d452ac9..aa256967 100644 --- a/Controllers/HyperXMouseController/HyperXPulsefireDartController.cpp +++ b/Controllers/HyperXMouseController/HyperXPulsefireDartController.cpp @@ -30,7 +30,12 @@ std::string HyperXPulsefireDartController::GetDeviceLocation() std::string HyperXPulsefireDartController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/HyperXMouseController/HyperXPulsefireFPSProController.cpp b/Controllers/HyperXMouseController/HyperXPulsefireFPSProController.cpp index 8ad757fa..6d53ac37 100644 --- a/Controllers/HyperXMouseController/HyperXPulsefireFPSProController.cpp +++ b/Controllers/HyperXMouseController/HyperXPulsefireFPSProController.cpp @@ -30,7 +30,12 @@ std::string HyperXPulsefireFPSProController::GetDeviceLocation() std::string HyperXPulsefireFPSProController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.cpp b/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.cpp index b3f8967c..9a1b4925 100644 --- a/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.cpp +++ b/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.cpp @@ -30,7 +30,12 @@ std::string HyperXPulsefireSurgeController::GetDeviceLocation() std::string HyperXPulsefireSurgeController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/HyperXMousematController/HyperXMousematController.cpp b/Controllers/HyperXMousematController/HyperXMousematController.cpp index 755d56a0..78f33663 100644 --- a/Controllers/HyperXMousematController/HyperXMousematController.cpp +++ b/Controllers/HyperXMousematController/HyperXMousematController.cpp @@ -30,7 +30,12 @@ std::string HyperXMousematController::GetDeviceLocation() std::string HyperXMousematController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/LogitechController/LogitechG203LController.cpp b/Controllers/LogitechController/LogitechG203LController.cpp index 3d7720d0..dda8bc94 100644 --- a/Controllers/LogitechController/LogitechG203LController.cpp +++ b/Controllers/LogitechController/LogitechG203LController.cpp @@ -21,7 +21,12 @@ std::string LogitechG203LController::GetDeviceLocation() std::string LogitechG203LController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/LogitechController/LogitechG213Controller.cpp b/Controllers/LogitechController/LogitechG213Controller.cpp index 035b4ba0..aa4d71ff 100644 --- a/Controllers/LogitechController/LogitechG213Controller.cpp +++ b/Controllers/LogitechController/LogitechG213Controller.cpp @@ -28,7 +28,12 @@ std::string LogitechG213Controller::GetDeviceLocation() std::string LogitechG213Controller::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/LogitechController/LogitechG810Controller.cpp b/Controllers/LogitechController/LogitechG810Controller.cpp index 9abdc3ea..124028e2 100644 --- a/Controllers/LogitechController/LogitechG810Controller.cpp +++ b/Controllers/LogitechController/LogitechG810Controller.cpp @@ -25,7 +25,12 @@ LogitechG810Controller::~LogitechG810Controller() std::string LogitechG810Controller::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128); + int ret = hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/LogitechController/LogitechG815Controller.cpp b/Controllers/LogitechController/LogitechG815Controller.cpp index cfecd5e1..4fc0c5d5 100644 --- a/Controllers/LogitechController/LogitechG815Controller.cpp +++ b/Controllers/LogitechController/LogitechG815Controller.cpp @@ -24,7 +24,12 @@ LogitechG815Controller::~LogitechG815Controller() std::string LogitechG815Controller::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128); + int ret = hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/LogitechController/LogitechG910Controller.cpp b/Controllers/LogitechController/LogitechG910Controller.cpp index 0b340a60..c212a45a 100644 --- a/Controllers/LogitechController/LogitechG910Controller.cpp +++ b/Controllers/LogitechController/LogitechG910Controller.cpp @@ -25,7 +25,12 @@ LogitechG910Controller::~LogitechG910Controller() std::string LogitechG910Controller::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128); + int ret = hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/LogitechController/LogitechGLightsyncController.cpp b/Controllers/LogitechController/LogitechGLightsyncController.cpp index 3bf47d2e..893ce13d 100644 --- a/Controllers/LogitechController/LogitechGLightsyncController.cpp +++ b/Controllers/LogitechController/LogitechGLightsyncController.cpp @@ -46,7 +46,12 @@ std::string LogitechGLightsyncController::GetDeviceLocation() std::string LogitechGLightsyncController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/LogitechController/LogitechLightspeedController.cpp b/Controllers/LogitechController/LogitechLightspeedController.cpp index 8670df3d..dc8d2d6b 100644 --- a/Controllers/LogitechController/LogitechLightspeedController.cpp +++ b/Controllers/LogitechController/LogitechLightspeedController.cpp @@ -30,7 +30,12 @@ std::string LogitechLightspeedController::GetDeviceLocation() std::string LogitechLightspeedController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/MSI3ZoneController/MSI3ZoneController.cpp b/Controllers/MSI3ZoneController/MSI3ZoneController.cpp index 1fd1c0fe..a7a0202b 100644 --- a/Controllers/MSI3ZoneController/MSI3ZoneController.cpp +++ b/Controllers/MSI3ZoneController/MSI3ZoneController.cpp @@ -35,7 +35,12 @@ std::string MSI3ZoneController::GetDeviceLocation() std::string MSI3ZoneController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/NZXTHue2Controller/NZXTHue2Controller.cpp b/Controllers/NZXTHue2Controller/NZXTHue2Controller.cpp index 12d7cb7f..b679aab2 100644 --- a/Controllers/NZXTHue2Controller/NZXTHue2Controller.cpp +++ b/Controllers/NZXTHue2Controller/NZXTHue2Controller.cpp @@ -71,7 +71,12 @@ std::string NZXTHue2Controller::GetFirmwareVersion() std::string NZXTHue2Controller::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/NZXTKrakenController/NZXTKrakenController.cpp b/Controllers/NZXTKrakenController/NZXTKrakenController.cpp index 32e94978..2d25272d 100644 --- a/Controllers/NZXTKrakenController/NZXTKrakenController.cpp +++ b/Controllers/NZXTKrakenController/NZXTKrakenController.cpp @@ -56,7 +56,12 @@ std::string NZXTKrakenController::GetLocation() std::string NZXTKrakenController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/RedragonController/RedragonM711Controller.cpp b/Controllers/RedragonController/RedragonM711Controller.cpp index 1d9da31e..f30d3ab6 100644 --- a/Controllers/RedragonController/RedragonM711Controller.cpp +++ b/Controllers/RedragonController/RedragonM711Controller.cpp @@ -26,7 +26,12 @@ std::string RedragonM711Controller::GetDeviceLocation() std::string RedragonM711Controller::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/SinowealthController/SinowealthController.cpp b/Controllers/SinowealthController/SinowealthController.cpp index 562d925f..61b26b8a 100644 --- a/Controllers/SinowealthController/SinowealthController.cpp +++ b/Controllers/SinowealthController/SinowealthController.cpp @@ -43,7 +43,12 @@ unsigned int SinowealthController::GetLEDCount() std::string SinowealthController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev_report_id_4, serial_string, 128); + int ret = hid_get_serial_number_string(dev_report_id_4, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/ThermaltakePoseidonZRGBController/ThermaltakePoseidonZRGBController.cpp b/Controllers/ThermaltakePoseidonZRGBController/ThermaltakePoseidonZRGBController.cpp index 9c7cb340..a0ffeb9c 100644 --- a/Controllers/ThermaltakePoseidonZRGBController/ThermaltakePoseidonZRGBController.cpp +++ b/Controllers/ThermaltakePoseidonZRGBController/ThermaltakePoseidonZRGBController.cpp @@ -41,7 +41,12 @@ std::string PoseidonZRGBController::GetDeviceLocation() std::string PoseidonZRGBController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp b/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp index 4769e597..c11e1a54 100644 --- a/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp +++ b/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp @@ -32,7 +32,12 @@ std::string ThermaltakeRiingController::GetDeviceLocation() std::string ThermaltakeRiingController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end()); diff --git a/Controllers/ZalmanZSyncController/ZalmanZSyncController.cpp b/Controllers/ZalmanZSyncController/ZalmanZSyncController.cpp index 6efe0fcb..c47530b4 100644 --- a/Controllers/ZalmanZSyncController/ZalmanZSyncController.cpp +++ b/Controllers/ZalmanZSyncController/ZalmanZSyncController.cpp @@ -74,7 +74,12 @@ std::string ZalmanZSyncController::GetLocationString() std::string ZalmanZSyncController::GetSerialString() { wchar_t serial_string[128]; - hid_get_serial_number_string(dev, serial_string, 128); + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } std::wstring return_wstring = serial_string; std::string return_string(return_wstring.begin(), return_wstring.end());