Skip to content

Commit 0b0ce9b

Browse files
committed
Auto Tablet mode toggle for Z13 #3816
1 parent 9e18d37 commit 0b0ce9b

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

app/AsusACPI.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public class AsusACPI
127127

128128
public const int MicMuteLed = 0x00040017;
129129

130-
public const int KeyboardConnected = 0x00120063;
130+
public const int SlateMode = 0x00120063;
131131
public const int TabletState = 0x00060077;
132132
public const int FnLock = 0x00100023;
133133

app/Input/InputDispatcher.cs

+17-5
Original file line numberDiff line numberDiff line change
@@ -717,18 +717,30 @@ public static void ToggleFnLock()
717717
Program.toast.RunToast(fnLock ? Properties.Strings.FnLockOn : Properties.Strings.FnLockOff, ToastIcon.FnLock);
718718
}
719719

720+
public static void SetSlateMode(int status)
721+
{
722+
try
723+
{
724+
Registry.SetValue(@"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\PriorityControl", "ConvertibleSlateMode", status, RegistryValueKind.DWord);
725+
Logger.WriteLine("Setting ConvertibleSlateMode : " + status);
726+
} catch (Exception ex)
727+
{
728+
Logger.WriteLine("Can't set ConvertibleSlateMode: " + ex.Message);
729+
}
730+
}
731+
720732
public static void TabletMode()
721733
{
722734
if (AppConfig.Is("disable_tablet")) return;
723735

724736
bool touchpadState = GetTouchpadState();
725-
int keyboardConnected = Program.acpi.DeviceGet(AsusACPI.KeyboardConnected);
726-
int tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState);
727-
bool tablet = tabletState > 0;
737+
bool tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState) > 0;
738+
int slateState = Program.acpi.DeviceGet(AsusACPI.SlateMode);
728739

729-
Logger.WriteLine($"Tablet: {tabletState} | TabletCheck {keyboardConnected} | Touchpad: {touchpadState}");
740+
Logger.WriteLine($"Tablet: {tabletState} | SlateMode: {slateState} | Touchpad: {touchpadState}");
730741

731-
if (tablet && touchpadState || !tablet && !touchpadState) ToggleTouchpad();
742+
if (slateState >= 0) SetSlateMode(slateState);
743+
if (tabletState && touchpadState || !tabletState && !touchpadState) ToggleTouchpad();
732744

733745
}
734746

0 commit comments

Comments
 (0)