From 70983fa23077959c8f06e7a4d1fc2f776a29d35a Mon Sep 17 00:00:00 2001 From: CasperH2O Date: Tue, 19 Dec 2023 14:03:27 +0100 Subject: [PATCH] Cleanup Coderabbit thick finger incident. --- .../Controllers/LegionController.cs | 37 +++++-------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/HandheldCompanion/Controllers/LegionController.cs b/HandheldCompanion/Controllers/LegionController.cs index ff0e3b193..d3ea3b717 100644 --- a/HandheldCompanion/Controllers/LegionController.cs +++ b/HandheldCompanion/Controllers/LegionController.cs @@ -44,6 +44,9 @@ private enum BackEnum private const byte PING_IDX = 40; private HashSet READY_STATES = new HashSet() {25, 60}; + private const byte MIN_WIRELESS_STATUS = 40; + private const byte MAX_WIRELESS_STATUS = 50; + private Thread dataThread; private bool dataThreadRunning; @@ -56,22 +59,13 @@ public override bool IsReady return READY_STATES.Contains(status); } } -private const byte MIN_WIRELESS_STATUS = 40; -private const byte MAX_WIRELESS_STATUS = 50; -public bool IsWireless -{ - get - { - return (status >= MIN_WIRELESS_STATUS && status <= MAX_WIRELESS_STATUS); - } -} public bool IsWireless { get { - byte status = GetStatus(PING_IDX); - return (status >= 40 && status <= 50); + byte status = GetStatus(PING_IDX); + return (status >= MIN_WIRELESS_STATUS && status <= MAX_WIRELESS_STATUS); } } @@ -245,12 +239,9 @@ private async void dataThreadLoop(object? obj) if (hidDevice is null) continue; - HidReport report = hidDevice.ReadReport(); -internal void SetPassthrough(bool enabled) -{ - SetTouchPadStatus(enabled ? 1 : 0); - IsPassthrough = enabled; -} + HidReport report = hidDevice.ReadReport(); + + if (report is not null) { // check if packet is safe if (READY_STATES.Contains(report.Data[STATUS_IDX])) @@ -384,17 +375,9 @@ public void HandleTouchpadInput(bool touched, ushort x, ushort y) internal void SetPassthrough(bool enabled) { - switch(enabled) - { - case true: - SetTouchPadStatus(1); - break; - case false: - SetTouchPadStatus(0); - break; - } - + SetTouchPadStatus(enabled ? 1 : 0); IsPassthrough = enabled; } + } }