Bindings fixes

This commit is contained in:
Serge
2023-08-04 21:36:44 +02:00
parent 2097a42973
commit 98a0c21355
5 changed files with 117 additions and 65 deletions

View File

@@ -260,4 +260,61 @@ public static class AppConfig
Set(name + "_" + Modes.GetCurrent(), value);
}
public static bool IsAlly()
{
return ContainsModel("RC71");
}
public static bool NoMKeys()
{
return ContainsModel("Z13") ||
ContainsModel("FX706") ||
ContainsModel("FA506") ||
ContainsModel("FX506") ||
ContainsModel("Duo") ||
ContainsModel("FX505");
}
public static bool IsTUF()
{
return ContainsModel("TUF");
}
// Devices with bugged bios command to change brightness
public static bool SwappedBrightness()
{
return ContainsModel("FA506IH") || ContainsModel("FX506LU");
}
public static bool IsDUO()
{
return ContainsModel("Duo");
}
// G14 2020 has no aura, but media keys instead
public static bool NoAura()
{
return ContainsModel("GA401I") && !ContainsModel("GA401IHR");
}
public static bool NoAuraColor()
{
return ContainsModel("GA401") || ContainsModel("X13");
}
public static bool IsStrix()
{
return ContainsModel("Strix");
}
public static bool IsZ13()
{
return ContainsModel("Z13");
}
public static bool HasTabletMode()
{
return ContainsModel("X16") || ContainsModel("X13");
}
}

View File

@@ -60,8 +60,8 @@ namespace GHelper
public static Color Color1 = Color.White;
public static Color Color2 = Color.Black;
static bool isTuf = AppConfig.ContainsModel("Tuf");
static bool isStrix = AppConfig.ContainsModel("Strix");
static bool isTuf = AppConfig.IsTUF();
static bool isStrix = AppConfig.IsStrix();
static System.Timers.Timer timer = new System.Timers.Timer(2000);
@@ -214,10 +214,6 @@ namespace GHelper
}
}
public static bool HasColor()
{
return AppConfig.ContainsModel("GA401") || AppConfig.ContainsModel("X13");
}
public static bool HasSecondColor()
{
@@ -581,7 +577,7 @@ namespace GHelper
device.CloseDevice();
}
if (AppConfig.ContainsModel("TUF"))
if (isTuf)
Program.acpi.TUFKeyboardRGB(Mode, Color1, _speed);
});

View File

@@ -91,31 +91,6 @@ namespace GHelper
{
InitializeComponent();
// Change text and hide irrelevant options on the ROG Ally,
// which is a bit of a special case piece of hardware.
if (AppConfig.ContainsModel("RC71"))
{
// The back paddles both seem to issue the same code;
// so we'll replace "M1/M2" with one field, for now.
// (Eventually, we should learn how Asus' software tells the difference.)
labelM1.Text = "Back Paddles";
labelM2.Visible = false;
comboM2.Visible = false;
textM2.Visible = false;
// Re-label M3 and M4 to match the front labels.
labelM3.Text = "Ctrl Center";
labelM4.Text = "ROG";
// Hide all of the FN options, as the Ally has no special keyboard FN key.
labelFNC.Visible = false;
comboFNC.Visible = false;
textFNC.Visible = false;
labelFNF4.Visible = false;
comboFNF4.Visible = false;
textFNF4.Visible = false;
}
labelBindings.Text = Properties.Strings.KeyBindings;
labelBacklightTitle.Text = Properties.Strings.LaptopBacklight;
labelSettings.Text = Properties.Strings.Other;
@@ -147,13 +122,39 @@ namespace GHelper
Text = Properties.Strings.ExtraSettings;
if (AppConfig.ContainsModel("Duo"))
if (AppConfig.IsDUO())
{
customActions.Add("screenpad_down", Properties.Strings.ScreenPadDown);
customActions.Add("screenpad_up", Properties.Strings.ScreenPadUp);
}
if (InputDispatcher.NoMKeys())
// Change text and hide irrelevant options on the ROG Ally,
// which is a bit of a special case piece of hardware.
if (AppConfig.IsAlly())
{
// The back paddles both seem to issue the same code;
// so we'll replace "M1/M2" with one field, for now.
// (Eventually, we should learn how Asus' software tells the difference.)
labelM1.Text = "Back Paddles";
labelM2.Visible = false;
comboM2.Visible = false;
textM2.Visible = false;
// Re-label M3 and M4 to match the front labels.
labelM3.Text = "Ctrl Center";
labelM4.Text = "ROG";
// Hide all of the FN options, as the Ally has no special keyboard FN key.
labelFNC.Visible = false;
comboFNC.Visible = false;
textFNC.Visible = false;
labelFNF4.Visible = false;
comboFNF4.Visible = false;
textFNF4.Visible = false;
}
if (AppConfig.NoMKeys())
{
labelM1.Text = "FN+F2";
labelM2.Text = "FN+F3";
@@ -162,7 +163,12 @@ namespace GHelper
labelFNF4.Visible = comboFNF4.Visible = textFNF4.Visible = false;
}
if (!AppConfig.ContainsModel("TUF"))
if (AppConfig.NoAura())
{
labelFNF4.Visible = comboFNF4.Visible = textFNF4.Visible = false;
}
if (!AppConfig.IsTUF())
{
labelFNE.Visible = comboFNE.Visible = textFNE.Visible = false;
}
@@ -236,7 +242,7 @@ namespace GHelper
checkSleepLogo.CheckedChanged += CheckPower_CheckedChanged;
checkShutdownLogo.CheckedChanged += CheckPower_CheckedChanged;
if (!AppConfig.ContainsModel("Strix"))
if (!AppConfig.IsStrix())
{
labelBacklightBar.Visible = false;
checkAwakeBar.Visible = false;
@@ -244,7 +250,7 @@ namespace GHelper
checkSleepBar.Visible = false;
checkShutdownBar.Visible = false;
if (!AppConfig.ContainsModel("Z13"))
if (!AppConfig.IsZ13())
{
labelBacklightLid.Visible = false;
checkAwakeLid.Visible = false;

View File

@@ -19,6 +19,8 @@ namespace GHelper.Input
static ModeControl modeControl = Program.modeControl;
static ScreenControl screenControl = new ScreenControl();
static bool isTUF = AppConfig.IsTUF();
KeyboardListener listener;
KeyboardHook hook = new KeyboardHook();
@@ -112,7 +114,7 @@ namespace GHelper.Input
hook.RegisterHotKey(ModifierKeys.Shift, Keys.VolumeUp);
}
if (!AppConfig.ContainsModel("Z13"))
if (!AppConfig.IsZ13() && !AppConfig.IsAlly())
{
if (actionM1 is not null && actionM1.Length > 0) hook.RegisterHotKey(ModifierKeys.None, Keys.VolumeDown);
if (actionM2 is not null && actionM2.Length > 0) hook.RegisterHotKey(ModifierKeys.None, Keys.VolumeUp);
@@ -147,33 +149,23 @@ namespace GHelper.Input
}
public static bool NoMKeys()
{
return AppConfig.ContainsModel("Z13") ||
AppConfig.ContainsModel("FX706") ||
AppConfig.ContainsModel("FA506") ||
AppConfig.ContainsModel("FX506") ||
AppConfig.ContainsModel("Duo") ||
AppConfig.ContainsModel("FX505");
}
static bool SwappedBrightness()
{
return (AppConfig.ContainsModel("FA506IH") || AppConfig.ContainsModel("FX506LU"));
}
static void SetBrightness(int delta)
{
var brightness = ScreenBrightness.Get();
int brightness = -1;
if (isTUF) brightness = ScreenBrightness.Get();
if (delta > 0 || SwappedBrightness()) HandleOptimizationEvent(32);
if (delta > 0 || AppConfig.SwappedBrightness()) HandleOptimizationEvent(32);
else HandleOptimizationEvent(16);
if (!AppConfig.ContainsModel("TUF")) return;
if (isTUF)
{
Thread.Sleep(100);
if (brightness == ScreenBrightness.Get())
Program.toast.RunToast(ScreenBrightness.Adjust(delta) + "%", (delta < 0 ) ? ToastIcon.BrightnessDown : ToastIcon.BrightnessUp);
}
Thread.Sleep(100);
if (brightness == ScreenBrightness.Get())
Program.toast.RunToast(ScreenBrightness.Adjust(delta) + "%", (delta < 0 ) ? ToastIcon.BrightnessDown : ToastIcon.BrightnessUp);
}
public void KeyPressed(object sender, KeyPressedEventArgs e)
@@ -183,7 +175,7 @@ namespace GHelper.Input
{
Logger.WriteLine(e.Key.ToString());
if (NoMKeys())
if (AppConfig.NoMKeys())
{
switch (e.Key)
{
@@ -199,7 +191,7 @@ namespace GHelper.Input
}
}
if (AppConfig.ContainsModel("Z13") || AppConfig.ContainsModel("Duo"))
if (AppConfig.IsZ13() || AppConfig.IsDUO())
{
switch (e.Key)
{
@@ -209,7 +201,7 @@ namespace GHelper.Input
}
}
if (AppConfig.ContainsModel("GA401I") && !AppConfig.ContainsModel("GA401IHR"))
if (AppConfig.NoAura())
{
switch (e.Key)
{
@@ -273,6 +265,7 @@ namespace GHelper.Input
default:
break;
}
}
if (e.Modifier == (ModifierKeys.Control | ModifierKeys.Shift))
@@ -432,7 +425,7 @@ namespace GHelper.Input
{
// The ROG Ally uses different M-key codes.
// We'll special-case the translation of those.
if (AppConfig.ContainsModel("RC71"))
if (AppConfig.IsAlly())
{
switch(EventID)
{

View File

@@ -631,12 +631,12 @@ namespace GHelper
comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged;
if (AsusUSB.HasColor())
if (AppConfig.NoAuraColor())
{
panelColor.Visible = false;
}
if (AppConfig.ContainsModel("GA401I"))
if (AppConfig.NoAura())
{
comboKeyboard.Visible = false;
}
@@ -930,7 +930,7 @@ namespace GHelper
if (Program.acpi.IsXGConnected())
AsusUSB.ApplyXGMLight(AppConfig.Is("xmg_light"));
if (AppConfig.ContainsModel("X16") || AppConfig.ContainsModel("X13")) InputDispatcher.TabletMode();
if (AppConfig.HasTabletMode()) InputDispatcher.TabletMode();
}