From 5f1c92652709ef26fb2f4ad7506f3e736c6bf003 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Tue, 4 Jul 2023 23:07:55 +0200 Subject: [PATCH] Keyboard listener retry --- app/Input/InputDispatcher.cs | 3 ++- app/Input/KeyboardListener.cs | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/Input/InputDispatcher.cs b/app/Input/InputDispatcher.cs index 1255a5c1..26e92f7d 100644 --- a/app/Input/InputDispatcher.cs +++ b/app/Input/InputDispatcher.cs @@ -12,7 +12,7 @@ namespace GHelper.Input public class InputDispatcher { System.Timers.Timer timer = new System.Timers.Timer(1000); - public bool backlightActivity = true; + public static bool backlightActivity = true; public static Keys keyProfile = Keys.F5; public static Keys keyApp = Keys.F12; @@ -342,6 +342,7 @@ namespace GHelper.Input public static void TabletMode() { + bool touchpadState = GetTouchpadState(); bool tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState) > 0; diff --git a/app/Input/KeyboardListener.cs b/app/Input/KeyboardListener.cs index 6e182e9b..693e320d 100644 --- a/app/Input/KeyboardListener.cs +++ b/app/Input/KeyboardListener.cs @@ -10,7 +10,20 @@ namespace GHelper.Input public KeyboardListener(Action KeyHandler) { HidDevice? input = AsusUSB.GetDevice(); - if (input == null) return; + + // Fallback + if (input == null) + { + AsusUSB.Init(); + Thread.Sleep(1000); + input = AsusUSB.GetDevice(); + } + + if (input == null) + { + Logger.WriteLine($"Input device not found"); + return; + } Logger.WriteLine($"Input: {input.DevicePath}");