예제 #1
0
 private void OnFnKeyCombinationDown(AppleKeyboardKeys appleKeyState, Keys key, Win32.KeyboardHookEventStruct keyEventStruct)
 {
     if (FnKeyCombinationDown != null)
     {
         FnKeyCombinationDown(this, new AppleKeyboardEventArgs(appleKeyState, key, keyEventStruct));
     }
 }
예제 #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);
     }
 }
예제 #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;
 }
예제 #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);
        }
예제 #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;
     }
 }
예제 #10
0
 private void OnFnKeyCombinationDown(AppleKeyboardKeys appleKeyState, Keys key, Win32.KeyboardHookEventStruct keyEventStruct)
 {
     if (FnKeyCombinationDown != null)
         FnKeyCombinationDown(this, new AppleKeyboardEventArgs(appleKeyState, key, keyEventStruct));
 }