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

@@ -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;
}