Ally Mappings

This commit is contained in:
Serge
2024-01-16 20:53:09 +01:00
parent 6dd4905b95
commit acef2407c7
2 changed files with 21 additions and 44 deletions

View File

@@ -43,38 +43,8 @@ namespace GHelper.Ally
public const int CodeM1 = 0x028f; public const int CodeM1 = 0x028f;
public const int CodeM2 = 0x028e; public const int CodeM2 = 0x028e;
private byte[] commitReset1of4 = new byte[64] static byte[] MappingReady = new byte[] { AsusHid.INPUT_ID, 0xd1, 0x0a, 0x01 };
{ static byte[] MappingSave = new byte[] { AsusHid.INPUT_ID, 0xd1, 0x0f, 0x20 };
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
};
public static Dictionary<int, string> BindingCodes = new Dictionary<int, string> public static Dictionary<int, string> BindingCodes = new Dictionary<int, string>
{ {
@@ -319,7 +289,7 @@ namespace GHelper.Ally
} }
static private void ApplyBindings(BindingZone zone) static private void MappingZone(BindingZone zone)
{ {
int Key1, Key2; int Key1, Key2;
switch (zone) switch (zone)
@@ -361,21 +331,26 @@ namespace GHelper.Ally
//AsusHid.WriteInput(Encoding.ASCII.GetBytes("ZASUS Tech.Inc."), "Init"); //AsusHid.WriteInput(Encoding.ASCII.GetBytes("ZASUS Tech.Inc."), "Init");
AsusHid.WriteInput(MappingReady);
AsusHid.WriteInput(bindings, $"Bind{zone}"); 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); MappingZone(BindingZone.DPadUpDown);
ApplyBindings(BindingZone.DPadLeftRight); MappingZone(BindingZone.DPadLeftRight);
ApplyBindings(BindingZone.AB); MappingZone(BindingZone.StickClick);
ApplyBindings(BindingZone.M1M2); MappingZone(BindingZone.Bumper);
ApplyBindings(BindingZone.XY); 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") 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, 0x0b, 0x01, (byte)applyMode }, log);
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 0x0a, 0x01 }); AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 0x01, 0x01, (byte)applyMode }, log);
SetBindings(); AsusHid.WriteInput(MappingSave);
SetMapping();
} }
private void SetMode(ControllerMode mode) private void SetMode(ControllerMode mode)

View File

@@ -103,7 +103,7 @@ namespace GHelper
if (value >= 0) AppConfig.Set(combo.Name, value); if (value >= 0) AppConfig.Set(combo.Name, value);
else AppConfig.Remove(combo.Name); else AppConfig.Remove(combo.Name);
AllyControl.SetBindings(); AllyControl.SetMapping();
} }
private void Controller_Complete(object? sender, EventArgs e) private void Controller_Complete(object? sender, EventArgs e)