Esempio n. 1
0
    void Input::sendPointerWheelEvent(spStage stage, const Vector2& dir, PointerState* ps)
    {
        TouchEvent me(dir.y > 0 ? TouchEvent::WHEEL_UP : TouchEvent::WHEEL_DOWN, true, ps->getPosition());
        me.index = ps->getIndex();
        stage->handleEvent(&me);


        TouchEvent te(TouchEvent::WHEEL_DIR, true, ps->getPosition());
        te.index = ps->getIndex();
        te.wheelDirection = dir;
        stage->handleEvent(&te);
    }
Esempio n. 2
0
    void Input::sendPointerButtonEvent(spStage stage, MouseButton button, float x, float y, float pressure, int type, PointerState* ps)
    {
        Vector2 p(x, y);

        TouchEvent me(type, true, p);
        me.index = ps->getIndex();
        me.mouseButton = button;
        me.pressure = pressure;

        if (type == TouchEvent::TOUCH_DOWN)
            ps->_isPressed[button] = true;
        else if (type == TouchEvent::TOUCH_UP)
            ps->_isPressed[button] = false;

        ps->_position = p;

        LOGD("sendPointerButtonEvent %d - (%.2f, %.2f), %d", me.index, p.x, p.y, type);

        stage->handleEvent(&me);

        if (type == TouchEvent::TOUCH_UP)
        {
            _ids[ps->getIndex() - 1] = 0;
        }
    }
Esempio n. 3
0
    void Input::sendPointerButtonEvent(spStage stage, MouseButton button, float x, float y, float pressure, int type, PointerState* ps)
    {
        if (!_multiTouch && ps->getIndex() != 1 && ps != &_pointerMouse)
        {
            if (type == TouchEvent::TOUCH_UP)
                _ids[ps->getIndex() - 1] = 0;

            return;
        }

        Vector2 p(x, y);

        TouchEvent me(type, true, p);
        me.index = ps->getIndex();
        me.mouseButton = button;
        me.pressure = pressure;

        if (type == TouchEvent::TOUCH_DOWN)
            ps->_pressed |= 1 << button;
        else if (type == TouchEvent::TOUCH_UP)
            ps->_pressed &= ~(1 << button);

        ps->_position = p;

        LOGD("sendPointerButtonEvent %d - (%.2f, %.2f), %d", me.index, p.x, p.y, type);

        stage->handleEvent(&me);

        if (type == TouchEvent::TOUCH_UP)
            _ids[ps->getIndex() - 1] = 0;
    }
Esempio n. 4
0
    void Input::sendPointerWheelEvent(spStage stage, int scroll, PointerState* ps)
    {
        TouchEvent me(scroll > 0 ? TouchEvent::WHEEL_UP : TouchEvent::WHEEL_DOWN, true);
        me.index = ps->getIndex();

        ps->_position = Vector2(0, 0);

        stage->handleEvent(&me);
    }
Esempio n. 5
0
    void Input::sendPointerMotionEvent(spStage stage, float x, float y, float pressure, PointerState* ps)
    {
        TouchEvent me(TouchEvent::MOVE, true, Vector2(x, y));
        me.index = ps->getIndex();
        me.pressure = pressure;
        ps->_position = Vector2(x, y);

        LOGD("sendPointerMotionEvent %d - (%.2f, %.2f)", me.index, x, y);
        stage->handleEvent(&me);
    }
Esempio n. 6
0
    void Input::sendPointerButtonEvent(spStage stage, MouseButton button, float x, float y, float pressure, int type, PointerState* ps)
    {
        Vector2 p(x, y);

        TouchEvent me(type, true, p);
        me.index = ps->getIndex();
        me.mouseButton = button;
        me.pressure = pressure;

        if (type == TouchEvent::TOUCH_DOWN)
            ps->_isPressed[button] = true;
        else if (type == TouchEvent::TOUCH_UP)
            ps->_isPressed[button] = false;

        ps->_position = p;

        LOGD("sendPointerButtonEvent %d - (%.2f, %.2f), %d", me.index, p.x, p.y, type);

        stage->handleEvent(&me);

        if (type == TouchEvent::TOUCH_UP)
        {
            // Remove id and compact the array:
            //  - stop on first copied zero id
            //  - if end is reached, zero the last element
            int i = ps->getIndex() - 1;
            while (i < MAX_TOUCHES - 1)
            {
                if ((_ids[i] = _ids[i + 1]) == 0)
                    break;
                _pointers[i] = _pointers[i + 1];
                _pointers[i]._index = i + 1;
                ++i;
            }
            if (i == MAX_TOUCHES - 1)
            {
                _ids[i] = 0;
                _pointers[i].init(i + 1);
            }
        }
    }