From acef2407c7967162f6806e74d4798a2907381dc4 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Tue, 16 Jan 2024 20:53:09 +0100 Subject: [PATCH] Ally Mappings --- app/Ally/AllyControl.cs | 63 +++++++++++++---------------------------- app/Handheld.cs | 2 +- 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/app/Ally/AllyControl.cs b/app/Ally/AllyControl.cs index 601d4749..de631f39 100644 --- a/app/Ally/AllyControl.cs +++ b/app/Ally/AllyControl.cs @@ -43,38 +43,8 @@ namespace GHelper.Ally public const int CodeM1 = 0x028f; public const int CodeM2 = 0x028e; - private byte[] commitReset1of4 = new byte[64] - { - 0x5A, 0xD1, 0x0F, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - - }; - - private byte[] commitReset2of4 = new byte[64] - { - 0x5A, 0xD1, 0x06, 0x02, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - private byte[] commitReset3of4 = new byte[64] - { - 0x5A, 0xD1, 0x04, 0x04, 0x00, 0x64, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - private byte[] commitReset4of4 = new byte[64] - { - 0x5A, 0xD1, 0x05, 0x04, 0x00, 0x64, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + static byte[] MappingReady = new byte[] { AsusHid.INPUT_ID, 0xd1, 0x0a, 0x01 }; + static byte[] MappingSave = new byte[] { AsusHid.INPUT_ID, 0xd1, 0x0f, 0x20 }; public static Dictionary BindingCodes = new Dictionary { @@ -319,7 +289,7 @@ namespace GHelper.Ally } - static private void ApplyBindings(BindingZone zone) + static private void MappingZone(BindingZone zone) { int Key1, Key2; switch (zone) @@ -361,21 +331,26 @@ namespace GHelper.Ally //AsusHid.WriteInput(Encoding.ASCII.GetBytes("ZASUS Tech.Inc."), "Init"); + AsusHid.WriteInput(MappingReady); AsusHid.WriteInput(bindings, $"Bind{zone}"); - AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 0x0a, 0x01 }); } - static public void SetBindings() + static public void SetMapping() { - ApplyBindings(BindingZone.DPadUpDown); - ApplyBindings(BindingZone.DPadLeftRight); - ApplyBindings(BindingZone.AB); - ApplyBindings(BindingZone.M1M2); - ApplyBindings(BindingZone.XY); + MappingZone(BindingZone.DPadUpDown); + MappingZone(BindingZone.DPadLeftRight); + MappingZone(BindingZone.StickClick); + MappingZone(BindingZone.Bumper); + MappingZone(BindingZone.AB); + MappingZone(BindingZone.XY); + MappingZone(BindingZone.ViewMenu); + MappingZone(BindingZone.M1M2); + MappingZone(BindingZone.Trigger); + AsusHid.WriteInput(MappingSave); } @@ -404,9 +379,11 @@ namespace GHelper.Ally private void ApplyMode(ControllerMode applyMode, string log = "ControllerMode") { - AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 1, 1, (byte)applyMode }, log); - AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 0x0a, 0x01 }); - SetBindings(); + //AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 0x0b, 0x01, (byte)applyMode }, log); + AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 0x01, 0x01, (byte)applyMode }, log); + AsusHid.WriteInput(MappingSave); + + SetMapping(); } private void SetMode(ControllerMode mode) diff --git a/app/Handheld.cs b/app/Handheld.cs index 9943c0d4..93929471 100644 --- a/app/Handheld.cs +++ b/app/Handheld.cs @@ -103,7 +103,7 @@ namespace GHelper if (value >= 0) AppConfig.Set(combo.Name, value); else AppConfig.Remove(combo.Name); - AllyControl.SetBindings(); + AllyControl.SetMapping(); } private void Controller_Complete(object? sender, EventArgs e)