Added touchpad toggle for tablet mode on x13/x16

This commit is contained in:
Serge
2023-05-15 23:59:21 +02:00
parent 853d0c231d
commit f39563fcdf
5 changed files with 39 additions and 15 deletions

View File

@@ -15,6 +15,7 @@ public class ASUSWmi
public const uint UniversalControl = 0x00100021; public const uint UniversalControl = 0x00100021;
public const int KB_Light_Up = 0xc4; public const int KB_Light_Up = 0xc4;
public const int KB_Light_Down = 0xc5; public const int KB_Light_Down = 0xc5;
public const int Touchpad_Toggle = 0x6B;
public const int ChargerMode = 0x0012006C; public const int ChargerMode = 0x0012006C;
@@ -59,6 +60,13 @@ public class ASUSWmi
public const int TUF_KB = 0x00100056; public const int TUF_KB = 0x00100056;
public const int TUF_KB_STATE = 0x00100057; 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 PerformanceBalanced = 0;
public const int PerformanceTurbo = 1; public const int PerformanceTurbo = 1;
public const int PerformanceSilent = 2; public const int PerformanceSilent = 2;

View File

@@ -16,7 +16,7 @@
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.62</AssemblyVersion> <AssemblyVersion>0.63</AssemblyVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@@ -1,4 +1,3 @@
using GHelper.Gpu;
using Microsoft.Win32; using Microsoft.Win32;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
@@ -64,7 +63,7 @@ namespace GHelper
} }
Logger.WriteLine("------------"); 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(); 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) static void WatcherEventArrived(object sender, EventArrivedEventArgs e)
{ {
@@ -278,6 +294,10 @@ namespace GHelper
case 179: // FN+F4 case 179: // FN+F4
KeyProcess("fnf4"); KeyProcess("fnf4");
return; return;
case 189: // Tablet mode
TabletMode();
return;
} }

View File

@@ -3,13 +3,10 @@ using GHelper.Gpu;
using Starlight.AnimeMatrix; using Starlight.AnimeMatrix;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO.Compression;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
using System.Timers; using System.Timers;
using System.Windows.Forms;
using System.Xml.Linq;
using Tools; using Tools;
namespace GHelper namespace GHelper
@@ -162,7 +159,7 @@ namespace GHelper
contextMenuStrip.Items.Clear(); contextMenuStrip.Items.Clear();
Padding padding = new Padding(15,5,5,5); Padding padding = new Padding(15, 5, 5, 5);
/* /*
TableLayoutPanel[] tables = { tablePerf, tableGPU }; TableLayoutPanel[] tables = { tablePerf, tableGPU };
@@ -300,9 +297,7 @@ namespace GHelper
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"); //appVersion = new Version("0.50.0.0");
int newer = gitVersion.CompareTo(appVersion); if (gitVersion.CompareTo(appVersion) > 0)
if (newer > 0)
{ {
SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, url); SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, url);
if (Program.config.getConfigString("skip_version") != tag) if (Program.config.getConfigString("skip_version") != tag)
@@ -364,7 +359,7 @@ namespace GHelper
cmd.StartInfo.UseShellExecute = false; cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.CreateNoWindow = true; cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.FileName = "powershell"; 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(); cmd.Start();
Debug.WriteLine(requestUri); Debug.WriteLine(requestUri);
@@ -1748,7 +1743,8 @@ namespace GHelper
try try
{ {
OptimizationService.SetChargeLimit(limit); OptimizationService.SetChargeLimit(limit);
} catch (Exception ex) }
catch (Exception ex)
{ {
Debug.WriteLine(ex); Debug.WriteLine(ex);
} }