From 50784ea29542379be0c9b45a01e74cb290bdf146 Mon Sep 17 00:00:00 2001 From: Clive Galway Date: Sat, 15 Jan 2022 18:46:22 +0000 Subject: [PATCH] Remove keyboard code from PollThread --- C#/AutoHotInterception/Manager.cs | 89 ------------------------------- 1 file changed, 89 deletions(-) diff --git a/C#/AutoHotInterception/Manager.cs b/C#/AutoHotInterception/Manager.cs index 241be02..122f560 100644 --- a/C#/AutoHotInterception/Manager.cs +++ b/C#/AutoHotInterception/Manager.cs @@ -630,96 +630,7 @@ namespace AutoHotInterception { if (i < 11) { - // Keyboard - var isMonitoredKeyboard = IsMonitoredDevice(i) == 1; - var hasSubscription = false; - var hasContext = ContextCallbacks.ContainsKey(i); - - // Process any waiting input for this keyboard - var block = false; - // If this is not a monitored keyboard, skip. - // This check should not really be needed as the IsMonitoredDevice() predicate should only match monitored keyboards... - // ... but in case it does, we want to ignore this bit and pass the input through - if (isMonitoredKeyboard) - { - var isKeyMapping = false; // True if this is a mapping to a single key, else it would be a mapping to a whole device - var processedState = HelperFunctions.KeyboardStrokeToKeyboardState(stroke); - var code = processedState.Code; - var state = processedState.State; - MappingOptions mapping = null; - - if (KeyboardMappings.ContainsKey(i)) - { - mapping = KeyboardMappings[i]; - } - else if (KeyboardKeyMappings.ContainsKey(i) && KeyboardKeyMappings[i].ContainsKey(code)) - { - isKeyMapping = true; - mapping = KeyboardKeyMappings[i][code]; - } - if (mapping != null) - { - // Process Subscription Mode - - #region KeyCode, State, Extended Flag translation - - // Begin translation of incoming key code, state, extended flag etc... - var processMappings = true; - - #endregion - - if (processedState.Ignore) - { - // Set flag to stop Context Mode from firing - hasSubscription = true; - // Set flag to indicate disable mapping processing - processMappings = false; - } - - // Code and state now normalized, proceed with checking for subscriptions... - if (processMappings) - { - hasSubscription = true; - - if (mapping.Block) block = true; - if (mapping.Concurrent) - { - if (isKeyMapping) - { - ThreadPool.QueueUserWorkItem(threadProc => mapping.Callback(state)); - } - else - { - ThreadPool.QueueUserWorkItem(threadProc => mapping.Callback(code, state)); - } - } - else - { - if (isKeyMapping) - { - WorkerThreads[i][code]?.Actions.Add(() => mapping.Callback(state)); - } - else - { - DeviceWorkerThreads[i]?.Actions.Add(() => mapping.Callback(code, state)); - } - } - } - } - } - - // If the key was blocked by Subscription Mode, then move on to next key... - if (block) continue; - - // If this key had no subscriptions, but Context Mode is set for this keyboard... - // ... then set the Context before sending the key - if (!hasSubscription && hasContext) ContextCallbacks[i](1); - - // Pass the key through to the OS. - ManagedWrapper.Send(DeviceContext, i, ref stroke, 1); - // If we are processing Context Mode, then Unset the context variable after sending the key - if (!hasSubscription && hasContext) ContextCallbacks[i](0); } else {