diff --git a/app/ASUSWmi.cs b/app/ASUSWmi.cs index 9dae0361..628eda06 100644 --- a/app/ASUSWmi.cs +++ b/app/ASUSWmi.cs @@ -15,6 +15,7 @@ public class ASUSWmi public const uint UniversalControl = 0x00100021; public const int KB_Light_Up = 0xc4; public const int KB_Light_Down = 0xc5; + public const int Touchpad_Toggle = 0x6B; public const int ChargerMode = 0x0012006C; @@ -59,6 +60,13 @@ public class ASUSWmi public const int TUF_KB = 0x00100056; public const int TUF_KB_STATE = 0x00100057; + public const int TabletState = 0x00060077; + + public const int Tablet_Notebook = 0; + public const int Tablet_Tablet = 1; + public const int Tablet_Tent = 2; + public const int Tablet_Rotated = 3; + public const int PerformanceBalanced = 0; public const int PerformanceTurbo = 1; public const int PerformanceSilent = 2; diff --git a/app/Aura.cs b/app/Aura.cs index 84977c28..e8a11e29 100644 --- a/app/Aura.cs +++ b/app/Aura.cs @@ -166,7 +166,7 @@ namespace GHelper { HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray(); foreach (HidDevice device in HidDeviceList) - if (device.IsConnected + if (device.IsConnected && device.Capabilities.FeatureReportByteLength > 0 && device.Capabilities.InputReportByteLength >= minInput) // yield return device; diff --git a/app/GHelper.csproj b/app/GHelper.csproj index ca4b7386..73f84281 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -16,7 +16,7 @@ AnyCPU False True - 0.62 + 0.63 diff --git a/app/Program.cs b/app/Program.cs index 1a8acec4..ed504279 100644 --- a/app/Program.cs +++ b/app/Program.cs @@ -1,4 +1,3 @@ -using GHelper.Gpu; using Microsoft.Win32; using System.Diagnostics; using System.Globalization; @@ -64,7 +63,7 @@ namespace GHelper } Logger.WriteLine("------------"); - Logger.WriteLine("App launched: " + config.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + (IsUserAdministrator()?"A":"")); + Logger.WriteLine("App launched: " + config.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + (IsUserAdministrator() ? "A" : "")); Application.EnableVisualStyles(); @@ -253,6 +252,23 @@ namespace GHelper } } + static void TabletMode() + { + bool touchpadState, tabletState; + + using (var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\Status", false)) + { + touchpadState = (key?.GetValue("Enabled")?.ToString() == "1"); + } + + tabletState = wmi.DeviceGet(ASUSWmi.TabletState) > 0; + + Logger.WriteLine("Tablet: " + tabletState + " Touchpad: " + touchpadState); + + if ((tabletState && touchpadState) || (!tabletState && !touchpadState)) + wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.Touchpad_Toggle, "Touchpad"); + + } static void WatcherEventArrived(object sender, EventArrivedEventArgs e) { @@ -278,6 +294,10 @@ namespace GHelper case 179: // FN+F4 KeyProcess("fnf4"); return; + case 189: // Tablet mode + TabletMode(); + return; + } diff --git a/app/Settings.cs b/app/Settings.cs index a6797b14..5552f6ea 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -3,13 +3,10 @@ using GHelper.Gpu; using Starlight.AnimeMatrix; using System.Diagnostics; using System.Drawing.Imaging; -using System.IO.Compression; using System.Net; using System.Reflection; using System.Text.Json; using System.Timers; -using System.Windows.Forms; -using System.Xml.Linq; using Tools; namespace GHelper @@ -162,7 +159,7 @@ namespace GHelper contextMenuStrip.Items.Clear(); - Padding padding = new Padding(15,5,5,5); + Padding padding = new Padding(15, 5, 5, 5); /* TableLayoutPanel[] tables = { tablePerf, tableGPU }; @@ -297,12 +294,10 @@ namespace GHelper var url = config.GetProperty("assets")[0].GetProperty("browser_download_url").ToString(); var gitVersion = new Version(tag); - var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString()); + var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString()); //appVersion = new Version("0.50.0.0"); - int newer = gitVersion.CompareTo(appVersion); - - if (newer > 0) + if (gitVersion.CompareTo(appVersion) > 0) { SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, url); if (Program.config.getConfigString("skip_version") != tag) @@ -350,7 +345,7 @@ namespace GHelper Uri uri = new Uri(requestUri); string zipName = Path.GetFileName(uri.LocalPath); - + string exeLocation = Application.ExecutablePath; string exeDir = Path.GetDirectoryName(exeLocation); string zipLocation = exeDir + "\\" + zipName; @@ -364,7 +359,7 @@ namespace GHelper cmd.StartInfo.UseShellExecute = false; cmd.StartInfo.CreateNoWindow = true; cmd.StartInfo.FileName = "powershell"; - cmd.StartInfo.Arguments = $"Start-Sleep -Seconds 1; Expand-Archive {zipLocation} -DestinationPath {exeDir} -Force; {exeLocation}"; + cmd.StartInfo.Arguments = $"Start-Sleep -Seconds 1; Expand-Archive {zipLocation} -DestinationPath {exeDir} -Force; {exeLocation}"; cmd.Start(); Debug.WriteLine(requestUri); @@ -1748,7 +1743,8 @@ namespace GHelper try { OptimizationService.SetChargeLimit(limit); - } catch (Exception ex) + } + catch (Exception ex) { Debug.WriteLine(ex); }