mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Ally mappings
This commit is contained in:
@@ -222,7 +222,7 @@ namespace GHelper.Ally
|
||||
|
||||
settings = settingsForm;
|
||||
|
||||
timer = new System.Timers.Timer(500);
|
||||
timer = new System.Timers.Timer(300);
|
||||
timer.Elapsed += Timer_Elapsed;
|
||||
|
||||
}
|
||||
@@ -236,6 +236,8 @@ namespace GHelper.Ally
|
||||
if (_applyMode != newMode) _autoCount++;
|
||||
else _autoCount = 0;
|
||||
|
||||
if (_mode != ControllerMode.Auto) return;
|
||||
|
||||
if (_autoCount > 2)
|
||||
{
|
||||
_applyMode = newMode;
|
||||
@@ -326,63 +328,81 @@ namespace GHelper.Ally
|
||||
|
||||
static private void MappingZone(BindingZone zone)
|
||||
{
|
||||
int Key1, Key2;
|
||||
int KeyL1, KeyR1;
|
||||
int KeyL2, KeyR2;
|
||||
|
||||
switch (zone)
|
||||
{
|
||||
case BindingZone.DPadUpDown:
|
||||
Key1 = AppConfig.Get("bind_du", MappingDU);
|
||||
Key2 = AppConfig.Get("bind_dd", MappingDD);
|
||||
KeyL1 = AppConfig.Get("bind_du", MappingDU);
|
||||
KeyR1 = AppConfig.Get("bind_dd", MappingDD);
|
||||
KeyL2 = AppConfig.Get("bind2_du");
|
||||
KeyR2 = AppConfig.Get("bind2_dd");
|
||||
break;
|
||||
case BindingZone.DPadLeftRight:
|
||||
Key1 = AppConfig.Get("bind_dl", MappingDL);
|
||||
Key2 = AppConfig.Get("bind_dr", MappingDR);
|
||||
KeyL1 = AppConfig.Get("bind_dl", MappingDL);
|
||||
KeyR1 = AppConfig.Get("bind_dr", MappingDR);
|
||||
KeyL2 = AppConfig.Get("bind2_dl");
|
||||
KeyR2 = AppConfig.Get("bind2_dr");
|
||||
break;
|
||||
case BindingZone.StickClick:
|
||||
Key1 = AppConfig.Get("bind_ls", MappingLS);
|
||||
Key2 = AppConfig.Get("bind_rs", MappingRS);
|
||||
KeyL1 = AppConfig.Get("bind_ls", MappingLS);
|
||||
KeyR1 = AppConfig.Get("bind_rs", MappingRS);
|
||||
KeyL2 = AppConfig.Get("bind2_ls");
|
||||
KeyR2 = AppConfig.Get("bind2_rs");
|
||||
break;
|
||||
case BindingZone.Bumper:
|
||||
Key1 = AppConfig.Get("bind_lb", MappingLB);
|
||||
Key2 = AppConfig.Get("bind_rb", MappingRB);
|
||||
KeyL1 = AppConfig.Get("bind_lb", MappingLB);
|
||||
KeyR1 = AppConfig.Get("bind_rb", MappingRB);
|
||||
KeyL2 = AppConfig.Get("bind2_lb");
|
||||
KeyR2 = AppConfig.Get("bind2_rb");
|
||||
break;
|
||||
case BindingZone.AB:
|
||||
Key1 = AppConfig.Get("bind_a", MappingA);
|
||||
Key2 = AppConfig.Get("bind_b", MappingB);
|
||||
KeyL1 = AppConfig.Get("bind_a", MappingA);
|
||||
KeyR1 = AppConfig.Get("bind_b", MappingB);
|
||||
KeyL2 = AppConfig.Get("bind2_a");
|
||||
KeyR2 = AppConfig.Get("bind2_b");
|
||||
break;
|
||||
case BindingZone.XY:
|
||||
Key1 = AppConfig.Get("bind_x", MappingX);
|
||||
Key2 = AppConfig.Get("bind_y", MappingY);
|
||||
KeyL1 = AppConfig.Get("bind_x", MappingX);
|
||||
KeyR1 = AppConfig.Get("bind_y", MappingY);
|
||||
KeyL2 = AppConfig.Get("bind2_x");
|
||||
KeyR2 = AppConfig.Get("bind2_y");
|
||||
break;
|
||||
case BindingZone.ViewMenu:
|
||||
Key1 = AppConfig.Get("bind_vb", MappingVB);
|
||||
Key2 = AppConfig.Get("bind_mv", MappingMB);
|
||||
KeyL1 = AppConfig.Get("bind_vb", MappingVB);
|
||||
KeyR1 = AppConfig.Get("bind_mb", MappingMB);
|
||||
KeyL2 = AppConfig.Get("bind2_vb");
|
||||
KeyR2 = AppConfig.Get("bind2_mb");
|
||||
break;
|
||||
case BindingZone.M1M2:
|
||||
Key1 = AppConfig.Get("bind_m2", MappingM2);
|
||||
Key2 = AppConfig.Get("bind_m1", MappingM1);
|
||||
KeyL1 = AppConfig.Get("bind_m2", MappingM2);
|
||||
KeyR1 = AppConfig.Get("bind_m1", MappingM1);
|
||||
KeyL2 = AppConfig.Get("bind2_m2", MappingM2);
|
||||
KeyR2 = AppConfig.Get("bind2_m1", MappingM1);
|
||||
break;
|
||||
default:
|
||||
Key1 = AppConfig.Get("bind_trl", MappingLT);
|
||||
Key2 = AppConfig.Get("bind_trr", MappingRT);
|
||||
KeyL1 = AppConfig.Get("bind_trl", MappingLT);
|
||||
KeyR1 = AppConfig.Get("bind_trr", MappingRT);
|
||||
KeyL2 = AppConfig.Get("bind2_trl");
|
||||
KeyR2 = AppConfig.Get("bind2_trr");
|
||||
break;
|
||||
}
|
||||
|
||||
if (Key1 == -1 && Key2 == -1) return;
|
||||
if (KeyL1 == -1 && KeyR1 == -1) return;
|
||||
|
||||
byte[] bindings = new byte[64];
|
||||
byte[] init = new byte[] { AsusHid.INPUT_ID, 0xd1, 0x02, (byte)zone, 0x2c };
|
||||
|
||||
init.CopyTo(bindings, 0);
|
||||
|
||||
DecodeBinding(Key1).CopyTo(bindings, 5);
|
||||
DecodeBinding(Key1).CopyTo(bindings, 16);
|
||||
DecodeBinding(KeyL1).CopyTo(bindings, 5);
|
||||
DecodeBinding(KeyL2).CopyTo(bindings, 16);
|
||||
|
||||
DecodeBinding(Key2).CopyTo(bindings, 27);
|
||||
DecodeBinding(Key2).CopyTo(bindings, 38);
|
||||
DecodeBinding(KeyR1).CopyTo(bindings, 27);
|
||||
DecodeBinding(KeyR2).CopyTo(bindings, 38);
|
||||
|
||||
//AsusHid.WriteInput(Encoding.ASCII.GetBytes("ZASUS Tech.Inc."), "Init");
|
||||
|
||||
AsusHid.WriteInput(MappingReady);
|
||||
AsusHid.WriteInput(MappingReady, null);
|
||||
AsusHid.WriteInput(bindings, $"Bind{zone}");
|
||||
|
||||
|
||||
@@ -418,7 +438,7 @@ namespace GHelper.Ally
|
||||
if (applyMode is not null) _applyMode = (ControllerMode)applyMode;
|
||||
|
||||
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 0x01, 0x01, (byte)_applyMode }, "Controller");
|
||||
AsusHid.WriteInput(MappingSave);
|
||||
AsusHid.WriteInput(MappingSave, null);
|
||||
|
||||
MappingZone(BindingZone.M1M2);
|
||||
|
||||
@@ -434,7 +454,7 @@ namespace GHelper.Ally
|
||||
MappingZone(BindingZone.Trigger);
|
||||
}
|
||||
|
||||
AsusHid.WriteInput(MappingSave);
|
||||
AsusHid.WriteInput(MappingSave, null);
|
||||
}
|
||||
|
||||
private void SetMode(ControllerMode mode)
|
||||
|
||||
48
app/Handheld.Designer.cs
generated
48
app/Handheld.Designer.cs
generated
@@ -68,6 +68,8 @@
|
||||
panelBindingsTitle = new Panel();
|
||||
pictureBindings = new PictureBox();
|
||||
labelBindings = new Label();
|
||||
labelPrimary = new Label();
|
||||
labelSecondary = new Label();
|
||||
panelController.SuspendLayout();
|
||||
panelVibra.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackVibra).BeginInit();
|
||||
@@ -90,6 +92,7 @@
|
||||
panelSDeadzone.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureSDeadzone).BeginInit();
|
||||
panelBindings.SuspendLayout();
|
||||
tableBindings.SuspendLayout();
|
||||
panelBindingsTitle.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBindings).BeginInit();
|
||||
SuspendLayout();
|
||||
@@ -557,9 +560,9 @@
|
||||
panelBindings.Controls.Add(panelBindingsTitle);
|
||||
panelBindings.Dock = DockStyle.Left;
|
||||
panelBindings.Location = new Point(570, 10);
|
||||
panelBindings.MinimumSize = new Size(600, 0);
|
||||
panelBindings.MinimumSize = new Size(700, 0);
|
||||
panelBindings.Name = "panelBindings";
|
||||
panelBindings.Size = new Size(600, 912);
|
||||
panelBindings.Size = new Size(700, 912);
|
||||
panelBindings.TabIndex = 46;
|
||||
//
|
||||
// tableBindings
|
||||
@@ -568,13 +571,16 @@
|
||||
tableBindings.ColumnCount = 3;
|
||||
tableBindings.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
|
||||
tableBindings.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40F));
|
||||
tableBindings.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 40F));
|
||||
tableBindings.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40F));
|
||||
tableBindings.Controls.Add(labelPrimary, 1, 0);
|
||||
tableBindings.Controls.Add(labelSecondary, 2, 0);
|
||||
tableBindings.Dock = DockStyle.Top;
|
||||
tableBindings.Location = new Point(0, 60);
|
||||
tableBindings.Name = "tableBindings";
|
||||
tableBindings.Padding = new Padding(5);
|
||||
tableBindings.RowCount = 1;
|
||||
tableBindings.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
|
||||
tableBindings.Size = new Size(500, 10);
|
||||
tableBindings.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||
tableBindings.Size = new Size(700, 52);
|
||||
tableBindings.TabIndex = 49;
|
||||
//
|
||||
// panelBindingsTitle
|
||||
@@ -587,7 +593,7 @@
|
||||
panelBindingsTitle.Location = new Point(0, 0);
|
||||
panelBindingsTitle.Margin = new Padding(4);
|
||||
panelBindingsTitle.Name = "panelBindingsTitle";
|
||||
panelBindingsTitle.Size = new Size(500, 60);
|
||||
panelBindingsTitle.Size = new Size(700, 60);
|
||||
panelBindingsTitle.TabIndex = 44;
|
||||
//
|
||||
// pictureBindings
|
||||
@@ -614,12 +620,36 @@
|
||||
labelBindings.TabIndex = 40;
|
||||
labelBindings.Text = "Bindings";
|
||||
//
|
||||
// labelPrimary
|
||||
//
|
||||
labelPrimary.AutoSize = true;
|
||||
labelPrimary.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelPrimary.Location = new Point(147, 5);
|
||||
labelPrimary.Margin = new Padding(4, 0, 4, 0);
|
||||
labelPrimary.Name = "labelPrimary";
|
||||
labelPrimary.Padding = new Padding(5);
|
||||
labelPrimary.Size = new Size(115, 42);
|
||||
labelPrimary.TabIndex = 41;
|
||||
labelPrimary.Text = "Primary";
|
||||
//
|
||||
// labelSecondary
|
||||
//
|
||||
labelSecondary.AutoSize = true;
|
||||
labelSecondary.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelSecondary.Location = new Point(423, 5);
|
||||
labelSecondary.Margin = new Padding(4, 0, 4, 0);
|
||||
labelSecondary.Name = "labelSecondary";
|
||||
labelSecondary.Padding = new Padding(5);
|
||||
labelSecondary.Size = new Size(144, 42);
|
||||
labelSecondary.TabIndex = 42;
|
||||
labelSecondary.Text = "Secondary";
|
||||
//
|
||||
// Handheld
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
AutoSize = true;
|
||||
ClientSize = new Size(1277, 932);
|
||||
ClientSize = new Size(1286, 932);
|
||||
Controls.Add(panelBindings);
|
||||
Controls.Add(panelController);
|
||||
MaximizeBox = false;
|
||||
@@ -661,6 +691,8 @@
|
||||
((System.ComponentModel.ISupportInitialize)pictureSDeadzone).EndInit();
|
||||
panelBindings.ResumeLayout(false);
|
||||
panelBindings.PerformLayout();
|
||||
tableBindings.ResumeLayout(false);
|
||||
tableBindings.PerformLayout();
|
||||
panelBindingsTitle.ResumeLayout(false);
|
||||
panelBindingsTitle.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBindings).EndInit();
|
||||
@@ -710,5 +742,7 @@
|
||||
private PictureBox pictureBindings;
|
||||
private Label labelBindings;
|
||||
private TableLayoutPanel tableBindings;
|
||||
private Label labelPrimary;
|
||||
private Label labelSecondary;
|
||||
}
|
||||
}
|
||||
@@ -44,36 +44,30 @@ namespace GHelper
|
||||
FillBinding("m1", "M1", AllyControl.MappingM1);
|
||||
FillBinding("m2", "M2", AllyControl.MappingM2);
|
||||
|
||||
FillBinding("a", "A", AllyControl.MappingA);
|
||||
FillBinding("b", "B", AllyControl.MappingB);
|
||||
FillBinding("x", "X", AllyControl.MappingX);
|
||||
FillBinding("y", "Y", AllyControl.MappingY);
|
||||
FillBinding("a", "A");
|
||||
FillBinding("b", "B");
|
||||
FillBinding("x", "X");
|
||||
FillBinding("y", "Y");
|
||||
|
||||
FillBinding("du", "DPad Up", AllyControl.MappingDU);
|
||||
FillBinding("dd", "DPad Down", AllyControl.MappingDD);
|
||||
FillBinding("du", "DPad Up");
|
||||
FillBinding("dd", "DPad Down");
|
||||
|
||||
FillBinding("dl", "DPad Left", AllyControl.MappingDL);
|
||||
FillBinding("dr", "DPad Right", AllyControl.MappingDR);
|
||||
FillBinding("dl", "DPad Left");
|
||||
FillBinding("dr", "DPad Right");
|
||||
|
||||
FillBinding("rb", "Right Bumper", AllyControl.MappingRB);
|
||||
FillBinding("lb", "Left Bumper", AllyControl.MappingLB);
|
||||
FillBinding("rb", "RBumper");
|
||||
FillBinding("lb", "LBumper");
|
||||
|
||||
FillBinding("rs", "Right Stick", AllyControl.MappingRS);
|
||||
FillBinding("ll", "Left Stick", AllyControl.MappingLS);
|
||||
FillBinding("rs", "RStick");
|
||||
FillBinding("ll", "LStick");
|
||||
|
||||
FillBinding("vb", "View");
|
||||
FillBinding("mb", "Menu");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void FillBinding(string name, string label, int defaultValue = -1)
|
||||
private RComboBox ComboBinding(string name, int value)
|
||||
{
|
||||
tableBindings.RowStyles.Add(new RowStyle(SizeType.AutoSize));
|
||||
tableBindings.Controls.Add(new Label { Text = label + ":", Anchor = AnchorStyles.Left, Dock = DockStyle.Fill, Padding = new Padding(5, 5, 5, 5) }, 0, tableBindings.RowCount - 1);
|
||||
|
||||
name = "bind_" + name;
|
||||
|
||||
var combo = new RComboBox();
|
||||
|
||||
combo.BorderColor = Color.White;
|
||||
combo.ButtonColor = Color.FromArgb(255, 255, 255);
|
||||
combo.Dock = DockStyle.Fill;
|
||||
@@ -83,18 +77,26 @@ namespace GHelper
|
||||
combo.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
combo.DisplayMember = "Value";
|
||||
combo.ValueMember = "Key";
|
||||
|
||||
int value = AppConfig.Get(name, defaultValue);
|
||||
|
||||
foreach (var item in AllyControl.BindingCodes)
|
||||
{
|
||||
combo.Items.Add(new KeyValuePair<int, string>(item.Key, item.Value));
|
||||
if (item.Key == value) combo.SelectedItem = item;
|
||||
}
|
||||
|
||||
combo.SelectedValueChanged += Binding_SelectedValueChanged;
|
||||
|
||||
tableBindings.Controls.Add(combo, 1, tableBindings.RowCount - 1);
|
||||
return combo;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void FillBinding(string binding, string label, int defaultValue = -1)
|
||||
{
|
||||
tableBindings.RowStyles.Add(new RowStyle(SizeType.AutoSize));
|
||||
tableBindings.Controls.Add(new Label { Text = label, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill, Padding = new Padding(5, 5, 5, 5) }, 0, tableBindings.RowCount);
|
||||
|
||||
tableBindings.Controls.Add(ComboBinding("bind_" + binding, AppConfig.Get("bind_" + binding, defaultValue)), 1, tableBindings.RowCount);
|
||||
tableBindings.Controls.Add(ComboBinding("bind2_" + binding, AppConfig.Get("bind2_" + binding)), 2, tableBindings.RowCount);
|
||||
|
||||
tableBindings.RowCount++;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user