Files
itgmania212121/stepmania/src/archutils/Win32/DebugInfoHunt.cpp
T

146 lines
3.4 KiB
C++
Raw Normal View History

2003-02-16 04:05:10 +00:00
#include "global.h"
2003-01-24 23:57:02 +00:00
#include "DebugInfoHunt.h"
#include "RageLog.h"
2003-01-24 23:57:03 +00:00
#include "RageUtil.h"
2003-05-26 23:36:17 +00:00
#include "VideoDriverInfo.h"
2003-11-14 17:17:36 +00:00
#include "windows.h"
#include <mmsystem.h>
2003-01-24 23:57:02 +00:00
void LogVideoDriverInfo( VideoDriverInfo info )
{
LOG->Info("Video Driver Information:");
2003-04-25 04:09:29 +00:00
LOG->Info("%-15s:\t%s", "Provider", info.sProvider.c_str());
LOG->Info("%-15s:\t%s", "Description", info.sDescription.c_str());
LOG->Info("%-15s:\t%s", "Version", info.sVersion.c_str());
LOG->Info("%-15s:\t%s", "Date", info.sDate.c_str());
LOG->Info("%-15s:\t%s", "DeviceID", info.sDeviceID.c_str());
}
2003-06-10 22:45:16 +00:00
static void GetMemoryDebugInfo()
{
MEMORYSTATUS mem;
GlobalMemoryStatus(&mem);
LOG->Info("Memory: %imb total, %imb swap (%imb swap avail)",
mem.dwTotalPhys / 1048576,
mem.dwTotalPageFile / 1048576,
mem.dwAvailPageFile / 1048576);
}
2003-01-24 23:57:02 +00:00
static void GetDisplayDriverDebugInfo()
{
CString sPrimaryDeviceName = GetPrimaryVideoName();
if( sPrimaryDeviceName == "" )
LOG->Info( "Primary display driver could not be determined." );
else
2003-04-25 04:09:29 +00:00
LOG->Info( "Primary display driver: %s", sPrimaryDeviceName.c_str() );
for( int i=0; true; i++ )
{
VideoDriverInfo info;
2003-05-26 23:36:17 +00:00
if( !GetVideoDriverInfo(i, info) )
break;
2003-06-10 22:45:16 +00:00
if( sPrimaryDeviceName == "" ) // failed to get primary display name (NT4)
{
LogVideoDriverInfo( info );
}
else if( info.sDescription == sPrimaryDeviceName )
{
LogVideoDriverInfo( info );
break;
}
}
2003-01-24 23:57:02 +00:00
}
2003-02-17 03:02:13 +00:00
static CString wo_ssprintf( MMRESULT err, const char *fmt, ...)
{
char buf[MAXERRORLENGTH];
waveOutGetErrorText(err, buf, MAXERRORLENGTH);
va_list va;
va_start(va, fmt);
CString s = vssprintf( fmt, va );
va_end(va);
return s += ssprintf( "(%s)", buf );
}
2003-06-10 22:45:16 +00:00
static void GetWindowsVersionDebugInfo()
{
/* Detect operating system. */
OSVERSIONINFO ovi;
ovi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (!GetVersionEx(&ovi))
{
LOG->Info("GetVersionEx failed!");
return;
}
CString Ver = ssprintf("Windows %i.%i (", ovi.dwMajorVersion, ovi.dwMinorVersion);
if(ovi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
if(ovi.dwMinorVersion == 0)
Ver += "Win95";
else if(ovi.dwMinorVersion == 10)
Ver += "Win98";
else if(ovi.dwMinorVersion == 90)
Ver += "WinME";
else
Ver += "unknown 9x-based";
}
else if(ovi.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
if(ovi.dwMajorVersion == 4 && ovi.dwMinorVersion == 0)
Ver += "WinNT 4.0";
else if(ovi.dwMajorVersion == 5 && ovi.dwMinorVersion == 0)
Ver += "Win2000";
else if(ovi.dwMajorVersion == 5 && ovi.dwMinorVersion == 1)
Ver += "WinXP";
else
Ver += "unknown NT-based";
} else Ver += "???";
Ver += ssprintf(") build %i [%s]", ovi.dwBuildNumber & 0xffff, ovi.szCSDVersion);
LOG->Info("%s", Ver.c_str());
}
2003-02-17 03:02:13 +00:00
static void GetSoundDriverDebugInfo()
{
int cnt = waveOutGetNumDevs();
for(int i = 0; i < cnt; ++i)
{
WAVEOUTCAPS caps;
MMRESULT ret = waveOutGetDevCaps(i, &caps, sizeof(caps));
if(ret != MMSYSERR_NOERROR)
{
LOG->Info(wo_ssprintf(ret, "waveOutGetDevCaps(%i) failed", i));
continue;
}
LOG->Info("Sound device %i: %s, %i.%i, MID %i, PID %i %s", i, caps.szPname,
HIBYTE(caps.vDriverVersion),
LOBYTE(caps.vDriverVersion),
caps.wMid, caps.wPid,
caps.dwSupport & WAVECAPS_SAMPLEACCURATE? "":"(INACCURATE)");
}
}
2003-06-29 21:45:48 +00:00
2003-01-24 23:57:02 +00:00
void SearchForDebugInfo()
{
2003-06-10 22:45:16 +00:00
GetWindowsVersionDebugInfo();
GetMemoryDebugInfo();
2003-01-24 23:57:02 +00:00
GetDisplayDriverDebugInfo();
2003-02-17 03:02:13 +00:00
GetSoundDriverDebugInfo();
2003-01-24 23:57:02 +00:00
}
/*
* Copyright (c) 2003 by the person(s) listed below. All rights reserved.
*
* Glenn Maynard
*/