Skip to content

Commit ac60986

Browse files
committed
Sleep Fix
1 parent 1e0169a commit ac60986

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

app/InputDispatcher.cs

+11-7
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,18 @@ static void KeyProcess(string name = "m3")
121121
}
122122
}
123123

124-
static void TabletMode()
124+
static bool GetTouchpadState()
125125
{
126-
bool touchpadState, tabletState;
127-
128126
using (var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\Status", false))
129127
{
130-
touchpadState = (key?.GetValue("Enabled")?.ToString() == "1");
128+
return (key?.GetValue("Enabled")?.ToString() == "1");
131129
}
130+
}
132131

133-
tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState) > 0;
132+
static void TabletMode()
133+
{
134+
bool touchpadState = GetTouchpadState();
135+
bool tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState) > 0;
134136

135137
Logger.WriteLine("Tablet: " + tabletState + " Touchpad: " + touchpadState);
136138

@@ -192,11 +194,13 @@ static void HandleEvent(int EventID)
192194
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, brightness + "%", ToastIcon.BrightnessUp);
193195
break;
194196
case 107: // FN+F10
197+
bool touchpadState = GetTouchpadState();
195198
AsusUSB.TouchpadToggle();
196-
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, "Touchpad", ToastIcon.Touchpad);
199+
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, touchpadState ? "Off" : "On", ToastIcon.Touchpad);
197200
break;
198201
case 108: // FN+F11
199-
Application.SetSuspendState(PowerState.Suspend, true, true);
202+
Program.acpi.DeviceSet(AsusACPI.UniversalControl, 0x6c, "Sleep");
203+
//NativeMethods.SetSuspendState(false, true, true);
200204
break;
201205
}
202206
}

app/NativeMethods.cs

+4
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@ public class PowerSettingGuid
435435
}
436436

437437

438+
[DllImport("Powrprof.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
439+
public static extern bool SetSuspendState(bool hiberate, bool forceCritical, bool disableWakeEvent);
440+
441+
438442
public const int KEYEVENTF_EXTENDEDKEY = 1;
439443
public const int KEYEVENTF_KEYUP = 2;
440444

0 commit comments

Comments
 (0)