Example #1
0
        public virtual void CallMouse(MouseMake.ButtonEvent e)
        {
            if (LSystem.IsLockAllTouchEvent())
            {
                return;
            }
            LProcess process = LSystem.GetProcess();

            if (process == null)
            {
                return;
            }
            bool stopMoveDrag = LSystem.IsNotAllowDragAndMove();

            Vector2f pos = process.ConvertXY(e.x, e.y);

            float touchX = pos.x;

            float touchY = pos.y;

            int button = e.button;

            finalTouch.isDraging = _isDraging;
            finalTouch.x         = touchX;
            finalTouch.y         = touchY;
            finalTouch.button    = e.button;
            finalTouch.pointer   = 0;
            finalTouch.id        = 0;
            ebuttons             = process.GetEmulatorButtons();
            if (button == -1)
            {
                if (buttons > 0)
                {
                    finalTouch.type = SysTouch.TOUCH_DRAG;
                }
                else
                {
                    finalTouch.type = SysTouch.TOUCH_MOVE;
                }
            }
            else
            {
                if (e.down)
                {
                    finalTouch.type = SysTouch.TOUCH_DOWN;
                }
                else
                {
                    if (finalTouch.type == SysTouch.TOUCH_DOWN || finalTouch.type == SysTouch.TOUCH_DRAG)
                    {
                        finalTouch.type = SysTouch.TOUCH_UP;
                    }
                }
            }

            switch (finalTouch.type)
            {
            case SysTouch.TOUCH_DOWN:
                finalTouch.button   = SysTouch.TOUCH_DOWN;
                finalTouch.duration = 0;
                finalTouch.timeDown = TimeUtils.Millis();
                if (useTouchCollection)
                {
                    touchCollection.Add(finalTouch.id, finalTouch.x, finalTouch.y);
                }
                process.MousePressed(finalTouch);
                buttons++;
                _isDraging = false;

                /*if (ebuttons != null && ebuttons.Visible)
                 * {
                 *      ebuttons.hit(0, touchX, touchY, false);
                 * }*/
                break;

            case SysTouch.TOUCH_UP:
                finalTouch.button   = SysTouch.TOUCH_UP;
                finalTouch.timeUp   = TimeUtils.Millis();
                finalTouch.duration = finalTouch.timeUp - finalTouch.timeDown;
                if (useTouchCollection)
                {
                    touchCollection.Update(finalTouch.id, LTouchLocationState.Released, finalTouch.x, finalTouch.y);
                }
                process.MouseReleased(finalTouch);
                buttons    = 0;
                _isDraging = false;

                /*if (ebuttons != null && ebuttons.Visible)
                 * {
                 *      ebuttons.unhit(0, touchX, touchY);
                 * }*/
                break;

            case SysTouch.TOUCH_MOVE:
                _offsetMoveX        = touchX;
                _offsetMoveY        = touchY;
                finalTouch.dx       = _offsetTouchX - _offsetMoveX;
                finalTouch.dy       = _offsetTouchY - _offsetMoveY;
                finalTouch.button   = SysTouch.TOUCH_MOVE;
                finalTouch.duration = TimeUtils.Millis() - finalTouch.timeDown;
                if (!_isDraging)
                {
                    if (useTouchCollection)
                    {
                        touchCollection.Update(finalTouch.id, LTouchLocationState.Dragged, finalTouch.x, finalTouch.y);
                    }
                    if (!stopMoveDrag)
                    {
                        process.MouseMoved(finalTouch);
                    }
                }

                /*if (ebuttons != null && ebuttons.Visible)
                 * {
                 *      ebuttons.unhit(0, touchX, touchY);
                 * }*/
                break;

            case SysTouch.TOUCH_DRAG:
                _offsetMoveX        = touchX;
                _offsetMoveY        = touchY;
                finalTouch.dx       = _offsetTouchX - _offsetMoveX;
                finalTouch.dy       = _offsetTouchY - _offsetMoveY;
                finalTouch.button   = SysTouch.TOUCH_DRAG;
                finalTouch.duration = TimeUtils.Millis() - finalTouch.timeDown;
                ebuttons            = process.GetEmulatorButtons();

                /*if (ebuttons != null && ebuttons.Visible)
                 * {
                 *      ebuttons.hit(0, touchX, touchY, true);
                 * }*/
                if (useTouchCollection)
                {
                    touchCollection.Update(finalTouch.id, LTouchLocationState.Dragged, finalTouch.x, finalTouch.y);
                }
                if (!stopMoveDrag)
                {
                    process.MouseDragged(finalTouch);
                }

                /*if (ebuttons != null && ebuttons.Visible)
                 * {
                 *      ebuttons.hit(0, touchX, touchY, false);
                 * }*/
                _isDraging = true;
                break;

            default:
                finalTouch.duration = 0;
                if (useTouchCollection)
                {
                    touchCollection.Update(finalTouch.id, LTouchLocationState.Invalid, finalTouch.x, finalTouch.y);
                }

                /*if (ebuttons != null && ebuttons.Visible)
                 * {
                 *      ebuttons.release();
                 * }*/
                break;
            }
        }
Example #2
0
 protected internal virtual void EmitMouseButton(double time, float x, float y, int btnid, bool down, int flags)
 {
     MouseMake.ButtonEvent e = new MouseMake.ButtonEvent(0, time, x, y, btnid, down);
     e.SetFlag(flags);
     mouseEvents.Emit(e);
 }