Exemplo n.º 1
0
        internal static void ApplyHandler(CursorInputHandler handler)
        {
            SetPosition(handler.Position);

            if (handler.Left != null)
            {
                MouseLeft = handler.Left.Value;
            }
            if (handler.Right != null)
            {
                MouseRight = handler.Right.Value;
            }
            if (handler.Middle != null)
            {
                MouseMiddle = handler.Middle.Value;
            }
            if (handler.Back != null)
            {
                MouseBack = handler.Back.Value;
            }
            if (handler.Forward != null)
            {
                MouseForward = handler.Forward.Value;
            }
        }
Exemplo n.º 2
0
        internal static CursorInputHandler HandleCursorInput(List <InputHandler> inputHandlers)
        {
            CursorInputHandler currentCursorHandler = null;

            CursorInputHandler mouseHandler    = null;
            CursorInputHandler rawMouseHandler = null;

            foreach (InputHandler h in inputHandlers)
            {
                // Make first handler which is active the current handler. (Handlers are ordered by priority.)
                if (currentCursorHandler == null && h.IsActive && h is CursorInputHandler)
                {
                    currentCursorHandler = (CursorInputHandler)h;
                }

                if (h is MouseHandler)
                {
                    mouseHandler = (CursorInputHandler)h;
                }

                if (h is RawMouseHandler)
                {
                    rawMouseHandler = (CursorInputHandler)h;
                }

                h.UpdateInput(currentCursorHandler == h);
            }

            if (currentCursorHandler != null)
            {
                if ((currentCursorHandler is MouseHandler || currentCursorHandler is RawMouseHandler) &&
                    mouseHandler != null &&
                    rawMouseHandler != null)
                {
                    Player.HaxCheckMouse(mouseHandler.Position - MousePosition, rawMouseHandler.Position - MousePosition);
                }

                ApplyHandler(currentCursorHandler);
            }

            return(currentCursorHandler);
        }