├── openvr_api.dll ├── manifest.vrmanifest ├── LICENSE.txt ├── LICENSE-OpenVR.txt ├── README.md └── main.cpp /openvr_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elvissteinjr/SteamVR-PrimaryDesktopOverlay/HEAD/openvr_api.dll -------------------------------------------------------------------------------- /manifest.vrmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "source" : "builtin", 3 | "applications": [{ 4 | "app_key": "elvissteinjr.PrimaryDesktopOverlay", 5 | "launch_type": "binary", 6 | "binary_path_windows": "SteamVR-PrimaryDesktopOverlay.exe", 7 | "is_dashboard_overlay": true, 8 | 9 | "strings": { 10 | "en_us": { 11 | "name": "Primary Desktop Overlay", 12 | "description": "Primary Desktop Overlay" 13 | } 14 | } 15 | }] 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. -------------------------------------------------------------------------------- /LICENSE-OpenVR.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Valve Corporation 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | 3. Neither the name of the copyright holder nor the names of its contributors 15 | may be used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SteamVR-PrimaryDesktopOverlay 2 | Crops the Steam Desktop overlay in SteamVR to the content of the primary display. 3 | 4 | This is a crude but working proof-of-concept application that would love to be replaced by a highly polished and customizable solution in the future. 5 | 6 | # What it does 7 | - Crop the Steam Desktop overlay to your primary screen 8 | - Do so automatically on SteamVR launch after the first use 9 | 10 | # What it does not 11 | - Anything else 12 | 13 | # Usage 14 | Make sure SteamVR is running, then execute SteamVR-PrimaryDesktopOverlay.exe. 15 | 16 | SteamVR-PrimaryDesktopOverlay will register itself as an overlay application to SteamVR and run automatically on following SteamVR launches. If you move the files of this application you'll have to repeat the first-run steps. 17 | 18 | ## "My overlay is tiny, what do?" 19 | Use [OpenVR-AdvancedSettings](https://github.com/OpenVR-Advanced-Settings/OpenVR-AdvancedSettings/) to scale and position the desktop overlay to your liking. 20 | 21 | ## "My overlay isn't where it's supposed to be after launching SteamVR!" 22 | Click on the OpenVR-AdvancedSettings overlay to make it restore your desktop overlay settings once again. 23 | 24 | ## "My overlay is blocking all overlay buttons, I can't switch!" 25 | Bringing up the System menu (bottom left button) will hide all overlays, giving you a chance to access the overlay buttons. 26 | 27 | # Building 28 | Just compile main.cpp and link it with openvr_api.dll 29 | 30 | For example: g++ -o SteamVR-PrimaryDesktopOverlay.exe main.cpp openvr_api.dll 31 | 32 | # License 33 | SteamVR-PrimaryDesktopOverlay is licensed under WTFPL 2.0. 34 | 35 | Do what you want with it. 36 | 37 | For the OpenVR API header and library, see LICENSE-OpenVR.txt. -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /* This program is free software. It comes without any warranty, to 2 | * the extent permitted by applicable law. You can redistribute it 3 | * and/or modify it under the terms of the Do What The Fuck You Want 4 | * To Public License, Version 2, as published by Sam Hocevar. See 5 | * http://www.wtfpl.net/ for more details. */ 6 | 7 | #include //Could use iostream, but I want to the keep the executable small for no reason 8 | #include 9 | 10 | #define WIN32_LEAN_AND_MEAN 11 | #include 12 | #include "openvr.h" 13 | 14 | int main() 15 | { 16 | //Calculate UV for the primary screen 17 | 18 | //Primary Screen is always at virtual 0,0 19 | //If a screen is above or to the left of it, their coordinates are negative 20 | float primary_x = GetSystemMetrics(SM_XVIRTUALSCREEN) * -1; 21 | float primary_y = GetSystemMetrics(SM_YVIRTUALSCREEN) * -1; 22 | float primary_w = GetSystemMetrics(SM_CXSCREEN); 23 | float primary_h = GetSystemMetrics(SM_CYSCREEN); 24 | float total_w = GetSystemMetrics(SM_CXVIRTUALSCREEN); 25 | float total_h = GetSystemMetrics(SM_CYVIRTUALSCREEN); 26 | 27 | vr::VRTextureBounds_t tex_bounds; 28 | 29 | tex_bounds.uMin = primary_x / total_w; 30 | tex_bounds.vMin = primary_y / total_h; 31 | tex_bounds.uMax = tex_bounds.uMin + (primary_w / total_w); 32 | tex_bounds.vMax = tex_bounds.vMin + (primary_h / total_h); 33 | 34 | //Init OpenVR 35 | vr::EVRInitError vr_error; 36 | vr::IVRSystem* vr_system = vr::VR_Init(&vr_error, vr::VRApplication_Overlay); 37 | 38 | if (!vr_system) 39 | { 40 | printf("Failed to load OpenVR: %i", (int)vr_error); 41 | return -1; 42 | } 43 | 44 | //Register application so it will be launched automagically next time 45 | if (!vr::VRApplications()->IsApplicationInstalled("elvissteinjr.PrimaryDesktopOverlay")) 46 | { 47 | //This is supposed to be just a simple crude application, so we'll make due with this for getting the application path (this likely won't work on unicode paths) 48 | DWORD length = GetCurrentDirectory(0, NULL); 49 | char* path = new char[length]; 50 | length = GetCurrentDirectory(length, path); 51 | 52 | if (length != 0) 53 | { 54 | std::string path_str(path); 55 | path_str.append("\\manifest.vrmanifest"); 56 | 57 | vr::EVRApplicationError app_error; 58 | app_error = vr::VRApplications()->AddApplicationManifest(path_str.c_str()); 59 | 60 | if (app_error == vr::VRApplicationError_None) 61 | { 62 | vr::VRApplications()->SetApplicationAutoLaunch("elvissteinjr.PrimaryDesktopOverlay", true); 63 | } 64 | } 65 | 66 | delete[] path; 67 | } 68 | 69 | //Look for Steam's Desktop overlay 70 | int tries = 0; 71 | vr::VROverlayHandle_t overlay_handle; 72 | vr::EVROverlayError overlay_error; 73 | overlay_error = vr::VROverlay()->FindOverlay("valve.steam.desktop", &overlay_handle); 74 | 75 | //If we can't find the overlay yet, keep trying for a minute every second 76 | while ( (overlay_error != vr::VROverlayError_None) && (tries < 60) ) 77 | { 78 | Sleep(1000); 79 | tries++; 80 | overlay_error = vr::VROverlay()->FindOverlay("valve.steam.desktop", &overlay_handle); 81 | } 82 | 83 | if (overlay_error == vr::VROverlayError_None) 84 | { 85 | //Set the previously calculated UV coordinates and hope it works 86 | vr::VROverlay()->SetOverlayTextureBounds(overlay_handle, &tex_bounds); 87 | 88 | if (overlay_error != vr::VROverlayError_None) 89 | { 90 | //Guess it didn't... 91 | printf("Error setting bounds: %i", (int)overlay_error); 92 | } 93 | } 94 | 95 | vr::VR_Shutdown(); 96 | 97 | return 0; 98 | } 99 | --------------------------------------------------------------------------------