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 <kiplatform/drivers.h>
#include <Windows.h>
#include <iostream>
#include <wx/string.h>
#include <wx/msw/registry.h>
#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() );
}