public override void Update(GameTime gameTime)
        {
            frame        += 1;
            currentTime   = gameTime.TotalGameTime;
            previousState = currentState;
            currentState  = Keyboard.GetState();
            currentFlags  = InputFlagsHelper.Create(currentState, Mouse.GetState());

            // collect some valid state, so on the _next_ update call we can detect changes and process events.
            if (!initialized)
            {
                initialized = true;
                return;
            }

            RaiseEvents();
            DrainTypedCharacters();
        }
Exemple #2
0
        public override void Update(GameTime gameTime)
        {
            frame        += 1;
            currentTime   = gameTime.TotalGameTime;
            currentFlags  = InputFlagsHelper.Create(Keyboard.GetState(), currentState);
            previousState = currentState;
            if (hasTransform)
            {
                currentState = TransformState(Mouse.GetState());
            }
            else
            {
                currentState = Mouse.GetState();
            }

            // collect some valid state, so on the _next_ update call we can detect changes and process events.
            if (!initialized)
            {
                initialized = true;
                return;
            }

            for (var index = 0; index < buttons.Count; index++)
            {
                var button = buttons[index];
                CheckButtonPressed(button);
                CheckButtonReleased(button);
            }

            if (currentState.Position != previousState.Position)
            {
                var args = new MouseEventData(MouseEventType.Moved, currentFlags, currentTime, frame, previousState, currentState);
                eventSink.PushEvent(args);
            }

            if (currentState.ScrollWheelValue != previousState.ScrollWheelValue)
            {
                var args = new MouseEventData(MouseEventType.WheelMoved, currentFlags, currentTime, frame, previousState, currentState);
                eventSink.PushEvent(args);
            }
        }
        public override void Update(GameTime gameTime)
        {
            frame      += 1;
            currentTime = gameTime.TotalGameTime;
            inputFlags  = InputFlagsHelper.Create();

            for (var p = 0; p < currentStates.Length; p += 1)
            {
                previousStates[p] = currentStates[p];
                currentStates[p]  = GamePad.GetState(p);

                // collect some valid state, so on the _next_ update call we can detect changes and process events.
                if (!initialized)
                {
                    initialized = true;
                    return;
                }

                CheckAllButtons(p);
            }
        }
Exemple #4
0
        public override void Update(GameTime gameTime)
        {
            frame += 1;

            var currentTime  = gameTime.TotalGameTime;
            var currentFlags = InputFlagsHelper.Create(Keyboard.GetState(), Mouse.GetState());

            var touchCollection = TransformState(TouchPanel.GetState());

            for (var index = 0; index < touchCollection.Count; index++)
            {
                var touchLocation = touchCollection[index];
                switch (touchLocation.State)
                {
                case TouchLocationState.Pressed:
                    eventSink.PushEvent(new TouchEventData(currentTime, frame, currentFlags, TouchEventType.Pressed, touchLocation));
                    break;

                case TouchLocationState.Moved:
                    eventSink.PushEvent(new TouchEventData(currentTime, frame, currentFlags, TouchEventType.Moved, touchLocation));
                    break;

                case TouchLocationState.Released:
                    eventSink.PushEvent(new TouchEventData(currentTime, frame, currentFlags, TouchEventType.Released, touchLocation));
                    break;

                case TouchLocationState.Invalid:
                    eventSink.PushEvent(new TouchEventData(currentTime, frame, currentFlags, TouchEventType.Cancelled, touchLocation));
                    break;
                }
            }

            while (TouchPanel.IsGestureAvailable)
            {
                var gesture = hasTransform ? TransformGesture(TouchPanel.ReadGesture()) : TouchPanel.ReadGesture();
                eventSink.PushEvent(new TouchEventData(currentTime, frame, currentFlags, TouchEventType.Gestured, gesture));
            }
        }