#ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif #pragma once #include #include #include #include #include #define GLFW_EXPOSE_NATIVE_WIN32 #include #include #include "imgui_internal.h" #include #include #include #include "firmware_update.h" #include "error_logging.h" #include "tex_loader.h" #include #define WM_SYSTRAY_MENU WM_APP enum class Crash_Log_State { Begin, WaitingMemoryDump, Done }; enum class Refresh_Rate { _75hz, _90hz, _72hz }; enum class SteamVR_Warned_Settings { MotionSmoothing, SuperSampleValue, SuperSampleAuto, DisplayIdle, PauseVR, GPUProfiling, GPUBusMonitoring }; enum class Page_Type { Home, Advanced, VRSettings }; enum class Warning_State { None, SteamVR, NoCamera }; enum class Locales { None, En, Jp, Max }; struct SteamVR_Flagged_Setting { std::string title; // User-friendly name (often the same name seen in the SteamVR settings window) std::string description; // User-friendly description of the setting and the potential issue that comes with it std::string json_category; // The json category containing the setting std::string steamvr_setting; // The setting name which is used in the JSON std::string steamvr_flag_value; // Intended value to look for, or the number threshold that the setting is greater than (or less than which is determined below) bool number_value_greater; // Check if greater, otherwise check less than bool check_absence; // Flag the setting if it does not exist in the SteamVR settings. This would mean the default value is problematic }; struct Warning_Banner { std::string title; std::string button_text; }; struct Lang_Setting { std::string flag_path; std::string font_path; int font_size; int header_size; }; // Stack saved variables in the ::run() method // Easy to pass a ref to this struct when calling // ui subfunctions rather than a loooong list of args struct UI_Run_State { firmware_update fw; Page_Type current_page; Warning_State active_warning; std::string pending_popup; // Some default strings std::wstring steamvr_path = L"C:\\Program Files (x86)\\Steam\\steamapps\\common\\SteamVR"; std::wstring steamvr_settings_file; std::wstring steam_config_path; std::wstring exe_path; std::wstring settings_path = L"beyond_settings.json"; std::wstring firmware_contents_path = L"latest.beyondfw"; std::wstring dfu_firmware_path = L"eyetracking_firm.dfu"; std::wstring config_memory_backup_path = L"headset_memory_backup"; std::wstring lighthouse_restore_path = L""; std::wstring memory_restore_path = L""; Refresh_Rate current_refresh_rate = Refresh_Rate::_75hz; const std::map< Refresh_Rate, std::string> refresh_rates = { {Refresh_Rate::_75hz, "75hz"}, {Refresh_Rate::_90hz, "90hz"}, {Refresh_Rate::_72hz, "72hz"} }; float color[3] = { 0.0f, 0.0f, 1.0f }; // RGB LED color int slider_brightness = 100; int brightness = 100; // OLED display brightness (normal mode) int overdrive_brightness = 125; // OLED display brightness (in overdrive mode) float overdrive_split_pos = 200.0f; // initial guess at slider width. will be corrected on 2nd displayed frame of UI run int fan_speed = 80; int adjusted_ipd = 64; int applied_ipd = 64; int prox_offset = 0; bool vxr_auto_off = false; bool overdrive = false; bool launching_bootloader = false; bool opened_folder_select = false; std::wstring error_log_file_name; bool first_time_in_bootloader = true; bool first_time_in_crashhandler = true; Crash_Log_State cl_state = Crash_Log_State::Begin; int cl_mem_num = 0; bool firmware_update_requested = false; bool dfu_update_requested = false; bool valid_path = false; // wsteam_path leads to lighthouse_console.exe bool firmware_contents_exists = false; // firmware_contents_path ("latest.beyondfw") is on disk bool dfu_firmware_exists = false; bool checked_steamvr_settings = false; bool dismissed_warning_banner = false; bool installed_et_driver = false; bool changed_proximity = false; bool has_eyetracking = false; bool rebuild_fonts = false; ImVec2 last_window_scale; uint64_t last_steamvr_check; uint64_t last_dpi_update; uint64_t last_et_firmware_check; uint64_t initiated_dfu_request; std::vector hmd_serial_history; std::vector ignored_steamvr_warnings; std::vector flagged_settings; int rate_n = 0; // Used only in changing the refresh rate int dfu_check_count = 0; SteamVR_Warned_Settings staged_ignore_setting; char tint_r[5] = { 0 }; char tint_g[5] = { 0 }; char tint_b[5] = { 0 }; Locales active_locale = Locales::None; }; struct UI_Constants { const int brightness_min = -20; const int brightness_max = 100; const int overdrive_brightness_min = 101; const int overdrive_brightness_max = 150; const int fan_speed_min = 40; const int fan_speed_max = 100; const int ipd_min = 48; const int ipd_max = 75; const int prox_min = -500; const int prox_max = 500; const float control_padding = 180; const float control_thickness = 6; const std::vector et_notify_processes = {"VRChat.exe", "Resonite.exe", "FlightSimulator.exe"}; // Beyond theme colors const ImVec4 button_fill = ImVec4(1, 1, 1, 1); const ImVec4 button_hover = ImVec4(0.9f, 0.9f, 0.9f, 1); const ImVec4 button_click = ImVec4(0.7f, 0.7f, 0.7f, 1); const ImVec4 button_text = ImVec4(0, 0, 0, 1); const ImVec4 grey_button_fill = ImVec4(0.08f, 0.08f, 0.08f, 1); const ImVec4 grey_button_hover = grey_button_fill; const ImVec4 grey_button_click = ImVec4(0.14f, 0.14f, 0.14f, 1); const ImVec4 grey_button_text = ImVec4(1, 1, 1, 1); const ImVec4 button_fill_inactive = ImVec4(0.2f, 0.2f, 0.2f, 1); const ImVec4 button_hover_inactive = ImVec4(0.45f, 0.45f, 0.45f, 1); const ImVec4 button_click_inactive = ImVec4(0.3f, 0.3f, 0.3f, 1); const ImVec4 button_text_inactive = ImVec4(0.8f, 0.8f, 0.8f, 1); const ImVec4 checkbox_fill = ImVec4(0.401f, 0.217f, 1.68f, 1); const ImVec4 checkbox_hover = ImVec4(0.401f, 0.217f, 1.68f, 1); const ImVec4 checkbox_click = ImVec4(0.201f, 0.017f, 0.868f, 1); const ImVec4 checkbox_icon = ImVec4(1, 1, 1, 1); const ImVec4 textbox_fill = ImVec4(0.401f, 0.217f, 1.68f, 1); const ImVec4 textbox_active = ImVec4(0.501f, 0.317f, 1.78f, 1); const ImVec4 textbox_text = ImVec4(1, 1, 1, 1); const ImVec4 slider_fill = ImVec4(0.401f, 0.217f, 1.68f, 1); const ImVec4 slider_active = ImVec4(0.501f, 0.317f, 1.78f, 1); const ImVec4 slider_button = ImVec4(0.601f, 0.417f, 1.88f, 1); const ImVec4 slider_button_active = ImVec4(0.601f, 0.417f, 1.88f, 1); const ImVec4 popup_title_color = ImVec4(0.401f, 0.217f, 1.68f, 1); const ImVec4 sub_text = ImVec4(0.47f, 0.494f, 0.505f, 1); const ImVec4 progress_fill = ImVec4(0.7f, 0.7f, 0.7f, 1); const int max_dfu_verification_checks = 4; }; inline UI_Constants UIConstants; struct UI { const std::map languages = { {Locales::En, {"images/en.png", "fonts/HaasGrotDisp-55Roman.otf", 14, 25}}, {Locales::Jp, {"images/jp.png", "fonts/YuGothM.ttc", 15, 26}} }; std::map warned_settings; std::map warning_banners; void create_window(bool startClosed); void run(); void shutdown(); void load_fonts(); void localize_tables(); ImVec2 update_dpi(); bool bring_foreground(bool foreground_external); // UI Sub-functions so we don't clutter run() void first_time_headset(UI_Run_State& rs); void show_steamvr_flagged_settings(UI_Run_State& rs); void show_advanced_settings(UI_Run_State& rs); void show_bootloader_menu(UI_Run_State& rs); void show_crashhandler_menu(UI_Run_State& rs); bool show_refresh_rate_buttons(UI_Run_State& rs); void show_dfu_menu(UI_Run_State& rs); void render_popups(UI_Run_State& rs); bool has_opened_eyetracking(); std::atomic alive; std::atomic app_inactive; int window_width = 600; int window_height = 690; int pushed_styles = 0; const char* app_version = "0.0.0"; GLFWwindow* window = nullptr; std::atomic changing_refresh; std::atomic changing_ipd; std::atomic fetching_config; std::atomic uploading_lighthouse_config; std::atomic set_steamvr_settings; std::atomic set_current_refresh; std::atomic refresh_progress; std::atomic ipd_progress; std::atomic saving; std::atomic saving_progress; std::atomic reboot_after_save; std::string deviceType; ImFont* font; ImFont* font_header; }; extern UI ui;