From 556a4ce4eedcfec9a47adf37ffa1542530d4007e Mon Sep 17 00:00:00 2001
From: Serge <5920850+seerge@users.noreply.github.com>
Date: Fri, 12 Jan 2024 22:56:12 +0100
Subject: [PATCH] Ally Controller Modes
---
app/Ally/AllyControl.cs | 52 ++++++++++
app/Program.cs | 6 ++
app/Properties/Resources.Designer.cs | 10 ++
app/Properties/Resources.resx | 25 ++---
app/Resources/icons8-controller-32.png | Bin 0 -> 396 bytes
app/Settings.Designer.cs | 132 ++++++++++++++++++++++++-
app/Settings.cs | 33 ++++++-
7 files changed, 241 insertions(+), 17 deletions(-)
create mode 100644 app/Ally/AllyControl.cs
create mode 100644 app/Resources/icons8-controller-32.png
diff --git a/app/Ally/AllyControl.cs b/app/Ally/AllyControl.cs
new file mode 100644
index 00000000..ce404457
--- /dev/null
+++ b/app/Ally/AllyControl.cs
@@ -0,0 +1,52 @@
+using GHelper.USB;
+
+namespace GHelper.Ally
+{
+
+ public enum ControllerMode : int
+ {
+ Gamepad = 1,
+ WASD = 2,
+ Mouse = 3,
+ }
+
+ public class AllyControl
+ {
+ SettingsForm settings;
+ ControllerMode mode = ControllerMode.Gamepad;
+ public AllyControl(SettingsForm settingsForm)
+ {
+ settings = settingsForm;
+ }
+
+ public void Init()
+ {
+ if (!AppConfig.IsAlly())
+ {
+ settings.VisualiseAlly(false);
+ return;
+ }
+
+ mode = (ControllerMode)AppConfig.Get("controller_mode", (int)ControllerMode.Gamepad);
+ SetMode(mode);
+ }
+
+ private void SetMode(ControllerMode mode)
+ {
+ AppConfig.Set("controller_mode", (int)mode);
+ AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 1, 1, (byte)mode }, "ControllerMode");
+ settings.VisualiseController(mode);
+ }
+
+ public void ToggleMode()
+ {
+ if (mode == ControllerMode.Mouse)
+ mode = ControllerMode.Gamepad;
+ else
+ mode++;
+
+ SetMode(mode);
+ }
+
+ }
+}
diff --git a/app/Program.cs b/app/Program.cs
index 494abac5..b94b1620 100644
--- a/app/Program.cs
+++ b/app/Program.cs
@@ -1,3 +1,4 @@
+using GHelper.Ally;
using GHelper.Battery;
using GHelper.Display;
using GHelper.Gpu;
@@ -5,6 +6,8 @@ using GHelper.Helpers;
using GHelper.Input;
using GHelper.Mode;
using GHelper.Peripherals;
+using GHelper.USB;
+using Microsoft.VisualBasic.Logging;
using Microsoft.Win32;
using Ryzen;
using System.Diagnostics;
@@ -30,6 +33,7 @@ namespace GHelper
public static ModeControl modeControl = new ModeControl();
public static GPUModeControl gpuControl = new GPUModeControl(settingsForm);
+ public static AllyControl controllerControl = new AllyControl(settingsForm);
public static ScreenControl screenControl = new ScreenControl();
public static ClamshellModeControl clamshellControl = new ClamshellModeControl();
@@ -225,6 +229,8 @@ namespace GHelper
settingsForm.AutoKeyboard();
settingsForm.matrixControl.SetMatrix(true);
+
+ controllerControl.Init();
}
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
diff --git a/app/Properties/Resources.Designer.cs b/app/Properties/Resources.Designer.cs
index c68924a0..4fe184b7 100644
--- a/app/Properties/Resources.Designer.cs
+++ b/app/Properties/Resources.Designer.cs
@@ -220,6 +220,16 @@ namespace GHelper.Properties {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap icons8_controller_32 {
+ get {
+ object obj = ResourceManager.GetObject("icons8-controller-32", 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 3242cd04..83108d59 100644
--- a/app/Properties/Resources.resx
+++ b/app/Properties/Resources.resx
@@ -133,6 +133,9 @@
..\Resources\icons8-hibernate-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\Font.otf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
..\Resources\icons8-quit-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -148,6 +151,9 @@
..\Resources\icons8-project-management-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\dot-standard.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
..\Resources\icons8-charging-battery-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -214,6 +220,9 @@
..\Resources\icons8-rocket-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\dot-ultimate.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
..\Resources\icons8-edit-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -277,6 +286,9 @@
..\Resources\icons8-settings-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\dot-eco.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
..\Resources\icons8-processor-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -289,16 +301,7 @@
..\Resources\icons8-rocket-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\Resources\Font.otf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- ..\Resources\dot-eco.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- ..\Resources\dot-standard.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- ..\Resources\dot-ultimate.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\icons8-controller-32.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-32.png b/app/Resources/icons8-controller-32.png
new file mode 100644
index 0000000000000000000000000000000000000000..2be3db0e8e4e5b109ea5f1e418f38008bb92e74c
GIT binary patch
literal 396
zcmV;70dxL|P)@K^TRg^aw@lcRp4AxuM024-i|1{+dDdWj0B(T1;uX*Lz_(#ePd0ybfM!&HlEyFs
zR!ln