bool QAbstractKineticScrollerPrivate::handleMouseMove(QMouseEvent *e) { Q_Q(QAbstractKineticScroller); qKSDebug() << "MM: pos: " << e->globalPos() << " - time: " << QTime::currentTime().msec(); if (!(e->buttons() & Qt::LeftButton)) return false; if ((state != QAbstractKineticScroller::MousePressed) && (state != QAbstractKineticScroller::Pushing) && (state != QAbstractKineticScroller::AutoScrolling)) return false; if (moved && !lastTime.elapsed()) return true; if (lastType == QEvent::MouseButtonPress) firstDrag = true; QPoint delta = e->globalPos() - pos; if (!moved) { checkMove(e, delta); } if (moved) { if (state != QAbstractKineticScroller::Pushing) { q->cancelLeftMouseButtonPress(ipos); changeState(QAbstractKineticScroller::Pushing); } handleMove(e, delta); } lastTime.restart(); lastType = e->type(); qKSDebug("MM: end %d", moved); return moved; }
void Isola::handle(const char& c){ if(mMoved){ handleDestroy(c); }else{ handleMove(c); } }
int ConsoleGame::run() { // std::string cmdString("4"); // std::istringstream iss(cmdString); // handlePerft(iss); // return 0; while (true) { std::cout << "\nsc: "; std::string inputString; std::getline(std::cin, inputString); std::istringstream iss(inputString); std::string commandString; iss >> commandString; if (commandString.empty()) continue; if (commandString == "quit") break; else if (commandString == "divide") handleDivide(iss); else if (commandString == "help") handleHelp(); else if (commandString == "print") handlePrint(); else if (commandString == "disp") handlePrint(); else if (commandString == "fen") handleFen(); else if (commandString == "perft") handlePerft(iss); // else if (commandString == "table") // handleTable(iss); else if (commandString == "move") handleMove(iss); else if (commandString == "setboard") handleSetBoard(iss); else if (commandString == "testmovegen") handleTestMoveGen(); else if (commandString == "new") handleNewGame(); else if (commandString == "show") handleShow(); else if (commandString == "undo") handleUndo(); else if (commandString == "twoplayer") handleTwoPlayer(); else if (commandString == "singleplayer") handleSinglePlayer(); else { std::cout << "Unrecognized command " << commandString << "\n"; std::cout << "Type help to show command list\n"; } } return 0; }
bool Gripper::handleMove(gripper::MoveGripper::Request &req, gripper::MoveGripper::Response &res) { res.succeeded = (unsigned char) true; handleMove(req.x, req.y); return true; }
// NOT IMPLEMENTED YET. // TODO: Hook this function into the game loop. void MonopolyGame::handleState() { /* * Pre turn state. */ if( m_turnState == TurnState::PRE_TURN ) { // Display pre-turn menu // - Improve Property // - Mortgage Property // - Roll Dice (turnState = ROLL_PHASE) // Handle the logic for this menu, this includes what menu entry is currently selected. //menu[PRE_TURN].logic(); // Then in the drawing phase we call, menu[PRE_TURN].draw() } /* * Rolling the dice phase. */ else if( m_turnState == TurnState::ROLL_PHASE ) { // If the player clicks the ROLL button: handleDiceRoll( m_playerList[m_playersTurn] ); m_firstMovePass = true; } /* * Move the player's icon phase. */ else if( m_turnState == TurnState::MOVE_PHASE ) { if( m_firstMovePass ) { // Ensure our destination is within bounds. if( m_moveDestination > MAX_PROPERTIES ) { m_moveDestination -= MAX_PROPERTIES; } m_firstMovePass = false; } handleMove(); } /* * Reacting the the dice results phase. */ else if( m_turnState == TurnState::REACT_PHASE ) { handleReaction(); } /* * Wrapping up the turn. */ else if( m_turnState == TurnState::POST_TURN ) { // This is the turn's wrap-up phase. A player can mortgage properties, trade or end their turn. m_turnDone = true; // debugging. m_doublesRollCounter = 0; } else { fprintf( stderr, "Invalid state encountered: %i\n", m_turnState ); } }
void MouseListener::handleEvent(const MinVR::EventRef& event, double synchronizedTime) { if (startsWith(event->getName(), "mouse_", 6)) { if (event->getName() == "mouse_scroll") { handleClick(MouseButton::SCROLL, event->get2DData().y > 0, event->get2DData()); return; } MinVR::WindowRef window = event->getWindow(); glm::dvec2 res(window->getWidth(), window->getHeight()); glm::dvec2 pos = event->get2DData() / res; if (event->getName() == "mouse_pointer") { handleMove(pos); } else { MouseButton button; if (stringCompare(event->getName(), "left", 10, 4)) { button = LEFT; } else if (stringCompare(event->getName(), "middle", 10, 6)) { button = MIDDLE; } else if (stringCompare(event->getName(), "right", 10, 5)) { button = RIGHT; } if (stringCompare(event->getName(), "up", event->getName().size()-2, 2)) { handleClick(button, false, pos); } else { handleClick(button, true, pos); } } } }
void gameTouch(GameTouchType type, float x, float y) { switch (type) { case GameTouchDown: g_touchStartX = x; g_touchStartY = y; break; case GameTouchMove: handleMove(x, y); break; case GameTouchUp: g_playerPosChangeTarget = 0.0f; g_playerAngleChangeTarget = 0.0f; break; } }
void QWSManager::mouseMoveEvent(QMouseEvent *e) { Q_D(QWSManager); if (d->newCachedRegion(e->globalPos())) { if(d->previousRegionType && d->previousRegionRepainted) repaintRegion(d->previousRegionType, QDecoration::Normal); if(d->cached_region.regionType) { d->previousRegionRepainted = repaintRegion(d->cached_region.regionType, QDecoration::Hover); } } #ifndef QT_NO_CURSOR QWSDisplay *qwsd = QApplication::desktop()->qwsDisplay(); qwsd->selectCursor(d->managed, regionToShape(d->cachedRegionAt())); #endif //QT_NO_CURSOR if (d->activeRegion) handleMove(e->globalPos()); }
LRESULT FavoriteHubsFrame::onMoveDown(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { handleMove(false); return 0; }
bool QAbstractKineticScrollerPrivate::handleMouseRelease(QMouseEvent *e) { qKSDebug() << "MR: pos: " << e->globalPos() << " - time: " << QTime::currentTime().msec(); Q_Q(QAbstractKineticScroller); if (e->button() != Qt::LeftButton) return false; if ((state != QAbstractKineticScroller::MousePressed) && (state != QAbstractKineticScroller::Pushing)) return false; // if last event was a motion-notify we have to check the // movement and launch the animation if (lastType == QEvent::MouseMove) { if (moved) { QPoint delta = e->globalPos() - pos; handleMove(e, delta); // move all the way to the last position now if (scrollTimerId) { killTimer(scrollTimerId); scrollTimerId = 0; setScrollPositionHelper(q->scrollPosition() - overshootDist - motion); motion = QPoint(0, 0); } } } // If overshoot has been initiated with a finger down, // on release set max speed if (overshootDist.x()) { overshooting = bounceSteps; // Hack to stop a bounce in the finger down case velocity.setX(-overshootDist.x() * qreal(0.8)); } if (overshootDist.y()) { overshooting = bounceSteps; // Hack to stop a bounce in the finger down case velocity.setY(-overshootDist.y() * qreal(0.8)); } bool forceFast = true; // if widget was moving fast in the panning, increase speed even more if ((lastPressTime.elapsed() < FastClick) && ((qAbs(oldVelocity.x()) > minVelocity) || (qAbs(oldVelocity.y()) > minVelocity)) && ((qAbs(oldVelocity.x()) > MinimumAccelerationThreshold) || (qAbs(oldVelocity.y()) > MinimumAccelerationThreshold))) { qKSDebug() << "FAST CLICK - using oldVelocity " << oldVelocity; int signX = 0, signY = 0; if (velocity.x()) signX = (velocity.x() > 0) == (oldVelocity.x() > 0) ? 1 : -1; if (velocity.y()) signY = (velocity.y() > 0) == (oldVelocity.y() > 0) ? 1 : -1; // calculate the acceleration velocity QPoint maxPos = q->maximumScrollPosition(); accelerationVelocity = QPoint(0, 0); QSize size = q->viewportSize(); if (size.width()) accelerationVelocity.setX(qMin(int(q->maximumVelocity()), maxPos.x() / size.width() * AccelFactor)); if (size.height()) accelerationVelocity.setY(qMin(int(q->maximumVelocity()), maxPos.y() / size.height() * AccelFactor)); velocity.setX(signX * (oldVelocity.x() + (oldVelocity.x() > 0 ? accelerationVelocity.x() : -accelerationVelocity.x()))); velocity.setY(signY * (oldVelocity.y() + (oldVelocity.y() > 0 ? accelerationVelocity.y() : -accelerationVelocity.y()))); forceFast = false; } if ((qAbs(velocity.x()) >= minVelocity) || (qAbs(velocity.y()) >= minVelocity)) { qKSDebug() << "over min velocity: " << velocity; // we have to move because we are in overshooting position if (!moved) { // (opt) emit panningStarted() } // (must) enable scrollbars if (forceFast) { if ((qAbs(velocity.x()) > MaximumVelocityThreshold) && (accelerationVelocity.x() > MaximumVelocityThreshold)) { velocity.setX(velocity.x() > 0 ? accelerationVelocity.x() : -accelerationVelocity.x()); } if ((qAbs(velocity.y()) > MaximumVelocityThreshold) && (accelerationVelocity.y() > MaximumVelocityThreshold)) { velocity.setY(velocity.y() > 0 ? accelerationVelocity.y() : -accelerationVelocity.y()); } qKSDebug() << "Force fast is on - velocity: " << velocity; } changeState(QAbstractKineticScroller::AutoScrolling); } else { if (moved) { // (opt) emit panningFinished() } changeState(QAbstractKineticScroller::Inactive); } // -- create the idle timer if we are auto scrolling or overshooting. if (!idleTimerId && ((qAbs(velocity.x()) >= minVelocity) || (qAbs(velocity.y()) >= minVelocity) || overshootDist.x() || overshootDist.y()) ) { idleTimerId = startTimer(1000 / scrollsPerSecond); } lastTime.restart(); lastType = e->type(); bool wasMoved = moved; moved = false; qKSDebug("MR: end %d", wasMoved); return wasMoved; // do not swallow the mouse release, if we didn't move at all }