#pragma once #include "ui.h" #include "json11.hpp" using namespace json11; #include #include #include #include #include #include #include "pathcch.h" #include "hid_handler.h" class Utils { public: bool is_file_dialog_active() { return opened_file_dialog; }; Json read_json(std::wstring file, int maxRetries = 3, int retryDelay = 100); bool write_json(std::wstring file, const Json& json); bool is_valid_json(std::wstring file, int maxRetries = 3, int retryDelay = 100); std::string string_wide_to_narrow(std::wstring wstr); std::string get_device_type(); std::wstring run_command(const std::wstring& command, std::string& streamedStr, PROCESS_INFORMATION& processHandle); bool write_to_stdin(const std::string& serial_select_command, const std::wstring& exe_path, const std::string& command, std::vector* serials); bool write_mem_config(HidHandler& hid, const std::wstring& config_mem_json_file, std::vector new_values, bool ignore_serial_check = false); bool restore_mem_config(HidHandler& hid, const std::wstring& backup_mem_json_file); bool update_config(HidHandler& hid, UI_Run_State& rs); bool install_et_driver(UI_Run_State& rs); bool install_bridge_driver(UI_Run_State& rs); void mic_volume_fix(UI_Run_State& rs); void update_et_driver_status(UI_Run_State& rs); void update_bridge_driver_status(UI_Run_State& rs); void update_ipd(UI_Run_State& rs); void update_refresh_rate(UI_Run_State& rs); void upload_lighthouse_config(UI_Run_State& rs); HANDLE get_et_handle(); void launch_enrollment(UI_Run_State& rs); Json get_steamvr_settings(UI_Run_State& rs); void grandfather_et_client(UI_Run_State& rs); bool read_settings_file(UI_Run_State& rs); bool write_settings_file(UI_Run_State& rs); bool write_steamvr_settings(UI_Run_State& rs, SteamVR_Flagged_Setting setting_details); std::wstring get_steam_config_folder(UI_Run_State& rs); void set_steamvr_color_gain(UI_Run_State& rs, std::wstring prop, char* gain); void find_flagged_settings(UI_Run_State& rs); void enter_dfu_mode(UI_Run_State& rs); void start_dfu_update(UI_Run_State& rs); std::tuple split_headset_firmware(); std::wstring open_file_select(const wchar_t* filter); int get_fan_generation(std::string serial, UI_Run_State& rs); void find_fan_generation(UI_Run_State& rs); void find_system_locale(UI_Run_State& rs); Lang_Setting get_locale_settings(UI_Run_State& rs); std::string float_to_string(float value, int precision); std::string get_clipboard(); std::string et_format_model_name(UI_Run_State& rs, const std::string& modelPath, bool skipCustom); void open_link(const std::string& url); bool check_utility_ver(); bool apply_quad_view_settings(UI_Run_State& rs); int get_XR_layer_count(); void shutdown(); private: std::thread steam_change_thread; std::thread steamvr_check; std::thread fan_check; bool opened_file_dialog = false; }; extern Utils utils;