Move wstring to string conversion to StringUtils.cpp and update most HID get serial number functions to use it

This commit is contained in:
Adam Honse 2024-07-28 03:50:29 -05:00
parent 366fda30f5
commit b4d15b9545
159 changed files with 623 additions and 930 deletions

View file

@ -11,6 +11,7 @@
#include <cstring>
#include "HyperXAlloyElite2Controller.h"
#include "StringUtils.h"
/*-----------------------------------------*\
| Skip these indices in the color output |
@ -43,10 +44,7 @@ std::string HyperXAlloyElite2Controller::GetSerialString()
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(StringUtils::wstring_to_string(serial_string));
}
void HyperXAlloyElite2Controller::SetLEDsDirect(const std::vector<RGBColor>& colors)

View file

@ -11,6 +11,7 @@
#include <cstring>
#include "HyperXAlloyEliteController.h"
#include "StringUtils.h"
using namespace std::chrono_literals;
@ -54,10 +55,7 @@ std::string HyperXAlloyEliteController::GetSerialString()
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(StringUtils::wstring_to_string(serial_string));
}
void HyperXAlloyEliteController::SetMode

View file

@ -11,6 +11,7 @@
#include <cstring>
#include "HyperXAlloyFPSController.h"
#include "StringUtils.h"
using namespace std::chrono_literals;
@ -50,10 +51,7 @@ std::string HyperXAlloyFPSController::GetSerialString()
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(StringUtils::wstring_to_string(serial_string));
}
void HyperXAlloyFPSController::SetLEDsDirect(std::vector<RGBColor> colors)

View file

@ -11,6 +11,7 @@
#include <cstring>
#include "HyperXAlloyOrigins60and65Controller.h"
#include "StringUtils.h"
HyperXAlloyOrigins60and65Controller::HyperXAlloyOrigins60and65Controller(hid_device* dev_handle, const char* path)
{
@ -38,10 +39,7 @@ std::string HyperXAlloyOrigins60and65Controller::GetSerialString()
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(StringUtils::wstring_to_string(serial_string));
}
void HyperXAlloyOrigins60and65Controller::SetLEDsDirect(std::vector<RGBColor> colors)

View file

@ -11,6 +11,7 @@
#include <cstring>
#include "HyperXAlloyOriginsController.h"
#include "StringUtils.h"
// Skip these indices in the color output
static unsigned int skip_idx[] = { 23, 29, 41, 47, 59, 70, 71, 87, 88, 93, 99, 100, 102, 108, 113, 114, 120, 123, 124 };
@ -41,10 +42,7 @@ std::string HyperXAlloyOriginsController::GetSerialString()
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(StringUtils::wstring_to_string(serial_string));
}
void HyperXAlloyOriginsController::SetLEDsDirect(std::vector<RGBColor> colors)

View file

@ -12,6 +12,7 @@
#include <cstring>
#include "HyperXAlloyOriginsCoreController.h"
#include "StringUtils.h"
// Skip these indices in the color output
static unsigned int skip_idx[] = {6, 7, 14, 15, 22, 23, 30, 31, 38, 39, 44, 46, 47, 54, 55, 58, 60, 61, 62, 63, 70, 71, 78, 79, 86, 87, 94, 95, 101, 102, 103, 109, 110, 111, 118, 119};
@ -53,10 +54,7 @@ std::string HyperXAlloyOriginsCoreController::GetSerialString()
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(StringUtils::wstring_to_string(serial_string));
}
std::string HyperXAlloyOriginsCoreController::GetFirmwareVersion()