Пример #1
0
        private void UpdatePressedStateForKey(Key.Scan key, bool state)
        {
            switch (key)
            {
            case Key.Scan.LeftShift:
                d_leftShift = state;
                break;

            case Key.Scan.RightShift:
                d_rightShift = state;
                break;

            case Key.Scan.LeftControl:
                d_leftCtrl = state;
                break;

            case Key.Scan.RightControl:
                d_rightCtrl = state;
                break;

            case Key.Scan.LeftAlt:
                d_leftAlt = state;
                break;

            case Key.Scan.RightAlt:
                d_rightAlt = state;
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// Gets semantic action for scan_code and sends the event
        /// </summary>
        /// <param name="scanCode"></param>
        /// <param name="shiftDown"></param>
        /// <param name="altDown"></param>
        /// <param name="ctrlDown"></param>
        /// <returns>
        /// True if the semantic action was handled
        /// </returns>
        public bool HandleScanCode(Key.Scan scanCode, bool shiftDown, bool altDown, bool ctrlDown)
        {
            var value = GetSemanticAction(scanCode, shiftDown, altDown, ctrlDown);

            if (value != (int)SemanticValue.SV_NoValue)
            {
                return(d_inputReceiver.InjectInputEvent(new SemanticInputEvent(value)));
            }

            return(false);
        }
Пример #3
0
        public virtual bool InjectKeyUp(Key.Scan scanCode)
        {
            if (d_inputReceiver == null)
            {
                return(false);
            }

            d_keysPressed[(int)scanCode] = false;

            if (!d_handleInKeyUp)
            {
                return(true);
            }

            return(HandleScanCode(scanCode, IsShiftPressed(), IsAltPressed(), IsControlPressed()));
        }
Пример #4
0
        public static SystemKey KeyCodeToSystemKey(Key.Scan key)
        {
            switch (key)
            {
            case Key.Scan.RightShift:
            case Key.Scan.LeftShift:
                return(SystemKey.Shift);

            case Key.Scan.LeftControl:
            case Key.Scan.RightControl:
                return(SystemKey.Control);

            case Key.Scan.LeftAlt:
            case Key.Scan.RightAlt:
                return(SystemKey.Alt);

            default:
                return(SystemKey.None);
            }
        }
Пример #5
0
 //! notify that the given key was released.
 public void KeyReleased(Key.Scan key)
 {
     UpdatePressedStateForKey(key, false);
     UpdateSystemKeyState(KeyCodeToSystemKey(key));
 }
Пример #6
0
 /// <summary>
 /// notify that the given key was presed
 /// </summary>
 /// <param name="key"></param>
 public void KeyPressed(Key.Scan key)
 {
     UpdatePressedStateForKey(key, true);
     UpdateSystemKeyState(KeyCodeToSystemKey(key));
 }
Пример #7
0
        /// <summary>
        /// Returns a semantic action matching the scan_code
        /// </summary>
        /// <param name="scanCode"></param>
        /// <param name="shiftDown"></param>
        /// <param name="altDown"></param>
        /// <param name="ctrlDown"></param>
        /// <returns></returns>
        public int GetSemanticAction(Key.Scan scanCode, bool shiftDown, bool altDown, bool ctrlDown)
        {
            int value = d_keyValuesMappings[(int)scanCode];

            // handle combined keys
            if (ctrlDown && shiftDown)
            {
                if (scanCode == Key.Scan.ArrowLeft)
                {
                    value = (int)SemanticValue.SV_SelectPreviousWord;
                }
                else if (scanCode == Key.Scan.ArrowRight)
                {
                    value = (int)SemanticValue.SV_SelectNextWord;
                }
                else if (scanCode == Key.Scan.End)
                {
                    value = (int)SemanticValue.SV_SelectToEndOfDocument;
                }
                else if (scanCode == Key.Scan.Home)
                {
                    value = (int)SemanticValue.SV_SelectToStartOfDocument;
                }
                else if (scanCode == Key.Scan.Z)
                {
                    value = (int)SemanticValue.SV_Redo;
                }
            }
            else if (ctrlDown)
            {
                if (scanCode == Key.Scan.ArrowLeft)
                {
                    value = (int)SemanticValue.SV_GoToPreviousWord;
                }
                else if (scanCode == Key.Scan.ArrowRight)
                {
                    value = (int)SemanticValue.SV_GoToNextWord;
                }
                else if (scanCode == Key.Scan.End)
                {
                    value = (int)SemanticValue.SV_GoToEndOfDocument;
                }
                else if (scanCode == Key.Scan.Home)
                {
                    value = (int)SemanticValue.SV_GoToStartOfDocument;
                }
                else if (scanCode == Key.Scan.A)
                {
                    value = (int)SemanticValue.SV_SelectAll;
                }
                else if (scanCode == Key.Scan.C)
                {
                    value = (int)SemanticValue.SV_Copy;
                }
                else if (scanCode == Key.Scan.V)
                {
                    value = (int)SemanticValue.SV_Paste;
                }
                else if (scanCode == Key.Scan.X)
                {
                    value = (int)SemanticValue.SV_Cut;
                }
                else if (scanCode == Key.Scan.Tab)
                {
                    value = (int)SemanticValue.SV_NavigateToPrevious;
                }
                else if (scanCode == Key.Scan.Z)
                {
                    value = (int)SemanticValue.SV_Undo;
                }
                else if (scanCode == Key.Scan.Y)
                {
                    value = (int)SemanticValue.SV_Redo;
                }
            }
            else if (shiftDown)
            {
                if (scanCode == Key.Scan.ArrowLeft)
                {
                    value = (int)SemanticValue.SV_SelectPreviousCharacter;
                }
                else if (scanCode == Key.Scan.ArrowRight)
                {
                    value = (int)SemanticValue.SV_SelectNextCharacter;
                }
                else if (scanCode == Key.Scan.ArrowUp)
                {
                    value = (int)SemanticValue.SV_SelectUp;
                }
                else if (scanCode == Key.Scan.ArrowDown)
                {
                    value = (int)SemanticValue.SV_SelectDown;
                }
                else if (scanCode == Key.Scan.End)
                {
                    value = (int)SemanticValue.SV_SelectToEndOfLine;
                }
                else if (scanCode == Key.Scan.Home)
                {
                    value = (int)SemanticValue.SV_SelectToStartOfLine;
                }
                else if (scanCode == Key.Scan.PageUp)
                {
                    value = (int)SemanticValue.SV_SelectPreviousPage;
                }
                else if (scanCode == Key.Scan.PageDown)
                {
                    value = (int)SemanticValue.SV_SelectNextPage;
                }
            }
            if (altDown)
            {
                if (scanCode == Key.Scan.Backspace)
                {
                    value = (int)SemanticValue.SV_Undo;
                }
            }

            return(value);
        }