Skip to content

Commit 3d95fb3

Browse files
committed
Controller mode binding
1 parent 8c5f4aa commit 3d95fb3

9 files changed

+54
-7
lines changed

app/Ally/AllyControl.cs

+19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using GHelper.Gpu.AMD;
2+
using GHelper.Helpers;
23
using GHelper.Input;
34
using GHelper.Mode;
45
using GHelper.USB;
@@ -90,6 +91,7 @@ public class AllyControl
9091
public const string BindBrightnessDown = "04-04-8C-88-8A-05";
9192
public const string BindBrightnessUp = "04-04-8C-88-8A-06";
9293
public const string BindXGM = "04-04-8C-88-8A-04";
94+
public const string BindToggleMode = "04-04-8C-88-8A-0C";
9395

9496
public const string BindOverlay = "04-03-8C-88-44";
9597

@@ -140,6 +142,8 @@ public class AllyControl
140142

141143
{ BindXB, "XBox/Steam" },
142144

145+
{ BindToggleMode, "Controller Mode" },
146+
143147
{ BindVolUp, "Vol Up" },
144148
{ BindVolDown, "Vol Down" },
145149
{ BindBrightnessUp, "Bright Up" },
@@ -584,6 +588,21 @@ private void SetMode(ControllerMode mode)
584588
settings.VisualiseController(mode);
585589
}
586590

591+
592+
public void ToggleModeHotkey()
593+
{
594+
if (_applyMode == ControllerMode.Gamepad)
595+
{
596+
SetMode(ControllerMode.Mouse);
597+
Program.toast.RunToast("Mouse", ToastIcon.Controller);
598+
}
599+
else
600+
{
601+
SetMode(ControllerMode.Gamepad);
602+
Program.toast.RunToast("Gamepad", ToastIcon.Controller);
603+
}
604+
}
605+
587606
public void ToggleMode()
588607
{
589608
switch (_mode)

app/Gpu/AMD/AmdGpuControl.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,14 @@ public AmdGpuControl()
6565
if (!Adl2.Load())
6666
return;
6767

68-
if (Adl2.ADL2_Main_Control_Create(1, out _adlContextHandle) != Adl2.ADL_SUCCESS)
68+
try
69+
{
70+
if (Adl2.ADL2_Main_Control_Create(1, out _adlContextHandle) != Adl2.ADL_SUCCESS) return;
71+
} catch (Exception ex)
72+
{
73+
Logger.WriteLine(ex.Message);
6974
return;
75+
}
7076

7177
ADLAdapterInfo? internalDiscreteAdapter = FindByType(ADLAsicFamilyType.Discrete);
7278

app/Helpers/ToastForm.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public enum ToastIcon
5050
MicrophoneMute,
5151
FnLock,
5252
Battery,
53-
Charger
53+
Charger,
54+
Controller
5455
}
5556

5657
public class ToastForm : OSDNativeForm
@@ -111,6 +112,9 @@ protected override void PerformPaint(PaintEventArgs e)
111112
case ToastIcon.Charger:
112113
icon = Properties.Resources.icons8_charging_battery_96;
113114
break;
115+
case ToastIcon.Controller:
116+
icon = Properties.Resources.icons8_controller_96;
117+
break;
114118

115119
}
116120

app/Input/InputDispatcher.cs

+4
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public void RegisterKeys()
146146
hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control | ModifierKeys.Alt, Keys.F1);
147147
hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control | ModifierKeys.Alt, Keys.F2);
148148
hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control | ModifierKeys.Alt, Keys.F3);
149+
hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control | ModifierKeys.Alt, Keys.F4);
149150
}
150151

151152
// FN-Lock group
@@ -374,6 +375,9 @@ public void KeyPressed(object sender, KeyPressedEventArgs e)
374375
case Keys.F3:
375376
Program.settingsForm.gpuControl.ToggleXGM(true);
376377
break;
378+
case Keys.F4:
379+
Program.settingsForm.allyControl.ToggleModeHotkey();
380+
break;
377381
case Keys.F14:
378382
Program.settingsForm.gpuControl.SetGPUMode(AsusACPI.GPUModeEco);
379383
break;

app/Properties/Resources.Designer.cs

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/Properties/Resources.resx

+3
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,7 @@
328328
<data name="icons8-xbox-rt-32" type="System.Resources.ResXFileRef, System.Windows.Forms">
329329
<value>..\Resources\icons8-xbox-rt-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
330330
</data>
331+
<data name="icons8_controller_96" type="System.Resources.ResXFileRef, System.Windows.Forms">
332+
<value>..\Resources\icons8-controller-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
333+
</data>
331334
</root>
1.74 KB
Loading

app/Settings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public partial class SettingsForm : RForm
2424
ToolStripMenuItem menuSilent, menuBalanced, menuTurbo, menuEco, menuStandard, menuUltimate, menuOptimized;
2525

2626
public GPUModeControl gpuControl;
27+
public AllyControl allyControl;
2728
ScreenControl screenControl = new ScreenControl();
28-
AllyControl allyControl;
2929
AutoUpdateControl updateControl;
3030

3131
AsusMouseSettings? mouseSettings;

app/USB/Aura.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -238,19 +238,19 @@ private static void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs
238238
}
239239

240240

241-
public static byte[] AuraMessage(AuraMode mode, Color color, Color color2, int speed, bool mono = false)
241+
public static byte[] AuraMessage(AuraMode mode, Color color, Color color2, int speed, bool mono = false, byte zoneByte = 0x00)
242242
{
243243

244244
byte[] msg = new byte[17];
245245
msg[0] = AsusHid.AURA_ID;
246-
msg[1] = 0xb3;
247-
msg[2] = 0x00; // Zone
246+
msg[1] = 0xB3;
247+
msg[2] = zoneByte; // Zone
248248
msg[3] = (byte)mode; // Aura Mode
249249
msg[4] = color.R; // R
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] = 0; // aura.direction as u8;
253+
msg[8] = 0xFF; // 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
@@ -665,6 +665,7 @@ public static void ApplyAura(double colorDim = 1)
665665
int _speed = (Speed == AuraSpeed.Normal) ? 0xeb : (Speed == AuraSpeed.Fast) ? 0xf5 : 0xe1;
666666

667667
AsusHid.Write(new List<byte[]> { AuraMessage(Mode, _Color1, _Color2, _speed, isSingleColor), MESSAGE_SET, MESSAGE_APPLY });
668+
//AsusHid.Write(new List<byte[]> { AuraMessage(Mode, _Color1, _Color2, _speed, isSingleColor, 0x0A), MESSAGE_SET, MESSAGE_APPLY });
668669

669670
if (isACPI)
670671
Program.acpi.TUFKeyboardRGB(Mode, Color1, _speed);

0 commit comments

Comments
 (0)