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

View File

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

View File

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

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

View File

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