Ejemplo n.º 1
0
        public override void Initialize(InputManager inputManager)
        {
            input                = inputManager;
            gameContext          = inputManager.Game.Context as GameContext <Control>;
            uiControl            = gameContext.Control;
            uiControl.LostFocus += UIControlOnLostFocus;

            // Hook window proc
            defaultWndProc = Win32Native.GetWindowLong(uiControl.Handle, Win32Native.WindowLongType.WndProc);
            // This is needed to prevent garbage collection of the delegate.
            inputWndProc = WndProc;
            var inputWndProcPtr = Marshal.GetFunctionPointerForDelegate(inputWndProc);

            Win32Native.SetWindowLong(uiControl.Handle, Win32Native.WindowLongType.WndProc, inputWndProcPtr);

            // Do not register keyboard devices when using raw input instead
            keyboard = new KeyboardWinforms(this, uiControl);
            RegisterDevice(keyboard);

            mouse = new MouseWinforms(this, uiControl);
            RegisterDevice(mouse);
        }