Esempio n. 1
0
        /// <summary>
        /// This function houses a hack to fix the window missing some input events,
        /// see Stride pull #181 for more information (https://github.com/stride3d/stride/pull/181).
        /// TODO: Find a proper solution to replace this workaround.
        /// </summary>
        private void MissingInputHack()
        {
#if STRIDE_INPUT_RAWINPUT
            Device.RegisterDevice(SharpDX.Multimedia.UsagePage.Generic, SharpDX.Multimedia.UsageId.GenericKeyboard, DeviceFlags.None);
            Device.KeyboardInput += (sender, args) =>
            {
                switch (args.State)
                {
                case KeyState.SystemKeyDown:
                case KeyState.ImeKeyDown:
                case KeyState.KeyDown:
                {
                    keyboard?.HandleKeyUp(args.Key);
                    heldKeys.Add(args.Key);
                    break;
                }

                case KeyState.SystemKeyUp:
                case KeyState.ImeKeyUp:
                case KeyState.KeyUp:
                {
                    heldKeys.Remove(args.Key);
                    keyboard?.HandleKeyDown(args.Key);
                    break;
                }
                }
            };
#endif
        }
Esempio n. 2
0
        internal void HandleKeyDown(IntPtr wParam, IntPtr lParam)
        {
            var lParamLong = lParam.ToInt64();

            if (MessageIsDownAutoRepeat(lParamLong))
            {
                return;
            }

            var virtualKey = (WinFormsKeys)wParam.ToInt64();

            virtualKey = GetCorrectExtendedKey(virtualKey, lParamLong);
            keyboard?.HandleKeyDown(virtualKey);
            heldKeys.Add(virtualKey);
        }