From 3d95fb33ce25c29da8848b126da15765c03813ec Mon Sep 17 00:00:00 2001
From: Serge <5920850+seerge@users.noreply.github.com>
Date: Sun, 28 Jan 2024 20:09:40 +0100
Subject: [PATCH] Controller mode binding
---
app/Ally/AllyControl.cs | 19 +++++++++++++++++++
app/Gpu/AMD/AmdGpuControl.cs | 8 +++++++-
app/Helpers/ToastForm.cs | 6 +++++-
app/Input/InputDispatcher.cs | 4 ++++
app/Properties/Resources.Designer.cs | 10 ++++++++++
app/Properties/Resources.resx | 3 +++
app/Resources/icons8-controller-96.png | Bin 0 -> 1782 bytes
app/Settings.cs | 2 +-
app/USB/Aura.cs | 9 +++++----
9 files changed, 54 insertions(+), 7 deletions(-)
create mode 100644 app/Resources/icons8-controller-96.png
diff --git a/app/Ally/AllyControl.cs b/app/Ally/AllyControl.cs
index f8aec50e..1a7bf5f0 100644
--- a/app/Ally/AllyControl.cs
+++ b/app/Ally/AllyControl.cs
@@ -1,4 +1,5 @@
using GHelper.Gpu.AMD;
+using GHelper.Helpers;
using GHelper.Input;
using GHelper.Mode;
using GHelper.USB;
@@ -90,6 +91,7 @@ namespace GHelper.Ally
public const string BindBrightnessDown = "04-04-8C-88-8A-05";
public const string BindBrightnessUp = "04-04-8C-88-8A-06";
public const string BindXGM = "04-04-8C-88-8A-04";
+ public const string BindToggleMode = "04-04-8C-88-8A-0C";
public const string BindOverlay = "04-03-8C-88-44";
@@ -140,6 +142,8 @@ namespace GHelper.Ally
{ BindXB, "XBox/Steam" },
+ { BindToggleMode, "Controller Mode" },
+
{ BindVolUp, "Vol Up" },
{ BindVolDown, "Vol Down" },
{ BindBrightnessUp, "Bright Up" },
@@ -584,6 +588,21 @@ namespace GHelper.Ally
settings.VisualiseController(mode);
}
+
+ public void ToggleModeHotkey()
+ {
+ if (_applyMode == ControllerMode.Gamepad)
+ {
+ SetMode(ControllerMode.Mouse);
+ Program.toast.RunToast("Mouse", ToastIcon.Controller);
+ }
+ else
+ {
+ SetMode(ControllerMode.Gamepad);
+ Program.toast.RunToast("Gamepad", ToastIcon.Controller);
+ }
+ }
+
public void ToggleMode()
{
switch (_mode)
diff --git a/app/Gpu/AMD/AmdGpuControl.cs b/app/Gpu/AMD/AmdGpuControl.cs
index bae8716c..6583f12a 100644
--- a/app/Gpu/AMD/AmdGpuControl.cs
+++ b/app/Gpu/AMD/AmdGpuControl.cs
@@ -65,8 +65,14 @@ public class AmdGpuControl : IGpuControl
if (!Adl2.Load())
return;
- if (Adl2.ADL2_Main_Control_Create(1, out _adlContextHandle) != Adl2.ADL_SUCCESS)
+ try
+ {
+ if (Adl2.ADL2_Main_Control_Create(1, out _adlContextHandle) != Adl2.ADL_SUCCESS) return;
+ } catch (Exception ex)
+ {
+ Logger.WriteLine(ex.Message);
return;
+ }
ADLAdapterInfo? internalDiscreteAdapter = FindByType(ADLAsicFamilyType.Discrete);
diff --git a/app/Helpers/ToastForm.cs b/app/Helpers/ToastForm.cs
index 31be15ca..a96cc509 100644
--- a/app/Helpers/ToastForm.cs
+++ b/app/Helpers/ToastForm.cs
@@ -50,7 +50,8 @@ namespace GHelper.Helpers
MicrophoneMute,
FnLock,
Battery,
- Charger
+ Charger,
+ Controller
}
public class ToastForm : OSDNativeForm
@@ -111,6 +112,9 @@ namespace GHelper.Helpers
case ToastIcon.Charger:
icon = Properties.Resources.icons8_charging_battery_96;
break;
+ case ToastIcon.Controller:
+ icon = Properties.Resources.icons8_controller_96;
+ break;
}
diff --git a/app/Input/InputDispatcher.cs b/app/Input/InputDispatcher.cs
index 01346d27..580d97f7 100644
--- a/app/Input/InputDispatcher.cs
+++ b/app/Input/InputDispatcher.cs
@@ -146,6 +146,7 @@ namespace GHelper.Input
hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control | ModifierKeys.Alt, Keys.F1);
hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control | ModifierKeys.Alt, Keys.F2);
hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control | ModifierKeys.Alt, Keys.F3);
+ hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control | ModifierKeys.Alt, Keys.F4);
}
// FN-Lock group
@@ -374,6 +375,9 @@ namespace GHelper.Input
case Keys.F3:
Program.settingsForm.gpuControl.ToggleXGM(true);
break;
+ case Keys.F4:
+ Program.settingsForm.allyControl.ToggleModeHotkey();
+ break;
case Keys.F14:
Program.settingsForm.gpuControl.SetGPUMode(AsusACPI.GPUModeEco);
break;
diff --git a/app/Properties/Resources.Designer.cs b/app/Properties/Resources.Designer.cs
index 7e09db07..7afc4654 100644
--- a/app/Properties/Resources.Designer.cs
+++ b/app/Properties/Resources.Designer.cs
@@ -250,6 +250,16 @@ namespace GHelper.Properties {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap icons8_controller_96 {
+ get {
+ object obj = ResourceManager.GetObject("icons8_controller_96", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
diff --git a/app/Properties/Resources.resx b/app/Properties/Resources.resx
index 1dc0a113..61b20e70 100644
--- a/app/Properties/Resources.resx
+++ b/app/Properties/Resources.resx
@@ -328,4 +328,7 @@
..\Resources\icons8-xbox-rt-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\icons8-controller-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/app/Resources/icons8-controller-96.png b/app/Resources/icons8-controller-96.png
new file mode 100644
index 0000000000000000000000000000000000000000..56f92739a6b92f6f76ad34871dcfa9ede4b7f7ee
GIT binary patch
literal 1782
zcmVUi-J!I`<4~uYC*xkH_Qjcsw4D$K&yMJRXmyOn`1cU&E)HD?tXjSBln1
zfL_2l?AQSGFHmcL;3G?|?*csomjSu}KNF8%i*Q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L6)FK{JPgz( { AuraMessage(Mode, _Color1, _Color2, _speed, isSingleColor), MESSAGE_SET, MESSAGE_APPLY });
+ //AsusHid.Write(new List { AuraMessage(Mode, _Color1, _Color2, _speed, isSingleColor, 0x0A), MESSAGE_SET, MESSAGE_APPLY });
if (isACPI)
Program.acpi.TUFKeyboardRGB(Mode, Color1, _speed);