From afeab6120d233eb80d9594bb21a06f9e0d0c75fa Mon Sep 17 00:00:00 2001 From: Syping Date: Fri, 13 Jul 2018 09:06:53 +0200 Subject: [PATCH] added GPUs to telemetry data --- TelemetryClass.cpp | 28 ++++++++++++++++++++++------ gta5view.pro | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/TelemetryClass.cpp b/TelemetryClass.cpp index 56f827c..6bf2448 100644 --- a/TelemetryClass.cpp +++ b/TelemetryClass.cpp @@ -44,6 +44,7 @@ #ifdef GTA5SYNC_WIN #include "windows.h" #include "intrin.h" +#include "d3d9.h" #endif TelemetryClass TelemetryClass::telemetryClassInstance; @@ -228,16 +229,16 @@ QJsonDocument TelemetryClass::getSystemHardware() #ifdef GTA5SYNC_WIN { int CPUInfo[4] = {-1}; - unsigned nExIds, i = 0; + unsigned nExIds, ic = 0; char CPUBrandString[0x40]; __cpuid(CPUInfo, 0x80000000); nExIds = CPUInfo[0]; - for (i = 0x80000000; i <= nExIds; ++i) + for (ic = 0x80000000; ic <= nExIds; ic++) { - __cpuid(CPUInfo, i); - if (i == 0x80000002) { memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo)); } - else if (i == 0x80000003) { memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo)); } - else if (i == 0x80000004) { memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo)); } + __cpuid(CPUInfo, ic); + if (ic == 0x80000002) { memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo)); } + else if (ic == 0x80000003) { memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo)); } + else if (ic == 0x80000004) { memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo)); } } jsonObject["CPUName"] = QString::fromLatin1(CPUBrandString).simplified(); SYSTEM_INFO sysInfo; @@ -247,6 +248,21 @@ QJsonDocument TelemetryClass::getSystemHardware() statex.dwLength = sizeof(statex); GlobalMemoryStatusEx(&statex); jsonObject["SystemRAM"] = QString(QString::number((statex.ullTotalPhys / 1024) / 1024) % "MB"); + QStringList gpusList; + IDirect3D9 *pD3D = Direct3DCreate9(D3D_SDK_VERSION); + int adapters = pD3D->GetAdapterCount(); + for (int ia = 0; ia < adapters; ia++) + { + D3DADAPTER_IDENTIFIER9 d3dIdent; + HRESULT result = pD3D->GetAdapterIdentifier(ia, 0, &d3dIdent); + if (result == D3D_OK) + { + QString gpuAdapter = QString::fromLatin1(d3dIdent.Description); + if (!gpusList.contains(gpuAdapter)) { gpusList << gpuAdapter; } + } + } + pD3D->Release(); + jsonObject["GPUs"] = QJsonValue::fromVariant(gpusList); } #else QDir procDir("/proc"); diff --git a/gta5view.pro b/gta5view.pro index e448ac0..6412937 100644 --- a/gta5view.pro +++ b/gta5view.pro @@ -163,7 +163,7 @@ DEFINES += GTA5SYNC_NOASSIST # Not assisting at proper usage of SnapmaticPicture win32: DEFINES += GTA5SYNC_WIN win32: RC_FILE += res/app.rc -win32: LIBS += -luser32 +win32: LIBS += -luser32 -ld3d9 win32: CONFIG -= embed_manifest_exe contains(DEFINES, GTA5SYNC_APV): greaterThan(QT_MAJOR_VERSION, 4): greaterThan(QT_MINOR_VERSION, 1): win32: LIBS += -ldwmapi