private void OnFnKeyCombinationDown(AppleKeyboardKeys appleKeyState, Keys key, Win32.KeyboardHookEventStruct keyEventStruct) { if (FnKeyCombinationDown != null) { FnKeyCombinationDown(this, new AppleKeyboardEventArgs(appleKeyState, key, keyEventStruct)); } }
private Boolean OnKeyUp(AppleKeyboardKeys appleKeyState, Keys key, Win32.KeyboardHookEventStruct keyEventStruct) { if (KeyUp != null) { AppleKeyboardEventArgs eArgs = new AppleKeyboardEventArgs(appleKeyState, key, keyEventStruct); KeyUp(this, eArgs); return(eArgs.Handled); } else { return(false); } }
private void SpecialKeyStateChanged(IAsyncResult ar) { if (_stream == null || !ar.IsCompleted) { return; } try { _stream.EndRead(ar); } catch (OperationCanceledException) { } catch (IOException ioe) { // restart (reconnected) Debug.WriteLine("Restart: " + ioe.Message); if (Disconnected != null) { Disconnected(this, EventArgs.Empty); } return; } Byte[] buffer = ar.AsyncState as Byte[]; foreach (Byte b in buffer) { Debug.Write(String.Format("{0:x2} ", b)); } if (buffer[0] == 0x11) { Debug.Write((AppleKeyboardKeys)buffer[1]); CurrentKeyState = (AppleKeyboardKeys)buffer[1]; } else if (buffer[0] == 0x13) { Debug.Write(buffer[1] == 1 ? "Power (Down)" : "Power (Up)"); CurrentPowerButtonIsDown = (buffer[1] == 1); } OnSpecialKeyDown(); Debug.WriteLine(""); _stream.BeginRead(buffer, 0, buffer.Length, SpecialKeyStateChanged, buffer); }
public AppleKeyboardEventArgs(AppleKeyboardKeys appleKeyState, Keys key, Win32.KeyboardHookEventStruct keyEventStruct) { AppleKeyState = appleKeyState; Key = key; KeyEventStruct = keyEventStruct; }
public KeyEventArgs(Boolean isPowerButtonDown, AppleKeyboardKeys appleKeyboardKey) { IsPowerButtonDown = isPowerButtonDown; AppleKeyboardKey = appleKeyboardKey; }
private void SpecialKeyStateChanged(IAsyncResult ar) { if (_stream == null || !ar.IsCompleted) return; try { _stream.EndRead(ar); } catch (OperationCanceledException) { } catch (IOException ioe) { // restart (reconnected) Debug.WriteLine("Restart: " + ioe.Message); if (Disconnected != null) Disconnected(this, EventArgs.Empty); return; } Byte[] buffer = ar.AsyncState as Byte[]; foreach (Byte b in buffer) Debug.Write(String.Format("{0:x2} ", b)); if (buffer[0] == 0x11) { Debug.Write((AppleKeyboardKeys) buffer[1]); CurrentKeyState = (AppleKeyboardKeys) buffer[1]; } else if (buffer[0] == 0x13) { Debug.Write(buffer[1] == 1 ? "Power (Down)" : "Power (Up)"); CurrentPowerButtonIsDown = (buffer[1] == 1); } OnSpecialKeyDown(); Debug.WriteLine(""); _stream.BeginRead(buffer, 0, buffer.Length, SpecialKeyStateChanged, buffer); }
private Boolean OnKeyUp(AppleKeyboardKeys appleKeyState, Keys key, Win32.KeyboardHookEventStruct keyEventStruct) { if (KeyUp != null) { AppleKeyboardEventArgs eArgs = new AppleKeyboardEventArgs(appleKeyState, key, keyEventStruct); KeyUp(this, eArgs); return eArgs.Handled; } else { return false; } }
private void OnFnKeyCombinationDown(AppleKeyboardKeys appleKeyState, Keys key, Win32.KeyboardHookEventStruct keyEventStruct) { if (FnKeyCombinationDown != null) FnKeyCombinationDown(this, new AppleKeyboardEventArgs(appleKeyState, key, keyEventStruct)); }