using System; using System.Diagnostics; using System.Globalization; using CefSharp; namespace VRCX { public class AppApiVr { public static readonly AppApiVr Instance; static AppApiVr() { Instance = new AppApiVr(); } public void VrInit() { if (MainForm.Instance?.Browser != null && !MainForm.Instance.Browser.IsLoading && MainForm.Instance.Browser.CanExecuteJavascriptInMainFrame) MainForm.Instance.Browser.ExecuteScriptAsync("$app.vrInit", ""); } /// /// Returns the current CPU usage as a percentage. /// /// The current CPU usage as a percentage. public float CpuUsage() { return CpuMonitor.Instance.CpuUsage; } /// /// Returns an array of arrays containing information about the connected VR devices. /// Each sub-array contains the type of device and its current state /// /// An array of arrays containing information about the connected VR devices. public string[][] GetVRDevices() { return VRCXVR.Instance.GetDevices(); } /// /// Returns the number of milliseconds that the system has been running. /// /// The number of milliseconds that the system has been running. public double GetUptime() { using var uptime = new PerformanceCounter("System", "System Up Time"); uptime.NextValue(); return TimeSpan.FromSeconds(uptime.NextValue()).TotalMilliseconds; } /// /// Returns the current language of the operating system. /// /// The current language of the operating system. public string CurrentCulture() { return CultureInfo.CurrentCulture.ToString(); } } }