Skip to content

Commit

Permalink
Re-apply Ally controller status on every wake up / reboot #3192
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Sep 30, 2024
1 parent 917fe11 commit ff5ac7d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
34 changes: 18 additions & 16 deletions app/Ally/AllyControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,9 @@ static public void SetDeadzones()

}

public static void ApplyXBoxStatus()
public static void DisableXBoxController(bool disabled)
{
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD1, 0x0B, 0x01, AppConfig.Is("controller_disabled") ? (byte)0x02 : (byte)0x01], "Status");
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD1, 0x0B, 0x01, disabled ? (byte)0x02 : (byte)0x01], $"ControllerDisabled: {disabled}");
}

public static void ApplyMode(ControllerMode applyMode = ControllerMode.Auto, bool init = false)
Expand Down Expand Up @@ -651,26 +651,28 @@ public static void ApplyMode(ControllerMode applyMode = ControllerMode.Auto, boo
InputDispatcher.SetBacklightAuto(true);
}

AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD1, 0x01, 0x01, (byte)_applyMode], "Controller");
//AsusHid.WriteInput(CommandSave, null);
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD1, 0x01, 0x01, (byte)_applyMode], "Controller");
//AsusHid.WriteInput(CommandSave, null);

BindZone(BindingZone.M1M2);
BindZone(BindingZone.DPadUpDown);
BindZone(BindingZone.DPadLeftRight);
BindZone(BindingZone.StickClick);
BindZone(BindingZone.Bumper);
BindZone(BindingZone.AB);
BindZone(BindingZone.XY);
BindZone(BindingZone.ViewMenu);
BindZone(BindingZone.Trigger);
BindZone(BindingZone.M1M2);
BindZone(BindingZone.DPadUpDown);
BindZone(BindingZone.DPadLeftRight);
BindZone(BindingZone.StickClick);
BindZone(BindingZone.Bumper);
BindZone(BindingZone.AB);
BindZone(BindingZone.XY);
BindZone(BindingZone.ViewMenu);
BindZone(BindingZone.Trigger);

AsusHid.WriteInput(CommandSave, null);
AsusHid.WriteInput(CommandSave, null);

SetDeadzones();
SetDeadzones();

if (init && AppConfig.Is("controller_disabled"))
{
ApplyXBoxStatus();
Thread.Sleep(500);
DisableXBoxController(false);
DisableXBoxController(true);
}

});
Expand Down
2 changes: 1 addition & 1 deletion app/Handheld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Handheld()
private void CheckController_CheckedChanged(object? sender, EventArgs e)
{
AppConfig.Set("controller_disabled", checkController.Checked ? 1 : 0);
AllyControl.ApplyXBoxStatus();
AllyControl.DisableXBoxController(checkController.Checked);
}

private void ComboBinding(RComboBox combo)
Expand Down

0 comments on commit ff5ac7d

Please sign in to comment.