Skip to content

Commit 279d07d

Browse files
committed
Controller Toggle tweaks
1 parent 8243d87 commit 279d07d

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

app/Ally/AllyControl.cs

+13-9
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public void Init()
314314
if (AppConfig.IsAlly()) settings.VisualiseAlly(true);
315315
else return;
316316

317-
SetMode((ControllerMode)AppConfig.Get("controller_mode", (int)ControllerMode.Auto));
317+
SetMode((ControllerMode)AppConfig.Get("controller_mode", (int)ControllerMode.Auto), true);
318318

319319
settings.VisualiseBacklight(InputDispatcher.GetBacklight());
320320
settings.VisualiseFPSLimit(amdControl.GetFPSLimit());
@@ -477,7 +477,7 @@ static private void BindZone(BindingZone zone)
477477
DecodeBinding(KeyR1).CopyTo(bindings, 27);
478478
DecodeBinding(KeyR2).CopyTo(bindings, 38);
479479

480-
AsusHid.WriteInput(CommandReady, null);
480+
//AsusHid.WriteInput(CommandReady, null);
481481
AsusHid.WriteInput(bindings, $"B{zone}");
482482

483483

@@ -491,7 +491,7 @@ static void WakeUp()
491491

492492
static public void SetDeadzones()
493493
{
494-
WakeUp();
494+
//WakeUp();
495495

496496
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 4, 4,
497497
(byte)AppConfig.Get("ls_min", 0),
@@ -519,7 +519,7 @@ public static void ApplyXBoxStatus()
519519
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xD1, 0x0B, 0x01, AppConfig.Is("controller_disabled") ? (byte)0x02 : (byte)0x01 }, "Status");
520520
}
521521

522-
public static void ApplyMode(ControllerMode applyMode = ControllerMode.Auto)
522+
public static void ApplyMode(ControllerMode applyMode = ControllerMode.Auto, bool init = false)
523523
{
524524
Task.Run(() =>
525525
{
@@ -543,11 +543,14 @@ public static void ApplyMode(ControllerMode applyMode = ControllerMode.Auto)
543543

544544
if (applyMode != ControllerMode.Auto) _applyMode = applyMode;
545545

546-
InputDispatcher.SetBacklightAuto(true);
547-
WakeUp();
546+
if (init)
547+
{
548+
WakeUp();
549+
InputDispatcher.SetBacklightAuto(true);
550+
}
548551

549552
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xD1, 0x01, 0x01, (byte)_applyMode }, "Controller");
550-
AsusHid.WriteInput(CommandSave, null);
553+
//AsusHid.WriteInput(CommandSave, null);
551554

552555
BindZone(BindingZone.M1M2);
553556

@@ -561,18 +564,19 @@ public static void ApplyMode(ControllerMode applyMode = ControllerMode.Auto)
561564
BindZone(BindingZone.Trigger);
562565

563566
AsusHid.WriteInput(CommandSave, null);
567+
564568
SetDeadzones();
565569

566570
});
567571
}
568572

569-
private void SetMode(ControllerMode mode)
573+
private void SetMode(ControllerMode mode, bool init = false)
570574
{
571575

572576
_mode = mode;
573577
AppConfig.Set("controller_mode", (int)mode);
574578

575-
ApplyMode(mode);
579+
ApplyMode(mode, init);
576580

577581
if (mode == ControllerMode.Auto)
578582
{

app/Extra.cs

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ private void SetKeyCombo(ComboBox combo, TextBox txbox, string name)
4444
customActions.Add("screenpad_up", Properties.Strings.ScreenPadUp);
4545
}
4646

47+
if (AppConfig.IsAlly())
48+
{
49+
customActions.Add("controller", "Controller Mode");
50+
}
51+
4752
switch (name)
4853
{
4954
case "m1":

app/Input/InputDispatcher.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public void KeyPressed(object sender, KeyPressedEventArgs e)
376376
Program.settingsForm.gpuControl.ToggleXGM(true);
377377
break;
378378
case Keys.F4:
379-
Program.settingsForm.allyControl.ToggleModeHotkey();
379+
Program.settingsForm.BeginInvoke(Program.settingsForm.allyControl.ToggleModeHotkey);
380380
break;
381381
case Keys.F14:
382382
Program.settingsForm.gpuControl.SetGPUMode(AsusACPI.GPUModeEco);
@@ -520,6 +520,9 @@ public static void KeyProcess(string name = "m3")
520520
case "calculator":
521521
LaunchProcess("calc");
522522
break;
523+
case "controller":
524+
Program.settingsForm.BeginInvoke(Program.settingsForm.allyControl.ToggleModeHotkey);
525+
break;
523526
default:
524527
break;
525528
}

app/Program.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,15 @@ public static void SetAutoModes(bool powerChanged = false, bool init = false)
229229

230230
BatteryControl.AutoBattery(init);
231231

232-
settingsForm.AutoKeyboard();
233232
settingsForm.matrixControl.SetMatrix(true);
234233

235-
allyControl.Init();
234+
if (AppConfig.IsAlly())
235+
{
236+
allyControl.Init();
237+
} else
238+
{
239+
settingsForm.AutoKeyboard();
240+
}
236241
}
237242

238243
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)

app/USB/Aura.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public static byte[] AuraMessage(AuraMode mode, Color color, Color color2, int s
250250
msg[5] = mono ? (byte)0 : color.G; // G
251251
msg[6] = mono ? (byte)0 : color.B; // B
252252
msg[7] = (byte)speed; // aura.speed as u8;
253-
msg[8] = 0xFF; // aura.direction as u8;
253+
msg[8] = 0x00; // aura.direction as u8;
254254
msg[9] = mode == AuraMode.AuraBreathe ? (byte)1 : (byte)0;
255255
msg[10] = color2.R; // R
256256
msg[11] = mono ? (byte)0 : color2.G; // G
@@ -294,12 +294,12 @@ public static void ApplyBrightness(int brightness, string log = "Backlight", boo
294294
if (delay) await Task.Delay(TimeSpan.FromSeconds(1));
295295
if (isACPI) Program.acpi.TUFKeyboardBrightness(brightness);
296296

297-
AsusHid.Write(new byte[] { AsusHid.AURA_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, log);
297+
AsusHid.Write(new byte[] { AsusHid.AURA_ID, 0xBA, 0xC5, 0xC4, (byte)brightness }, log);
298298

299299
if (AppConfig.IsAlly()) ApplyAura();
300300

301301
if (AppConfig.ContainsModel("GA503"))
302-
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, log);
302+
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xBA, 0xC5, 0xC4, (byte)brightness }, log);
303303
});
304304

305305

0 commit comments

Comments
 (0)