bool SwipeArea::touchMove(QPointF pos) { if (d->pos.x() < 0 && d->pos.y() < 0) { return false; } QPointF p = pos - d->pos; if (qAbs(p.y()) > 60) { d->pos = QPointF(-1, -1); return false; } if (p.x() > 200) { d->pos = QPointF(-1, -1); emit swipeRight(); return false; } else if (p.x() < -200) { d->pos = QPointF(-1, -1); emit swipeLeft(); return false; } return true; }
void EventReceiver::_onEvent(const int socket) { if (socket != _stream.getDescriptor()) return; while (_stream.hasEvent()) { const Event& deflectEvent = _stream.getEvent(); switch (deflectEvent.type) { case Event::EVT_CLOSE: _stop(); return; case Event::EVT_PRESS: emit pressed(_pos(deflectEvent)); break; case Event::EVT_RELEASE: emit released(_pos(deflectEvent)); break; case Event::EVT_MOVE: emit moved(_pos(deflectEvent)); break; case Event::EVT_VIEW_SIZE_CHANGED: emit resized(QSize{int(deflectEvent.dx), int(deflectEvent.dy)}); break; case Event::EVT_SWIPE_LEFT: emit swipeLeft(); break; case Event::EVT_SWIPE_RIGHT: emit swipeRight(); break; case Event::EVT_SWIPE_UP: emit swipeUp(); break; case Event::EVT_SWIPE_DOWN: emit swipeDown(); break; case Event::EVT_KEY_PRESS: emit keyPress(deflectEvent.key, deflectEvent.modifiers, QString::fromStdString(deflectEvent.text)); break; case Event::EVT_KEY_RELEASE: emit keyRelease(deflectEvent.key, deflectEvent.modifiers, QString::fromStdString(deflectEvent.text)); break; case Event::EVT_TOUCH_ADD: emit touchPointAdded(deflectEvent.key, _pos(deflectEvent)); break; case Event::EVT_TOUCH_UPDATE: emit touchPointUpdated(deflectEvent.key, _pos(deflectEvent)); break; case Event::EVT_TOUCH_REMOVE: emit touchPointRemoved(deflectEvent.key, _pos(deflectEvent)); break; case Event::EVT_CLICK: case Event::EVT_DOUBLECLICK: case Event::EVT_PINCH: case Event::EVT_WHEEL: default: break; } } if (!_stream.isConnected()) _stop(); }
void XN_CALLBACK_TYPE AirCursor::swipeRightCB(XnFloat fVelocity, XnFloat fAngle, void* cxt) { //std::cout << "Swipe RIGHT velocity: " << fVelocity << " angle: " << fAngle << std::endl; AirCursor* ac = (AirCursor*)cxt; ac->emit swipeRight(fVelocity, fAngle); }