コード例 #1
0
        KeyboardEventInit initKeyEvent(KeyboardDevice Device, EKeyboardCode KeyCode, char Key, bool isRepeat)
        {
            bool   altKey   = Device.IsDown(EKeyboardCode.AltLeft) | Device.IsDown(EKeyboardCode.AltRight);
            bool   shiftKey = Device.IsDown(EKeyboardCode.ShiftLeft) | Device.IsDown(EKeyboardCode.ShiftRight);
            bool   ctrlKey  = Device.IsDown(EKeyboardCode.ControlLeft) | Device.IsDown(EKeyboardCode.ControlRight);
            bool   superKey = Device.IsDown(EKeyboardCode.MetaLeft) | Device.IsDown(EKeyboardCode.MetaRight);
            string key      = Key == 0 ? ((char)Lookup.Data(KeyCode).Data[1]).ToString() : Key.ToString();

            return(new KeyboardEventInit()
            {
                view = this,
                key = key,
                code = KeyCode,
                repeat = isRepeat,

                altKey = altKey,
                shiftKey = shiftKey,
                ctrlKey = ctrlKey,
                metaKey = superKey,

                modifierCapsLock = Device.IsDown(EKeyboardCode.CapsLock),
                modifierFn = Device.IsDown(EKeyboardCode.Fn),
                modifierFnLock = Device.IsDown(EKeyboardCode.FnLock),
                modifierNumLock = Device.IsDown(EKeyboardCode.NumLock),
                modifierScrollLock = Device.IsDown(EKeyboardCode.ScrollLock),
                modifierSuper = superKey,

                modifierSymbol = false,
                modifierSymbolLock = false,
                modifierHyper = false,
                modifierAltGraph = false,
            });
        }
コード例 #2
0
        /// <summary>
        /// Passes keyboard input to the DOM window
        /// </summary>
        protected void Handle_Keyboard_Input(KeyboardDevice Device, EKeyboardInputType InputType, EKeyboardCode KeyCode, char Key)
        {
            Event RetEvent = null;

            switch (InputType)
            {
            case EKeyboardInputType.KeyDown:
            {
                bool Old = KeyState[(int)KeyCode];
                KeyState[(int)KeyCode] = true;
                RetEvent = new KeyboardEvent(EEventName.KeyDown, initKeyEvent(Device, KeyCode, Key, Old == true));
            }
            break;

            case EKeyboardInputType.KeyUp:
            {
                KeyState[(int)KeyCode] = false;
                RetEvent = new KeyboardEvent(EEventName.KeyUp, initKeyEvent(Device, KeyCode, Key, false));
            }
            break;

            case EKeyboardInputType.KeyPress:
            {
                KeyState[(int)KeyCode] = false;
                RetEvent = new KeyboardEvent(EEventName.KeyPress, initKeyEvent(Device, KeyCode, Key, false));
            }
            break;

            default:
            {
                throw new NotImplementedException($"No logic implemented for {nameof(EKeyboardInputType)} value \"{InputType}\"");
            }
            }

            dispatchEvent(RetEvent);
        }
コード例 #3
0
 /// <summary>
 /// Returns true if the systems current keyboard device has the given <paramref name="key"/> on it
 /// </summary>
 /// <param name="key">They key to check for</param>
 public abstract bool Has_Key(EKeyboardCode key);
コード例 #4
0
 /// <summary>
 /// Returns true if the given <paramref name="key"/> on the systems current keyboard device is currently in the 'down' state
 /// </summary>
 /// <param name="key">They key to check for</param>
 public abstract bool IsDown(EKeyboardCode key);