Exemplo n.º 1
0
 private void OnFnKeyCombinationDown(AppleKeyboardKeys appleKeyState, Keys key, Win32.KeyboardHookEventStruct keyEventStruct)
 {
     if (FnKeyCombinationDown != null)
     {
         FnKeyCombinationDown(this, new AppleKeyboardEventArgs(appleKeyState, key, keyEventStruct));
     }
 }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
        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;
 }
 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;
 }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
 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;
     }
 }
Exemplo n.º 10
0
 private void OnFnKeyCombinationDown(AppleKeyboardKeys appleKeyState, Keys key, Win32.KeyboardHookEventStruct keyEventStruct)
 {
     if (FnKeyCombinationDown != null)
         FnKeyCombinationDown(this, new AppleKeyboardEventArgs(appleKeyState, key, keyEventStruct));
 }