mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Ally controller wake up tweaks
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using GHelper.Gpu.AMD;
|
||||
using GHelper.Input;
|
||||
using GHelper.USB;
|
||||
using HidSharp;
|
||||
using System.Text;
|
||||
|
||||
namespace GHelper.Ally
|
||||
@@ -35,7 +36,7 @@ namespace GHelper.Ally
|
||||
SettingsForm settings;
|
||||
|
||||
static ControllerMode _mode = ControllerMode.Auto;
|
||||
static ControllerMode _applyMode = ControllerMode.Auto;
|
||||
static ControllerMode _applyMode = ControllerMode.Mouse;
|
||||
static int _autoCount = 0;
|
||||
|
||||
static int fpsLimit = -1;
|
||||
@@ -241,9 +242,8 @@ namespace GHelper.Ally
|
||||
|
||||
if (_autoCount > 2)
|
||||
{
|
||||
_applyMode = newMode;
|
||||
_autoCount = 0;
|
||||
ApplyMode(_applyMode);
|
||||
ApplyMode(newMode);
|
||||
Logger.WriteLine(fps.ToString());
|
||||
}
|
||||
|
||||
@@ -254,14 +254,10 @@ namespace GHelper.Ally
|
||||
if (AppConfig.IsAlly()) settings.VisualiseAlly(true);
|
||||
else return;
|
||||
|
||||
SetDeadzones();
|
||||
SetMode((ControllerMode)AppConfig.Get("controller_mode", (int)ControllerMode.Auto));
|
||||
|
||||
settings.VisualiseBacklight(InputDispatcher.GetBacklight());
|
||||
|
||||
fpsLimit = amdControl.GetFPSLimit();
|
||||
Logger.WriteLine($"FPS Limit: {fpsLimit}");
|
||||
settings.VisualiseFPSLimit(fpsLimit);
|
||||
settings.VisualiseFPSLimit(amdControl.GetFPSLimit());
|
||||
|
||||
}
|
||||
|
||||
@@ -439,12 +435,29 @@ namespace GHelper.Ally
|
||||
|
||||
}
|
||||
|
||||
public static void ApplyMode(ControllerMode? applyMode = null)
|
||||
public static void ApplyMode(ControllerMode applyMode = ControllerMode.Auto)
|
||||
{
|
||||
Task.Run(() => {
|
||||
|
||||
if (applyMode is not null) _applyMode = (ControllerMode)applyMode;
|
||||
HidStream? input = AsusHid.FindHidStream(AsusHid.INPUT_ID);
|
||||
int count = 0;
|
||||
|
||||
while (input == null && count++ < 5)
|
||||
{
|
||||
input = AsusHid.FindHidStream(AsusHid.INPUT_ID);
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
if (input == null)
|
||||
{
|
||||
Logger.WriteLine($"Controller not found");
|
||||
return;
|
||||
}
|
||||
|
||||
if (applyMode != ControllerMode.Auto) _applyMode = applyMode;
|
||||
|
||||
WakeUp();
|
||||
|
||||
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xd1, 0x01, 0x01, (byte)_applyMode }, "Controller");
|
||||
AsusHid.WriteInput(CommandSave, null);
|
||||
|
||||
@@ -463,13 +476,19 @@ namespace GHelper.Ally
|
||||
}
|
||||
|
||||
AsusHid.WriteInput(CommandSave, null);
|
||||
SetDeadzones();
|
||||
});
|
||||
}
|
||||
|
||||
private void SetMode(ControllerMode mode)
|
||||
{
|
||||
|
||||
_mode = mode;
|
||||
ApplyMode(mode);
|
||||
AppConfig.Set("controller_mode", (int)mode);
|
||||
|
||||
if (mode == ControllerMode.Auto)
|
||||
{
|
||||
_applyMode = ControllerMode.Auto;
|
||||
amdControl.StartFPS();
|
||||
timer.Start();
|
||||
}
|
||||
@@ -477,11 +496,8 @@ namespace GHelper.Ally
|
||||
{
|
||||
timer.Stop();
|
||||
amdControl.StopFPS();
|
||||
ApplyMode(mode);
|
||||
}
|
||||
|
||||
_mode = mode;
|
||||
AppConfig.Set("controller_mode", (int)mode);
|
||||
settings.VisualiseController(mode);
|
||||
}
|
||||
|
||||
@@ -491,17 +507,16 @@ namespace GHelper.Ally
|
||||
switch (_mode)
|
||||
{
|
||||
case ControllerMode.Auto:
|
||||
_mode = ControllerMode.Gamepad;
|
||||
SetMode(ControllerMode.Gamepad);
|
||||
break;
|
||||
case ControllerMode.Gamepad:
|
||||
_mode = ControllerMode.Mouse;
|
||||
SetMode(ControllerMode.Mouse);
|
||||
break;
|
||||
case ControllerMode.Mouse:
|
||||
_mode = ControllerMode.Auto;
|
||||
SetMode(ControllerMode.Auto);
|
||||
break;
|
||||
}
|
||||
|
||||
SetMode(_mode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -168,6 +168,9 @@ public class AmdGpuControl : IGpuControl
|
||||
if (_adlContextHandle == nint.Zero || _iGPU == null) return -1;
|
||||
ADLFPSSettingsOutput settings;
|
||||
if (ADL2_FPS_Settings_Get(_adlContextHandle, ((ADLAdapterInfo)_iGPU).AdapterIndex, out settings) != Adl2.ADL_SUCCESS) return -1;
|
||||
|
||||
Logger.WriteLine($"FPS Limit: {settings.ulACFPSCurrent}");
|
||||
|
||||
return settings.ulACFPSCurrent;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace GHelper.Input
|
||||
HidStream? input = AsusHid.FindHidStream(AsusHid.INPUT_ID);
|
||||
|
||||
// Fallback
|
||||
|
||||
int count = 0;
|
||||
|
||||
while (input == null && count++ < 5)
|
||||
@@ -39,8 +38,6 @@ namespace GHelper.Input
|
||||
|
||||
Logger.WriteLine($"Input: {input.Device.DevicePath}");
|
||||
|
||||
if (AppConfig.IsAlly()) AllyControl.ApplyMode();
|
||||
|
||||
try
|
||||
{
|
||||
while (!cancellationTokenSource.Token.IsCancellationRequested)
|
||||
|
||||
Reference in New Issue
Block a user