From 577b3cbc9058962a8867ee7b6942ed6feb542fbe Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 26 Dec 2018 09:06:25 -0800 Subject: [PATCH 01/15] Implemented online help. --- tools/nitpick/src/ui/HelpWindow.cpp | 14 --------- tools/nitpick/src/ui/HelpWindow.h | 22 -------------- tools/nitpick/src/ui/HelpWindow.ui | 46 ----------------------------- tools/nitpick/src/ui/Nitpick.cpp | 9 +++--- tools/nitpick/src/ui/Nitpick.h | 3 -- tools/nitpick/src/ui/Nitpick.ui | 4 +-- 6 files changed, 6 insertions(+), 92 deletions(-) delete mode 100644 tools/nitpick/src/ui/HelpWindow.cpp delete mode 100644 tools/nitpick/src/ui/HelpWindow.h delete mode 100644 tools/nitpick/src/ui/HelpWindow.ui diff --git a/tools/nitpick/src/ui/HelpWindow.cpp b/tools/nitpick/src/ui/HelpWindow.cpp deleted file mode 100644 index 21c5d9d375..0000000000 --- a/tools/nitpick/src/ui/HelpWindow.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// -// HelpWindow.cpp -// -// Created by Nissim Hadar on 8 Aug 2017. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -#include "HelpWindow.h" - -HelpWindow::HelpWindow(QWidget *parent) { - setupUi(this); -} diff --git a/tools/nitpick/src/ui/HelpWindow.h b/tools/nitpick/src/ui/HelpWindow.h deleted file mode 100644 index 5ce91b360d..0000000000 --- a/tools/nitpick/src/ui/HelpWindow.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// HelpWindow.h -// -// Created by Nissim Hadar on 8 Aug 2017. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -#ifndef hifi_HelpWindow_h -#define hifi_HelpWindow_h - -#include "ui_HelpWindow.h" - -class HelpWindow : public QDialog, public Ui::HelpWindow { - Q_OBJECT - -public: - HelpWindow(QWidget* parent = Q_NULLPTR); -}; - -#endif \ No newline at end of file diff --git a/tools/nitpick/src/ui/HelpWindow.ui b/tools/nitpick/src/ui/HelpWindow.ui deleted file mode 100644 index 1ce6e8c321..0000000000 --- a/tools/nitpick/src/ui/HelpWindow.ui +++ /dev/null @@ -1,46 +0,0 @@ - - - HelpWindow - - - Qt::ApplicationModal - - - - 0 - 0 - 696 - 546 - - - - Nitpick Help - - - - - 50 - 50 - 581 - 381 - - - - - - - 300 - 460 - 93 - 28 - - - - Close - - - - - - - diff --git a/tools/nitpick/src/ui/Nitpick.cpp b/tools/nitpick/src/ui/Nitpick.cpp index cdd2ff89d9..38124e1f39 100644 --- a/tools/nitpick/src/ui/Nitpick.cpp +++ b/tools/nitpick/src/ui/Nitpick.cpp @@ -15,6 +15,8 @@ #include #endif +#include + Nitpick::Nitpick(QWidget* parent) : QMainWindow(parent) { _ui.setupUi(this); @@ -36,10 +38,7 @@ Nitpick::Nitpick(QWidget* parent) : QMainWindow(parent) { _ui.statusLabel->setText(""); _ui.plainTextEdit->setReadOnly(true); - setWindowTitle("Nitpick - v1.2"); - - // Coming soon to a nitpick near you... - //// _helpWindow.textBrowser->setText() + setWindowTitle("Nitpick - v1.3"); } Nitpick::~Nitpick() { @@ -287,7 +286,7 @@ void Nitpick::about() { } void Nitpick::content() { - _helpWindow.show(); + QDesktopServices::openUrl(QUrl("https://github.com/highfidelity/hifi/blob/master/tools/nitpick/README.md")); } void Nitpick::setUserText(const QString& user) { diff --git a/tools/nitpick/src/ui/Nitpick.h b/tools/nitpick/src/ui/Nitpick.h index 21b917654b..08e41e0a90 100644 --- a/tools/nitpick/src/ui/Nitpick.h +++ b/tools/nitpick/src/ui/Nitpick.h @@ -18,7 +18,6 @@ #include "../Downloader.h" #include "../Test.h" -#include "HelpWindow.h" #include "../TestRunner.h" #include "../AWSInterface.h" @@ -116,8 +115,6 @@ private: bool _isRunningFromCommandline{ false }; - HelpWindow _helpWindow; - void* _caller; }; diff --git a/tools/nitpick/src/ui/Nitpick.ui b/tools/nitpick/src/ui/Nitpick.ui index 5e20e75553..78f7dcf2bf 100644 --- a/tools/nitpick/src/ui/Nitpick.ui +++ b/tools/nitpick/src/ui/Nitpick.ui @@ -803,7 +803,7 @@ 0 0 720 - 22 + 21 @@ -843,7 +843,7 @@ - Content + Online readme From 70a2412a71f31508cb330452676c2f8f7eef57c9 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 26 Dec 2018 12:23:26 -0800 Subject: [PATCH 02/15] Windows version now deletes entities before starting tests. --- tools/nitpick/src/TestRunner.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/nitpick/src/TestRunner.cpp b/tools/nitpick/src/TestRunner.cpp index 9b99e114a7..bbdd36a12a 100644 --- a/tools/nitpick/src/TestRunner.cpp +++ b/tools/nitpick/src/TestRunner.cpp @@ -469,12 +469,30 @@ void TestRunner::runInterfaceWithTestScript() { url = "hifi://localhost"; } + QString deleteScript = + QString("https://raw.githubusercontent.com/") + _user + "/hifi_tests/" + _branch + "/tests/utils/deleteNearbyEntities.js"; + QString testScript = QString("https://raw.githubusercontent.com/") + _user + "/hifi_tests/" + _branch + "/tests/testRecursive.js"; QString commandLine; #ifdef Q_OS_WIN - QString exeFile = QString("\"") + QDir::toNativeSeparators(_installationFolder) + "\\interface.exe\""; + QString exeFile; + // First, run script to delete any entities in test area + // Note that this will run to completion before continuing + exeFile = QString("\"") + QDir::toNativeSeparators(_installationFolder) + "\\interface.exe\""; + commandLine = "start /wait \"\" " + exeFile + + " --url " + url + + " --no-updater" + + " --no-login-suggestion" + " --testScript " + deleteScript + " quitWhenFinished" + + " --testResultsLocation " + _snapshotFolder; + + + system(commandLine.toStdString().c_str()); + + // Now run the test suite + exeFile = QString("\"") + QDir::toNativeSeparators(_installationFolder) + "\\interface.exe\""; commandLine = exeFile + " --url " + url + " --no-updater" + From 493a05f905504a3357c89ef4f28bc52a143ba7ef Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 28 Dec 2018 08:45:45 -0800 Subject: [PATCH 03/15] Remove bad comment. --- tools/nitpick/src/TestRunner.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tools/nitpick/src/TestRunner.cpp b/tools/nitpick/src/TestRunner.cpp index bbdd36a12a..9aca2bf3e6 100644 --- a/tools/nitpick/src/TestRunner.cpp +++ b/tools/nitpick/src/TestRunner.cpp @@ -485,9 +485,7 @@ void TestRunner::runInterfaceWithTestScript() { " --url " + url + " --no-updater" + " --no-login-suggestion" - " --testScript " + deleteScript + " quitWhenFinished" + - " --testResultsLocation " + _snapshotFolder; - + " --testScript " + deleteScript + " quitWhenFinished"; system(commandLine.toStdString().c_str()); @@ -503,10 +501,6 @@ void TestRunner::runInterfaceWithTestScript() { _interfaceWorker->setCommandLine(commandLine); emit startInterface(); #elif defined Q_OS_MAC - // On The Mac, we need to resize Interface. The Interface window opens a few seconds after the process - // has started. - // Before starting interface, start a process that will resize interface 10s after it opens - // This is performed by creating a bash script that runs to processes QFile script; script.setFileName(_workingFolder + "/runInterfaceTests.sh"); if (!script.open(QIODevice::WriteOnly | QIODevice::Text)) { @@ -516,7 +510,20 @@ void TestRunner::runInterfaceWithTestScript() { } script.write("#!/bin/sh\n\n"); - + + // First, run script to delete any entities in test area + commandLine = + "open -W \"" +_installationFolder + "/interface.app\" --args" + + " --url " + url + + " --no-updater" + + " --no-login-suggestion" + " --testScript " + deleteScript + " quitWhenFinished\n"; + + script.write(commandLine.toStdString().c_str()); + + // On The Mac, we need to resize Interface. The Interface window opens a few seconds after the process + // has started. + // Before starting interface, start a process that will resize interface 10s after it opens commandLine = _workingFolder +"/waitForStart.sh interface && sleep 10 && " + _workingFolder +"/setInterfaceSizeAndPosition.sh &\n"; script.write(commandLine.toStdString().c_str()); @@ -527,7 +534,7 @@ void TestRunner::runInterfaceWithTestScript() { " --no-login-suggestion" " --testScript " + testScript + " quitWhenFinished" + " --testResultsLocation " + _snapshotFolder + - " && " + _workingFolder +"/waitForFinish.sh interface"; + " && " + _workingFolder +"/waitForFinish.sh interface\n"; script.write(commandLine.toStdString().c_str()); From c28167f7973ae3de14e8f24f2d8faabb3777b3b7 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 28 Dec 2018 14:24:19 -0800 Subject: [PATCH 04/15] Initial creation of class - has COPY of getOperatingSystemType(). --- .../PlatformInfoScriptingInterface.cpp | 23 ++++++++++++++ .../PlatformInfoScriptingInterface.h | 30 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 interface/src/scripting/PlatformInfoScriptingInterface.cpp create mode 100644 interface/src/scripting/PlatformInfoScriptingInterface.h diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp new file mode 100644 index 0000000000..e2fea92ed3 --- /dev/null +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -0,0 +1,23 @@ +// +// Created by Nissim Hadar on 2018/12/28 +// Copyright 2013-2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#include "PlatformInfoScriptingInterface.h" + +PlatformInfoScriptingInterface* PlatformInfoScriptingInterface::getInstance() { + static PlatformInfoScriptingInterface sharedInstance; + return &sharedInstance; +} + +QString PlatformInfoScriptingInterface::getOperatingSystemType() { +#ifdef Q_OS_WIN + return "WINDOWS"; +#elif defined Q_OS_MAC + return "MACOS"; +#else + return "UNKNOWN"; +#endif +} diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.h b/interface/src/scripting/PlatformInfoScriptingInterface.h new file mode 100644 index 0000000000..b30af12071 --- /dev/null +++ b/interface/src/scripting/PlatformInfoScriptingInterface.h @@ -0,0 +1,30 @@ +// +// Created by Nissim Hadar on 2018/12/28 +// Copyright 2013-2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_PlatformInfoScriptingInterface_h +#define hifi_PlatformInfoScriptingInterface_h + +#include + +class QScriptValue; + +class PlatformInfoScriptingInterface : public QObject { + Q_OBJECT + +public slots: + static PlatformInfoScriptingInterface* getInstance(); + + /**jsdoc + * Returns the Operating Sytem type + * @function Test.getOperatingSystemType + * @returns {string} "WINDOWS", "MACOS" or "UNKNOWN" + */ + QString getOperatingSystemType(); +}; + +#endif // hifi_PlatformInfoScriptingInterface_h From 246c4dab9474a94dae6a14d27f7717fcfd251aa4 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 28 Dec 2018 14:41:55 -0800 Subject: [PATCH 05/15] Created the PlatformInfo scripting object. --- interface/src/Application.cpp | 2 ++ interface/src/scripting/PlatformInfoScriptingInterface.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5e41530d93..56130160c4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -170,6 +170,7 @@ #include "scripting/Audio.h" #include "networking/CloseEventSender.h" #include "scripting/TestScriptingInterface.h" +#include "scripting/PlatformInfoScriptingInterface.h" #include "scripting/AssetMappingsScriptingInterface.h" #include "scripting/ClipboardScriptingInterface.h" #include "scripting/DesktopScriptingInterface.h" @@ -6994,6 +6995,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance()); } + scriptEngine->registerGlobalObject("PlatformInfo", PlatformInfoScriptingInterface::getInstance()); scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this)); // hook our avatar and avatar hash map object into this script engine diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.h b/interface/src/scripting/PlatformInfoScriptingInterface.h index b30af12071..dc88e1963f 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.h +++ b/interface/src/scripting/PlatformInfoScriptingInterface.h @@ -25,6 +25,10 @@ public slots: * @returns {string} "WINDOWS", "MACOS" or "UNKNOWN" */ QString getOperatingSystemType(); + + /**jsdoc + * Returns the CPU brand + */ }; #endif // hifi_PlatformInfoScriptingInterface_h From 63ea3009217957aff86d0a70593662003658381e Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sat, 29 Dec 2018 17:24:44 -0800 Subject: [PATCH 06/15] Can get CPU brand. --- .../PlatformInfoScriptingInterface.cpp | 34 +++++++++++++++++++ .../PlatformInfoScriptingInterface.h | 3 ++ 2 files changed, 37 insertions(+) diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index e2fea92ed3..a6ef660b27 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -21,3 +21,37 @@ QString PlatformInfoScriptingInterface::getOperatingSystemType() { return "UNKNOWN"; #endif } + +QString PlatformInfoScriptingInterface::getCPUBrand() { + int CPUInfo[4] = { -1 }; + unsigned nExIds, i = 0; + char CPUBrandString[0x40]; + // Get the information associated with each extended ID. + __cpuid(CPUInfo, 0x80000000); + nExIds = CPUInfo[0]; + for (i = 0x80000000; i <= nExIds; ++i) { + __cpuid(CPUInfo, i); + // Interpret CPU brand string + 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)); + } + } + + return CPUBrandString; + //////string includes manufacturer, model and clockspeed + ////cout << "CPU Type: " << CPUBrandString << endl; + + + ////SYSTEM_INFO sysInfo; + ////GetSystemInfo(&sysInfo); + ////cout << "Number of Cores: " << sysInfo.dwNumberOfProcessors << endl; + + ////MEMORYSTATUSEX statex; + ////statex.dwLength = sizeof (statex); + ////GlobalMemoryStatusEx(&statex); + ////cout << "Total System Memory: " << (statex.ullTotalPhys / 1024) / 1024 << "MB" << endl; +} \ No newline at end of file diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.h b/interface/src/scripting/PlatformInfoScriptingInterface.h index dc88e1963f..d8cba43884 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.h +++ b/interface/src/scripting/PlatformInfoScriptingInterface.h @@ -28,7 +28,10 @@ public slots: /**jsdoc * Returns the CPU brand + *function PlatformInfo.getCPUBrand() + * @returns {string} brand of CPU */ + QString getCPUBrand(); }; #endif // hifi_PlatformInfoScriptingInterface_h From 3a9214747a99f379341b35beb92a71c56309880f Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sat, 29 Dec 2018 20:49:54 -0800 Subject: [PATCH 07/15] Can read number of logical processors --- .../PlatformInfoScriptingInterface.cpp | 26 +++++++++++++------ .../PlatformInfoScriptingInterface.h | 7 +++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index a6ef660b27..647262c547 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -7,6 +7,10 @@ // #include "PlatformInfoScriptingInterface.h" +#ifdef Q_OS_WIN +#include +#endif + PlatformInfoScriptingInterface* PlatformInfoScriptingInterface::getInstance() { static PlatformInfoScriptingInterface sharedInstance; return &sharedInstance; @@ -23,6 +27,7 @@ QString PlatformInfoScriptingInterface::getOperatingSystemType() { } QString PlatformInfoScriptingInterface::getCPUBrand() { +#ifdef Q_OS_WIN int CPUInfo[4] = { -1 }; unsigned nExIds, i = 0; char CPUBrandString[0x40]; @@ -42,16 +47,21 @@ QString PlatformInfoScriptingInterface::getCPUBrand() { } return CPUBrandString; - //////string includes manufacturer, model and clockspeed - ////cout << "CPU Type: " << CPUBrandString << endl; - - - ////SYSTEM_INFO sysInfo; - ////GetSystemInfo(&sysInfo); - ////cout << "Number of Cores: " << sysInfo.dwNumberOfProcessors << endl; - +#else + return "NOT IMPLEMENTED"; +#endif +} ////MEMORYSTATUSEX statex; ////statex.dwLength = sizeof (statex); ////GlobalMemoryStatusEx(&statex); ////cout << "Total System Memory: " << (statex.ullTotalPhys / 1024) / 1024 << "MB" << endl; + +int PlatformInfoScriptingInterface::getNumCores() { +#ifdef Q_OS_WIN + SYSTEM_INFO sysInfo; + GetSystemInfo(&sysInfo); + return sysInfo.dwNumberOfProcessors; +#else + return -1; +#endif } \ No newline at end of file diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.h b/interface/src/scripting/PlatformInfoScriptingInterface.h index d8cba43884..47c8401455 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.h +++ b/interface/src/scripting/PlatformInfoScriptingInterface.h @@ -32,6 +32,13 @@ public slots: * @returns {string} brand of CPU */ QString getCPUBrand(); + + /**jsdoc + * Returns the number of CPU cores + *function PlatformInfo.getNumCores() + * @returns {int} number of CPU cores + */ + int getNumCores(); }; #endif // hifi_PlatformInfoScriptingInterface_h From 6debd996c5a7d02c8e19bec3e28146661e064955 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sat, 29 Dec 2018 21:59:18 -0800 Subject: [PATCH 08/15] Added method to get total system memory in MB. --- .../PlatformInfoScriptingInterface.cpp | 21 ++++++++++++------- .../PlatformInfoScriptingInterface.h | 15 +++++++++---- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index 647262c547..3ffb00e4b8 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -7,6 +7,8 @@ // #include "PlatformInfoScriptingInterface.h" +# include + #ifdef Q_OS_WIN #include #endif @@ -34,6 +36,7 @@ QString PlatformInfoScriptingInterface::getCPUBrand() { // Get the information associated with each extended ID. __cpuid(CPUInfo, 0x80000000); nExIds = CPUInfo[0]; + for (i = 0x80000000; i <= nExIds; ++i) { __cpuid(CPUInfo, i); // Interpret CPU brand string @@ -51,16 +54,18 @@ QString PlatformInfoScriptingInterface::getCPUBrand() { return "NOT IMPLEMENTED"; #endif } - ////MEMORYSTATUSEX statex; - ////statex.dwLength = sizeof (statex); - ////GlobalMemoryStatusEx(&statex); - ////cout << "Total System Memory: " << (statex.ullTotalPhys / 1024) / 1024 << "MB" << endl; -int PlatformInfoScriptingInterface::getNumCores() { +unsigned int PlatformInfoScriptingInterface::getNumLogicalCores() { + + return std::thread::hardware_concurrency(); +} + +int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() { #ifdef Q_OS_WIN - SYSTEM_INFO sysInfo; - GetSystemInfo(&sysInfo); - return sysInfo.dwNumberOfProcessors; + MEMORYSTATUSEX statex; + statex.dwLength = sizeof (statex); + GlobalMemoryStatusEx(&statex); + return statex.ullTotalPhys / 1024 / 1024; #else return -1; #endif diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.h b/interface/src/scripting/PlatformInfoScriptingInterface.h index 47c8401455..f0b8122fa5 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.h +++ b/interface/src/scripting/PlatformInfoScriptingInterface.h @@ -34,11 +34,18 @@ public slots: QString getCPUBrand(); /**jsdoc - * Returns the number of CPU cores - *function PlatformInfo.getNumCores() - * @returns {int} number of CPU cores + * Returns the number of logical CPU cores + *function PlatformInfo.getNumLogicalCores() + * @returns {int} number of logical CPU cores */ - int getNumCores(); + unsigned int getNumLogicalCores(); + + /**jsdoc + * Returns the total system memory in megabyte + *function PlatformInfo.getTotalSystemMemory() + * @returns {int} size of memory in megabytes + */ + int getTotalSystemMemoryMB(); }; #endif // hifi_PlatformInfoScriptingInterface_h From 76ce63da64be5360fa25401789b14a6cceacb0e8 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sun, 30 Dec 2018 20:24:00 -0800 Subject: [PATCH 09/15] Can read graphics card type. --- interface/src/Application.cpp | 4 ++++ interface/src/Application.h | 3 ++- interface/src/scripting/PlatformInfoScriptingInterface.cpp | 7 ++++++- interface/src/scripting/PlatformInfoScriptingInterface.h | 7 +++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 56130160c4..503e974f24 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -8931,6 +8931,10 @@ void Application::copyToClipboard(const QString& text) { QApplication::clipboard()->setText(text); } +QString Application::getGraphicsCardType() { + return GPUIdent::getInstance()->getName(); +} + #if defined(Q_OS_ANDROID) void Application::beforeEnterBackground() { auto nodeList = DependencyManager::get(); diff --git a/interface/src/Application.h b/interface/src/Application.h index fd45a594b5..66667518fc 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -459,6 +459,8 @@ public slots: void changeViewAsNeeded(float boomLength); + QString Application::getGraphicsCardType(); + private slots: void onDesktopRootItemCreated(QQuickItem* qmlContext); void onDesktopRootContextCreated(QQmlContext* qmlContext); @@ -787,6 +789,5 @@ private: bool _showTrackedObjects { false }; bool _prevShowTrackedObjects { false }; - }; #endif // hifi_Application_h diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index 3ffb00e4b8..7f5ee3e08a 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -6,8 +6,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "PlatformInfoScriptingInterface.h" +#include "Application.h" -# include +#include #ifdef Q_OS_WIN #include @@ -69,4 +70,8 @@ int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() { #else return -1; #endif +} + +QString PlatformInfoScriptingInterface::getGraphicsCardType() { + return qApp->getGraphicsCardType(); } \ No newline at end of file diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.h b/interface/src/scripting/PlatformInfoScriptingInterface.h index f0b8122fa5..903658cc20 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.h +++ b/interface/src/scripting/PlatformInfoScriptingInterface.h @@ -46,6 +46,13 @@ public slots: * @returns {int} size of memory in megabytes */ int getTotalSystemMemoryMB(); + + /**jsdoc + * Returns the graphics card type + * @function Test.getGraphicsCardType + * @returns {string} graphics card type + */ + QString getGraphicsCardType(); }; #endif // hifi_PlatformInfoScriptingInterface_h From bb54353644d5d99f4b2415113d26ca8f7884d72b Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sun, 30 Dec 2018 22:36:15 -0800 Subject: [PATCH 10/15] Compilation error. --- interface/src/Application.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index a41c9f39f2..f8f78cc46a 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -459,7 +459,7 @@ public slots: void changeViewAsNeeded(float boomLength); - QString Application::getGraphicsCardType(); + QString getGraphicsCardType(); private slots: void onDesktopRootItemCreated(QQuickItem* qmlContext); From 9c00bdcddbccb174bb279591b9f916f2eb2ce722 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 31 Dec 2018 11:00:29 -0800 Subject: [PATCH 11/15] getCPUBrand works on Mac --- .../PlatformInfoScriptingInterface.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index 7f5ee3e08a..33b349e032 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -12,6 +12,8 @@ #ifdef Q_OS_WIN #include +#elif defined Q_OS_MAC +#include #endif PlatformInfoScriptingInterface* PlatformInfoScriptingInterface::getInstance() { @@ -51,8 +53,17 @@ QString PlatformInfoScriptingInterface::getCPUBrand() { } return CPUBrandString; -#else - return "NOT IMPLEMENTED"; +#elif defined Q_OS_MAC + FILE* stream = popen("sysctl -n machdep.cpu.brand_string", "r"); + + std::ostringstream hostStream; + while (!feof(stream) && !ferror(stream)) { + char buf[128]; + int bytesRead = fread(buf, 1, 128, stream); + hostStream.write(buf, bytesRead); + } + + return QString::fromStdString(hostStream.str()); #endif } @@ -74,4 +85,4 @@ int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() { QString PlatformInfoScriptingInterface::getGraphicsCardType() { return qApp->getGraphicsCardType(); -} \ No newline at end of file +} From a3dde612d1a4417cafa7b16bc06a1b63b886e676 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 31 Dec 2018 11:56:27 -0800 Subject: [PATCH 12/15] Can get total memory on Mac --- .../scripting/PlatformInfoScriptingInterface.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index 33b349e032..bcf4e79d76 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -78,8 +78,19 @@ int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() { statex.dwLength = sizeof (statex); GlobalMemoryStatusEx(&statex); return statex.ullTotalPhys / 1024 / 1024; -#else - return -1; +#elif defined Q_OS_MAC + FILE* stream = popen("sysctl -a | grep hw.memsize", "r"); + + std::ostringstream hostStream; + while (!feof(stream) && !ferror(stream)) { + char buf[128]; + int bytesRead = fread(buf, 1, 128, stream); + hostStream.write(buf, bytesRead); + } + + QString result = QString::fromStdString(hostStream.str()); + QStringList parts = result.split(' '); + return (int)(parts[1].toDouble() / 1024 / 1024); #endif } From c0a784fa9474ab00e678cb8278ecf3aa05e0dcfb Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 1 Jan 2019 12:44:09 -0800 Subject: [PATCH 13/15] Get graphics card type works on Mac laptop --- .../PlatformInfoScriptingInterface.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index bcf4e79d76..b965eb4331 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -95,5 +95,27 @@ int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() { } QString PlatformInfoScriptingInterface::getGraphicsCardType() { +#ifdef Q_OS_WIN return qApp->getGraphicsCardType(); +#elif defined Q_OS_MAC + FILE* stream = popen("system_profiler SPDisplaysDataType | grep Chipset", "r"); + + std::ostringstream hostStream; + while (!feof(stream) && !ferror(stream)) { + char buf[128]; + int bytesRead = fread(buf, 1, 128, stream); + hostStream.write(buf, bytesRead); + } + + QString result = QString::fromStdString(hostStream.str()); + QStringList parts = result.split('\n'); + for (int i = 0; i < parts.size(); ++i) { + if (parts[i].toLower().contains("radeon") || parts[i].toLower().contains("nvidia")) { + return parts[i]; + } + } + + return "UNKNOWN"; +#endif + } From 56ee91dc606235d7f8230e8f44ca2718d611586f Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 2 Jan 2019 13:23:20 -0800 Subject: [PATCH 14/15] Fixed Ubuntu warnings. --- .../src/scripting/PlatformInfoScriptingInterface.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index b965eb4331..bcbf87689e 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -64,6 +64,8 @@ QString PlatformInfoScriptingInterface::getCPUBrand() { } return QString::fromStdString(hostStream.str()); +#else + return QString("NO IMPLEMENTED"); #endif } @@ -91,6 +93,8 @@ int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() { QString result = QString::fromStdString(hostStream.str()); QStringList parts = result.split(' '); return (int)(parts[1].toDouble() / 1024 / 1024); +#else + return -1; #endif } @@ -115,7 +119,9 @@ QString PlatformInfoScriptingInterface::getGraphicsCardType() { } } + // unkown graphics card return "UNKNOWN"; +#else + return QString("NO IMPLEMENTED"); #endif - } From 65d975fe5bf47b65dafdc4f98104dd0448dd0748 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 2 Jan 2019 16:53:38 -0800 Subject: [PATCH 15/15] Added detection of Rift and Vive controllers. --- interface/src/Application.cpp | 8 ++++++++ interface/src/Application.h | 4 ++++ .../src/scripting/PlatformInfoScriptingInterface.cpp | 8 ++++++++ .../src/scripting/PlatformInfoScriptingInterface.h | 12 ++++++++++++ 4 files changed, 32 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 06362e8885..0dc7253ba6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -8711,6 +8711,14 @@ void Application::updateLoginDialogOverlayPosition() { } } +bool Application::hasRiftControllers() { + return PluginUtils::isOculusTouchControllerAvailable(); +} + +bool Application::hasViveControllers() { + return PluginUtils::isViveControllerAvailable(); +} + void Application::onDismissedLoginDialog() { _loginDialogPoppedUp = false; loginDialogPoppedUp.set(false); diff --git a/interface/src/Application.h b/interface/src/Application.h index b70d5e72b9..dc30c3c22c 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -326,6 +326,10 @@ public: void createLoginDialogOverlay(); void updateLoginDialogOverlayPosition(); + // Check if a headset is connected + bool hasRiftControllers(); + bool hasViveControllers(); + #if defined(Q_OS_ANDROID) void beforeEnterBackground(); void enterBackground(); diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index bcbf87689e..b6e4df0d40 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -125,3 +125,11 @@ QString PlatformInfoScriptingInterface::getGraphicsCardType() { return QString("NO IMPLEMENTED"); #endif } + +bool PlatformInfoScriptingInterface::hasRiftControllers() { + return qApp->hasRiftControllers(); +} + +bool PlatformInfoScriptingInterface::hasViveControllers() { + return qApp->hasViveControllers(); +} diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.h b/interface/src/scripting/PlatformInfoScriptingInterface.h index 903658cc20..3ed57965c9 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.h +++ b/interface/src/scripting/PlatformInfoScriptingInterface.h @@ -53,6 +53,18 @@ public slots: * @returns {string} graphics card type */ QString getGraphicsCardType(); + + /**jsdoc + * Returns true if Oculus Rift is connected (looks for hand controllers) + * @function Window.hasRift + * @returns {boolean} true if running on Windows, otherwise false.*/ + bool hasRiftControllers(); + + /**jsdoc + * Returns true if HTC Vive is connected (looks for hand controllers) + * @function Window.hasRift + * @returns {boolean} true if running on Windows, otherwise false.*/ + bool hasViveControllers(); }; #endif // hifi_PlatformInfoScriptingInterface_h