From 8f57a9bcf08cc283d79979d71a36caf011957478 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Wed, 24 Jan 2024 19:04:06 -0500 Subject: [PATCH] Fix spacemouse version check by pawning it off on wxWidgets Version is a value not a key name. Also the registry returns things in wchars soooo lets just pawn off the encoding mess on wxWidgets Fixes https://gitlab.com/kicad/code/kicad/-/issues/16730 --- libs/kiplatform/msw/drivers.cpp | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/libs/kiplatform/msw/drivers.cpp b/libs/kiplatform/msw/drivers.cpp index 2db04f74ad..dc9f92a5ad 100644 --- a/libs/kiplatform/msw/drivers.cpp +++ b/libs/kiplatform/msw/drivers.cpp @@ -20,33 +20,26 @@ #include #include -#include -#include +#include +#include #define MIN_WIN_VERSION "10.7.2" bool KIPLATFORM::DRIVERS::Valid3DConnexionDriverVersion() { - HKEY hKey; - std::string version; + const wxString versionValName = wxT( "Version" ); + wxRegKey smKey( wxRegKey::HKLM, wxT( "Software\\3Dconnexion\\3DxSoftware" ) ); - // Open the registry key for 3dConnexion - if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, - L"Software\\3Dconnexion\\3DxSoftware\\Version", - 0, KEY_READ, &hKey ) == ERROR_SUCCESS ) - { - char buffer[256]; - DWORD bufferSize = sizeof( buffer ); + if( !smKey.Exists() ) + return false; - // Query the version value - if( RegQueryValueEx( hKey, nullptr, nullptr, nullptr, ( LPBYTE ) buffer, &bufferSize ) - == ERROR_SUCCESS ) - { - version = buffer; - } + if( !smKey.HasValue( versionValName ) ) + return false; - RegCloseKey( hKey ); - } + wxString versionStr; + if( !smKey.QueryValue( versionValName, versionStr ) ) + return false; - return !version.empty() && compareVersionStrings( MIN_WIN_VERSION, version ); + return !versionStr.empty() + && compareVersionStrings( MIN_WIN_VERSION, versionStr.ToStdString() ); } \ No newline at end of file