Handle systems where the video driver regkey isn't "0000".
Merge 9x and 2k/XP probing.
This commit is contained in:
@@ -29,7 +29,7 @@ static void GetMemoryDebugInfo()
|
|||||||
|
|
||||||
static void GetDisplayDriverDebugInfo()
|
static void GetDisplayDriverDebugInfo()
|
||||||
{
|
{
|
||||||
CString sPrimaryDeviceName = GetPrimaryVideoName9xAnd2k();
|
CString sPrimaryDeviceName = GetPrimaryVideoName();
|
||||||
|
|
||||||
if( sPrimaryDeviceName == "" )
|
if( sPrimaryDeviceName == "" )
|
||||||
LOG->Info( "Primary display driver could not be determined." );
|
LOG->Info( "Primary display driver could not be determined." );
|
||||||
|
|||||||
@@ -3,6 +3,28 @@
|
|||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
|
|
||||||
|
static void GetRegSubKeys( HKEY hKey, vector<CString> &lst )
|
||||||
|
{
|
||||||
|
char szBuffer[MAX_PATH];
|
||||||
|
DWORD nSize = sizeof(szBuffer)-1;
|
||||||
|
FILETIME ft;
|
||||||
|
|
||||||
|
for( int index = 0; ; ++index )
|
||||||
|
{
|
||||||
|
LONG ret = RegEnumKeyEx( hKey, index, szBuffer, &nSize, NULL, NULL, NULL, &ft);
|
||||||
|
if( ret == ERROR_NO_MORE_ITEMS )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA )
|
||||||
|
{
|
||||||
|
LOG->Warn( werr_ssprintf(ret, "GetRegSubKeys(%p,%i) error", hKey, index) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lst.push_back( szBuffer );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static CString GetRegValue( HKEY hKey, CString sName )
|
static CString GetRegValue( HKEY hKey, CString sName )
|
||||||
{
|
{
|
||||||
char szBuffer[MAX_PATH];
|
char szBuffer[MAX_PATH];
|
||||||
@@ -13,55 +35,10 @@ static CString GetRegValue( HKEY hKey, CString sName )
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetVideoDriverInfo9x( int iIndex, VideoDriverInfo& infoOut )
|
|
||||||
{
|
|
||||||
HKEY hkey;
|
|
||||||
CString sKey = ssprintf("SYSTEM\\CurrentControlSet\\Services\\Class\\Display\\%04d",iIndex);
|
|
||||||
if (RegOpenKey(HKEY_LOCAL_MACHINE, sKey, &hkey) != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
/* The first card should always exist. */
|
|
||||||
if( iIndex == 0 )
|
|
||||||
LOG->Warn("GetVideoDriverInfo9x error: index 0 doesn't exist!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
infoOut.sDate = GetRegValue( hkey, "DriverDate");
|
|
||||||
infoOut.sDescription = GetRegValue( hkey, "DriverDesc");
|
|
||||||
infoOut.sDeviceID = GetRegValue( hkey, "MatchingDeviceId");
|
|
||||||
infoOut.sProvider = GetRegValue( hkey, "ProviderName");
|
|
||||||
infoOut.sVersion = GetRegValue( hkey, "Ver");
|
|
||||||
|
|
||||||
RegCloseKey(hkey);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GetVideoDriverInfo2k( int iIndex, VideoDriverInfo& infoOut )
|
|
||||||
{
|
|
||||||
HKEY hkey;
|
|
||||||
CString sKey = ssprintf("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}\\%04d",iIndex);
|
|
||||||
if (RegOpenKey(HKEY_LOCAL_MACHINE, sKey, &hkey) != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
if( iIndex == 0 )
|
|
||||||
LOG->Warn("GetVideoDriverInfo2k error: index 0 doesn't exist!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
infoOut.sDate = GetRegValue( hkey, "DriverDate");
|
|
||||||
infoOut.sDescription = GetRegValue( hkey, "DriverDesc");
|
|
||||||
infoOut.sDeviceID = GetRegValue( hkey, "MatchingDeviceId");
|
|
||||||
infoOut.sProvider = GetRegValue( hkey, "ProviderName");
|
|
||||||
infoOut.sVersion = GetRegValue( hkey, "DriverVersion");
|
|
||||||
|
|
||||||
RegCloseKey(hkey);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// this will not work on 95 and NT b/c of EnumDisplayDevices
|
// this will not work on 95 and NT b/c of EnumDisplayDevices
|
||||||
CString GetPrimaryVideoName9xAnd2k()
|
CString GetPrimaryVideoName()
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef BOOL (WINAPI* pfnEnumDisplayDevices)(PVOID,DWORD,PDISPLAY_DEVICE,DWORD);
|
typedef BOOL (WINAPI* pfnEnumDisplayDevices)(PVOID,DWORD,PDISPLAY_DEVICE,DWORD);
|
||||||
pfnEnumDisplayDevices EnumDisplayDevices;
|
pfnEnumDisplayDevices EnumDisplayDevices;
|
||||||
HINSTANCE hInstUser32;
|
HINSTANCE hInstUser32;
|
||||||
@@ -99,11 +76,11 @@ CString GetPrimaryVideoName9xAnd2k()
|
|||||||
|
|
||||||
CString GetPrimaryVideoDriverName()
|
CString GetPrimaryVideoDriverName()
|
||||||
{
|
{
|
||||||
const CString sPrimaryDeviceName = GetPrimaryVideoName9xAnd2k();
|
const CString sPrimaryDeviceName = GetPrimaryVideoName();
|
||||||
if( sPrimaryDeviceName != "" )
|
if( sPrimaryDeviceName != "" )
|
||||||
return sPrimaryDeviceName;
|
return sPrimaryDeviceName;
|
||||||
|
|
||||||
LOG->Warn("GetPrimaryVideoName9xAnd2k failed; renderer selection may be wrong");
|
LOG->Warn("GetPrimaryVideoName failed; renderer selection may be wrong");
|
||||||
|
|
||||||
VideoDriverInfo info;
|
VideoDriverInfo info;
|
||||||
if( !GetVideoDriverInfo(0, info) )
|
if( !GetVideoDriverInfo(0, info) )
|
||||||
@@ -120,5 +97,64 @@ bool GetVideoDriverInfo(int cardno, VideoDriverInfo &info)
|
|||||||
GetVersionEx(&version);
|
GetVersionEx(&version);
|
||||||
const bool bIsWin9x = version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
|
const bool bIsWin9x = version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
|
||||||
|
|
||||||
return (bIsWin9x ? GetVideoDriverInfo9x : GetVideoDriverInfo2k)(cardno,info);
|
static bool Initialized=false;
|
||||||
|
static vector<CString> lst;
|
||||||
|
if( !Initialized )
|
||||||
|
{
|
||||||
|
Initialized = true;
|
||||||
|
|
||||||
|
const CString TopKey = bIsWin9x?
|
||||||
|
"SYSTEM\\CurrentControlSet\\Services\\Class\\Display":
|
||||||
|
"SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}";
|
||||||
|
|
||||||
|
HKEY hkey;
|
||||||
|
int ret = RegOpenKey(HKEY_LOCAL_MACHINE, TopKey, &hkey);
|
||||||
|
if ( ret != ERROR_SUCCESS )
|
||||||
|
{
|
||||||
|
LOG->Warn( werr_ssprintf(ret, "RegOpenKey(%s) error", TopKey.c_str()) );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetRegSubKeys( hkey, lst );
|
||||||
|
RegCloseKey( hkey );
|
||||||
|
|
||||||
|
for( int i = lst.size()-1; i >= 0; --i )
|
||||||
|
{
|
||||||
|
/* Remove all keys that aren't four characters long ("Properties"). */
|
||||||
|
if( lst[i].size() != 4 )
|
||||||
|
lst.erase( lst.begin()+i );
|
||||||
|
lst[i] = TopKey + "\\" + lst[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( lst.size() == 0 )
|
||||||
|
{
|
||||||
|
LOG->Warn("GetVideoDriverInfo error: no cards found!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while( cardno < (int)lst.size() )
|
||||||
|
{
|
||||||
|
const CString sKey = lst[cardno];
|
||||||
|
HKEY hkey;
|
||||||
|
int ret = RegOpenKey(HKEY_LOCAL_MACHINE, sKey, &hkey);
|
||||||
|
if ( ret != ERROR_SUCCESS )
|
||||||
|
{
|
||||||
|
/* Remove this one from the list and ignore it, */
|
||||||
|
LOG->Warn( werr_ssprintf(ret, "RegOpenKey(%s) error", sKey.c_str()) );
|
||||||
|
lst.erase( lst.begin()+cardno );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
info.sDate = GetRegValue( hkey, "DriverDate");
|
||||||
|
info.sDescription = GetRegValue( hkey, "DriverDesc");
|
||||||
|
info.sDeviceID = GetRegValue( hkey, "MatchingDeviceId");
|
||||||
|
info.sProvider = GetRegValue( hkey, "ProviderName");
|
||||||
|
info.sVersion = GetRegValue( hkey, bIsWin9x? "Ver":"DriverVersion");
|
||||||
|
|
||||||
|
RegCloseKey(hkey);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ struct VideoDriverInfo
|
|||||||
CString sDeviceID;
|
CString sDeviceID;
|
||||||
};
|
};
|
||||||
|
|
||||||
CString GetPrimaryVideoName9xAnd2k();
|
CString GetPrimaryVideoName();
|
||||||
bool GetVideoDriverInfo(int cardno, VideoDriverInfo &info);
|
bool GetVideoDriverInfo(int cardno, VideoDriverInfo &info);
|
||||||
CString GetPrimaryVideoDriverName();
|
CString GetPrimaryVideoDriverName();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user