Skip to content

Commit

Permalink
Hardware FN-Lock for ProArt #2973 #3012
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Aug 23, 2024
1 parent e265a78 commit 21a2dca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 5 additions & 0 deletions app/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ public static bool IsVivoZenPro()
return ContainsModel("Vivobook") || ContainsModel("Zenbook") || ContainsModel("ProArt");
}

public static bool IsHardwareFnLock()
{
return IsVivoZenPro();
}

// Devices with bugged bios command to change brightness
public static bool SwappedBrightness()
{
Expand Down
15 changes: 10 additions & 5 deletions app/Input/InputDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public void Init()

InitBacklightTimer();

if (AppConfig.IsVivoZenbook())
Program.acpi.DeviceSet(AsusACPI.FnLock, AppConfig.Is("fn_lock") ^ AppConfig.IsInvertedFNLock() ? 1 : 0, "FnLock");
if (AppConfig.IsHardwareFnLock()) HardwareFnLock(AppConfig.Is("fn_lock"));

}

Expand Down Expand Up @@ -155,7 +154,7 @@ public void RegisterKeys()

// FN-Lock group

if (AppConfig.Is("fn_lock") && !AppConfig.IsVivoZenbook())
if (AppConfig.Is("fn_lock") && !AppConfig.IsHardwareFnLock())
for (Keys i = Keys.F1; i <= Keys.F11; i++) hook.RegisterHotKey(ModifierKeys.None, i);

// Arrow-lock group
Expand Down Expand Up @@ -629,13 +628,19 @@ public static void ToggleArrowLock()
Program.toast.RunToast("Arrow-Lock " + (arLock == 1 ? Properties.Strings.On : Properties.Strings.Off), ToastIcon.FnLock);
}

public static void HardwareFnLock(bool fnLock)
{
Program.acpi.DeviceSet(AsusACPI.FnLock, fnLock ^ AppConfig.IsInvertedFNLock() ? 1 : 0, "FnLock");
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x4E, fnLock ? (byte)0x01 : (byte)0x00], "USB FnLock");
}

public static void ToggleFnLock()
{
bool fnLock = !AppConfig.Is("fn_lock");
AppConfig.Set("fn_lock", fnLock ? 1 : 0);

if (AppConfig.IsVivoZenbook())
Program.acpi.DeviceSet(AsusACPI.FnLock, fnLock ^ AppConfig.IsInvertedFNLock() ? 1 : 0, "FnLock");
if (AppConfig.IsHardwareFnLock())
HardwareFnLock(fnLock);
else
Program.settingsForm.BeginInvoke(Program.inputDispatcher.RegisterKeys);

Expand Down
4 changes: 2 additions & 2 deletions app/USB/Aura.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ public static void Init()
if (AppConfig.IsProArt())
{
AsusHid.WriteInput([AsusHid.INPUT_ID, 0x05, 0x20, 0x31, 0x00, 0x08], "ProArt Init");
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x4E], "ProArt Init");
//AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x4E], "ProArt Init");
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xBA, 0xC5, 0xC4], "ProArt Init");
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x8F, 0x01], "ProArt Init");
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x85, 0xFF], "ProArt Init");
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x4E], "ProArt Init");
//AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x4E], "ProArt Init");
}
}

Expand Down

0 comments on commit 21a2dca

Please sign in to comment.