private static KeyNode AddOrGetNode(KeyNode parent, LedKey key) { if (parent.Children.TryGetValue(key, out var node)) { return(node); } node = new KeyNode() { Key = key }; parent.Children.Add(key, node); return(node); }
private void SetLedState(LedKey key, PinValue state) { int virtualKey = 0; if (key == LedKey.NumLock) { virtualKey = Interop.VK_NUMLOCK; } else if (key == LedKey.CapsLock) { virtualKey = Interop.VK_CAPITAL; } else if (key == LedKey.ScrollLock) { virtualKey = Interop.VK_SCROLL; } else { throw new NotSupportedException("No such key"); } // Bit 1 indicates whether the LED is currently on or off (or, whether Scroll lock, num lock, caps lock is on) int currentKeyState = Interop.GetKeyState(virtualKey) & 1; if ((state == PinValue.High && currentKeyState == 0) || (state == PinValue.Low && currentKeyState != 0)) { // Simulate a key press Interop.keybd_event((byte)virtualKey, 0x45, Interop.KEYEVENTF_EXTENDEDKEY | 0, IntPtr.Zero); // Simulate a key release Interop.keybd_event((byte)virtualKey, 0x45, Interop.KEYEVENTF_EXTENDEDKEY | Interop.KEYEVENTF_KEYUP, IntPtr.Zero); } }
public override bool SetKeyColor(LedKey key, LedColor color) { return(LogiLedSetLightingForKeyWithHidCode((int)key, color.Rperc, color.Gperc, color.Bperc)); }
public virtual bool SetKeyColor(LedKey key, LedColor color) { throw new NotImplementedException(); }
public KeyPressedArgs(LedKey key, bool isPressed) { Key = key; IsPressed = isPressed; }