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
This commit is contained in:
Marek Roszko 2024-01-24 19:04:06 -05:00
parent 5d7eac7677
commit 8f57a9bcf0
1 changed files with 13 additions and 20 deletions

View File

@ -20,33 +20,26 @@
#include <core/version_compare.h> #include <core/version_compare.h>
#include <kiplatform/drivers.h> #include <kiplatform/drivers.h>
#include <Windows.h> #include <wx/string.h>
#include <iostream> #include <wx/msw/registry.h>
#define MIN_WIN_VERSION "10.7.2" #define MIN_WIN_VERSION "10.7.2"
bool KIPLATFORM::DRIVERS::Valid3DConnexionDriverVersion() bool KIPLATFORM::DRIVERS::Valid3DConnexionDriverVersion()
{ {
HKEY hKey; const wxString versionValName = wxT( "Version" );
std::string version; wxRegKey smKey( wxRegKey::HKLM, wxT( "Software\\3Dconnexion\\3DxSoftware" ) );
// Open the registry key for 3dConnexion if( !smKey.Exists() )
if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, return false;
L"Software\\3Dconnexion\\3DxSoftware\\Version",
0, KEY_READ, &hKey ) == ERROR_SUCCESS )
{
char buffer[256];
DWORD bufferSize = sizeof( buffer );
// Query the version value if( !smKey.HasValue( versionValName ) )
if( RegQueryValueEx( hKey, nullptr, nullptr, nullptr, ( LPBYTE ) buffer, &bufferSize ) return false;
== ERROR_SUCCESS )
{
version = buffer;
}
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() );
} }