From 4438f4cd28a0e17dd7f2c4a2c949d1545b1d4a73 Mon Sep 17 00:00:00 2001 From: Vasily Date: Tue, 25 Dec 2018 21:44:26 +0100 Subject: [PATCH 01/39] Add table of contents, docs on command line args and building for windows The current readme lacks a table of contents, which makes finding what you're looking for difficult because of the large amount of images and text. The current documentation on building for windows doesn't mention the fact that package.cmd also has to be run to create a full build. It is also lacking in other areas, such as the packaging programs required. The current documentation doesn't reflect the fact that you can pass command line arguments to the program. --- Readme.md | 91 ++++++++++++++++++++++++++++++------ docs/building_for_windows.md | 34 ++++++++++++++ 2 files changed, 111 insertions(+), 14 deletions(-) create mode 100644 docs/building_for_windows.md diff --git a/Readme.md b/Readme.md index d3a86b3..eb5a805 100644 --- a/Readme.md +++ b/Readme.md @@ -1,12 +1,41 @@ ![language](https://img.shields.io/badge/Language-C%2B%2B11%2C%20QML-green.svg) ![dependencies](https://img.shields.io/badge/Dependencies-OpenVR%2C%20Qt5-green.svg) ![license_gpl3](https://img.shields.io/badge/License-GPL%203.0-green.svg) [![Build status](https://ci.appveyor.com/api/projects/status/8oivf5xws6vsq2x3/branch/master?svg=true)](https://ci.appveyor.com/project/icewind1991/openvr-advancedsettings/branch/master) + > * [Features](#features) + > * [Usage](#usage) + > * [Installer](#installer) + > * [Standalone](#standalone) + > * [Command Line Arguments](#command_line_arguments) + > * [Desktop mode](#desktop_mode) + > * [Preview Builds](#preview_builds) + > * [Documentation](#documentation) + > * [Top Page](#top_page) + > * [SteamVR Page](#steamvr_page) + > * [Chaperone Page](#chaperone_page) + > * [Chaperone Proximity Warning Settings Page](#chaperone_proximity_page) + > * [Play Space Page](#play_space_page) + > * [Playspace Fix Page](#playspace_fix_page) + > * [Audio Page](#audio_page) + > * [Revive Page](#revive_page) + > * [Utilities Page](#utilities_page) + > * [Accessibility Page](#accessibility_page) + > * [Statistics Page](#statistics_page) + > * [Settings Page](#settings_page) + > * [How To Compile](#how_to_compile) + > * [Building on Windows](#building_on_windows) + > * [Building on Linux](#building_on_linux) + > * [Notes](#notes) + > * [Known Bugs](#known_bugs) + > * [License](#license) + + # OpenVR Advanced Settings Overlay Adds an overlay to the OpenVR dashboard that allows access to advanced settings. ![Example Screenshot](docs/screenshots/InVRScreenshot.png) + # Features - Set supersampling values. @@ -28,34 +57,55 @@ Adds an overlay to the OpenVR dashboard that allows access to advanced settings. - Simple Alarm Clock - Player height adjust toggle (Credits to mklim) + # Usage + ## Installer -Download the newest installer from the [release section](https://github.com/icewind1991/OpenVR-AdvancedSettings/releases) and execute it. +Download the newest installer from the [release section](https://github.com/OpenVR-Advanced-Settings/OpenVR-AdvancedSettings/releases) and execute it. If you have an older standalone version installed, delete the old application folder first. + ## Standalone +I am not currently providing standalone Archives if you want a standalone version you can: -Download the newest standalone archive from the [release section](https://github.com/icewind1991/OpenVR-AdvancedSettings/releases) and unpack the archive. +Download the newest standalone archive from the [release section](https://github.com/OpenVR-Advanced-Settings/OpenVR-AdvancedSettings/releases)and unpack the archive. -To install for the first time simply start AdvancedSettings.exe once while SteamVRis running. It will register with SteamVR and automatically starts whenever SteamVR starts (Can be disabled in the settings). +To install for the first time simply start AdvancedSettings.exe once while SteamVR is running. It will register with SteamVR and automatically starts whenever SteamVR starts (Can be disabled in the settings). To upgrade an existing installation first stop SteamVR and delete the old application folder (or override it). Then start SteamVR and run AdvancedSettings.exe once. + +## Command Line Arguments + +The application (`AdvancedSettings.exe`) can be run with the following five optional arguments: + +`"-desktop"`: Creates a settings window on the desktop. + +`"-nosound"`: Forces sound effects off. + +`"-nomanifest"`: Forces not creating a `.vrmanifest`. + +`"-installmanifest"`: Force installs the `.vrmanifest`. + +`"-removemanifest"`: Force uninstalls the `.vrmanifest`. + + ## Desktop mode Executing startdesktopmode.bat from the application folder shows a window on the desktop instead of a vr overlay. Desktop mode can be used alongside an already running vr overlay instance. + ## Preview builds -If you want to try latest and greatest unreleased features, you can download the latest [automated build](https://ci.appveyor.com/project/icewind1991/openvr-advancedsettings/branch/master/artifacts). - -Note that these unreleased builds often only get minimal testing and might be broken. +If you want to try latest and greatest unreleased features, you can download latest changes in the alpha branches of the repository. + # Documentation + ## Top Page: ![Root Page](docs/screenshots/RootPage.png) @@ -65,6 +115,7 @@ Note that these unreleased builds often only get minimal testing and might be br - **Microphone**: Allows to set the microphone volume and to mute/unmute it. - **Push-to-Talk**: Enable/disable push-to-talk and allows to apply push-to-talk profiles. Profiles can be created on the Audio page. + ## - SteamVR Page: ![SteamVR Page](docs/screenshots/SteamVRPage.png) @@ -78,6 +129,7 @@ Note that these unreleased builds often only get minimal testing and might be br - **Enable Always-on Reprojection**: Enable/disable forced reprojection. - **Restart SteamVR**: Restart SteamVR (May crash the Steam overlay when SteamVR Home is running when you restart. Therefore I advice that you close SteamVR Home before restarting). + ## - Chaperone Page: ![Chaperone Page](docs/screenshots/ChaperonePage.png) @@ -93,7 +145,7 @@ Note that these unreleased builds often only get minimal testing and might be br - **Flip Orientation**: Flips the orientation of the play space. - **Reload from Disk**: Reloads the chaperone bounds geometry from disk. - + ## - Chaperone Proximity Warning Settings Page: ![Chaperone Proximity Warning Settings Page](docs/screenshots/ChaperoneWarningPage.png) @@ -106,6 +158,7 @@ Note that these unreleased builds often only get minimal testing and might be br - **Open dashboard**: Opens the dashboard when the user's distance to the chaperone falls below the configured activation distance. The idea is to pause the game (most single-player games auto-pause when the dashboard is shown) to give the user time for reorientation. - **Velocity Dependent Fade/Activation Distance**: Dynamically modifies the chaperone's fade distance and the proximity warning's activation distance as a function of the player's speed. The used formula is: *distance = old_distance * ( 1 + distance_modifier * max(left_controller_speed, right_controller_speed, hmd_speed) )* + ## - Play Space Page: ![Play Space Page](docs/screenshots/PlayspacePage.png) @@ -115,6 +168,7 @@ Allows to temporarily move and rotate the center of the playspace. This allows t - **Virtual Move Shortcut**: Allows moving the placespace center by holding down the application menu shortcut and moving the controller. - **Adjust Chaperone**: When enabled then the chaperone bounds stay in place when the playspace is moved or rotated (so noone gets hurt). Unfortunately this does not work when moving up/down. + ## - Playspace Fix Page: ![Playspace Fix Page](docs/screenshots/FloorFixPage.png) @@ -123,6 +177,7 @@ Allows to temporarily move and rotate the center of the playspace. This allows t - **Fix Floor** Allows you to fix the height of your floor. Just place one controller on your floor and press the button. - **Recenter Playspace** Besides fixing the floor height, also recenters the place space around the controller on the floor. + ## - Audio Page: ![Audio Page](docs/screenshots/AudioPage.png) @@ -136,8 +191,10 @@ Allows to temporarily move and rotate the center of the playspace. This allows t - **Right Controller**: Configure the right controller for push-to-talk. - **Show Notification**: Shows a notification icon in the headset when push-to-talk is enabled a configured button is pressed. - **Push-to-Mute**: Inverse push-to-talk. The Microphone is unmuted by default and muted when any of the configured buttons is pressed. -- **Profile**: Allows to apply/define/delete push-to-talk profiles that save buttons, controller and notification settings. +- **PTT Profile**: Allows you to apply/define/delete push-to-talk profiles that save buttons, controller and notification settings. +- **Audio Profile**: Allows you to apply/define/delete audio profiles that save playback devices, mute state, and volume. + ## - Revive Page: ![Revive Page](docs/screenshots/RevivePage.png) @@ -160,6 +217,7 @@ Any changes to controller settings are immediately applied by Revive (Requires R - **Z**: Allows to modify the touch controllers z-offset. (TouchZ setting the vrsettings file) - **Controller Profile**: Allows to apply/define/delete controller profiles that save the controller settings (grip button mode, deadzone, sensitivity, pitch/yaw/roll and x/y/z-offsets). + ## - Utilities Page: ![Utilities Page](docs/screenshots/UtilitiesPage.png) @@ -170,12 +228,14 @@ Any changes to controller settings are immediately applied by Revive (Requires R - **Steam Desktop Overlay Width:** Allows to increase the size of the Steam desktop overlay. Useful for multi-monitor setups. + ## - Accessibility Page: ![Accessibility Page](docs/screenshots/AccessibilityPage.png) - **Adjust Player Height:** Offsets the player height to allows short or wheelchair-bound players to fully interact with height-limited applications by both boosting their height and being able to touch the in-game floor when necessary by pressing a configurable motion controller button. + ## - Statistics Page: ![Statistics Page](docs/screenshots/StatisticsPage.png) @@ -190,6 +250,7 @@ Any changes to controller settings are immediately applied by Revive (Requires R - **Timed Out**: Number of times the currently running application timed out. - **Reprojection Ratio**: Ratio of presented frames to reprojected frames. + ## - Settings Page: ![Settings Page](docs/screenshots/SettingsPage.png) @@ -197,21 +258,21 @@ Any changes to controller settings are immediately applied by Revive (Requires R - **Autostart:** Allows you to enable/disable auto start. - **Force Revive Page:** Force the Revive page button on the root page to be visible. + # How to Compile -Building has been tested with Qt 5.10 and Visual Studio 2017 community. -If both have been installed in their default paths than the project can be build using `build_windows.cmd`, this compiles the binary and copies all files necessary for execution into the output directory. + +## Building on Windows -The following environment variables should be set for the build script to work - -- QT: `C:\Qt\5.10.1\msvc2017_64` or wherever you installed Qt. -- PLATFORM: `amd64` only x64 builds have been tested atm. +Full build instructions can be found [here](docs/building_for_windows.md). + ## Building on Linux If you want to run Advanced Settings on linux you can build it yourself using `qmake` and `make` or using Qt Creator, you'll have to copy the `res` folder from the `src` folder into folder that contains the binary and copy `third-party/openvr/lib/linux64/libopenvr_api.so` into your systems library path. + # Notes: - The center marker and the play space marker are provided by the chaperone subsystem, and therefore they will have the same color and visibility settings as the chaperone bounds. @@ -220,10 +281,12 @@ and copy `third-party/openvr/lib/linux64/libopenvr_api.so` into your systems lib - You can modify the shutdown wait time when restarting SteamVR by opening restartvrserver.bat and changing the number behind "timeout /t" (unit is seconds). + # Known Bugs - None yet. + # License This software is released under GPL 3.0. diff --git a/docs/building_for_windows.md b/docs/building_for_windows.md new file mode 100644 index 0000000..b6c7b51 --- /dev/null +++ b/docs/building_for_windows.md @@ -0,0 +1,34 @@ +# Building for Windows + + + > * [Requirements](#requirements) + > * [Locations and Environment Variables](#locs_and_envs) + > * [Building](#features) + + +## Requirements + +For compiling: + +1. Microsoft Visual Studio (tested on 2017 Community) +2. Qt Framework (tested on 5.10 and 5.11) + +Additionally, for fully building portable and installer release versions: +3. 7zip Command Line +4. Nullsoft Scriptable Install System (NSIS) + + +## Locations and Environment Variables + +Visual Studio must be installed in the default location of `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community`. + +The `QT` environment variable must be set to the location of your Qt installation (for example `C:\Qt\5.11.1\msvc2017_64`). + +The `PLATFORM` environment variable must be set to `amd64`. + +For building the portable and installer release versions, the locations of 7zip Command Line (`7z.exe`) and NSIS (`makensis.exe`) must be in the `PATH` environment variable. + + +## Building + +With the programs above installed and environment variables set, go into the root folder of the repository and first run `build_windows.cmd` and then `package.cmd`. Compiled binaries along with everything needed to run portable will output to `.\bin\win64\AdvancedSettings\`. From 30fe09c5eae675440bd73732b61701893ec3ec95 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 25 Dec 2018 21:50:44 +0100 Subject: [PATCH 02/39] cleanup .pro file --- advancedSettings.pro | 65 ++------------------------------------------ 1 file changed, 3 insertions(+), 62 deletions(-) diff --git a/advancedSettings.pro b/advancedSettings.pro index dacff55..fe86ccb 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -27,37 +27,7 @@ SOURCES += src/main.cpp\ src/tabcontrollers/AccessibilityTabController.cpp \ src/utils/ChaperoneUtils.cpp \ src/tabcontrollers/audiomanager/AudioManagerDummy.cpp \ - src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp \ - release/moc_AccessibilityTabController.cpp \ - release/moc_AudioTabController.cpp \ - release/moc_ChaperoneTabController.cpp \ - release/moc_FixFloorTabController.cpp \ - release/moc_MoveCenterTabController.cpp \ - release/moc_overlaycontroller.cpp \ - release/moc_PttController.cpp \ - release/moc_ReviveTabController.cpp \ - release/moc_SettingsTabController.cpp \ - release/moc_StatisticsTabController.cpp \ - release/moc_SteamVRTabController.cpp \ - release/moc_UtilitiesTabController.cpp \ - src/tabcontrollers/audiomanager/AudioManagerDummy.cpp \ - src/tabcontrollers/audiomanager/AudioManagerWindows.cpp \ - src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp \ - src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp \ - src/tabcontrollers/AccessibilityTabController.cpp \ - src/tabcontrollers/AudioTabController.cpp \ - src/tabcontrollers/ChaperoneTabController.cpp \ - src/tabcontrollers/FixFloorTabController.cpp \ - src/tabcontrollers/MoveCenterTabController.cpp \ - src/tabcontrollers/PttController.cpp \ - src/tabcontrollers/ReviveTabController.cpp \ - src/tabcontrollers/SettingsTabController.cpp \ - src/tabcontrollers/StatisticsTabController.cpp \ - src/tabcontrollers/SteamVRTabController.cpp \ - src/tabcontrollers/UtilitiesTabController.cpp \ - src/utils/ChaperoneUtils.cpp \ - src/main.cpp \ - src/overlaycontroller.cpp + src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp HEADERS += src/overlaycontroller.h \ src/logging.h \ @@ -77,42 +47,13 @@ HEADERS += src/overlaycontroller.h \ src/utils/Matrix.h \ src/utils/ChaperoneUtils.h \ src/tabcontrollers/audiomanager/AudioManagerDummy.h \ - src/tabcontrollers/keyboardinput/KeyboardInputDummy.h \ - release/moc_predefs.h \ - src/tabcontrollers/audiomanager/AudioManagerDummy.h \ - src/tabcontrollers/audiomanager/AudioManagerWindows.h \ - src/tabcontrollers/audiomanager/IPolicyConfig.h \ - src/tabcontrollers/keyboardinput/KeyboardInputDummy.h \ - src/tabcontrollers/keyboardinput/KeyboardInputWindows.h \ - src/tabcontrollers/AccessibilityTabController.h \ - src/tabcontrollers/AudioManager.h \ - src/tabcontrollers/AudioTabController.h \ - src/tabcontrollers/ChaperoneTabController.h \ - src/tabcontrollers/FixFloorTabController.h \ - src/tabcontrollers/KeyboardInput.h \ - src/tabcontrollers/MoveCenterTabController.h \ - src/tabcontrollers/PttController.h \ - src/tabcontrollers/ReviveTabController.h \ - src/tabcontrollers/SettingsTabController.h \ - src/tabcontrollers/StatisticsTabController.h \ - src/tabcontrollers/SteamVRTabController.h \ - src/tabcontrollers/UtilitiesTabController.h \ - src/utils/ChaperoneUtils.h \ - src/utils/Matrix.h \ - src/logging.h \ - src/overlaycontroller.h \ - third-party/easylogging++/easylogging++.h \ - third-party/openvr/bin/osx64/OpenVR.framework/Versions/A/Headers/openvr.h \ - third-party/openvr/bin/osx64/OpenVR.framework/Versions/A/Headers/openvr_capi.h \ - third-party/openvr/bin/osx64/OpenVR.framework/Versions/A/Headers/openvr_driver.h \ - third-party/openvr/headers/openvr.h \ - third-party/openvr/headers/openvr_capi.h \ - third-party/openvr/headers/openvr_driver.h + src/tabcontrollers/keyboardinput/KeyboardInputDummy.h win32 { SOURCES += src/tabcontrollers/audiomanager/AudioManagerWindows.cpp \ src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp HEADERS += src/tabcontrollers/audiomanager/AudioManagerWindows.h \ + src/tabcontrollers/audiomanager/IPolicyConfig.h \ src/tabcontrollers/keyboardinput/KeyboardInputWindows.h } From 1e7f2a5bad7dba79e90878a7dd9bd8c49d8fdf0e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 26 Dec 2018 01:03:07 +0100 Subject: [PATCH 03/39] add travis config for linux ci build --- .travis.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..111ee46 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: cpp +dist: xenial +compiler: + - clang + - gcc + +install: + - sudo apt-get update -qq + - sudo apt-get install build-essential qtbase5-dev qttools5-dev qtdeclarative5-dev qtmultimedia5-dev qt5-default qttools5-dev-tools + +script: + - mkdir build && cd build + - qmake .. + - make From d8044803c3b0325f3fbc466c926706bedaa6767f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 26 Dec 2018 01:55:58 +0100 Subject: [PATCH 04/39] specify c++11 --- advancedSettings.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/advancedSettings.pro b/advancedSettings.pro index fe86ccb..d54a379 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -5,6 +5,7 @@ #------------------------------------------------- QT += core gui qml quick multimedia +CONFIG += c++11 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets From 32fd6335883b2b2f6195e0d1f692729169618c57 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 26 Dec 2018 01:56:33 +0100 Subject: [PATCH 05/39] use kubuntu backports in travis for qt 5.6 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 111ee46..98504bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ compiler: - gcc install: + - sudo add-apt-repository ppa:kubuntu-ppa/backports -y - sudo apt-get update -qq - sudo apt-get install build-essential qtbase5-dev qttools5-dev qtdeclarative5-dev qtmultimedia5-dev qt5-default qttools5-dev-tools From f383fe081e8ec066f3c59d397c34323f7632ac1f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 26 Dec 2018 02:09:50 +0100 Subject: [PATCH 06/39] switch to cmath and std::isnan --- src/tabcontrollers/ChaperoneTabController.cpp | 12 ++++++------ src/utils/ChaperoneUtils.cpp | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/tabcontrollers/ChaperoneTabController.cpp b/src/tabcontrollers/ChaperoneTabController.cpp index cbde2e2..92572bf 100644 --- a/src/tabcontrollers/ChaperoneTabController.cpp +++ b/src/tabcontrollers/ChaperoneTabController.cpp @@ -1,7 +1,7 @@ #include "ChaperoneTabController.h" #include #include "../overlaycontroller.h" -#include +#include // application namespace namespace advsettings { @@ -361,7 +361,7 @@ void ChaperoneTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses, poseHmd.mDeviceToAbsoluteTracking.m[1][3], poseHmd.mDeviceToAbsoluteTracking.m[2][3] }); - if (!isnan(distanceHmd)) { + if (!std::isnan(distanceHmd)) { minDistance = distanceHmd; } } @@ -374,7 +374,7 @@ void ChaperoneTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses, poseLeft.mDeviceToAbsoluteTracking.m[1][3], poseLeft.mDeviceToAbsoluteTracking.m[2][3] }); - if (!isnan(distanceLeft) && (isnan(minDistance) || distanceLeft < minDistance)) { + if (!std::isnan(distanceLeft) && (std::isnan(minDistance) || distanceLeft < minDistance)) { minDistance = distanceLeft; } } @@ -388,12 +388,12 @@ void ChaperoneTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses, poseRight.mDeviceToAbsoluteTracking.m[1][3], poseRight.mDeviceToAbsoluteTracking.m[2][3] }); - if (!isnan(distanceRight) && (isnan(minDistance) || distanceRight < minDistance)) { + if (!std::isnan(distanceRight) && (std::isnan(minDistance) || distanceRight < minDistance)) { minDistance = distanceRight; } } } - if (!isnan(minDistance)) { + if (!std::isnan(minDistance)) { handleChaperoneWarnings(minDistance); } } @@ -1002,7 +1002,7 @@ float ChaperoneTabController::getBoundsMaxY() { } else { ci = 2; } - if (isnan(result) || result < collisionBounds[b].vCorners[ci].v[1]) { + if (std::isnan(result) || result < collisionBounds[b].vCorners[ci].v[1]) { result = collisionBounds[b].vCorners[ci].v[1]; } } diff --git a/src/utils/ChaperoneUtils.cpp b/src/utils/ChaperoneUtils.cpp index a0cbf6c..832593a 100644 --- a/src/utils/ChaperoneUtils.cpp +++ b/src/utils/ChaperoneUtils.cpp @@ -1,7 +1,6 @@ - #include "ChaperoneUtils.h" #include -#include +#include namespace utils { @@ -43,7 +42,7 @@ float ChaperoneUtils::_getDistanceToChaperone(const vr::HmdVector3_t & x, vr::Hm float d_z = x1_z - x.v[2]; d = sqrt(d_x*d_x + d_z*d_z); } - if (isnan(distance) || d < distance) { + if (std::isnan(distance) || d < distance) { distance = d; if (projectedPoint) { projectedPoint->v[0] = x1_x; From 192e315f9ff11a1d3d5121bf169b1b94c7c9e880 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 26 Dec 2018 15:09:34 +0100 Subject: [PATCH 07/39] add qtcreator's .pro.user.* to gitignore --- .gitignore | 2 +- advancedSettings.pro.user.e9f45e7 | 318 ------------------------------ 2 files changed, 1 insertion(+), 319 deletions(-) delete mode 100644 advancedSettings.pro.user.e9f45e7 diff --git a/.gitignore b/.gitignore index 27860a8..92354b8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ Makefile* *.vs *.stash *.appxmanifest -*.user +*.user* diff --git a/advancedSettings.pro.user.e9f45e7 b/advancedSettings.pro.user.e9f45e7 deleted file mode 100644 index ab2fa5e..0000000 --- a/advancedSettings.pro.user.e9f45e7 +++ /dev/null @@ -1,318 +0,0 @@ - - - - - - EnvironmentId - {e9f45e75-3f05-4ad6-a0dc-8a090aa48e0b} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - Desktop Qt 5.10.1 MSVC2017 64bit - Desktop Qt 5.10.1 MSVC2017 64bit - qt.qt5.5101.win64_msvc2017_64_kit - 0 - 0 - 0 - - C:/Users/robin/Documents/build-advancedSettings-Desktop_Qt_5_10_1_MSVC2017_64bit-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - C:/Users/robin/Documents/build-advancedSettings-Desktop_Qt_5_10_1_MSVC2017_64bit-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - - C:/Users/robin/Documents/build-advancedSettings-Desktop_Qt_5_10_1_MSVC2017_64bit-Profile - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - true - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 3 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy locally - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - advancedSettings - advancedSettings2 - Qt4ProjectManager.Qt4RunConfiguration://192.168.1.165/win10/OpenVR-AdvancedSettings/advancedSettings.pro - true - - advancedSettings.pro - false - - C:/Users/robin/Documents/build-advancedSettings-Desktop_Qt_5_10_1_MSVC2017_64bit-Debug/bin/win64/AdvancedSettings - 3768 - false - true - false - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 18 - - - Version - 18 - - From c57b9bc62d0ab9d46dd4938e5eca77b6687a994d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 26 Dec 2018 15:26:59 +0100 Subject: [PATCH 08/39] specify dependency on qt >5.6 --- advancedSettings.pro | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/advancedSettings.pro b/advancedSettings.pro index d54a379..03159dc 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -4,10 +4,11 @@ # #------------------------------------------------- -QT += core gui qml quick multimedia +QT += core gui qml quick multimedia widgets CONFIG += c++11 -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5.6 or higher") +lessThan(QT_MINOR_VERSION, 6): error("requires Qt 5.6 or higher") TARGET = AdvancedSettings TEMPLATE = app From 8e2ca3602a24baf3afb9b831c4e53247f42e4eba Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 26 Dec 2018 16:32:38 +0100 Subject: [PATCH 09/39] Add option to send Alt-Tab as keyboard input --- src/res/qml/UtilitiesPage.qml | 16 +++- src/tabcontrollers/KeyboardInput.h | 1 + src/tabcontrollers/UtilitiesTabController.cpp | 4 + src/tabcontrollers/UtilitiesTabController.h | 1 + .../keyboardinput/KeyboardInputDummy.cpp | 5 ++ .../keyboardinput/KeyboardInputDummy.h | 1 + .../keyboardinput/KeyboardInputWindows.cpp | 82 +++++++++---------- .../keyboardinput/KeyboardInputWindows.h | 1 + 8 files changed, 62 insertions(+), 49 deletions(-) diff --git a/src/res/qml/UtilitiesPage.qml b/src/res/qml/UtilitiesPage.qml index 5a575ee..76841cf 100644 --- a/src/res/qml/UtilitiesPage.qml +++ b/src/res/qml/UtilitiesPage.qml @@ -45,7 +45,7 @@ MyStackViewPage { MyPushButton { text: "Keyboard Input" - Layout.preferredWidth: 250 + Layout.preferredWidth: 200 onClicked: { OverlayController.showKeyboard("", 601) } @@ -61,15 +61,23 @@ MyStackViewPage { MyPushButton { text: "Enter" - Layout.preferredWidth: 250 + Layout.preferredWidth: 200 onClicked: { UtilitiesTabController.sendKeyboardEnter() } } + MyPushButton { + text: "Alt-Tab" + Layout.preferredWidth: 200 + onClicked: { + UtilitiesTabController.sendKeyboardAltTab() + } + } + MyPushButton { text: "Backspace" - Layout.preferredWidth: 250 + Layout.preferredWidth: 200 onClicked: { UtilitiesTabController.sendKeyboardBackspace(1) } @@ -77,7 +85,7 @@ MyStackViewPage { MyPushButton { text: "10x Backspace" - Layout.preferredWidth: 250 + Layout.preferredWidth: 200 onClicked: { UtilitiesTabController.sendKeyboardBackspace(10) } diff --git a/src/tabcontrollers/KeyboardInput.h b/src/tabcontrollers/KeyboardInput.h index 28c2468..05fcfc0 100644 --- a/src/tabcontrollers/KeyboardInput.h +++ b/src/tabcontrollers/KeyboardInput.h @@ -16,6 +16,7 @@ public: virtual void sendKeyboardInput(QString input) = 0; virtual void sendKeyboardEnter() = 0; virtual void sendKeyboardBackspace(int count) = 0; + virtual void sendKeyboardAltTab() = 0; }; } diff --git a/src/tabcontrollers/UtilitiesTabController.cpp b/src/tabcontrollers/UtilitiesTabController.cpp index 0ca7744..4cd203e 100644 --- a/src/tabcontrollers/UtilitiesTabController.cpp +++ b/src/tabcontrollers/UtilitiesTabController.cpp @@ -61,6 +61,10 @@ namespace advsettings { keyboardInput->sendKeyboardEnter(); } + void UtilitiesTabController::sendKeyboardAltTab() { + keyboardInput->sendKeyboardAltTab(); + } + void UtilitiesTabController::sendKeyboardBackspace(int count) { keyboardInput->sendKeyboardBackspace(count); } diff --git a/src/tabcontrollers/UtilitiesTabController.h b/src/tabcontrollers/UtilitiesTabController.h index 22e2f63..29d24e6 100644 --- a/src/tabcontrollers/UtilitiesTabController.h +++ b/src/tabcontrollers/UtilitiesTabController.h @@ -59,6 +59,7 @@ namespace advsettings { public slots: void sendKeyboardInput(QString input); void sendKeyboardEnter(); + void sendKeyboardAltTab(); void sendKeyboardBackspace(int count); void setAlarmEnabled(bool enabled, bool notify = true); diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp index f0ab55b..69054a9 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp @@ -17,4 +17,9 @@ void KeyboardInputDummy::sendKeyboardBackspace(int count) // noop } +void KeyboardInputDummy::sendKeyboardAltTab() +{ + // noop +} + } diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.h b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.h index 53b651c..f5ee302 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.h +++ b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.h @@ -12,6 +12,7 @@ public: virtual void sendKeyboardInput(QString input) override; virtual void sendKeyboardEnter() override; virtual void sendKeyboardBackspace(int count) override; + virtual void sendKeyboardAltTab() override; }; } diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp index dfa1518..aafa129 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp @@ -17,6 +17,24 @@ void fillKiStruct(INPUT& ip, WORD scanCode, bool keyup) { ip.ki.time = 0; }; +void sendKeyboardInputRaw(int inputCount, LPINPUT input) { + if (!SendInput(inputCount, input, sizeof(INPUT))) { + char *err; + auto errCode = GetLastError(); + if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + errCode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language + (LPTSTR)&err, + 0, + NULL)){ + LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; + } else { + LOG(ERROR) << "Error calling SendInput(): " << err; + } + } +} + void KeyboardInputWindows::sendKeyboardInput(QString input) { int len = input.length(); @@ -69,21 +87,8 @@ void KeyboardInputWindows::sendKeyboardInput(QString input) fillKiStruct(ips[ii++], VK_MENU, true); altPressed = false; } - if (!SendInput(ii, ips, sizeof(INPUT))) { - char *err; - auto errCode = GetLastError(); - if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - errCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language - (LPTSTR)&err, - 0, - NULL)){ - LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; - } else { - LOG(ERROR) << "Error calling SendInput(): " << err; - } - } + + sendKeyboardInputRaw(ii, ips); delete ips; } } @@ -93,21 +98,8 @@ void KeyboardInputWindows::sendKeyboardEnter() LPINPUT ips = new INPUT[2]; fillKiStruct(ips[0], VK_RETURN, false); fillKiStruct(ips[1], VK_RETURN, true); - if (!SendInput(2, ips, sizeof(INPUT))) { - char *err; - auto errCode = GetLastError(); - if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - errCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language - (LPTSTR)&err, - 0, - NULL)) { - LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; - } else { - LOG(ERROR) << "Error calling SendInput(): " << err; - } - } + + sendKeyboardInputRaw(2, ips); delete ips; } @@ -119,23 +111,23 @@ void KeyboardInputWindows::sendKeyboardBackspace(int count) fillKiStruct(ips[2 * i], VK_BACK, false); fillKiStruct(ips[2 * i + 1], VK_BACK, true); } - if (!SendInput(2 * count, ips, sizeof(INPUT))) { - char *err; - auto errCode = GetLastError(); - if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - errCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language - (LPTSTR)&err, - 0, - NULL)) { - LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; - } else { - LOG(ERROR) << "Error calling SendInput(): " << err; - } - } + + sendKeyboardInputRaw(count * 2, ips); delete ips; } } +void KeyboardInputWindows::sendKeyboardAltTab() +{ + LPINPUT ips = new INPUT[4]; + // VK_MENU is alt + fillKiStruct(ips[0], VK_MENU, false); + fillKiStruct(ips[1], VK_TAB, false); + fillKiStruct(ips[2], VK_TAB, true); + fillKiStruct(ips[3], VK_MENU, true); + + sendKeyboardInputRaw(4, ips); + delete ips; +} + } diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.h b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.h index 70318a5..3292b72 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.h +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.h @@ -12,6 +12,7 @@ public: virtual void sendKeyboardInput(QString input) override; virtual void sendKeyboardEnter() override; virtual void sendKeyboardBackspace(int count) override; + virtual void sendKeyboardAltTab() override; }; } From 8bec43d01e7cf5d092f893d5433c465105fbccfc Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 15:17:00 +0100 Subject: [PATCH 10/39] Add new build scripts for windows The old build scripts used hard coded directory paths, didn't check if the paths actually existed and didn't differentiate between compiling, deploying libraries and packaging for release. The new build scripts are split into three different files. They are all longer than the old build scripts, but most of the extra lines are error checking, which the old one lacked. It was considered writing the build scripts in another language like Python or Powershell, but the relatively small size of the project and unlikelihood of the build systems needing to grow massively means that a very simple imperative language like the Microsoft scripting language is fine. --- build_scripts/win/build_windows.cmd | 105 +++++++++++++++++++++++ build_scripts/win/deploy_windows.cmd | 119 ++++++++++++++++++++++++++ build_scripts/win/package_windows.cmd | 70 +++++++++++++++ 3 files changed, 294 insertions(+) create mode 100644 build_scripts/win/build_windows.cmd create mode 100644 build_scripts/win/deploy_windows.cmd create mode 100644 build_scripts/win/package_windows.cmd diff --git a/build_scripts/win/build_windows.cmd b/build_scripts/win/build_windows.cmd new file mode 100644 index 0000000..46a9d72 --- /dev/null +++ b/build_scripts/win/build_windows.cmd @@ -0,0 +1,105 @@ +@echo off +REM Echo off to avoid spam. + +REM Non zero is failure, 0 is success. +SET exit_code_success=0 +SET exit_code_failure_build_apps=1 +SET exit_code_failure_build_locations=2 + +REM Used for echos. +SET current_activity=BUILD + +REM If scripts are chain called the original dirs should not be overwritten. +IF NOT DEFINED original_dir ( + SET original_dir=%CD% +) +IF NOT DEFINED project_dir ( + REM Arg 0 (called %0) is the full path to the file. + REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters + REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only. + SET folder_path=%~dp0 + REM Project dir is up two dirs from the file. + SET project_dir=%folder_path%\..\..\ +) + +REM Change dir to the project dir, otherwise qmake doesn't know where it is. +CD %project_dir% + +ECHO %current_activity%: Testing if all required build environment values are set: +IF NOT DEFINED QT_LOC ( + ECHO %current_activity%: QT_LOC not defined. Using default value. + SET QT_LOC="C:\Qt\5.11.1\msvc2017_64\bin\" +) +ECHO %current_activity%: QT_LOC set to '%QT_LOC%'. +IF EXIST %QT_LOC% ( + ECHO %current_activity%: QT_LOC exists. +) ELSE ( + ECHO %current_activity%: QT_LOC directory does not exist. Exiting. + EXIT /B %exit_code_failure_build_locations% +) + +IF NOT DEFINED VS_LOC ( + ECHO %current_activity%: VS_LOC not defined. Using default value. + SET VS_LOC="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" +) +ECHO %current_activity%: VS_LOC set to '%VS_LOC%'. +IF EXIST %VS_LOC% ( + ECHO %current_activity%: VS_LOC exists. +) ELSE ( + ECHO %current_activity%: VS_LOC directory does not exist. Exiting. + EXIT /B %exit_code_failure_build_locations% +) + +ECHO %current_activity%: All required build environment values are set. + +IF DEFINED BUILD_DEBUG ( + ECHO %current_activity%: BUILD_DEBUG var set. Compiling for debug. + SET compile_level=debug +) ELSE ( + ECHO %current_activity%: BUILD_DEBUG var not set. Compiling for release. + SET compile_level=release +) + +ECHO %current_activity%: Setting up environment with Visual Studio 'vcvarsall.bat'. +REM Currently only this platform is supported. +SET target_platform=AMD64 +REM Set up environment for qmake. +CALL %VS_LOC% %target_platform% + +IF DEFINED BUILD_VSPROJ ( + ECHO %current_activity%: BUILD_VSPROJ defined. Building Visual Studio project files. + %QT_LOC%\qmake -tp vc + ECHO %current_activity%: Building Visual Studio project files done. +) ELSE ( + ECHO %current_activity%: BUILD_VSPROJ not defined. Not building Visual Studio project files. +) + +ECHO %current_activity%: Running qmake for %compile_level%: +%QT_LOC%\qmake -spec win32-msvc CONFIG+=x86_64 CONFIG+=%compile_level% +ECHO %current_activity%: qmake done. + +IF NOT DEFINED JOM_LOC ( + ECHO %current_activity%: JOM_LOC not defined. Using default value. + SET JOM_LOC="C:\Qt\Tools\QtCreator\bin\jom.exe" +) +ECHO %current_activity%: JOM_LOC set to '%JOM_LOC%'. + +IF EXIST %JOM_LOC% ( + ECHO %current_activity%: JOM_LOC exists. + ECHO %current_activity%: Running jom: + %JOM_LOC% + REM jom will not exit with an error code. Leading to a passing build even with errors. + IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps% + ECHO %current_activity%: jom done. +) ELSE ( + ECHO JOM_LOC directory does not exist. Using nmake. + ECHO %current_activity%: Running nmake: + nmake + REM nmake will not exit with an error code. Leading to a passing build even with errors. + IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps% + ECHO %current_activity%: nmake done. +) + +CD %original_dir% + +ECHO %current_activity%: %current_activity% DONE. \ No newline at end of file diff --git a/build_scripts/win/deploy_windows.cmd b/build_scripts/win/deploy_windows.cmd new file mode 100644 index 0000000..3a78495 --- /dev/null +++ b/build_scripts/win/deploy_windows.cmd @@ -0,0 +1,119 @@ +@echo off +REM Echo off to avoid spam. + +REM Non zero is failure, 0 is success. +SET exit_code_success=0 +SET exit_code_failure_build_apps=1 +SET exit_code_failure_build_locations=2 + +SET output_dir="\bin\win64\" + +REM Used for echos. +SET current_activity=DEPLOY + +REM If scripts are chain called the original dirs should not be overwritten. +IF NOT DEFINED original_dir ( + SET original_dir=%CD% +) +IF NOT DEFINED project_dir ( + REM Arg 0 (called %0) is the full path to the file. + REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters + REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only. + SET folder_path=%~dp0 + REM Project dir is up two dirs from the file. + SET project_dir=%folder_path%\..\..\ +) + +ECHO %current_activity%: Testing if all required build environment values are set: +IF NOT DEFINED QT_LOC ( + ECHO %current_activity%: QT_LOC not defined. Using default value. + SET QT_LOC="C:\Qt\5.11.1\msvc2017_64\bin\" +) +ECHO %current_activity%: QT_LOC set to '%QT_LOC%'. +IF EXIST %QT_LOC% ( + ECHO %current_activity%: QT_LOC exists. +) ELSE ( + ECHO %current_activity%: QT_LOC directory does not exist. Exiting. + EXIT /B %exit_code_failure_build_locations% +) + +ECHO %current_activity%: All required build environment values are set. + +IF NOT EXIST %project_dir%\%output_dir% ( + ECHO %current_activity%: Output dir '%output_dir%' does not exist. Creating. + mkdir %project_dir%\%output_dir% + ECHO %current_activity%: Output dir created. +) + +cd %project_dir%\%output_dir% + +IF DEFINED BUILD_DEBUG ( + ECHO %current_activity%: BUILD_DEBUG var set. Compiling for debug. + SET compile_level=debug +) ELSE ( + ECHO %current_activity%: BUILD_DEBUG var not set. Compiling for release. + SET compile_level=release +) + +ECHO %current_activity%: Running windeployqt: + +REM windeployqt requires the QT\bin location to be in the path. +REM Changing the PATH var is not ideal, but windeployqt does not work otherwise. +set original_path=%PATH% +set PATH=%QT_LOC%;%PATH% + +REM Caret newline (^CFLR) splits a command over several lines. +REM This is done to avoid one ultra long line. + +windeployqt --dir AdvancedSettings\qtdata ^ +--libdir AdvancedSettings ^ +--plugindir AdvancedSettings\qtdata\plugins ^ +--no-system-d3d-compiler ^ +--no-opengl-sw ^ +--%compile_level% ^ +--qmldir ..\..\src\res\qml\ ^ +AdvancedSettings\AdvancedSettings.exe + +REM windeployqt does not exit on error by itself. +IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps% +REM Return the PATH to original as quickly as possible. +set PATH=%original_path% +ECHO %current_activity%: windeployqt done. + +REM Switches used for copy: +REM /V Verifies that files have been copied correctly. +REM /Q Suppresses xcopy spam. +REM /Y Skips the overwrite yes prompt. +REM /E Copies all subdirs, even if they are empty. +REM /I "If Source is a directory or contains wildcards and Destination does not exist, +REM xcopy assumes Destination specifies a directory name and creates a new directory. +REM Then, xcopy copies all specified files into the new directory. By default, +REM xcopy prompts you to specify whether Destination is a file or a directory." + +ECHO %current_activity%: Copying necessary files. +copy /V /Y "%project_dir%\Readme.md" "%project_dir%\%output_dir%\AdvancedSettings\Readme.md" +ECHO %current_activity%: README copied. + +REM All three licenses must be included in binary releases, as per the terms. +copy /V /Y "%project_dir%\LICENSE" "%project_dir%\%output_dir%\AdvancedSettings\LICENSE-GPL.txt" +copy /V /Y "%project_dir%\third-party\openvr\LICENSE" "%project_dir%\%output_dir%\AdvancedSettings\LICENSE-VALVE.txt" +copy /V /Y "%project_dir%\third-party\easylogging++\LICENSE" "%project_dir%\%output_dir%\AdvancedSettings\LICENSE-MIT.txt" +ECHO %current_activity%: LICENSE files copied. + +xcopy /Q /Y /E /I /V "%project_dir%\src\res" "%project_dir%\%output_dir%\AdvancedSettings\res\" +ECHO %current_activity%: Resource files copied. + +copy /V /Y "%project_dir%\src\restartvrserver.bat" "%project_dir%\%output_dir%\AdvancedSettings\restartvrserver.bat" +copy /V /Y "%project_dir%\src\startdesktopmode.bat" "%project_dir%\%output_dir%\AdvancedSettings\startdesktopmode.bat" +ECHO %current_activity%: Extra batch files copied. + +copy /V /Y "%project_dir%\src\qt.conf" "%project_dir%\%output_dir%\AdvancedSettings\qt.conf" +copy /V /Y "%project_dir%\src\manifest.vrmanifest" "%project_dir%\%output_dir%\AdvancedSettings\manifest.vrmanifest" +ECHO %current_activity%: VR specific configuration files copied. + +copy /V /Y "%project_dir%\third-party\openvr\bin\win64\openvr_api.dll" "%project_dir%\%output_dir%\AdvancedSettings\openvr_api.dll" +ECHO %current_activity%: OpenVR .dll copied. + +cd %original_dir% + +ECHO %current_activity%: %current_activity% DONE. \ No newline at end of file diff --git a/build_scripts/win/package_windows.cmd b/build_scripts/win/package_windows.cmd new file mode 100644 index 0000000..175e848 --- /dev/null +++ b/build_scripts/win/package_windows.cmd @@ -0,0 +1,70 @@ +@echo off +REM Echo off to avoid spam. + +REM Non zero is failure, 0 is success. +SET exit_code_success=0 +SET exit_code_failure_build_apps=1 +SET exit_code_failure_build_locations=2 + +SET output_dir="\bin\win64\" + +REM Used for echos. +SET current_activity=PACKAGE + +REM If scripts are chain called the original dirs should not be overwritten. +IF NOT DEFINED original_dir ( + SET original_dir=%CD% +) +IF NOT DEFINED project_dir ( + REM Arg 0 (called %0) is the full path to the file. + REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters + REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only. + SET folder_path=%~dp0 + REM Project dir is up two dirs from the file. + SET project_dir=%folder_path%\..\..\ +) + +REM ZIP_LOC can't be called 7Z_LOC because of Windows limitations. +ECHO %current_activity%: Testing if all required build environment values are set: +IF NOT DEFINED ZIP_LOC ( + ECHO %current_activity%: ZIP_LOC not defined. Using default value. + SET ZIP_LOC="C:\Program Files\7-Zip\7z.exe" +) +ECHO %current_activity%: ZIP_LOC set to '%ZIP_LOC%'. +IF EXIST %ZIP_LOC% ( + ECHO %current_activity%: ZIP_LOC exists. +) ELSE ( + ECHO %current_activity%: ZIP_LOC directory does not exist. Exiting. + EXIT /B %exit_code_failure_build_locations% +) + +ECHO %current_activity%: Testing if all required build environment values are set: +IF NOT DEFINED NSIS_LOC ( + ECHO %current_activity%: NSIS_LOC not defined. Using default value. + SET NSIS_LOC="C:\Program Files (x86)\NSIS\" +) +ECHO %current_activity%: NSIS_LOC set to '%NSIS_LOC%'. +IF EXIST %NSIS_LOC% ( + ECHO %current_activity%: NSIS_LOC exists. +) ELSE ( + ECHO %current_activity%: NSIS_LOC directory does not exist. Exiting. + EXIT /B %exit_code_failure_build_locations% +) + +ECHO %current_activity%: All required build environment values are set. + +ECHO %current_activity%: Running 7zip: +%ZIP_LOC% a %project_dir%\%output_dir%\AdvancedSettings.zip %project_dir%\%output_dir%\AdvancedSettings\* +ECHO %current_activity%: 7zip done. + +ECHO %current_activity%: Running NSIS: +REM Trying to launch makensis without CD into the dir does not work for some reason. +CD %NSIS_LOC% +REM /V2 is show warnings and errors, /WX is treat warnings as errors. +makensis /V2 /WX %project_dir%\installer\installer.nsi +IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps% +ECHO %current_activity%: NSIS done. + +CD %original_dir% + +ECHO %current_activity%: %current_activity% DONE. \ No newline at end of file From eee7148c00291b2f309db64df6feaf1079a7032f Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 18:05:06 +0100 Subject: [PATCH 11/39] New build_windows.cmd Change names of build scripts --- .../win/{build_windows.cmd => build.cmd} | 0 .../win/{deploy_windows.cmd => deploy.cmd} | 0 .../win/{package_windows.cmd => package.cmd} | 8 ++++ build_windows.cmd | 44 +++++++++++-------- package.cmd | 22 ---------- 5 files changed, 33 insertions(+), 41 deletions(-) rename build_scripts/win/{build_windows.cmd => build.cmd} (100%) rename build_scripts/win/{deploy_windows.cmd => deploy.cmd} (100%) rename build_scripts/win/{package_windows.cmd => package.cmd} (86%) delete mode 100644 package.cmd diff --git a/build_scripts/win/build_windows.cmd b/build_scripts/win/build.cmd similarity index 100% rename from build_scripts/win/build_windows.cmd rename to build_scripts/win/build.cmd diff --git a/build_scripts/win/deploy_windows.cmd b/build_scripts/win/deploy.cmd similarity index 100% rename from build_scripts/win/deploy_windows.cmd rename to build_scripts/win/deploy.cmd diff --git a/build_scripts/win/package_windows.cmd b/build_scripts/win/package.cmd similarity index 86% rename from build_scripts/win/package_windows.cmd rename to build_scripts/win/package.cmd index 175e848..158937b 100644 --- a/build_scripts/win/package_windows.cmd +++ b/build_scripts/win/package.cmd @@ -53,6 +53,14 @@ IF EXIST %NSIS_LOC% ( ECHO %current_activity%: All required build environment values are set. +IF DEFINED BUILD_DEBUG ( + ECHO %current_activity%: BUILD_DEBUG var set. NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS. + ECHO %current_activity%: NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS. + ECHO %current_activity%: NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS. + ECHO %current_activity%: NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS. + EXIT /B %exit_code_failure_build_apps% +) + ECHO %current_activity%: Running 7zip: %ZIP_LOC% a %project_dir%\%output_dir%\AdvancedSettings.zip %project_dir%\%output_dir%\AdvancedSettings\* ECHO %current_activity%: 7zip done. diff --git a/build_windows.cmd b/build_windows.cmd index ffa19e3..e092cc8 100644 --- a/build_windows.cmd +++ b/build_windows.cmd @@ -1,25 +1,31 @@ -echo on +@echo off +REM Echo off to avoid spam. -SET project_dir="%cd%" +REM Used for echos. +SET top_level_activity=MASTER -echo Set up environment... -set original_path=%PATH% -set PATH=%QT%\bin\;C:\Qt\Tools\QtCreator\bin\;C:\Qt\QtIFW2.0.1\bin\;C:\Program Files (x86)\NSIS\;%PATH% -call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %PLATFORM% +REM If scripts are chain called the original dirs should not be overwritten. +IF NOT DEFINED original_dir ( + SET original_dir=%CD% +) +IF NOT DEFINED project_dir ( + REM Arg 0 (called %0) is the full path to the file. + REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters + REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only. + SET folder_path=%~dp0 + REM Project dir is up two dirs from the file. + SET project_dir=%folder_path%\..\..\ +) -cd "%project_dir% -echo Building AdvancedSettings... -qmake -spec win32-msvc CONFIG+=x86_64 CONFIG-=debug CONFIG+=release -nmake +ECHO %top_level_activity%: Calling build script. +CALL %project_dir%\build_scripts\win\build_windows.cmd -echo Packaging... -mkdir %project_dir%\bin\win64\ -cd %project_dir%\bin\win64\ -windeployqt --dir AdvancedSettings\qtdata --libdir AdvancedSettings --plugindir AdvancedSettings\qtdata\plugins --no-system-d3d-compiler --no-opengl-sw --release --qmldir ..\..\src\res\qml\ AdvancedSettings\AdvancedSettings.exe +ECHO %top_level_activity%: Calling deployment script. +CALL %project_dir%\build_scripts\win\deploy_windows.cmd -rd /s /q AdvancedSettings\moc\ -rd /s /q AdvancedSettings\obj\ -rd /s /q AdvancedSettings\qrc\ +ECHO %top_level_activity%: Calling packaging script. +CALL %project_dir%\build_scripts\win\package_windows.cmd -set PATH=%original_path% -cd %project_dir% +CD %original_dir% + +ECHO %top_level_activity%: MASTER DONE. \ No newline at end of file diff --git a/package.cmd b/package.cmd deleted file mode 100644 index 19a7a58..0000000 --- a/package.cmd +++ /dev/null @@ -1,22 +0,0 @@ -echo on - -SET project_dir="%cd%" - -cd %project_dir%\bin\win64\ - -echo Copying project files for archival... -copy "%project_dir%\Readme.md" "AdvancedSettings\Readme.md" -copy "%project_dir%\LICENSE" "AdvancedSettings\LICENSE.txt" -xcopy /Y /E /I "%project_dir%\src\res" "AdvancedSettings\res\" -copy "%project_dir%\src\restartvrserver.bat" "AdvancedSettings\restartvrserver.bat" -copy "%project_dir%\src\startdesktopmode.bat" "AdvancedSettings\startdesktopmode.bat" -copy "%project_dir%\src\qt.conf" "AdvancedSettings\qt.conf" -copy "%project_dir%\src\manifest.vrmanifest" "AdvancedSettings\manifest.vrmanifest" -copy "%project_dir%\third-party\openvr\bin\win64\openvr_api.dll" "AdvancedSettings\openvr_api.dll" - -echo Packaging portable archive... -7z a AdvancedSettings.zip AdvancedSettings - -echo Creating installer... -cd %project_dir%/installer -makensis installer.nsi From 43eafba7a75a2143b27754e8ec60dcd15946d6f8 Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 18:20:13 +0100 Subject: [PATCH 12/39] Add error handling to master --- build_windows.cmd | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build_windows.cmd b/build_windows.cmd index e092cc8..1fe6045 100644 --- a/build_windows.cmd +++ b/build_windows.cmd @@ -14,17 +14,20 @@ IF NOT DEFINED project_dir ( REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only. SET folder_path=%~dp0 REM Project dir is up two dirs from the file. - SET project_dir=%folder_path%\..\..\ + SET project_dir=%folder_path% ) ECHO %top_level_activity%: Calling build script. CALL %project_dir%\build_scripts\win\build_windows.cmd +IF ERRORLEVEL 1 EXIT /B 1 ECHO %top_level_activity%: Calling deployment script. CALL %project_dir%\build_scripts\win\deploy_windows.cmd +IF ERRORLEVEL 1 EXIT /B 1 ECHO %top_level_activity%: Calling packaging script. CALL %project_dir%\build_scripts\win\package_windows.cmd +IF ERRORLEVEL 1 EXIT /B 1 CD %original_dir% From 2085d0716b10ddcde74c8aff7e2bf5fb094861f7 Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 19:04:17 +0100 Subject: [PATCH 13/39] Update appveyor, .gitignore and master build script --- .gitignore | 1 + appveyor.yml | 9 ++++++--- build_windows.cmd | 28 ++++++++++++++-------------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 27860a8..17ae462 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ Makefile* *.stash *.appxmanifest *.user +installer/AdvancedSettings-Installer.exe \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 3c215a3..af3c294 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,10 +2,14 @@ image: Visual Studio 2017 environment: matrix: - - QT: C:\Qt\5.10.1\msvc2017_64 - PLATFORM: amd64 + - QT_LOC: C:\Qt\5.11.2\msvc2017_64\bin\ + VS_LOC: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"' + JOM_LOC: C:\Qt\Tools\QtCreator\bin\jom.exe + NSIS_LOC: C:\Program Files (x86)\NSIS\ + ZIP_LOC: 7z COMPILER: msvc VSVER: 14 + clone_depth: 1 @@ -14,7 +18,6 @@ init: build_script: - call "build_windows.cmd" - - call "package.cmd" artifacts: - path: bin\win64\AdvancedSettings.zip diff --git a/build_windows.cmd b/build_windows.cmd index 1fe6045..87afac4 100644 --- a/build_windows.cmd +++ b/build_windows.cmd @@ -5,28 +5,28 @@ REM Used for echos. SET top_level_activity=MASTER REM If scripts are chain called the original dirs should not be overwritten. -IF NOT DEFINED original_dir ( - SET original_dir=%CD% -) -IF NOT DEFINED project_dir ( - REM Arg 0 (called %0) is the full path to the file. - REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters - REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only. - SET folder_path=%~dp0 - REM Project dir is up two dirs from the file. - SET project_dir=%folder_path% -) + +SET original_dir=%CD% + + +REM Arg 0 (called %0) is the full path to the file. +REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters +REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only. +SET folder_path=%~dp0 +REM Project dir is up two dirs from the file. +SET project_dir=%folder_path% + ECHO %top_level_activity%: Calling build script. -CALL %project_dir%\build_scripts\win\build_windows.cmd +CALL %project_dir%\build_scripts\win\build.cmd IF ERRORLEVEL 1 EXIT /B 1 ECHO %top_level_activity%: Calling deployment script. -CALL %project_dir%\build_scripts\win\deploy_windows.cmd +CALL %project_dir%\build_scripts\win\deploy.cmd IF ERRORLEVEL 1 EXIT /B 1 ECHO %top_level_activity%: Calling packaging script. -CALL %project_dir%\build_scripts\win\package_windows.cmd +CALL %project_dir%\build_scripts\win\package.cmd IF ERRORLEVEL 1 EXIT /B 1 CD %original_dir% From fc103633fefb4ac9318e2aeacea8fd9ce9a01c6c Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 20:04:55 +0100 Subject: [PATCH 14/39] Update package script to consider path vars --- build_scripts/win/package.cmd | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/build_scripts/win/package.cmd b/build_scripts/win/package.cmd index 158937b..59901fd 100644 --- a/build_scripts/win/package.cmd +++ b/build_scripts/win/package.cmd @@ -26,25 +26,38 @@ IF NOT DEFINED project_dir ( REM ZIP_LOC can't be called 7Z_LOC because of Windows limitations. ECHO %current_activity%: Testing if all required build environment values are set: + IF NOT DEFINED ZIP_LOC ( ECHO %current_activity%: ZIP_LOC not defined. Using default value. SET ZIP_LOC="C:\Program Files\7-Zip\7z.exe" ) ECHO %current_activity%: ZIP_LOC set to '%ZIP_LOC%'. -IF EXIST %ZIP_LOC% ( + +REM EXIST won't find items in the PATH. WHERE will. +SET ZIP_VALID=0 +IF EXIST %ZIP_LOC% SET ZIP_VALID=1 +WHERE /Q %ZIP_LOC% +IF NOT ERRORLEVEL 1 SET ZIP_VALID=1 + +IF %ZIP_VALID% EQU 1 ( ECHO %current_activity%: ZIP_LOC exists. ) ELSE ( ECHO %current_activity%: ZIP_LOC directory does not exist. Exiting. EXIT /B %exit_code_failure_build_locations% ) -ECHO %current_activity%: Testing if all required build environment values are set: IF NOT DEFINED NSIS_LOC ( ECHO %current_activity%: NSIS_LOC not defined. Using default value. SET NSIS_LOC="C:\Program Files (x86)\NSIS\" ) ECHO %current_activity%: NSIS_LOC set to '%NSIS_LOC%'. -IF EXIST %NSIS_LOC% ( + +SET NSIS_VALID=0 +IF EXIST %NSIS_LOC% SET NSIS_VALID=1 +WHERE /Q %NSIS_LOC% +IF NOT ERRORLEVEL 1 SET NSIS_VALID=1 + +IF %NSIS_VALID% EQU 1 ( ECHO %current_activity%: NSIS_LOC exists. ) ELSE ( ECHO %current_activity%: NSIS_LOC directory does not exist. Exiting. From 8d0277f6cf35b904f935a1b1fb9e6f442b06e120 Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 20:11:02 +0100 Subject: [PATCH 15/39] Add quotes to all env vars in appveyor --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index af3c294..2f9978d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,10 +2,10 @@ image: Visual Studio 2017 environment: matrix: - - QT_LOC: C:\Qt\5.11.2\msvc2017_64\bin\ + - QT_LOC: '"C:\Qt\5.11.2\msvc2017_64\bin\"' VS_LOC: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"' - JOM_LOC: C:\Qt\Tools\QtCreator\bin\jom.exe - NSIS_LOC: C:\Program Files (x86)\NSIS\ + JOM_LOC: '"C:\Qt\Tools\QtCreator\bin\jom.exe"' + NSIS_LOC: '"C:\Program Files (x86)\NSIS\"' ZIP_LOC: 7z COMPILER: msvc VSVER: 14 From de8dffe40f781ab27fb3e9857f5c9ac4d0a740ec Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 20:23:16 +0100 Subject: [PATCH 16/39] Add extra checks for environment vars --- build_scripts/win/build.cmd | 13 ++++++++++++- build_scripts/win/deploy.cmd | 1 + build_scripts/win/package.cmd | 14 ++++++++++---- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/build_scripts/win/build.cmd b/build_scripts/win/build.cmd index 46a9d72..c88a9f3 100644 --- a/build_scripts/win/build.cmd +++ b/build_scripts/win/build.cmd @@ -25,6 +25,7 @@ IF NOT DEFINED project_dir ( REM Change dir to the project dir, otherwise qmake doesn't know where it is. CD %project_dir% +REM QT_LOC is a directory, it can't be in the path, no reason to check using WHERE. ECHO %current_activity%: Testing if all required build environment values are set: IF NOT DEFINED QT_LOC ( ECHO %current_activity%: QT_LOC not defined. Using default value. @@ -43,7 +44,17 @@ IF NOT DEFINED VS_LOC ( SET VS_LOC="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" ) ECHO %current_activity%: VS_LOC set to '%VS_LOC%'. -IF EXIST %VS_LOC% ( + +REM EXIST won't find items in the PATH. WHERE will. +SET VS_VALID=0 +IF EXIST %VS_LOC% SET VS_VALID=1 +REM Prevents error message spam if it doesn't find it in PATH. +IF NOT %VS_VALID% EQU 1 ( + WHERE /Q %VS_LOC% + IF NOT ERRORLEVEL 1 SET VS_VALID=1 +) + +IF %VS_VALID% EQU 1 ( ECHO %current_activity%: VS_LOC exists. ) ELSE ( ECHO %current_activity%: VS_LOC directory does not exist. Exiting. diff --git a/build_scripts/win/deploy.cmd b/build_scripts/win/deploy.cmd index 3a78495..91fc32a 100644 --- a/build_scripts/win/deploy.cmd +++ b/build_scripts/win/deploy.cmd @@ -29,6 +29,7 @@ IF NOT DEFINED QT_LOC ( ECHO %current_activity%: QT_LOC not defined. Using default value. SET QT_LOC="C:\Qt\5.11.1\msvc2017_64\bin\" ) +REM QT_LOC is a directory, it can't be in the path, no reason to check using WHERE. ECHO %current_activity%: QT_LOC set to '%QT_LOC%'. IF EXIST %QT_LOC% ( ECHO %current_activity%: QT_LOC exists. diff --git a/build_scripts/win/package.cmd b/build_scripts/win/package.cmd index 59901fd..a1d7320 100644 --- a/build_scripts/win/package.cmd +++ b/build_scripts/win/package.cmd @@ -36,8 +36,10 @@ ECHO %current_activity%: ZIP_LOC set to '%ZIP_LOC%'. REM EXIST won't find items in the PATH. WHERE will. SET ZIP_VALID=0 IF EXIST %ZIP_LOC% SET ZIP_VALID=1 -WHERE /Q %ZIP_LOC% -IF NOT ERRORLEVEL 1 SET ZIP_VALID=1 +IF %ZIP_VALID% EQU 0 ( + WHERE /Q %ZIP_LOC% + IF NOT ERRORLEVEL 1 SET ZIP_VALID=1 +) IF %ZIP_VALID% EQU 1 ( ECHO %current_activity%: ZIP_LOC exists. @@ -52,10 +54,14 @@ IF NOT DEFINED NSIS_LOC ( ) ECHO %current_activity%: NSIS_LOC set to '%NSIS_LOC%'. +REM EXIST won't find items in the PATH. WHERE will. SET NSIS_VALID=0 IF EXIST %NSIS_LOC% SET NSIS_VALID=1 -WHERE /Q %NSIS_LOC% -IF NOT ERRORLEVEL 1 SET NSIS_VALID=1 +REM Prevents error message spam if it doesn't find it in PATH. +IF %NSIS_VALID% EQU 0 ( + WHERE /Q %NSIS_LOC% + IF NOT ERRORLEVEL 1 SET NSIS_VALID=1 +) IF %NSIS_VALID% EQU 1 ( ECHO %current_activity%: NSIS_LOC exists. From 2aa32bafad60072180d0f9b784590db47c1d797f Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 21:58:03 +0100 Subject: [PATCH 17/39] Change variable expansion in build scripts Currently the variable expansion sometimes doesn't work when done over two variables. Inlining the ~dp0 call along with \..\..\ seems to work. Testing leads me to believe that the Windows command prompt caches things in a weird way. --- build_scripts/win/build.cmd | 3 +-- build_scripts/win/deploy.cmd | 3 +-- build_scripts/win/package.cmd | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/build_scripts/win/build.cmd b/build_scripts/win/build.cmd index c88a9f3..1118d41 100644 --- a/build_scripts/win/build.cmd +++ b/build_scripts/win/build.cmd @@ -17,9 +17,8 @@ IF NOT DEFINED project_dir ( REM Arg 0 (called %0) is the full path to the file. REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only. - SET folder_path=%~dp0 REM Project dir is up two dirs from the file. - SET project_dir=%folder_path%\..\..\ + SET project_dir=%~dp0\..\..\ ) REM Change dir to the project dir, otherwise qmake doesn't know where it is. diff --git a/build_scripts/win/deploy.cmd b/build_scripts/win/deploy.cmd index 91fc32a..f19f1b9 100644 --- a/build_scripts/win/deploy.cmd +++ b/build_scripts/win/deploy.cmd @@ -19,9 +19,8 @@ IF NOT DEFINED project_dir ( REM Arg 0 (called %0) is the full path to the file. REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only. - SET folder_path=%~dp0 REM Project dir is up two dirs from the file. - SET project_dir=%folder_path%\..\..\ + SET project_dir=%~dp0\..\..\ ) ECHO %current_activity%: Testing if all required build environment values are set: diff --git a/build_scripts/win/package.cmd b/build_scripts/win/package.cmd index a1d7320..b7b76ad 100644 --- a/build_scripts/win/package.cmd +++ b/build_scripts/win/package.cmd @@ -19,9 +19,8 @@ IF NOT DEFINED project_dir ( REM Arg 0 (called %0) is the full path to the file. REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only. - SET folder_path=%~dp0 REM Project dir is up two dirs from the file. - SET project_dir=%folder_path%\..\..\ + SET project_dir=%~dp0\..\..\ ) REM ZIP_LOC can't be called 7Z_LOC because of Windows limitations. From b5877cd4e7e4cabf4bccc6fc7d05e2b4a787f251 Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 22:08:45 +0100 Subject: [PATCH 18/39] Update documentation for building on windows --- docs/building_for_windows.md | 57 ++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/docs/building_for_windows.md b/docs/building_for_windows.md index b6c7b51..960d5ba 100644 --- a/docs/building_for_windows.md +++ b/docs/building_for_windows.md @@ -4,6 +4,8 @@ > * [Requirements](#requirements) > * [Locations and Environment Variables](#locs_and_envs) > * [Building](#features) + > * [Using with QtCreator](#qt_creator) + > * [Using with Visual Studio](#visual_studio) ## Requirements @@ -14,21 +16,64 @@ For compiling: 2. Qt Framework (tested on 5.10 and 5.11) Additionally, for fully building portable and installer release versions: -3. 7zip Command Line +3. 7zip 4. Nullsoft Scriptable Install System (NSIS) ## Locations and Environment Variables -Visual Studio must be installed in the default location of `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community`. +The following environmental variables are relevant for building the project. -The `QT` environment variable must be set to the location of your Qt installation (for example `C:\Qt\5.11.1\msvc2017_64`). +| Environment Variable | Purpose | +| -------------------- | ------------- | +| `QT_LOC` | Path to your Qt `\bin\` folder. | +| `VS_LOC` | Path to your Visual Studio `vcvarsall.bat` file. | +| `JOM_LOC` | Path to an `.exe` of `jom.exe`. Usually installed with Qt. `jom` is a wrapper around `nmake` allowing more threads to be used. It is not required, but using `nmake`is slower. If `JOM_LOC` isn't defined, or the `.exe` can't be found `nmake` will be used by default. | +| `ZIP_LOC` | Path to your 7zip `.exe`. Both portable and installer will work. | +| `NSIS_LOC` | Path to your installation of NSIS containing the `makensis` file. Both portable and installer will work. | -The `PLATFORM` environment variable must be set to `amd64`. +If an environment variable isn't set a default value will be provided. The default values are shown in the table below. -For building the portable and installer release versions, the locations of 7zip Command Line (`7z.exe`) and NSIS (`makensis.exe`) must be in the `PATH` environment variable. +| Environment Variable | Default Value | +| -------------------- | ------------- | +| `QT_LOC` | `"C:\Qt\5.11.1\msvc2017_64\bin\"` | +| `VS_LOC` | `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"` | +| `JOM_LOC` | `"C:\Qt\Tools\QtCreator\bin\jom.exe"`| +| `ZIP_LOC` | `"C:\Program Files\7-Zip\7z.exe"` | +| `NSIS_LOC` | `"C:\Program Files (x86)\NSIS\"` | + +Additionally, these optional environment variables are supported. + +| Environment Variable | Purpose | +| -------------------- | ------------- | +| `BUILD_DEBUG` | If set, a debug version will be built. The packaging script will not run with this var set. | +| `BUILD_VSPROJ` | If set, Visual Studio project files will be built. | + +Remember that there's a difference between an unset variable and a variable set to an empty string. `SET BUILD_DEBUG=""` does not unset the variable. You need to write `SET BUILD_DEBUG=`. + +The `.dll` files necessary for a release build differ from those needed by a debug build. Therefore you need to make sure you run all scripts with `BUILD_DEBUG` either defined or undefined, depending on your needs. ## Building -With the programs above installed and environment variables set, go into the root folder of the repository and first run `build_windows.cmd` and then `package.cmd`. Compiled binaries along with everything needed to run portable will output to `.\bin\win64\AdvancedSettings\`. +With the programs above installed and environment variables set, go into the root folder of the repository and run `build_windows.cmd`. Compiled binaries along with everything needed to run portable will output to `.\bin\win64\AdvancedSettings\`. + + +## Using with QtCreator + +Run `build_windows.cmd` once and fully build (packaging not necessary) the application. Open the `.pro` file in Qt Creator. A build and toolchain option should be marked in Qt Creator, with all others unmarked. If it isn't, set the directory to be the root repo directory. You should now be able to compile and run in Qt Creator without issues. + +Notice that you may need to redeploy library files if you make large changes (run `build_scripts\win\deploy.cmd`). + +Additionally, you can set Qt Creator to run `build_scripts\win\deploy.cmd` on compilation in order to ensure that the correct libraries are present. Remember to set or unset `BUILD_DEBUG` depending on your needs. + + +## Using with Visual Studio + +Run `build_windows.cmd` once and fully build (packaging not necessary) the application with the `BUILD_VSPROJ` environment variable set. Open the newly created project file. If you compiled a release build (`BUILD_DEBUG` not set) change the build type to release in Visual Studio. You should be able to compile and run with Visual Studio without issues. + +Notice that any new files you add or compiler settings you change will not be backported to the `.pro` file. Hence it is necessary to manually change the `.pro` file. + +Notice that you may need to redeploy library files if you make large changes (run `build_scripts\win\deploy.cmd`). + +Additionally, you can set Visual Studio to run `build_scripts\win\deploy.cmd` on compilation in order to ensure that the correct libraries are present. Remember to set or unset `BUILD_DEBUG` depending on your needs. \ No newline at end of file From 62489ed642aab24477638831649941f2f1497abb Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 22:32:21 +0100 Subject: [PATCH 19/39] Move global level strings into scope of main --- src/main.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 922bcc6..fdb600c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,21 +10,6 @@ #include #include "logging.h" -const char* logConfigFileName = "logging.conf"; - -const char* logConfigDefault = -"* GLOBAL:\n" -" FORMAT = \"[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg\"\n" -" FILENAME = \"AdvancedSettings.log\"\n" -" ENABLED = true\n" -" TO_FILE = true\n" -" TO_STANDARD_OUTPUT = true\n" -" MAX_LOG_FILE_SIZE = 2097152 ## 2MB\n" -"* TRACE:\n" -" ENABLED = false\n" -"* DEBUG:\n" -" ENABLED = false\n"; - INITIALIZE_EASYLOGGINGPP void myQtMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { @@ -141,6 +126,21 @@ enum ReturnErrorCode { int main(int argc, char *argv[]) { + const char* logConfigFileName = "logging.conf"; + + const char* logConfigDefault = + "* GLOBAL:\n" + " FORMAT = \"[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg\"\n" + " FILENAME = \"AdvancedSettings.log\"\n" + " ENABLED = true\n" + " TO_FILE = true\n" + " TO_STANDARD_OUTPUT = true\n" + " MAX_LOG_FILE_SIZE = 2097152 ## 2MB\n" + "* TRACE:\n" + " ENABLED = false\n" + "* DEBUG:\n" + " ENABLED = false\n"; + const bool desktop_mode = argument::CheckCommandLineArgument(argc, argv, argument::DESKTOP_MODE); const bool no_sound = argument::CheckCommandLineArgument(argc, argv, argument::NO_SOUND); const bool no_manifest = argument::CheckCommandLineArgument(argc, argv, argument::NO_MANIFEST); From 1a043b667266e76105f1eb5ec808f12e584136fe Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 22:33:26 +0100 Subject: [PATCH 20/39] Remove code path that would never be executed --- src/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index fdb600c..c137975 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -256,5 +256,4 @@ int main(int argc, char *argv[]) { LOG(FATAL) << e.what(); return ReturnErrorCode::GENERAL_FAILURE; } - return ReturnErrorCode::SUCCESS; } From 6d3b5fdf632bc64980418b3efd69d67e6c79698b Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 26 Dec 2018 23:01:11 +0100 Subject: [PATCH 21/39] Remove warnings for unreferenced parameters The warnings in dummy functions are preventing the project from being compiled with warnings as errors. There were two options: * Using a define to create a noop (chosen option). * Commenting out the variable name, leaving only the type. The first option was chosen because the second option would leave out information from the IDE and compiler, while the first option wouldn't. The intent is also clearer with the first option, otherwise it would likely be necessary to leave comments with every single parameter that was commented out. --- .../audiomanager/AudioManagerDummy.cpp | 14 ++++++++++++++ .../keyboardinput/KeyboardInputDummy.cpp | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp b/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp index 2c3a612..d20016b 100644 --- a/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp +++ b/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp @@ -1,16 +1,22 @@ #include "AudioManagerDummy.h" +// Used to get the compiler to shut up about C4100: unreferenced formal parameter. +#define UNREFERENCED_PARAMETER(P) (P) + // application namespace namespace advsettings { void AudioManagerDummy::init(AudioTabController *controller) { // noop + UNREFERENCED_PARAMETER(controller); } void AudioManagerDummy::setPlaybackDevice(const std::string &id, bool notify) { // noop + UNREFERENCED_PARAMETER(id); + UNREFERENCED_PARAMETER(notify); } std::string AudioManagerDummy::getPlaybackDevName() @@ -26,6 +32,8 @@ std::string AudioManagerDummy::getPlaybackDevId() void AudioManagerDummy::setMirrorDevice(const std::string &id, bool notify) { // noop + UNREFERENCED_PARAMETER(id); + UNREFERENCED_PARAMETER(notify); } bool AudioManagerDummy::isMirrorValid() @@ -50,6 +58,7 @@ float AudioManagerDummy::getMirrorVolume() bool AudioManagerDummy::setMirrorVolume(float value) { + UNREFERENCED_PARAMETER(value); return false; } @@ -60,6 +69,7 @@ bool AudioManagerDummy::getMirrorMuted() bool AudioManagerDummy::setMirrorMuted(bool value) { + UNREFERENCED_PARAMETER(value); return false; } @@ -71,6 +81,8 @@ bool AudioManagerDummy::isMicValid() void AudioManagerDummy::setMicDevice(const std::string &id, bool notify) { // noop + UNREFERENCED_PARAMETER(id); + UNREFERENCED_PARAMETER(notify); } std::string AudioManagerDummy::getMicDevName() @@ -90,6 +102,7 @@ float AudioManagerDummy::getMicVolume() bool AudioManagerDummy::setMicVolume(float value) { + UNREFERENCED_PARAMETER(value); return false; } @@ -100,6 +113,7 @@ bool AudioManagerDummy::getMicMuted() bool AudioManagerDummy::setMicMuted(bool value) { + UNREFERENCED_PARAMETER(value); return false; } diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp index 69054a9..2b00e33 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp @@ -1,10 +1,14 @@ #include "KeyboardInputDummy.h" +// Used to get the compiler to shut up about C4100: unreferenced formal parameter. +#define UNREFERENCED_PARAMETER(P) (P) + namespace advsettings { void KeyboardInputDummy::sendKeyboardInput(QString input) { // noop + UNREFERENCED_PARAMETER(input); } void KeyboardInputDummy::sendKeyboardEnter() @@ -15,6 +19,7 @@ void KeyboardInputDummy::sendKeyboardEnter() void KeyboardInputDummy::sendKeyboardBackspace(int count) { // noop + UNREFERENCED_PARAMETER(count); } void KeyboardInputDummy::sendKeyboardAltTab() From 629c956618c26f0228beea6719cd3f1461cf9259 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 00:29:08 +0100 Subject: [PATCH 22/39] Change variable being shadowed apperror was shadowing another variable in the scope outside of the if statement, leading to a warning. Adding an underscore changes the var name without changing the meaning. In the future a different structure should probably be chosen for the statements. --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c137975..96bfff1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,8 +58,8 @@ void installManifest(bool cleaninstall = false) { if (apperror != vr::VRApplicationError_None) { throw std::runtime_error(std::string("Could not add application manifest: ") + std::string(vr::VRApplications()->GetApplicationsErrorNameFromEnum(apperror))); } else if (!alreadyInstalled || cleaninstall) { - auto apperror = vr::VRApplications()->SetApplicationAutoLaunch(advsettings::OverlayController::applicationKey, true); - if (apperror != vr::VRApplicationError_None) { + auto app_error = vr::VRApplications()->SetApplicationAutoLaunch(advsettings::OverlayController::applicationKey, true); + if (app_error != vr::VRApplicationError_None) { throw std::runtime_error(std::string("Could not set auto start: ") + std::string(vr::VRApplications()->GetApplicationsErrorNameFromEnum(apperror))); } } From 087d2426646325569ad0965ac43ba9b8ddc11449 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 00:53:47 +0100 Subject: [PATCH 23/39] Add compiler switches for warnings as errors Currently with /W3 on MSVC there are no warnings. Clang and g++ are not tested. The "QMAKE_CFLAGS_WARN_ON -= -W3" and "QMAKE_CXXFLAGS_WARN_ON -= -W3" are necessary because if they are not removed in the config, the compiler will give D9025: overriding '/W4' with '/W3' error warnings and not actually use /W4. --- advancedSettings.pro | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/advancedSettings.pro b/advancedSettings.pro index 03159dc..1d180ff 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -13,7 +13,24 @@ lessThan(QT_MINOR_VERSION, 6): error("requires Qt 5.6 or higher") TARGET = AdvancedSettings TEMPLATE = app +*msvc* { + #/W4 still has warnings. Including warnings in third party files. + #QMAKE_CFLAGS_WARN_ON -= -W3 + #QMAKE_CXXFLAGS_WARN_ON -= -W3 + #Removing -W3 from both FLAGS is necessary, otherwise compiler will give + #D9025: overriding '/W4' with '/W3' + #QMAKE_CXXFLAGS += /W4 + + QMAKE_CXXFLAGS += /WX +} +*g++* { + QMAKE_CXXFLAGS += -Werror +} + +*clang* { + QMAKE_CXXFLAGS += -Werror +} SOURCES += src/main.cpp\ src/overlaycontroller.cpp \ src/tabcontrollers/AudioTabController.cpp \ From 4904ccaa35922e95c7a703a34356ef22b2566c8f Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 01:17:02 +0100 Subject: [PATCH 24/39] Move variables to .cpp file to prevent unused var warning message --- src/tabcontrollers/SteamVRTabController.cpp | 7 +++++++ src/tabcontrollers/SteamVRTabController.h | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/tabcontrollers/SteamVRTabController.cpp b/src/tabcontrollers/SteamVRTabController.cpp index e56603e..4643220 100644 --- a/src/tabcontrollers/SteamVRTabController.cpp +++ b/src/tabcontrollers/SteamVRTabController.cpp @@ -10,6 +10,13 @@ namespace vr { // application namespace namespace advsettings { +// openvr's github repo hasn't been updated yet to reflect changes in beta 1477423729. +//static const char* vrsettings_steamvr_allowAsyncReprojection = "allowAsyncReprojection"; +//static const char* vrsettings_steamvr_allowInterleavedReprojection = "allowInterleavedReprojection"; + +static const char* vrsettings_steamvr_supersampleScale = "supersampleScale"; +static const char* vrsettings_steamvr_allowSupersampleFiltering = "allowSupersampleFiltering"; +static const char* vrsettings_compositor_category = "compositor"; void SteamVRTabController::initStage1() { eventLoopTick(); diff --git a/src/tabcontrollers/SteamVRTabController.h b/src/tabcontrollers/SteamVRTabController.h index 79d5ba0..e644cb9 100644 --- a/src/tabcontrollers/SteamVRTabController.h +++ b/src/tabcontrollers/SteamVRTabController.h @@ -3,12 +3,6 @@ #include -// openvr's github repo hasn't been updated yet to reflect changes in beta 1477423729. -//static const char* vrsettings_steamvr_allowAsyncReprojection = "allowAsyncReprojection"; -//static const char* vrsettings_steamvr_allowInterleavedReprojection = "allowInterleavedReprojection"; -static const char* vrsettings_compositor_category = "compositor"; -static const char* vrsettings_steamvr_supersampleScale = "supersampleScale"; -static const char* vrsettings_steamvr_allowSupersampleFiltering = "allowSupersampleFiltering"; class QQuickWindow; From f4feafaa03a88457b5d11c9f4e38009edb8e1668 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 01:26:13 +0100 Subject: [PATCH 25/39] Add parens around statement to banish warning --- src/overlaycontroller.cpp | 4 ++-- src/overlaycontroller.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/overlaycontroller.cpp b/src/overlaycontroller.cpp index f4ded03..a85891f 100644 --- a/src/overlaycontroller.cpp +++ b/src/overlaycontroller.cpp @@ -301,8 +301,8 @@ void OverlayController::OnRenderRequest() { void OverlayController::renderOverlay() { if (!desktopMode) { - // skip rendering if the overlay isn't visible - if (!vr::VROverlay() || !vr::VROverlay()->IsOverlayVisible(m_ulOverlayHandle) && !vr::VROverlay()->IsOverlayVisible(m_ulOverlayThumbnailHandle)) + // skip rendering if the overlay isn't visible + if (!vr::VROverlay() || (!vr::VROverlay()->IsOverlayVisible(m_ulOverlayHandle) && !vr::VROverlay()->IsOverlayVisible(m_ulOverlayThumbnailHandle))) return; m_pRenderControl->polishItems(); m_pRenderControl->sync(); diff --git a/src/overlaycontroller.h b/src/overlaycontroller.h index 257d0db..f47a4a9 100644 --- a/src/overlaycontroller.h +++ b/src/overlaycontroller.h @@ -64,7 +64,7 @@ private: bool dashboardVisible = false; QPoint m_ptLastMouse; - Qt::MouseButtons m_lastMouseButtons = 0; + Qt::MouseButtons m_lastMouseButtons = 0; bool desktopMode; bool noSound; @@ -112,7 +112,7 @@ public: void AddOffsetToCollisionBounds(float offset[3], bool commit = true); void RotateCollisionBounds(float angle, bool commit = true); // around y axis - bool isDesktopMode() { return desktopMode; }; + bool isDesktopMode() { return desktopMode; }; utils::ChaperoneUtils& chaperoneUtils() noexcept { return m_chaperoneUtils; } From e54f2445089b82dbc1b45c1c117f71c904e89b3f Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 01:55:49 +0100 Subject: [PATCH 26/39] Fix warnings in AudioTabController Mostly casts and unsigned to signed comparisons. Testing to ensure that the int isn't below 0. If it is, it can't be used in the array later anyway. After we're sure it isn't below 0 it's safe to static_cast(). --- src/tabcontrollers/AudioTabController.cpp | 99 ++++++++++++----------- 1 file changed, 54 insertions(+), 45 deletions(-) diff --git a/src/tabcontrollers/AudioTabController.cpp b/src/tabcontrollers/AudioTabController.cpp index 788abdb..e743566 100644 --- a/src/tabcontrollers/AudioTabController.cpp +++ b/src/tabcontrollers/AudioTabController.cpp @@ -55,10 +55,10 @@ namespace advsettings { if (QFile::exists(QString::fromStdString(notifIconPath))) { vr::VROverlay()->SetOverlayFromFile(m_ulNotificationOverlayHandle, notifIconPath.c_str()); vr::VROverlay()->SetOverlayWidthInMeters(m_ulNotificationOverlayHandle, 0.02f); - vr::HmdMatrix34_t notificationTransform = { - 1.0f, 0.0f, 0.0f, 0.12f, - 0.0f, 1.0f, 0.0f, 0.08f, - 0.0f, 0.0f, 1.0f, -0.3f + vr::HmdMatrix34_t notificationTransform = { + 1.0f, 0.0f, 0.0f, 0.12f, + 0.0f, 1.0f, 0.0f, 0.08f, + 0.0f, 0.0f, 1.0f, -0.3f }; vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(m_ulNotificationOverlayHandle, vr::k_unTrackedDeviceIndex_Hmd, ¬ificationTransform); } else { @@ -307,25 +307,25 @@ namespace advsettings { emit recordingDeviceListChanged(); } - int AudioTabController::getPlaybackDeviceCount() { - return (int)m_playbackDevices.size(); + int AudioTabController::getPlaybackDeviceCount() { + return static_cast(m_playbackDevices.size()); } - QString AudioTabController::getPlaybackDeviceName(int index) { - if (index < m_playbackDevices.size()) { - return QString::fromStdString(m_playbackDevices[index].second); + QString AudioTabController::getPlaybackDeviceName(int index) { + if (index > 0 && static_cast(index) < m_playbackDevices.size()) { + return QString::fromStdString(m_playbackDevices[static_cast(index)].second); } else { return ""; } } - int AudioTabController::getRecordingDeviceCount() { - return (int)m_recordingDevices.size(); + int AudioTabController::getRecordingDeviceCount() { + return static_cast(m_recordingDevices.size()); } QString AudioTabController::getRecordingDeviceName(int index) { - if (index < m_recordingDevices.size()) { - return QString::fromStdString(m_recordingDevices[index].second); + if (index > 0 && static_cast(index) < m_playbackDevices.size()) { + return QString::fromStdString(m_recordingDevices[static_cast(index)].second); } else { return ""; } @@ -346,15 +346,18 @@ namespace advsettings { void AudioTabController::setPlaybackDeviceIndex(int index, bool notify) { if (index != m_playbackDeviceIndex) { - if (index < m_playbackDevices.size() && index != m_mirrorDeviceIndex) { + if (index > 0 && static_cast(index) < m_playbackDevices.size() && index != m_mirrorDeviceIndex) { vr::EVRSettingsError vrSettingsError; //Applys Audio Switch IN VR - vr::VRSettings()->SetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackDevice_String, m_playbackDevices[index].first.c_str(), &vrSettingsError); + vr::VRSettings()->SetString(vr::k_pch_audio_Section, + vr::k_pch_audio_OnPlaybackDevice_String, + m_playbackDevices[static_cast(index)].first.c_str(), + &vrSettingsError); if (vrSettingsError != vr::VRSettingsError_None) { LOG(WARNING) << "Could not write \"" << vr::k_pch_audio_OnPlaybackDevice_String << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); } else { - vr::VRSettings()->Sync(); - audioManager->setPlaybackDevice(m_playbackDevices[index].first, notify); + vr::VRSettings()->Sync(); + audioManager->setPlaybackDevice(m_playbackDevices[static_cast(index)].first, notify); } } else if (notify) { emit playbackDeviceIndexChanged(m_playbackDeviceIndex); @@ -373,14 +376,17 @@ namespace advsettings { vr::VRSettings()->Sync(); audioManager->setMirrorDevice("", notify); } - } else if (index < m_playbackDevices.size() && index != m_playbackDeviceIndex && index != m_mirrorDeviceIndex) { - vr::EVRSettingsError vrSettingsError; - vr::VRSettings()->SetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackMirrorDevice_String, m_playbackDevices[index].first.c_str(), &vrSettingsError); + } else if (index > 0 && static_cast(index) < m_playbackDevices.size() && index != m_playbackDeviceIndex && index != m_mirrorDeviceIndex) { + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetString(vr::k_pch_audio_Section, + vr::k_pch_audio_OnPlaybackMirrorDevice_String, + m_playbackDevices[static_cast(index)].first.c_str(), + &vrSettingsError); if (vrSettingsError != vr::VRSettingsError_None) { LOG(WARNING) << "Could not write \"" << vr::k_pch_audio_OnPlaybackMirrorDevice_String << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); } else { vr::VRSettings()->Sync(); - audioManager->setMirrorDevice(m_playbackDevices[index].first, notify); + audioManager->setMirrorDevice(m_playbackDevices[static_cast(index)].first, notify); } } else if (notify) { emit mirrorDeviceIndexChanged(m_mirrorDeviceIndex); @@ -390,14 +396,14 @@ namespace advsettings { void AudioTabController::setMicDeviceIndex(int index, bool notify) { if (index != m_recordingDeviceIndex) { - if (index < m_recordingDevices.size()) { - vr::EVRSettingsError vrSettingsError; - vr::VRSettings()->SetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnRecordDevice_String, m_recordingDevices[index].first.c_str(), &vrSettingsError); + if (index > 0 && static_cast(index) < m_recordingDevices.size()) { + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnRecordDevice_String, m_recordingDevices[static_cast(index)].first.c_str(), &vrSettingsError); if (vrSettingsError != vr::VRSettingsError_None) { LOG(WARNING) << "Could not write \"" << vr::k_pch_audio_OnRecordDevice_String << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); } else { - vr::VRSettings()->Sync(); - audioManager->setMicDevice(m_recordingDevices[index].first, notify); + vr::VRSettings()->Sync(); + audioManager->setMicDevice(m_recordingDevices[static_cast(index)].first, notify); } } else if (notify) { emit micDeviceIndexChanged(m_recordingDeviceIndex); @@ -496,8 +502,8 @@ namespace advsettings { auto profileCount = settings->beginReadArray("audioProfiles"); for (int i = 0; i < profileCount; i++) { settings->setArrayIndex(i); - audioProfiles.emplace_back(); - auto& entry = audioProfiles[i]; + audioProfiles.emplace_back(); + auto& entry = audioProfiles[static_cast(i)]; entry.profileName = settings->value("profileName").toString().toStdString(); entry.playbackName = settings->value("playbackName").toString().toStdString(); entry.micName = settings->value("micName").toString().toStdString(); @@ -528,9 +534,9 @@ namespace advsettings { auto settings = OverlayController::appSettings(); settings->beginGroup(getSettingsName()); settings->beginWriteArray("audioProfiles"); - unsigned i = 0; - for (auto& p : audioProfiles) { - settings->setArrayIndex(i); + int i = 0; + for (auto& p : audioProfiles) { + settings->setArrayIndex(i); settings->setValue("profileName", QString::fromStdString(p.profileName)); settings->setValue("playbackName", QString::fromStdString(p.playbackName)); settings->setValue("micName", QString::fromStdString(p.micName)); @@ -657,9 +663,9 @@ namespace advsettings { } - unsigned AudioTabController::getAudioProfileCount() { - return (unsigned)audioProfiles.size(); - } + unsigned AudioTabController::getAudioProfileCount() { + return static_cast(audioProfiles.size()); + } QString AudioTabController::getAudioProfileName(unsigned index) { if (index < audioProfiles.size()) { @@ -676,28 +682,31 @@ namespace advsettings { description: Gets proper index value for selecting specific devices. */ - int AudioTabController::getPlaybackIndex(std::string str) { - for (int i = 0; i < m_playbackDevices.size(); i++) { - if (str.compare(m_playbackDevices[i].second)==0) { - return i; + int AudioTabController::getPlaybackIndex(std::string str) { + //Unsigned to avoid two casts. i won't be negative because we only increment it. + for (unsigned int i = 0; i < m_playbackDevices.size(); i++) { + if (str.compare(m_playbackDevices[i].second)==0) { + return static_cast(i); } } return m_playbackDeviceIndex; } - int AudioTabController::getRecordingIndex(std::string str) { - for (int i = 0; i < m_recordingDevices.size(); i++) { - if (str.compare(m_recordingDevices[i].second) == 0) { - return i; + int AudioTabController::getRecordingIndex(std::string str) { + //Unsigned to avoid two casts. i won't be negative because we only increment it. + for (unsigned int i = 0; i < m_recordingDevices.size(); i++) { + if (str.compare(m_recordingDevices[i].second) == 0) { + return static_cast(i); } } return m_recordingDeviceIndex; } int AudioTabController::getMirrorIndex(std::string str) { - for (int i = 0; i < m_playbackDevices.size(); i++) { - if (str.compare(m_playbackDevices[i].second) == 0) { - return i; + //Unsigned to avoid two casts. i won't be negative because we only increment it. + for (unsigned int i = 0; i < m_playbackDevices.size(); i++) { + if (str.compare(m_playbackDevices[i].second) == 0) { + return static_cast(i); } } return -1; From 9a2c388a1caee6eaee2715af0958625384a4fba4 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 12:14:07 +0100 Subject: [PATCH 27/39] Solve initialization bug in MOveCenterTabController MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC gave error ../src/tabcontrollers/MoveCenterTabController.cpp:57:67: error: operation on ‘((advsettings::MoveCenterTabController*)this)->advsettings::MoveCenterTabController::lastMoveButtonClick[0]’ may be undefined [-Werror=sequence-point] Because assigning a value to itself twice is undefined behavior. It is highly likely that intended behavior was to initialize both array members to the same value at once. --- src/tabcontrollers/MoveCenterTabController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabcontrollers/MoveCenterTabController.cpp b/src/tabcontrollers/MoveCenterTabController.cpp index 8641185..a6a6d13 100644 --- a/src/tabcontrollers/MoveCenterTabController.cpp +++ b/src/tabcontrollers/MoveCenterTabController.cpp @@ -54,7 +54,7 @@ void MoveCenterTabController::initStage1() { m_lockZToggle = value.toBool(); } settings->endGroup(); - lastMoveButtonClick[0] = lastMoveButtonClick[0] = clock::now(); + lastMoveButtonClick[0] = lastMoveButtonClick[1] = clock::now(); } void MoveCenterTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { From f32c91fe030b06a44bb9982f984292aefddacf6f Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 12:37:55 +0100 Subject: [PATCH 28/39] Fix GCC warning about unused value Casting to void should shut up GCC about error: statement has no effect [-Werror=unused-value] static_cast() is possible for all current types. Supposedly an old C style cast could also be used, but they should not be used in modern C++ code. --- src/tabcontrollers/audiomanager/AudioManagerDummy.cpp | 3 ++- src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp b/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp index d20016b..a36781b 100644 --- a/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp +++ b/src/tabcontrollers/audiomanager/AudioManagerDummy.cpp @@ -1,7 +1,8 @@ #include "AudioManagerDummy.h" // Used to get the compiler to shut up about C4100: unreferenced formal parameter. -#define UNREFERENCED_PARAMETER(P) (P) +// The cast is to get GCC to shut up about it. +#define UNREFERENCED_PARAMETER(P) static_cast((P)) // application namespace namespace advsettings { diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp index 2b00e33..83cd526 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp @@ -1,7 +1,8 @@ #include "KeyboardInputDummy.h" // Used to get the compiler to shut up about C4100: unreferenced formal parameter. -#define UNREFERENCED_PARAMETER(P) (P) +// The cast is to get GCC to shut up about it. +#define UNREFERENCED_PARAMETER(P) static_cast((P)) namespace advsettings { From 0d6917566ebfc270573cc0e143f70e99f04eb94b Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:04:14 +0100 Subject: [PATCH 29/39] Add clang switch to ignore third party warnings The --system-header-prefix=third-party treats all includes with a path matching third-party as system files, meaning they won't show warnings. --- advancedSettings.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/advancedSettings.pro b/advancedSettings.pro index 1d180ff..6cbf415 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -30,6 +30,7 @@ TEMPLATE = app *clang* { QMAKE_CXXFLAGS += -Werror + QMAKE_CXXFLAGS += --system-header-prefix=third-party } SOURCES += src/main.cpp\ src/overlaycontroller.cpp \ From 6c4541018ded6f73bc9730da933fa0e717214058 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:05:37 +0100 Subject: [PATCH 30/39] Change NULL to nullptr --- src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp index aafa129..2ea948b 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp @@ -22,12 +22,12 @@ void sendKeyboardInputRaw(int inputCount, LPINPUT input) { char *err; auto errCode = GetLastError(); if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, errCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language (LPTSTR)&err, 0, - NULL)){ + nullptr)){ LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; } else { LOG(ERROR) << "Error calling SendInput(): " << err; From 450bf91db69bf81791fc53a9aebfa4c8ab885e7e Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:13:27 +0100 Subject: [PATCH 31/39] Resolve implicit unsigned/signed casts --- .../keyboardinput/KeyboardInputWindows.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp index 2ea948b..fb08ccf 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp @@ -18,7 +18,7 @@ void fillKiStruct(INPUT& ip, WORD scanCode, bool keyup) { }; void sendKeyboardInputRaw(int inputCount, LPINPUT input) { - if (!SendInput(inputCount, input, sizeof(INPUT))) { + if ((inputCount > 0) && !SendInput(static_cast(inputCount), input, sizeof(INPUT))) { char *err; auto errCode = GetLastError(); if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, @@ -39,8 +39,8 @@ void KeyboardInputWindows::sendKeyboardInput(QString input) { int len = input.length(); if (len > 0) { - LPINPUT ips = new INPUT[len * 5 + 3]; - unsigned ii = 0; + LPINPUT ips = new INPUT[static_cast(len) * 5 + 3]; + int ii = 0; bool shiftPressed = false; bool ctrlPressed = false; bool altPressed = false; @@ -106,7 +106,8 @@ void KeyboardInputWindows::sendKeyboardEnter() void KeyboardInputWindows::sendKeyboardBackspace(int count) { if (count > 0) { - LPINPUT ips = new INPUT[count * 2]; + // We ensure that count is nonnegative, therefore safe cast. + LPINPUT ips = new INPUT[static_cast(count) * 2]; for (int i = 0; i < count; i++) { fillKiStruct(ips[2 * i], VK_BACK, false); fillKiStruct(ips[2 * i + 1], VK_BACK, true); From b452e6845635e7b230e03bf6fa7870ba70f69444 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:14:49 +0100 Subject: [PATCH 32/39] Fix minor memory leaks The delete keyword only calls a single destructor, the delete[] keyword calls as many destructors as there are members of the array. --- src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp index fb08ccf..b4f7b6e 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp @@ -89,7 +89,7 @@ void KeyboardInputWindows::sendKeyboardInput(QString input) } sendKeyboardInputRaw(ii, ips); - delete ips; + delete[] ips; } } @@ -100,7 +100,7 @@ void KeyboardInputWindows::sendKeyboardEnter() fillKiStruct(ips[1], VK_RETURN, true); sendKeyboardInputRaw(2, ips); - delete ips; + delete[] ips; } void KeyboardInputWindows::sendKeyboardBackspace(int count) @@ -114,7 +114,7 @@ void KeyboardInputWindows::sendKeyboardBackspace(int count) } sendKeyboardInputRaw(count * 2, ips); - delete ips; + delete[] ips; } } @@ -128,7 +128,7 @@ void KeyboardInputWindows::sendKeyboardAltTab() fillKiStruct(ips[3], VK_MENU, true); sendKeyboardInputRaw(4, ips); - delete ips; + delete[] ips; } } From d9a4da5f5d38dc8c308441802f85ad4f7e357cec Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:18:03 +0100 Subject: [PATCH 33/39] Change C style cast to reinterpret_cast static_cast won't cast between pointer types, reinterpret_cast will. --- src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp index b4f7b6e..471f27a 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp @@ -25,7 +25,7 @@ void sendKeyboardInputRaw(int inputCount, LPINPUT input) { nullptr, errCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language - (LPTSTR)&err, + reinterpret_cast(&err), 0, nullptr)){ LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; From e7e7272d5228a845595ae0b54966140ed5ed5da6 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:23:54 +0100 Subject: [PATCH 34/39] Fix memory leaks as result of missing delete[] The delete keyword only calls a single destructor, delete[] calls as many as there are members in the array. --- src/overlaycontroller.cpp | 4 ++-- src/tabcontrollers/ChaperoneTabController.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/overlaycontroller.cpp b/src/overlaycontroller.cpp index a85891f..c0195dc 100644 --- a/src/overlaycontroller.cpp +++ b/src/overlaycontroller.cpp @@ -593,7 +593,7 @@ void OverlayController::AddOffsetToCollisionBounds(float offset[3], bool commit) } } vr::VRChaperoneSetup()->SetWorkingCollisionBoundsInfo(collisionBounds, collisionBoundsCount); - delete collisionBounds; + delete[] collisionBounds; } if (commit && collisionBoundsCount > 0) { vr::VRChaperoneSetup()->CommitWorkingCopy(vr::EChaperoneConfigFile_Live); @@ -621,7 +621,7 @@ void OverlayController::RotateCollisionBounds(float angle, bool commit) { } } vr::VRChaperoneSetup()->SetWorkingCollisionBoundsInfo(collisionBounds, collisionBoundsCount); - delete collisionBounds; + delete[] collisionBounds; } if (commit && collisionBoundsCount > 0) { vr::VRChaperoneSetup()->CommitWorkingCopy(vr::EChaperoneConfigFile_Live); diff --git a/src/tabcontrollers/ChaperoneTabController.cpp b/src/tabcontrollers/ChaperoneTabController.cpp index 92572bf..ce706ef 100644 --- a/src/tabcontrollers/ChaperoneTabController.cpp +++ b/src/tabcontrollers/ChaperoneTabController.cpp @@ -486,7 +486,7 @@ void ChaperoneTabController::setHeight(float value, bool notify) { } vr::VRChaperoneSetup()->SetWorkingCollisionBoundsInfo(collisionBounds, collisionBoundsCount); vr::VRChaperoneSetup()->CommitWorkingCopy(vr::EChaperoneConfigFile_Live); - delete collisionBounds; + delete[] collisionBounds; } if (notify) { emit heightChanged(m_fadeDistance); @@ -1006,7 +1006,7 @@ float ChaperoneTabController::getBoundsMaxY() { result = collisionBounds[b].vCorners[ci].v[1]; } } - delete collisionBounds; + delete[] collisionBounds; } return result; } From f42c481308e5a92cb6e86f8c3a351b248e5b0d59 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:29:22 +0100 Subject: [PATCH 35/39] Add brackets around intialization of 2D array inside struct 2 brackets are necessary because it's initialization of a struct, intializing an 3 member array of 4 floats. --- src/tabcontrollers/AudioTabController.cpp | 12 ++++++------ src/tabcontrollers/UtilitiesTabController.cpp | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/tabcontrollers/AudioTabController.cpp b/src/tabcontrollers/AudioTabController.cpp index e743566..84c89d4 100644 --- a/src/tabcontrollers/AudioTabController.cpp +++ b/src/tabcontrollers/AudioTabController.cpp @@ -54,12 +54,12 @@ namespace advsettings { std::string notifIconPath = QApplication::applicationDirPath().toStdString() + "/res/qml/ptt_notification.png"; if (QFile::exists(QString::fromStdString(notifIconPath))) { vr::VROverlay()->SetOverlayFromFile(m_ulNotificationOverlayHandle, notifIconPath.c_str()); - vr::VROverlay()->SetOverlayWidthInMeters(m_ulNotificationOverlayHandle, 0.02f); - vr::HmdMatrix34_t notificationTransform = { - 1.0f, 0.0f, 0.0f, 0.12f, - 0.0f, 1.0f, 0.0f, 0.08f, - 0.0f, 0.0f, 1.0f, -0.3f - }; + vr::VROverlay()->SetOverlayWidthInMeters(m_ulNotificationOverlayHandle, 0.02f); + vr::HmdMatrix34_t notificationTransform = {{ + {1.0f, 0.0f, 0.0f, 0.12f}, + {0.0f, 1.0f, 0.0f, 0.08f}, + {0.0f, 0.0f, 1.0f, -0.3f} + }}; vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(m_ulNotificationOverlayHandle, vr::k_unTrackedDeviceIndex_Hmd, ¬ificationTransform); } else { LOG(ERROR) << "Could not find notification icon \"" << notifIconPath << "\""; diff --git a/src/tabcontrollers/UtilitiesTabController.cpp b/src/tabcontrollers/UtilitiesTabController.cpp index 4cd203e..705999a 100644 --- a/src/tabcontrollers/UtilitiesTabController.cpp +++ b/src/tabcontrollers/UtilitiesTabController.cpp @@ -210,11 +210,11 @@ namespace advsettings { if (QFile::exists(QString::fromStdString(batteryIconPath))) { vr::VROverlay()->SetOverlayFromFile(handle, batteryIconPath.c_str()); vr::VROverlay()->SetOverlayWidthInMeters(handle, 0.05f); - vr::HmdMatrix34_t notificationTransform = { - 1.0f, 0.0f, 0.0f, 0.00f, - 0.0f, -1.0f, 0.0f, 0.01f, - 0.0f, 0.0f, -1.0f, -0.013f - }; + vr::HmdMatrix34_t notificationTransform = {{ + {1.0f, 0.0f, 0.0f, 0.00f}, + {0.0f, -1.0f, 0.0f, 0.01f}, + {0.0f, 0.0f, -1.0f, -0.013f} + }}; vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(handle, index, ¬ificationTransform); LOG(INFO) << "Created battery overlay for device " << index; } else { From 412e56fa1154222b3b536f90171bf6d708f3cb1b Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 16:27:31 +0100 Subject: [PATCH 36/39] Add switches for msvc-clang The clang frontend for MSVC does not allow the same type of switches that regular clang does, therefore we need logic to gate off msvc-clang. --- advancedSettings.pro | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/advancedSettings.pro b/advancedSettings.pro index 6cbf415..497199d 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -22,14 +22,25 @@ TEMPLATE = app #QMAKE_CXXFLAGS += /W4 QMAKE_CXXFLAGS += /WX + + #The MSVC frontend for clang does not understand /external + !*clang-msvc{ + #external:anglebrackets suppresses warnings made in #includes + #made with angle brackets, like #include , but will + #still report for includes done with quotes. + QMAKE_CXXFLAGS += /experimental:external /external:anglebrackets + } } *g++* { QMAKE_CXXFLAGS += -Werror } -*clang* { +#Look for anything clang that is not clang-msvc, since it does not +#allow all the same switches as regular clang. +*clang|*clang-g++|*clang-libc++ { QMAKE_CXXFLAGS += -Werror + #All includes from the third-party directory will not warn. QMAKE_CXXFLAGS += --system-header-prefix=third-party } SOURCES += src/main.cpp\ From b097908b124c2f7657c657bb9282a6aa6cde61a4 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 18:27:27 +0100 Subject: [PATCH 37/39] Rename parameters shadowing class members Parameters with the same name as class members are ripe for introducing bugs. The fact that the "this->" syntax is optional creates confusion for maintaining programmers who can only guess at the intention. --- src/tabcontrollers/AccessibilityTabController.cpp | 6 +++--- src/tabcontrollers/AudioTabController.cpp | 6 +++--- src/tabcontrollers/ChaperoneTabController.cpp | 6 +++--- src/tabcontrollers/FixFloorTabController.cpp | 6 +++--- src/tabcontrollers/MoveCenterTabController.cpp | 6 +++--- src/tabcontrollers/ReviveTabController.cpp | 6 +++--- src/tabcontrollers/SettingsTabController.cpp | 6 +++--- src/tabcontrollers/StatisticsTabController.cpp | 6 +++--- src/tabcontrollers/SteamVRTabController.cpp | 6 +++--- src/tabcontrollers/UtilitiesTabController.cpp | 6 +++--- src/tabcontrollers/audiomanager/AudioManagerWindows.cpp | 4 ++-- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/tabcontrollers/AccessibilityTabController.cpp b/src/tabcontrollers/AccessibilityTabController.cpp index 6c8e34b..c2dfa9c 100644 --- a/src/tabcontrollers/AccessibilityTabController.cpp +++ b/src/tabcontrollers/AccessibilityTabController.cpp @@ -19,9 +19,9 @@ void AccessibilityTabController::initStage1() { reloadPttConfig(); } -void AccessibilityTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void AccessibilityTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void AccessibilityTabController::setTrackingUniverse(int value) { diff --git a/src/tabcontrollers/AudioTabController.cpp b/src/tabcontrollers/AudioTabController.cpp index 84c89d4..ab79030 100644 --- a/src/tabcontrollers/AudioTabController.cpp +++ b/src/tabcontrollers/AudioTabController.cpp @@ -44,9 +44,9 @@ namespace advsettings { } - void AudioTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; + void AudioTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; std::string notifKey = std::string(OverlayController::applicationKey) + ".pptnotification"; vr::VROverlayError overlayError = vr::VROverlay()->CreateOverlay(notifKey.c_str(), notifKey.c_str(), &m_ulNotificationOverlayHandle); diff --git a/src/tabcontrollers/ChaperoneTabController.cpp b/src/tabcontrollers/ChaperoneTabController.cpp index ce706ef..f286cd9 100644 --- a/src/tabcontrollers/ChaperoneTabController.cpp +++ b/src/tabcontrollers/ChaperoneTabController.cpp @@ -32,9 +32,9 @@ void ChaperoneTabController::initStage1() { } -void ChaperoneTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void ChaperoneTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } diff --git a/src/tabcontrollers/FixFloorTabController.cpp b/src/tabcontrollers/FixFloorTabController.cpp index 8ac480d..34d2e69 100644 --- a/src/tabcontrollers/FixFloorTabController.cpp +++ b/src/tabcontrollers/FixFloorTabController.cpp @@ -9,9 +9,9 @@ namespace advsettings { void FixFloorTabController::initStage1() { } -void FixFloorTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void FixFloorTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void FixFloorTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses) { diff --git a/src/tabcontrollers/MoveCenterTabController.cpp b/src/tabcontrollers/MoveCenterTabController.cpp index a6a6d13..1dec969 100644 --- a/src/tabcontrollers/MoveCenterTabController.cpp +++ b/src/tabcontrollers/MoveCenterTabController.cpp @@ -57,9 +57,9 @@ void MoveCenterTabController::initStage1() { lastMoveButtonClick[0] = lastMoveButtonClick[1] = clock::now(); } -void MoveCenterTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void MoveCenterTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } diff --git a/src/tabcontrollers/ReviveTabController.cpp b/src/tabcontrollers/ReviveTabController.cpp index 58994d8..78c7d80 100644 --- a/src/tabcontrollers/ReviveTabController.cpp +++ b/src/tabcontrollers/ReviveTabController.cpp @@ -167,9 +167,9 @@ namespace advsettings { } } - void ReviveTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; + void ReviveTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void ReviveTabController::eventLoopTick() { diff --git a/src/tabcontrollers/SettingsTabController.cpp b/src/tabcontrollers/SettingsTabController.cpp index 82bde48..ae747c5 100644 --- a/src/tabcontrollers/SettingsTabController.cpp +++ b/src/tabcontrollers/SettingsTabController.cpp @@ -17,9 +17,9 @@ void SettingsTabController::initStage1() { } } -void SettingsTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void SettingsTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void SettingsTabController::eventLoopTick() { diff --git a/src/tabcontrollers/StatisticsTabController.cpp b/src/tabcontrollers/StatisticsTabController.cpp index 2195af5..6ee28d6 100644 --- a/src/tabcontrollers/StatisticsTabController.cpp +++ b/src/tabcontrollers/StatisticsTabController.cpp @@ -8,9 +8,9 @@ namespace advsettings { void StatisticsTabController::initStage1() { } -void StatisticsTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void StatisticsTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void StatisticsTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses, float leftSpeed, float rightSpeed) { diff --git a/src/tabcontrollers/SteamVRTabController.cpp b/src/tabcontrollers/SteamVRTabController.cpp index 4643220..d3cfaba 100644 --- a/src/tabcontrollers/SteamVRTabController.cpp +++ b/src/tabcontrollers/SteamVRTabController.cpp @@ -24,9 +24,9 @@ void SteamVRTabController::initStage1() { } -void SteamVRTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; +void SteamVRTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } diff --git a/src/tabcontrollers/UtilitiesTabController.cpp b/src/tabcontrollers/UtilitiesTabController.cpp index 705999a..c83cfd3 100644 --- a/src/tabcontrollers/UtilitiesTabController.cpp +++ b/src/tabcontrollers/UtilitiesTabController.cpp @@ -48,9 +48,9 @@ namespace advsettings { } - void UtilitiesTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { - this->parent = parent; - this->widget = widget; + void UtilitiesTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) { + this->parent = var_parent; + this->widget = var_widget; } void UtilitiesTabController::sendKeyboardInput(QString input) { diff --git a/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp b/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp index 7e41a32..89a1c06 100644 --- a/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp +++ b/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp @@ -31,7 +31,7 @@ AudioManagerWindows::~AudioManagerWindows() { audioDeviceEnumerator->Release(); } -void AudioManagerWindows::init(AudioTabController* controller) { +void AudioManagerWindows::init(AudioTabController* var_controller) { std::lock_guard lock(_mutex); audioDeviceEnumerator = getAudioDeviceEnumerator(); if (!audioDeviceEnumerator) { @@ -47,7 +47,7 @@ void AudioManagerWindows::init(AudioTabController* controller) { } else { LOG(WARNING) << "Could not find a default recording device."; } - this->controller = controller; + this->controller = var_controller; audioDeviceEnumerator->RegisterEndpointNotificationCallback((IMMNotificationClient*)this); policyConfig = getPolicyConfig(); if (!policyConfig) { From e8cda901d1edcc5599c43720fd4fc6689b40bad5 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 18:42:29 +0100 Subject: [PATCH 38/39] Rename local var that shadows member var Notice that the class has an identical var that is used in several places. It is unknown if the original programmer intended to use the member var in this function, but what is actually being done is a new var being created, changed and returned. This may not respect the original intention, but it does preserve the original mechanics. --- .../audiomanager/AudioManagerWindows.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp b/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp index 89a1c06..b05fcf5 100644 --- a/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp +++ b/src/tabcontrollers/audiomanager/AudioManagerWindows.cpp @@ -277,20 +277,20 @@ IMMDeviceEnumerator* AudioManagerWindows::getAudioDeviceEnumerator() { } IPolicyConfig * AudioManagerWindows::getPolicyConfig() { - IPolicyConfig* policyConfig = nullptr; + IPolicyConfig* var_policyConfig = nullptr; // for Win 10 - auto hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig2, (LPVOID *)&policyConfig); + auto hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig2, (LPVOID *)&var_policyConfig); if (hr != S_OK) { - hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig1, (LPVOID *)&policyConfig); + hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig1, (LPVOID *)&var_policyConfig); } // for Win Vista, 7, 8, 8.1 if (hr != S_OK) { - hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig0, (LPVOID *)&policyConfig); + hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig0, (LPVOID *)&var_policyConfig); } if (hr != S_OK) { return nullptr; } else { - return policyConfig; + return var_policyConfig; } } From f1f39ac1a81e6c2724d5dfa3e97a8c89c2e5f64f Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 20:09:48 +0100 Subject: [PATCH 39/39] Add /WX switches for MSVC compilers, except clang-msvc Clang-msvc has problems with around 400 "-Wexpansion-to-defined" errors in easylogging++.h. No flags seem to be able to disable this error. Clang-cl is generally in an awkward halfway place between clang and msvc. Msvc has problems with C4127 "conditional expression is constant" in the "qvarlengtharray.h", hence it being disabled with /wd4127. Neither msvc* compiler has proper support for disabling errors in specific files. It's either QMAKE magic or waiting for proper support. --- advancedSettings.pro | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/advancedSettings.pro b/advancedSettings.pro index 497199d..9458a0f 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -14,21 +14,14 @@ TARGET = AdvancedSettings TEMPLATE = app *msvc* { - #/W4 still has warnings. Including warnings in third party files. - #QMAKE_CFLAGS_WARN_ON -= -W3 - #QMAKE_CXXFLAGS_WARN_ON -= -W3 #Removing -W3 from both FLAGS is necessary, otherwise compiler will give #D9025: overriding '/W4' with '/W3' - #QMAKE_CXXFLAGS += /W4 + QMAKE_CFLAGS_WARN_ON -= -W3 + QMAKE_CXXFLAGS_WARN_ON -= -W3 + QMAKE_CXXFLAGS += /W4 /wd4127 - QMAKE_CXXFLAGS += /WX - - #The MSVC frontend for clang does not understand /external !*clang-msvc{ - #external:anglebrackets suppresses warnings made in #includes - #made with angle brackets, like #include , but will - #still report for includes done with quotes. - QMAKE_CXXFLAGS += /experimental:external /external:anglebrackets + QMAKE_CXXFLAGS += /WX } }