Controller Toggle tweaks

This commit is contained in:
Serge
2024-01-28 21:34:15 +01:00
parent 8243d87824
commit 279d07d674
5 changed files with 32 additions and 15 deletions

View File

@@ -314,7 +314,7 @@ namespace GHelper.Ally
if (AppConfig.IsAlly()) settings.VisualiseAlly(true);
else return;
SetMode((ControllerMode)AppConfig.Get("controller_mode", (int)ControllerMode.Auto));
SetMode((ControllerMode)AppConfig.Get("controller_mode", (int)ControllerMode.Auto), true);
settings.VisualiseBacklight(InputDispatcher.GetBacklight());
settings.VisualiseFPSLimit(amdControl.GetFPSLimit());
@@ -477,7 +477,7 @@ namespace GHelper.Ally
DecodeBinding(KeyR1).CopyTo(bindings, 27);
DecodeBinding(KeyR2).CopyTo(bindings, 38);
AsusHid.WriteInput(CommandReady, null);
//AsusHid.WriteInput(CommandReady, null);
AsusHid.WriteInput(bindings, $"B{zone}");
@@ -491,7 +491,7 @@ namespace GHelper.Ally
static public void SetDeadzones()
{
WakeUp();
//WakeUp();
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 4, 4,
(byte)AppConfig.Get("ls_min", 0),
@@ -519,7 +519,7 @@ namespace GHelper.Ally
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xD1, 0x0B, 0x01, AppConfig.Is("controller_disabled") ? (byte)0x02 : (byte)0x01 }, "Status");
}
public static void ApplyMode(ControllerMode applyMode = ControllerMode.Auto)
public static void ApplyMode(ControllerMode applyMode = ControllerMode.Auto, bool init = false)
{
Task.Run(() =>
{
@@ -543,11 +543,14 @@ namespace GHelper.Ally
if (applyMode != ControllerMode.Auto) _applyMode = applyMode;
InputDispatcher.SetBacklightAuto(true);
WakeUp();
if (init)
{
WakeUp();
InputDispatcher.SetBacklightAuto(true);
}
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xD1, 0x01, 0x01, (byte)_applyMode }, "Controller");
AsusHid.WriteInput(CommandSave, null);
//AsusHid.WriteInput(CommandSave, null);
BindZone(BindingZone.M1M2);
@@ -561,18 +564,19 @@ namespace GHelper.Ally
BindZone(BindingZone.Trigger);
AsusHid.WriteInput(CommandSave, null);
SetDeadzones();
});
}
private void SetMode(ControllerMode mode)
private void SetMode(ControllerMode mode, bool init = false)
{
_mode = mode;
AppConfig.Set("controller_mode", (int)mode);
ApplyMode(mode);
ApplyMode(mode, init);
if (mode == ControllerMode.Auto)
{

View File

@@ -44,6 +44,11 @@ namespace GHelper
customActions.Add("screenpad_up", Properties.Strings.ScreenPadUp);
}
if (AppConfig.IsAlly())
{
customActions.Add("controller", "Controller Mode");
}
switch (name)
{
case "m1":

View File

@@ -376,7 +376,7 @@ namespace GHelper.Input
Program.settingsForm.gpuControl.ToggleXGM(true);
break;
case Keys.F4:
Program.settingsForm.allyControl.ToggleModeHotkey();
Program.settingsForm.BeginInvoke(Program.settingsForm.allyControl.ToggleModeHotkey);
break;
case Keys.F14:
Program.settingsForm.gpuControl.SetGPUMode(AsusACPI.GPUModeEco);
@@ -520,6 +520,9 @@ namespace GHelper.Input
case "calculator":
LaunchProcess("calc");
break;
case "controller":
Program.settingsForm.BeginInvoke(Program.settingsForm.allyControl.ToggleModeHotkey);
break;
default:
break;
}

View File

@@ -229,10 +229,15 @@ namespace GHelper
BatteryControl.AutoBattery(init);
settingsForm.AutoKeyboard();
settingsForm.matrixControl.SetMatrix(true);
allyControl.Init();
if (AppConfig.IsAlly())
{
allyControl.Init();
} else
{
settingsForm.AutoKeyboard();
}
}
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)

View File

@@ -250,7 +250,7 @@ namespace GHelper.USB
msg[5] = mono ? (byte)0 : color.G; // G
msg[6] = mono ? (byte)0 : color.B; // B
msg[7] = (byte)speed; // aura.speed as u8;
msg[8] = 0xFF; // aura.direction as u8;
msg[8] = 0x00; // aura.direction as u8;
msg[9] = mode == AuraMode.AuraBreathe ? (byte)1 : (byte)0;
msg[10] = color2.R; // R
msg[11] = mono ? (byte)0 : color2.G; // G
@@ -294,12 +294,12 @@ namespace GHelper.USB
if (delay) await Task.Delay(TimeSpan.FromSeconds(1));
if (isACPI) Program.acpi.TUFKeyboardBrightness(brightness);
AsusHid.Write(new byte[] { AsusHid.AURA_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, log);
AsusHid.Write(new byte[] { AsusHid.AURA_ID, 0xBA, 0xC5, 0xC4, (byte)brightness }, log);
if (AppConfig.IsAlly()) ApplyAura();
if (AppConfig.ContainsModel("GA503"))
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, log);
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xBA, 0xC5, 0xC4, (byte)brightness }, log);
});