#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: 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 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); void mic_volume_fix(UI_Run_State& rs); void update_et_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(); bool launch_et_client(); Json get_steamvr_settings(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); void find_system_locale(UI_Run_State& rs); Lang_Setting get_locale_settings(UI_Run_State& rs); void shutdown(); private: std::thread steam_change_thread; std::thread steamvr_check; }; extern Utils utils;