diff --git a/OpenVR Display Devices/OpenVR Display Devices.rc b/OpenVR Display Devices/OpenVR Display Devices.rc new file mode 100644 index 0000000..87fdcef Binary files /dev/null and b/OpenVR Display Devices/OpenVR Display Devices.rc differ diff --git a/OpenVR Display Devices/OpenVR Display Devices.vcxproj b/OpenVR Display Devices/OpenVR Display Devices.vcxproj index e5a01ac..531fbbd 100644 --- a/OpenVR Display Devices/OpenVR Display Devices.vcxproj +++ b/OpenVR Display Devices/OpenVR Display Devices.vcxproj @@ -135,6 +135,9 @@ true ..\3rdparty\WinToast\include;..\3rdparty\simpleini;..\3rdparty\imgui\backends;..\3rdparty\imgui;..\3rdparty\openvr\headers;..\3rdparty\gl3w\include;..\3rdparty\glfw\include;..\3rdparty\PlatformFolders\sago;%(AdditionalIncludeDirectories) stdcpp20 + true + Speed + true Windows @@ -143,6 +146,7 @@ true ..\3rdparty\glfw\lib-vc2022;..\3rdparty\openvr\lib\win64;%(AdditionalLibraryDirectories) opengl32.lib;glfw3.lib;openvr_api.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration @@ -169,6 +173,7 @@ + @@ -184,9 +189,26 @@ + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/OpenVR Display Devices/OpenVR Display Devices.vcxproj.filters b/OpenVR Display Devices/OpenVR Display Devices.vcxproj.filters index 1d90520..0faab5f 100644 --- a/OpenVR Display Devices/OpenVR Display Devices.vcxproj.filters +++ b/OpenVR Display Devices/OpenVR Display Devices.vcxproj.filters @@ -101,6 +101,9 @@ Fichiers d%27en-tête + + Fichiers d%27en-tête + @@ -115,5 +118,19 @@ + + + + + Fichiers de ressources + + + + + Fichiers de ressources + + + Fichiers de ressources + \ No newline at end of file diff --git a/OpenVR Display Devices/OpenVR-Display-Devices.cpp b/OpenVR Display Devices/OpenVR-Display-Devices.cpp index 580953c..128f0aa 100644 --- a/OpenVR Display Devices/OpenVR-Display-Devices.cpp +++ b/OpenVR Display Devices/OpenVR-Display-Devices.cpp @@ -32,8 +32,10 @@ double lastFrameStartTime = glfwGetTime(); #pragma comment(linker,"\"/manifestdependency:type='win32' \ name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; -extern "C" __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001; +//extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; +//extern "C" __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001; + +//extern void ActivateMultipleDrivers(); void CreateConsole() { static bool created = false; @@ -66,6 +68,8 @@ void InitVR() { } else if (!vr::VR_IsInterfaceVersionValid(vr::IVROverlay_Version)) { throw std::runtime_error("OpenVR error: Outdated IVROverlay_Version"); } + + //ActivateMultipleDrivers(); } void CreateGLFWWindow() { @@ -77,7 +81,7 @@ void CreateGLFWWindow() { fboTextureWidth = 1600; fboTextureHeight = 800; - glfwWindow = glfwCreateWindow(fboTextureWidth, fboTextureHeight, "OpenVR-Display-Devices", NULL, NULL); + glfwWindow = glfwCreateWindow(fboTextureWidth, fboTextureHeight, OPENVR_APPLICATION_NAME/*"OpenVR-Display-Devices"*/, NULL, NULL); if (!glfwWindow) { throw std::runtime_error("Failed to create window"); } @@ -87,9 +91,9 @@ void CreateGLFWWindow() { gl3wInit(); // Minimize the window on start if enabled -#ifndef _DEBUG - glfwIconifyWindow(glfwWindow); -#endif +//#ifndef _DEBUG + //glfwIconifyWindow(glfwWindow); +//#endif ImGui::CreateContext(); ImGuiIO &io = ImGui::GetIO(); @@ -121,6 +125,75 @@ void CreateGLFWWindow() { } } +extern BatteryChecker batteryChecker; +std::string overlayThumbnailCurrent = ""; + +void UpdateOverlayIcon() { + if (!vr::VROverlay() || !overlayThumbnailHandle) + { + return; + } + + std::string iconPath = cwd; + + if (batteryChecker.hmdCharging) + { + if (batteryChecker.hmdCharge > 80) + { + iconPath += "\\icons\\c100.png"; + } + else if (batteryChecker.hmdCharge > 60) + { + iconPath += "\\icons\\c80.png"; + } + else if (batteryChecker.hmdCharge > 40) + { + iconPath += "\\icons\\c60.png"; + } + else if (batteryChecker.hmdCharge > 20) + { + iconPath += "\\icons\\c40.png"; + } + else + { + iconPath += "\\icons\\c20.png"; + } + } + else + { + if (batteryChecker.hmdCharge > 80) + { + iconPath += "\\icons\\100.png"; + } + else if (batteryChecker.hmdCharge > 60) + { + iconPath += "\\icons\\80.png"; + } + else if (batteryChecker.hmdCharge > 40) + { + iconPath += "\\icons\\60.png"; + } + else if (batteryChecker.hmdCharge > 20) + { + iconPath += "\\icons\\40.png"; + } + else + { + iconPath += "\\icons\\20.png"; + } + } + + if (overlayThumbnailCurrent == iconPath.c_str()) + {// Unchanged... + return; + } + + //printf("icon : %s\n", iconPath.c_str()); + vr::VROverlay()->ClearOverlayTexture(overlayThumbnailHandle); + vr::VROverlay()->SetOverlayFromFile(overlayThumbnailHandle, iconPath.c_str()); + overlayThumbnailCurrent = iconPath.c_str(); +} + void TryCreateVROverlay() { if (overlayMainHandle || !vr::VROverlay()) { return; @@ -139,10 +212,35 @@ void TryCreateVROverlay() { vr::VROverlay()->SetOverlayWidthInMeters(overlayMainHandle, 3.0f); vr::VROverlay()->SetOverlayInputMethod(overlayMainHandle, vr::VROverlayInputMethod_Mouse); vr::VROverlay()->SetOverlayFlag(overlayMainHandle, vr::VROverlayFlags_SendVRDiscreteScrollEvents, true); - - // can set icon here but idc lol + UpdateOverlayIcon(); } +/*void ActivateMultipleDrivers() { + vr::EVRSettingsError vrSettingsError; + bool enabled = vr::VRSettings()->GetBool(vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool, &vrSettingsError); + + if (vrSettingsError != vr::VRSettingsError_None) { + std::string err = "Could not read \"" + std::string(vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool) + "\" setting: " + + vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + + throw std::runtime_error(err); + } + + if (!enabled) { + vr::VRSettings()->SetBool(vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool, true, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + std::string err = "Could not set \"" + std::string(vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool) + "\" setting: " + + vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + + throw std::runtime_error(err); + } + + std::cerr << "Enabled \"" << vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool << "\" setting" << std::endl; + } else { + std::cerr << "\"" << vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool << "\" setting previously enabled" << std::endl; + } +}*/ + void RunLoop() { while (!glfwWindowShouldClose(glfwWindow)) { TryCreateVROverlay(); @@ -154,7 +252,7 @@ void RunLoop() { if (overlayMainHandle && vr::VROverlay()) { auto &io = ImGui::GetIO(); - dashboardVisible = vr::VROverlay()->IsActiveDashboardOverlay(overlayMainHandle); + dashboardVisible = vr::VROverlay()->IsActiveDashboardOverlay(overlayMainHandle) || vr::VROverlay()->IsDashboardVisible(); vr::VREvent_t vrEvent; while (vr::VROverlay()->PollNextOverlayEvent(overlayMainHandle, &vrEvent, sizeof(vrEvent))) { @@ -180,7 +278,8 @@ void RunLoop() { } } - if (windowVisible || dashboardVisible) { + //if (windowVisible || dashboardVisible) + { auto &io = ImGui::GetIO(); io.DisplaySize = ImVec2((float)fboTextureWidth, (float)fboTextureHeight); io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f); @@ -189,6 +288,7 @@ void RunLoop() { if (dashboardVisible) { io.ConfigFlags = io.ConfigFlags | ImGuiConfigFlags_NoMouseCursorChange; } + ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); @@ -215,21 +315,39 @@ void RunLoop() { if (dashboardVisible) { vr::Texture_t vrTex; vrTex.eType = vr::TextureType_OpenGL; - vrTex.eColorSpace = vr::ColorSpace_Auto; + //vrTex.eColorSpace = vr::ColorSpace_Auto; + vrTex.eColorSpace = vr::ColorSpace_Linear; vrTex.handle = (void *) #if defined _WIN64 || defined _LP64 (uint64_t) #endif fboTextureHandle; + - vr::HmdVector2_t mouseScale = { (float)fboTextureWidth, (float)fboTextureHeight }; + //vrTex.handle = reinterpret_cast(static_cast(fboTextureHandle)); + vr::VROverlay()->ClearOverlayTexture(overlayMainHandle); vr::VROverlay()->SetOverlayTexture(overlayMainHandle, &vrTex); + //vr::VROverlay()->SetOverlayAlpha(overlayMainHandle, 1.0f); + + //vr::VROverlay()->ClearOverlayTexture(overlayMainHandle); + //vr::VROverlay()->SetOverlayFromFile(overlayMainHandle, overlayThumbnailCurrent.c_str()); + + /*vr::Texture_t texture = {(void *)(uintptr_t)&fboTextureHandle, vr::TextureType_OpenGL, vr::ColorSpace_Auto}; + vr::VROverlay()->SetOverlayTexture(overlayMainHandle, &texture);*/ + + vr::HmdVector2_t mouseScale = { (float)fboTextureWidth, (float)fboTextureHeight }; vr::VROverlay()->SetOverlayMouseScale(overlayMainHandle, &mouseScale); + + //printf("Overlay set to texture %I64u. Resolution %i x %i.\n", (uint64_t)vrTex.handle, fboTextureWidth, fboTextureHeight); } } + if (vr::VROverlay()->IsDashboardVisible()) { + UpdateOverlayIcon(); + } + const double dashboardInterval = 1.0 / 90.0; // fps double waitEventsTimeout = std::max(UPDATE_INTERVAL, dashboardInterval); @@ -341,8 +459,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance // Load config then do post-config setup if needed loadOrInitConfiguration(application_configuration); - if (application_configuration.notificationsWindows) { - enableWindowsNotifications(); + if (application_configuration.notificationsSound) { + enableSoundNotifications(); } if (application_configuration.notificationsXsOverlay) { enableXsOverlayNotifications(); @@ -353,8 +471,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance } RunLoop(); - if (application_configuration.notificationsWindows) { - disableWindowsNotifications(); + if (application_configuration.notificationsSound) { + disableSoundNotifications(); } if (application_configuration.notificationsXsOverlay) { disableXsOverlayNotifications(); diff --git a/OpenVR Display Devices/battery_checker.h b/OpenVR Display Devices/battery_checker.h index 925a218..0d01b8b 100644 --- a/OpenVR Display Devices/battery_checker.h +++ b/OpenVR Display Devices/battery_checker.h @@ -8,11 +8,11 @@ #include // Should be plenty sufficient... -#define BATCHECK_MAX_INDEXES 20 +#define BATCHECK_MAX_INDEXES 50 // Every five minutes -#define BATCHECK_CHECK_EVERY 5 * 60 -// Every 10s -#define BATCHECK_CHECK_CHG_EVERY 10 +#define BATCHECK_CHECK_EVERY 10 //5 * 60 +// Every 10s - uq: 5 secs +#define BATCHECK_CHECK_CHG_EVERY 5 class BatteryChecker { private: @@ -38,34 +38,34 @@ class BatteryChecker { } void dispatchLowNotification(int index) { - std::string title = "Low tracker battery !"; - std::string content = std::format("Tracker {} is low on battery: {}%", gaugesNames[index], gauges[index]).c_str(); + std::string title = "Low battery!"; + std::string content = std::format("Device {} is low on battery: {}%", gaugesNames[index], gauges[index]).c_str(); - std::cout << "LOW battery for tracker '" << gaugesNames[index] << "' id " << index << " level: " << gauges[index] << std::endl; + std::cout << "LOW battery for device '" << gaugesNames[index] << "' id " << index << " level: " << gauges[index] << std::endl; sendNotification(title, content); } void dispatchWarnNotification(int index) { - std::string title = "Tracker battery warning !"; - std::string content = std::format("Tracker {} battery warning: {}%", gaugesNames[index], gauges[index]).c_str(); + std::string title = "Battery warning!"; + std::string content = std::format("Device {} battery warning: {}%", gaugesNames[index], gauges[index]).c_str(); - std::cout << "WARN battery for tracker '" << gaugesNames[index] << "' id " << index << " level: " << gauges[index] << std::endl; + std::cout << "WARN battery for device '" << gaugesNames[index] << "' id " << index << " level: " << gauges[index] << std::endl; sendNotification(title, content); } void dispatchSlowChargeNotification(int index) { - std::string title = "Slow charge tracker battery !"; - std::string content = std::format("Tracker {} charging too slowly ! {}%", gaugesNames[index], gauges[index]).c_str(); + std::string title = "Slow charge battery!"; + std::string content = std::format("Device {} is charging too slowly ! {}%", gaugesNames[index], gauges[index]).c_str(); - std::cout << "WARN charging too slow for tracker '" << gaugesNames[index] << "' id " << index << " level: " << gauges[index] << std::endl; + std::cout << "WARN charging too slow for device '" << gaugesNames[index] << "' id " << index << " level: " << gauges[index] << std::endl; sendNotification(title, content); } void dispatchChargeWarn(int index) { std::string title, content; if (gaugesCharging[index]) { - title = "HMD is now charging"; - content = std::format("HMD is now charging"); + title = "Headset is now charging"; + content = std::format(""); } else { - title = "HMD not charging !"; - content = std::format("WOOP WOOP PLS CHECK CABLE"); + title = "Headset is not charging!"; + content = std::format("Check the headset battery."); } std::cout << "HMD Charge changed from " << gaugesChargingPrev[index] << " to " << gaugesCharging[index] << std::endl; @@ -85,6 +85,9 @@ class BatteryChecker { ~BatteryChecker() { }; + bool hmdCharging = false; + int hmdCharge = 0; + void updateGauge(int index, int value, std::string role, bool charging) { // Set previous value with current value gaugesPrev[index] = gauges[index]; @@ -153,6 +156,13 @@ class BatteryChecker { } } + if (isHmd) + {// Update global-accessable value so we can update the icon for charing and charge level... + hmdCharging = gaugesCharging[index]; + hmdCharge = gauges[index]; + } + + // Do nothing as we still haven't waited enough } }; diff --git a/OpenVR Display Devices/config.h b/OpenVR Display Devices/config.h index 09fbbb5..94958d5 100644 --- a/OpenVR Display Devices/config.h +++ b/OpenVR Display Devices/config.h @@ -1,7 +1,9 @@ #pragma once // lol +#ifndef UNICODE #define UNICODE +#endif // To avoid windows.h to redefine min() and max() #define NOMINMAX diff --git a/OpenVR Display Devices/configuration.cpp b/OpenVR Display Devices/configuration.cpp index 0e96487..9fd4677 100644 --- a/OpenVR Display Devices/configuration.cpp +++ b/OpenVR Display Devices/configuration.cpp @@ -41,9 +41,9 @@ void loadOrInitConfiguration(AppConfig &app_cfg) { // Then set the struct from config app_cfg.alertLowBattery = cfgIni.GetBoolValue("battery_alert", "alert_low_on_battery", false, nullptr); app_cfg.alertHmdCycling = cfgIni.GetBoolValue("battery_alert", "alert_hmd_cycling", false, nullptr); - app_cfg.batteryWarn = cfgIni.GetDoubleValue("battery_alert", "battery_warn", 50, nullptr); - app_cfg.batteryLow = cfgIni.GetDoubleValue("battery_alert", "battery_low", 20, nullptr); - app_cfg.notificationsWindows = cfgIni.GetBoolValue("notifications", "notifications_windows", false, nullptr); + app_cfg.batteryWarn = (float)cfgIni.GetDoubleValue("battery_alert", "battery_warn", 50, nullptr); + app_cfg.batteryLow = (float)cfgIni.GetDoubleValue("battery_alert", "battery_low", 20, nullptr); + app_cfg.notificationsSound = cfgIni.GetBoolValue("notifications", "notifications_windows", false, nullptr); app_cfg.notificationsXsOverlay = cfgIni.GetBoolValue("notifications", "notifications_xsoverlay", false, nullptr); // Then set the config to the loaded state @@ -71,8 +71,8 @@ void saveConfiguration(AppConfig &cfg) { if (cfgIni.SetDoubleValue("battery_alert", "battery_low", cfg.batteryLow) < 0) { throw std::runtime_error("Cannot save batteryLow to config"); } - if (cfgIni.SetBoolValue("notifications", "notifications_windows", cfg.notificationsWindows) < 0) { - throw std::runtime_error("Cannot save notificationsWindows to config"); + if (cfgIni.SetBoolValue("notifications", "notifications_windows", cfg.notificationsSound) < 0) { + throw std::runtime_error("Cannot save notificationsSound to config"); } if (cfgIni.SetBoolValue("notifications", "notifications_xsoverlay", cfg.notificationsXsOverlay) < 0) { throw std::runtime_error("Cannot save notificationsXsOverlay to config"); diff --git a/OpenVR Display Devices/configuration.h b/OpenVR Display Devices/configuration.h index 86bff59..1364b52 100644 --- a/OpenVR Display Devices/configuration.h +++ b/OpenVR Display Devices/configuration.h @@ -20,7 +20,7 @@ struct AppConfig { bool alertHmdCycling = false; // Config section notifications - bool notificationsWindows = false; // not implemented yet + bool notificationsSound = false; // not implemented yet bool notificationsXsOverlay = false; }; diff --git a/OpenVR Display Devices/icon1.ico b/OpenVR Display Devices/icon1.ico new file mode 100644 index 0000000..5d06b9f Binary files /dev/null and b/OpenVR Display Devices/icon1.ico differ diff --git a/OpenVR Display Devices/notifications.cpp b/OpenVR Display Devices/notifications.cpp index 1eb6b4b..243e5d3 100644 --- a/OpenVR Display Devices/notifications.cpp +++ b/OpenVR Display Devices/notifications.cpp @@ -1,8 +1,9 @@ #include "notifications.h" +#include -Webchaussette wsClient(XSOVERLAY_WS_HOST, XSOVERLAY_WS_PORT, XSOVERLAY_WS_QUERY); +//Webchaussette wsClient(XSOVERLAY_WS_HOST, XSOVERLAY_WS_PORT, XSOVERLAY_WS_QUERY); -void enableWindowsNotifications() { +void enableSoundNotifications() { if (!WinToastLib::WinToast::isCompatible()) { throw std::runtime_error("System incompatible :("); } @@ -13,24 +14,25 @@ void enableWindowsNotifications() { throw std::runtime_error("Woops, error when initializing the WinToaster"); } - std::string title = "Test notification"; + /*std::string title = "Test notification"; std::string content = "nya~ :3"; - sendNativeNotification(title, content); - std::cout << "Enabled toaster notifications" << std::endl; + sendSoundNotifications(title, content); + std::cout << "Enabled toaster notifications" << std::endl;*/ } -void disableWindowsNotifications() { +void disableSoundNotifications() { // Nothing to do here } void enableXsOverlayNotifications() { - wsClient.Start(); + /*wsClient.Start(); std::string title = "Test notification"; std::string content = "nya~ :3"; sendXsOverlayNotification(title, content); std::cout << "Enabled XSOverlay notifications" << std::endl; + */ } std::string buildXsOverlayJson(std::string title, std::string content) { @@ -58,15 +60,28 @@ std::string buildXsOverlayJson(std::string title, std::string content) { } void disableXsOverlayNotifications() { - wsClient.Stop(); + //wsClient.Stop(); } std::wstring charToWstring(const char *src) { return std::wstring(src, src + strlen(src)); } -void sendNativeNotification(std::string &title, std::string &msg) { - WinToastLib::WinToastTemplate::AudioOption audioOptions = WinToastLib::WinToastTemplate::AudioOption::Default; +wchar_t *CharToWchar(const char *str) { + int lenW, lenA = lstrlenA(str); + wchar_t *unicodestr; + + lenW = MultiByteToWideChar(CP_ACP, 0, str, lenA, NULL, 0); + if (lenW > 0) { + unicodestr = SysAllocStringLen(0, lenW); + MultiByteToWideChar(CP_ACP, 0, str, lenA, unicodestr, lenW); + return unicodestr; + } + return NULL; +} + +void sendSoundNotifications(std::string &title, std::string &msg) { + /*WinToastLib::WinToastTemplate::AudioOption audioOptions = WinToastLib::WinToastTemplate::AudioOption::Default; WinToastLib::WinToastTemplate templ(WinToastLib::WinToastTemplate::Text02); // Title @@ -77,18 +92,51 @@ void sendNativeNotification(std::string &title, std::string &msg) { // templ.setExpiration(5); if (WinToastLib::WinToast::instance()->showToast(templ, new CustomHandler()) < 0) { throw std::runtime_error("Woops, cannot toast :("); + }*/ + + ISpVoice *pVoice = NULL; + + /*if (FAILED(::CoInitialize(NULL))) { + std::cout << "SAPI failed to initialize." << std::endl; + return; + }*/ + + //std::string speakText = title + "\n\n" + msg; + std::string speakText = title; + + HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice); + if (SUCCEEDED(hr)) { + //hr = pVoice->Speak(L"Hello world", 0, NULL); + //hr = pVoice->Speak(speakText.c_str(), 0, NULL); + + /*wchar_t *wtext; + wtext = malloc(speakText.length() * sizeof(wchar_t)); + mbstowcs(wtext, speakText.c_str(), speakText.length());//includes null + LPWSTR ptr = wtext; + hr = pVoice->Speak(ptr, 0, NULL); + free(wtext); + */ + wchar_t *text = CharToWchar(speakText.c_str()); + hr = pVoice->Speak(text, 0, NULL); + + pVoice->Release(); + pVoice = NULL; + } + else + { + std::cout << "SAPI failed to create instance." << std::endl; } } void sendXsOverlayNotification(std::string &title, std::string &msg) { std::string jmsg = buildXsOverlayJson(title, msg); - wsClient.Send(jmsg); + //wsClient.Send(jmsg); } void sendNotification(std::string &title, std::string &msg) { - if (application_configuration.notificationsWindows) { + if (application_configuration.notificationsSound) { std::cout << "SN: " << title << std::endl; - sendNativeNotification(title, msg); + sendSoundNotifications(title, msg); } if (application_configuration.notificationsXsOverlay) { sendXsOverlayNotification(title, msg); diff --git a/OpenVR Display Devices/notifications.h b/OpenVR Display Devices/notifications.h index d5009d9..db56ccd 100644 --- a/OpenVR Display Devices/notifications.h +++ b/OpenVR Display Devices/notifications.h @@ -9,9 +9,13 @@ #include #include -#define XSOVERLAY_WS "ws://localhost:42070/?client=OVRDisplayDevices" +/*#define XSOVERLAY_WS "ws://localhost:42070/?client=OVRDisplayDevices" #define XSOVERLAY_WS_HOST "localhost" #define XSOVERLAY_WS_PORT 42070 +#define XSOVERLAY_WS_QUERY "?client=OVRDisplayDevices"*/ +#define XSOVERLAY_WS "ws://localhost:12070/?client=OVRDisplayDevices" +#define XSOVERLAY_WS_HOST "localhost" +#define XSOVERLAY_WS_PORT 12070 #define XSOVERLAY_WS_QUERY "?client=OVRDisplayDevices" #include @@ -48,11 +52,11 @@ class CustomHandler : public WinToastLib::IWinToastHandler { } }; -void enableWindowsNotifications(); -void disableWindowsNotifications(); +void enableSoundNotifications(); +void disableSoundNotifications(); void enableXsOverlayNotifications(); void disableXsOverlayNotifications(); void sendNotification(std::string &title, std::string &msg); void sendXsOverlayNotification(std::string &title, std::string &msg); -void sendNativeNotification(std::string &title, std::string &msg); +void sendSoundNotifications(std::string &title, std::string &msg); std::string buildXsOverlayJson(std::string title, std::string content); diff --git a/OpenVR Display Devices/packages.config b/OpenVR Display Devices/packages.config new file mode 100644 index 0000000..7be85a0 --- /dev/null +++ b/OpenVR Display Devices/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OpenVR Display Devices/resource.h b/OpenVR Display Devices/resource.h new file mode 100644 index 0000000..cc1499e --- /dev/null +++ b/OpenVR Display Devices/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by OpenVR Display Devices.rc +// +#define IDI_ICON1 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/OpenVR Display Devices/user_interface.cpp b/OpenVR Display Devices/user_interface.cpp index f40fb67..157242b 100644 --- a/OpenVR Display Devices/user_interface.cpp +++ b/OpenVR Display Devices/user_interface.cpp @@ -4,9 +4,9 @@ static bool runningInOverlay; static const ImGuiWindowFlags bareWindowFlags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | -ImGuiWindowFlags_NoMove | +ImGuiWindowFlags_NoMove /* | ImGuiWindowFlags_NoScrollbar | -ImGuiWindowFlags_NoScrollWithMouse | +ImGuiWindowFlags_NoScrollWithMouse*/ | ImGuiWindowFlags_NoCollapse; BatteryChecker batteryChecker; @@ -112,7 +112,7 @@ void Show_StatusTable() { if (pError != vr::TrackedProp_Success && pError != vr::TrackedProp_UnknownProperty) { wchar_t message[1024]; - swprintf(message, 1024, L"Could not get Prop_ControllerType of device %i: %s", i, vr::VRSystem()->GetPropErrorNameFromEnum(pError)); + swprintf(message, 1024, L"Could not get Prop_ControllerType of device %i: %s", i, (wchar_t*)vr::VRSystem()->GetPropErrorNameFromEnum(pError)); MessageBox(nullptr, message, L"Runtime Error", 0); } @@ -121,7 +121,7 @@ void Show_StatusTable() { vr::VRSystem()->GetStringTrackedDeviceProperty(i, vr::Prop_SerialNumber_String, serialBuffer, vr::k_unMaxPropertyStringSize, &pError); if (pError != vr::TrackedProp_Success && pError != vr::TrackedProp_UnknownProperty) { wchar_t message[1024]; - swprintf(message, 1024, L"Could not get Prop_SerialNumber of device %i: %s", i, vr::VRSystem()->GetPropErrorNameFromEnum(pError)); + swprintf(message, 1024, L"Could not get Prop_SerialNumber of device %i: %s", i, (wchar_t *)vr::VRSystem()->GetPropErrorNameFromEnum(pError)); MessageBox(nullptr, message, L"Runtime Error", 0); } @@ -129,20 +129,20 @@ void Show_StatusTable() { float deviceBatteryPercent = vr::VRSystem()->GetFloatTrackedDeviceProperty(i, vr::Prop_DeviceBatteryPercentage_Float, &pError); if (pError != vr::TrackedProp_Success && pError != vr::TrackedProp_UnknownProperty) { wchar_t message[1024]; - swprintf(message, 1024, L"Could not get Prop_DeviceBatteryPercentage of device %i: %s", i, vr::VRSystem()->GetPropErrorNameFromEnum(pError)); + swprintf(message, 1024, L"Could not get Prop_DeviceBatteryPercentage of device %i: %s", i, (wchar_t *)vr::VRSystem()->GetPropErrorNameFromEnum(pError)); MessageBox(nullptr, message, L"Runtime Error", 0); } bool deviceIsCharging = vr::VRSystem()->GetBoolTrackedDeviceProperty(i, vr::Prop_DeviceIsCharging_Bool, &pError); if (pError != vr::TrackedProp_Success && pError != vr::TrackedProp_UnknownProperty) { wchar_t message[1024]; - swprintf(message, 1024, L"Could not get Prop_DeviceIsCharging of device %i: %s", i, vr::VRSystem()->GetPropErrorNameFromEnum(pError)); + swprintf(message, 1024, L"Could not get Prop_DeviceIsCharging of device %i: %s", i, (wchar_t *)vr::VRSystem()->GetPropErrorNameFromEnum(pError)); MessageBox(nullptr, message, L"Runtime Error", 0); } // Fill the state std::string role = roleBuffer; - batteryChecker.updateGauge(i, deviceBatteryPercent * 100, role, deviceIsCharging); + batteryChecker.updateGauge(i, (int)(deviceBatteryPercent * 100.0f), role, deviceIsCharging); // Then check the status batteryChecker.checkGaugeAndDispatchNotifications(i, (deviceClass == vr::TrackedDeviceClass_HMD)); @@ -151,21 +151,21 @@ void Show_StatusTable() { vr::VRSystem()->GetStringTrackedDeviceProperty(i, vr::Prop_ManufacturerName_String, manufacturerBuffer, vr::k_unMaxPropertyStringSize, &pError); if (pError != vr::TrackedProp_Success && pError != vr::TrackedProp_UnknownProperty) { wchar_t message[1024]; - swprintf(message, 1024, L"Could not get Prop_ManufacturerName of device %i: %s", i, vr::VRSystem()->GetPropErrorNameFromEnum(pError)); + swprintf(message, 1024, L"Could not get Prop_ManufacturerName of device %i: %s", i, (wchar_t *)vr::VRSystem()->GetPropErrorNameFromEnum(pError)); MessageBox(nullptr, message, L"Runtime Error", 0); } char modelNumberBuffer[vr::k_unMaxPropertyStringSize] = ""; vr::VRSystem()->GetStringTrackedDeviceProperty(i, vr::Prop_ModelNumber_String, modelNumberBuffer, vr::k_unMaxPropertyStringSize, &pError); if (pError != vr::TrackedProp_Success && pError != vr::TrackedProp_UnknownProperty) { wchar_t message[1024]; - swprintf(message, 1024, L"Could not get Prop_ModelNumber of device %i: %s", i, vr::VRSystem()->GetPropErrorNameFromEnum(pError)); + swprintf(message, 1024, L"Could not get Prop_ModelNumber of device %i: %s", i, (wchar_t *)vr::VRSystem()->GetPropErrorNameFromEnum(pError)); MessageBox(nullptr, message, L"Runtime Error", 0); } char trackingSystemBuffer[vr::k_unMaxPropertyStringSize] = ""; vr::VRSystem()->GetStringTrackedDeviceProperty(i, vr::Prop_TrackingSystemName_String, trackingSystemBuffer, vr::k_unMaxPropertyStringSize, &pError); if (pError != vr::TrackedProp_Success && pError != vr::TrackedProp_UnknownProperty) { wchar_t message[1024]; - swprintf(message, 1024, L"Could not get Prop_TrackingSystemName of device %i: %s", i, vr::VRSystem()->GetPropErrorNameFromEnum(pError)); + swprintf(message, 1024, L"Could not get Prop_TrackingSystemName of device %i: %s", i, (wchar_t *)vr::VRSystem()->GetPropErrorNameFromEnum(pError)); MessageBox(nullptr, message, L"Runtime Error", 0); } @@ -269,11 +269,11 @@ void Show_Settings() { } ImGui::NewLine(); - if (ImGui::Checkbox("Windows notifications", &application_configuration.notificationsWindows)) { - if (application_configuration.notificationsWindows) { - enableWindowsNotifications(); + if (ImGui::Checkbox("Sound notifications", &application_configuration.notificationsSound)) { + if (application_configuration.notificationsSound) { + enableSoundNotifications(); } else { - disableWindowsNotifications(); + disableSoundNotifications(); } saveConfiguration(application_configuration); } @@ -296,7 +296,7 @@ void Show_Settings() { ImGui::SameLine(0, 1 * ImGui::GetStyle().ItemSpacing.x + 100); if (ImGui::Button("Test notifications", ImVec2(0, 0))) { std::string title = "Test notification"; - std::string content = "nya nya nya~"; + std::string content = ""; sendNotification(title, content); } } diff --git a/icon.ico b/icon.ico new file mode 100644 index 0000000..b35f15a Binary files /dev/null and b/icon.ico differ diff --git a/icons/100.png b/icons/100.png new file mode 100644 index 0000000..7d07f90 Binary files /dev/null and b/icons/100.png differ diff --git a/icons/20.png b/icons/20.png new file mode 100644 index 0000000..5e25ce8 Binary files /dev/null and b/icons/20.png differ diff --git a/icons/40.png b/icons/40.png new file mode 100644 index 0000000..9391fe6 Binary files /dev/null and b/icons/40.png differ diff --git a/icons/60.png b/icons/60.png new file mode 100644 index 0000000..b58e5e3 Binary files /dev/null and b/icons/60.png differ diff --git a/icons/80.png b/icons/80.png new file mode 100644 index 0000000..12d3736 Binary files /dev/null and b/icons/80.png differ diff --git a/icons/c100.png b/icons/c100.png new file mode 100644 index 0000000..51131e7 Binary files /dev/null and b/icons/c100.png differ diff --git a/icons/c20.png b/icons/c20.png new file mode 100644 index 0000000..b7e8652 Binary files /dev/null and b/icons/c20.png differ diff --git a/icons/c40.png b/icons/c40.png new file mode 100644 index 0000000..f0afc44 Binary files /dev/null and b/icons/c40.png differ diff --git a/icons/c60.png b/icons/c60.png new file mode 100644 index 0000000..51a1cbf Binary files /dev/null and b/icons/c60.png differ diff --git a/icons/c80.png b/icons/c80.png new file mode 100644 index 0000000..7c755fb Binary files /dev/null and b/icons/c80.png differ