diff --git a/app/InputDispatcher.cs b/app/InputDispatcher.cs index 8368afaf..e15b49dc 100644 --- a/app/InputDispatcher.cs +++ b/app/InputDispatcher.cs @@ -121,16 +121,18 @@ namespace GHelper } } - static void TabletMode() + static bool GetTouchpadState() { - bool touchpadState, tabletState; - using (var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\Status", false)) { - touchpadState = (key?.GetValue("Enabled")?.ToString() == "1"); + return (key?.GetValue("Enabled")?.ToString() == "1"); } + } - tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState) > 0; + static void TabletMode() + { + bool touchpadState = GetTouchpadState(); + bool tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState) > 0; Logger.WriteLine("Tablet: " + tabletState + " Touchpad: " + touchpadState); @@ -192,11 +194,13 @@ namespace GHelper Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, brightness + "%", ToastIcon.BrightnessUp); break; case 107: // FN+F10 + bool touchpadState = GetTouchpadState(); AsusUSB.TouchpadToggle(); - Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, "Touchpad", ToastIcon.Touchpad); + Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, touchpadState ? "Off" : "On", ToastIcon.Touchpad); break; case 108: // FN+F11 - Application.SetSuspendState(PowerState.Suspend, true, true); + Program.acpi.DeviceSet(AsusACPI.UniversalControl, 0x6c, "Sleep"); + //NativeMethods.SetSuspendState(false, true, true); break; } } diff --git a/app/NativeMethods.cs b/app/NativeMethods.cs index 11f08dc4..fba2c2a6 100644 --- a/app/NativeMethods.cs +++ b/app/NativeMethods.cs @@ -435,6 +435,10 @@ public class NativeMethods } + [DllImport("Powrprof.dll", CharSet = CharSet.Auto, ExactSpelling = true)] + public static extern bool SetSuspendState(bool hiberate, bool forceCritical, bool disableWakeEvent); + + public const int KEYEVENTF_EXTENDEDKEY = 1; public const int KEYEVENTF_KEYUP = 2;