fixed Windows serial port names list

This commit is contained in:
Thomas Jentzsch 2021-10-17 17:29:56 +02:00
parent 12ccc2d15c
commit e2b8e0f2a9
2 changed files with 13 additions and 5 deletions

View File

@ -652,7 +652,7 @@ class EventHandler
;
// The event(s) assigned to each combination event
BSPF::array2D<Event::Type, COMBO_SIZE, EVENTS_PER_COMBO> myComboTable{Event::NoType};
BSPF::array2D<Event::Type, COMBO_SIZE, EVENTS_PER_COMBO> myComboTable;
// Holds static strings for the remap menu (emulation and menu events)
using EmulActionList = std::array<ActionList, EMUL_ACTIONLIST_SIZE>;

View File

@ -129,12 +129,13 @@ StringList SerialPortWINDOWS::portNames()
&numValues, NULL, NULL, NULL, NULL);
if (result == ERROR_SUCCESS)
{
DWORD type = 0;
DWORD deviceNameLen = 2047;
DWORD friendlyNameLen = 31;
for (DWORD i = 0; i < numValues; ++i)
{
// must be reset to work in a loop!
DWORD type = 0;
DWORD deviceNameLen = 2047;
DWORD friendlyNameLen = 31;
result = RegEnumValue(hKey, i, deviceName, &deviceNameLen,
NULL, &type, (LPBYTE)friendlyName, &friendlyNameLen);
@ -145,5 +146,12 @@ StringList SerialPortWINDOWS::portNames()
}
RegCloseKey(hKey);
std::sort(ports.begin(), ports.end(),
[](const std::string& a, const std::string& b)
{
return a < b;
}
);
return ports;
}