Exemplo n.º 1
0
        protected override void Initialize()
        {
            MouseState.Clear();

            this._mouse = new SharpDX.DirectInput.Mouse(this._directInput);

            this._mouse.Properties.AxisMode = MDI.DeviceAxisMode.Relative;

            this._window = ((DirectXInputManager)Creator).WindowHandle;

            if (this._coopSettings != 0)
            {
                this._mouse.SetCooperativeLevel(this._window, this._coopSettings);
            }

            if (IsBuffered)
            {
                this._mouse.Properties.BufferSize = BufferSize;
            }

            try
            {
                this._mouse.Acquire();
            }
            catch (Exception e)
            {
                throw new Exception("Failed to acquire mouse using DirectInput.", e);
            }

            hide(this._hideMouse);
        }
Exemplo n.º 2
0
        public void Update(GameEngine engine)
        {
            //Console.WriteLine(DeltaScrollWheel);
            //DeltaScrollWheel = 0; //we only want the difference for each frame, the total value is irrelevant

            PreviousKeyboardState.Clear();
            PreviousMouseState.Clear();
            PreviousMousePosition = MousePosition;

            MousePosition = Mouse.GetPosition(engine.Window);
            foreach (KeyValuePair <Keyboard.Key, bool> valuePair in KeyboardState)
            {
                PreviousKeyboardState.Add(valuePair.Key, valuePair.Value);
            }
            foreach (KeyValuePair <Mouse.Button, bool> valuePair in MouseState)
            {
                PreviousMouseState.Add(valuePair.Key, valuePair.Value);
            }

            KeyboardState.Clear();
            MouseState.Clear();
            foreach (Keyboard.Key key in keysEnum)
            {
                KeyboardState.Add(key, CheckKey(key));
            }
            foreach (Mouse.Button button in buttonsEnum)
            {
                MouseState.Add(button, CheckButton(button));
            }
        }