void TouchManager::mouseTouchBegin(const ci::app::MouseEvent &event, int id){ ci::Vec2f globalPos = translateMousePoint(event.getPos()); if(shouldDiscardTouch(globalPos)){ return; } inputBegin(id, globalPos); }
void TouchManager::touchesBegin(const TouchEvent &event) { for (std::vector<TouchEvent::Touch>::const_iterator touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt) { // This system uses a mouse click for the first touch, which allows for use of the mouse and touches simultaneously // It's possible we'll run into a scenario where we need to reverse this, which we can just add a bool flag to the settings to use all touches and ignore all mouses. if (TouchMode::hasSystem(mTouchMode) && ci::System::hasMultiTouch() && TouchMode::hasMouse(mTouchMode)) { mIgnoreFirstTouchId = touchIt->getId(); return; } ci::Vec2f touchPos = touchIt->getPos(); if(mOverrideTranslation){ overrideTouchTranslation(touchPos); } int fingerId = touchIt->getId() + MOUSE_RESERVED_IDS; if(shouldDiscardTouch(touchPos)){ mDiscardTouchMap[fingerId] = true; continue; } mDiscardTouchMap[fingerId] = false; TouchInfo touchInfo; touchInfo.mCurrentGlobalPoint = Vec3f(touchPos, 0.0f); touchInfo.mFingerId = fingerId; touchInfo.mStartPoint = mTouchStartPoint[touchInfo.mFingerId] = touchInfo.mCurrentGlobalPoint; mTouchPreviousPoint[touchInfo.mFingerId] = touchInfo.mCurrentGlobalPoint; touchInfo.mDeltaPoint = touchInfo.mCurrentGlobalPoint - mTouchPreviousPoint[touchInfo.mFingerId]; touchInfo.mPhase = TouchInfo::Added; touchInfo.mPassedTouch = false; if (mCapture) mCapture->touchBegin(touchInfo); Sprite *currentSprite = getHit(touchInfo.mCurrentGlobalPoint); touchInfo.mPickedSprite = currentSprite; mRotationTranslator.down(touchInfo); if ( currentSprite ) { mFingerDispatcher[touchInfo.mFingerId] = currentSprite; currentSprite->processTouchInfo(touchInfo); } } }
void TouchManager::touchesBegin(const ds::ui::TouchEvent &event) { for (auto touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt) { ci::Vec2f touchPos = touchIt->getPos(); if(mOverrideTranslation && !event.getInWorldSpace()){ overrideTouchTranslation(touchPos); } int fingerId = touchIt->getId() + MOUSE_RESERVED_IDS; if(shouldDiscardTouch(touchPos)){ mDiscardTouchMap[fingerId] = true; continue; } inputBegin(fingerId, touchPos); } }