mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
UI tweaks
This commit is contained in:
@@ -32,6 +32,7 @@ public class AsusACPI
|
||||
|
||||
const uint DSTS = 0x53545344;
|
||||
const uint DEVS = 0x53564544;
|
||||
const uint INIT = 0x54494E49;
|
||||
|
||||
public const uint UniversalControl = 0x00100021;
|
||||
public const int KB_Light_Up = 0xc4;
|
||||
@@ -161,7 +162,7 @@ public class AsusACPI
|
||||
public void RunListener()
|
||||
{
|
||||
|
||||
eventHandle = CreateEvent(IntPtr.Zero, false, false, "ATK Event");
|
||||
eventHandle = CreateEvent(IntPtr.Zero, false, false, "ATK4001");
|
||||
|
||||
byte[] outBuffer = new byte[16];
|
||||
byte[] data = new byte[8];
|
||||
@@ -178,7 +179,7 @@ public class AsusACPI
|
||||
WaitForSingleObject(eventHandle, Timeout.Infinite);
|
||||
Control(0x222408, new byte[0], outBuffer);
|
||||
int code = BitConverter.ToInt32(outBuffer);
|
||||
Logger.WriteLine("Code: " + code);
|
||||
Logger.WriteLine("ACPI Code: " + code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,6 +241,13 @@ public class AsusACPI
|
||||
|
||||
}
|
||||
|
||||
public byte[] DeviceInit()
|
||||
{
|
||||
byte[] args = new byte[8];
|
||||
return CallMethod(INIT, args);
|
||||
|
||||
}
|
||||
|
||||
public int DeviceSet(uint DeviceID, int Status, string logName)
|
||||
{
|
||||
byte[] args = new byte[8];
|
||||
|
||||
@@ -229,9 +229,9 @@ namespace GHelper
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
Task.Run(() =>
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var devices = GetHidDevices(deviceIds);
|
||||
var devices = GetHidDevices(deviceIds, 0);
|
||||
foreach (HidDevice device in devices)
|
||||
{
|
||||
device.OpenDevice();
|
||||
@@ -248,7 +248,7 @@ namespace GHelper
|
||||
|
||||
public static void ApplyBrightness(int brightness)
|
||||
{
|
||||
Task.Run(() =>
|
||||
Task.Run(async () =>
|
||||
{
|
||||
|
||||
byte[] msg = { INPUT_HID_ID, 0xba, 0xc5, 0xc4, (byte)brightness };
|
||||
|
||||
@@ -182,7 +182,7 @@ public class NvidiaGpuControl : IGpuControl
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.Message);
|
||||
Debug.WriteLine(ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +151,7 @@ public static class HardwareControl
|
||||
GpuControl?.Dispose();
|
||||
|
||||
IGpuControl _gpuControl = new NvidiaGpuControl();
|
||||
|
||||
if (_gpuControl.IsValid)
|
||||
{
|
||||
GpuControl = _gpuControl;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using HidLibrary;
|
||||
using Microsoft.Win32;
|
||||
using NAudio.CoreAudioApi;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
using Tools;
|
||||
@@ -15,17 +16,9 @@ namespace GHelper
|
||||
public KeyboardListener(Action<int> KeyHandler)
|
||||
{
|
||||
HidDevice? input = AsusUSB.GetDevice();
|
||||
if (input == null) return;
|
||||
|
||||
if (input == null)
|
||||
{
|
||||
Logger.WriteLine("Input device not found");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.WriteLine("Listener input " + input.DevicePath);
|
||||
}
|
||||
|
||||
Logger.WriteLine($"Input: {input.DevicePath}");
|
||||
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
@@ -36,7 +29,7 @@ namespace GHelper
|
||||
var data = input.Read().Data;
|
||||
if (data.Length > 1 && data[0] == AsusUSB.INPUT_HID_ID && data[1] > 0)
|
||||
{
|
||||
Logger.WriteLine("Key:" + data[1]);
|
||||
Logger.WriteLine($"Key: {data[1]}");
|
||||
KeyHandler(data[1]);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +55,6 @@ namespace GHelper
|
||||
public class InputDispatcher
|
||||
{
|
||||
|
||||
private static bool isOptimizationRunning = OptimizationService.IsRunning();
|
||||
private static nint windowHandle;
|
||||
|
||||
public static Keys keyProfile = Keys.F5;
|
||||
@@ -76,7 +68,12 @@ namespace GHelper
|
||||
|
||||
windowHandle = handle;
|
||||
|
||||
byte[] result = Program.acpi.DeviceInit();
|
||||
Debug.WriteLine($"Init: {BitConverter.ToString(result)}");
|
||||
|
||||
Program.acpi.SubscribeToEvents(WatcherEventArrived);
|
||||
//Task.Run(Program.acpi.RunListener);
|
||||
|
||||
|
||||
// CTRL + SHIFT + F5 to cycle profiles
|
||||
if (AppConfig.getConfig("keybind_profile") != -1) keyProfile = (Keys)AppConfig.getConfig("keybind_profile");
|
||||
@@ -95,6 +92,7 @@ namespace GHelper
|
||||
|
||||
if (!OptimizationService.IsRunning())
|
||||
listener = new KeyboardListener(HandleEvent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +158,7 @@ namespace GHelper
|
||||
action = "aura";
|
||||
if (name == "fnf5")
|
||||
action = "performance";
|
||||
if (name == "m3" && !isOptimizationRunning)
|
||||
if (name == "m3" && !OptimizationService.IsRunning())
|
||||
action = "micmute";
|
||||
}
|
||||
|
||||
@@ -251,16 +249,13 @@ namespace GHelper
|
||||
return;
|
||||
}
|
||||
|
||||
if (isOptimizationRunning) return;
|
||||
if (OptimizationService.IsRunning()) return;
|
||||
|
||||
// Asus Optimization service Events
|
||||
|
||||
int backlight = AppConfig.getConfig("keyboard_brightness");
|
||||
|
||||
string[] backlightNames = new string[] { "Off", "Low", "Mid", "Max" };
|
||||
|
||||
int brightness;
|
||||
|
||||
switch (EventID)
|
||||
{
|
||||
case 197: // FN+F2
|
||||
@@ -289,7 +284,7 @@ namespace GHelper
|
||||
break;
|
||||
case 107: // FN+F10
|
||||
bool touchpadState = GetTouchpadState();
|
||||
if (!AsusUSB.TouchpadToggle()) Program.acpi.DeviceSet(AsusACPI.UniversalControl, 0x6B, "Touchpad");
|
||||
AsusUSB.TouchpadToggle();
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, touchpadState ? "Off" : "On", ToastIcon.Touchpad);
|
||||
break;
|
||||
case 108: // FN+F11
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace GHelper
|
||||
{
|
||||
return (Process.GetProcessesByName("AsusOptimization").Count() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1437,6 +1437,8 @@ namespace GHelper
|
||||
|
||||
UltimateUI(mux == 1);
|
||||
|
||||
if (eco < 0) tableGPU.Visible = false;
|
||||
|
||||
}
|
||||
|
||||
AppConfig.setConfig("gpu_mode", GpuMode);
|
||||
|
||||
Reference in New Issue
Block a user