void TouchInputHandler::handleTouchEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (hasTouch()) { UINT inputCount = LOWORD(wParam); HTOUCHINPUT touchInputData = (HTOUCHINPUT)lParam; TOUCHINPUT *inputs = new TOUCHINPUT[inputCount]; if (touchInfo(touchInputData, inputCount, inputs, sizeof(TOUCHINPUT))) { for (UINT i = 0; i < inputCount; i++) { float x, y; if (!GetTouchPoint(hWnd, inputs[i], x, y)) continue; if (inputs[i].dwFlags & TOUCHEVENTF_DOWN) { touchDown(ToTouchID(inputs[i].dwID), x, y); } if (inputs[i].dwFlags & TOUCHEVENTF_MOVE) { touchMove(ToTouchID(inputs[i].dwID), x, y); } if (inputs[i].dwFlags & TOUCHEVENTF_UP) { int id = ToTouchID(inputs[i].dwID, false); if (id >= 0) { touchUp(id, x, y); touchIds[id] = 0; } } } closeTouch(touchInputData); } else { WARN_LOG(SYSTEM, "Failed to read input data: %s", GetLastErrorMsg()); } delete [] inputs; } }
int rate(Group animalsOnBoard, Move move, Group enemyHand){ // Score a Move Board board = makeBoard(&animalsOnBoard,move); // Get Tile info from Group and Move int i; for(i=0; i<animalsOnBoard.num; i++){ applyReach(animalsOnBoard.animal[i], &board); // apply list of animals that can reach the tile } int score = getScore(board); score -= placePenalty(move); score += effectRange(board); score += catchLion(board); score += touchDown(board); score += placeDanger(board,enemyHand); score += lionPosition(animalsOnBoard); // Score is (board score) + (placement penalty) // + (moveable range) + (did we catched lion?) + (did lion get touchdown?) int x,y; for(y=0; y<4; y++){ for(x=0; x<3; x++){ printf("%c",board.tile[x][y].occupied); } printf("\n"); } printf("place : %d\nlion : %d\ntotal : %d\n",placeDanger(board,enemyHand),lionPosition(animalsOnBoard),score); return score; }
//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ ofTouchEventArgs t; t.x = x; t.y = y; t.id = button; touchDown(t); }
//-------------------------------------------------------------- bool GuiControl::_touchDown(int _x, int _y, int touchId){ if(!enabled) return false; down = over = hitTest(_x, _y); if(down) { if(editing) { editPoint = ofPoint(_x, _y); // todo this should be pixels not percent if(scalable && _x-x>width-SCALE_TRIANGLE_SIZE && _y-y>height-SCALE_TRIANGLE_SIZE) { editState = EDIT_SCALE; } else { editState = EDIT_MOVE; } } else { touchDown(_x, _y, touchId); } if(listeners!=NULL) { for(int i = 0; i < numListeners; i++) { listeners[i]->controlChanged(this); } //GuiControl * l = (GuiControl*) listener; //printf("%s\n", l->name.c_str()); } } return over; }
//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ ofTouchEventArgs t; t.x = (float)x/ofGetWidth(); t.y = (float)y/ofGetHeight(); t.id = button; touchDown(t); }
void Orbit::update(){ float timeNow = ofGetElapsedTimef(); float timeSinceLastInteraction = timeNow - timeOfLastInteraction; if((volume > volumeThreshold) && (timeSinceLastInteraction > 0.3f )){ touchDown(WIDTH/2.f, HEIGHT/2.f, 0); //simulate a touch in the centre of the screen } }
//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ if ( debug ) { interf.mousePressed( x, y ); } if (mouseToTouch) { touchDown(ofConvertMouseToTouch(x, y, button)); } isMouseDown = true; }
//determines whether the ball touches the brick //and takes the necessary action void whetherBallTouchesBrick(){ for(int i=0;i<20;i++){ for(int j=0;j<8;j++){ if(isBrick[i][j]==1&&b.cy<240){ int touchCx=abs(b.cx+5); int touchCy=abs(b.cy+5); int brickLeft=i*brickLen; int brickRight=brickLeft+brickLen; int brickUp=j*brickBred; int brickDown=brickUp+brickBred; if((touchCx==brickRight)&&(abs(b.upy-brickUp)<=abs(brickBred-b.radius)&&abs(b.downy-brickDown)<=abs(brickBred-b.radius))){ touchLeft(); isBrick[i][j]=0; } else if((touchCx==brickLeft)&&(abs(b.upy-brickUp)<=abs(brickBred-b.radius)&&abs(b.downy-brickDown)<=abs(brickBred-b.radius))){ touchRight(); isBrick[i][j]=0; } else if((touchCy==brickDown)&&(abs(b.leftx-brickLeft)<=abs(brickLen-b.radius)&&abs(b.rightx-brickRight)<=abs(brickLen-b.radius))){ touchUp(); isBrick[i][j]=0; } else if((touchCy==brickUp)&&(abs(b.leftx-brickLeft)<=abs(brickLen-b.radius)&&abs(b.rightx-brickRight)<=abs(brickLen-b.radius))){ touchDown(); isBrick[i][j]=0; } else if((abs(abs(b.cx)-brickLeft)+abs(abs(b.cx)-brickRight)==brickLen)&&(abs(abs(b.cy)-brickUp)+abs(abs(b.cy)-brickDown)==brickBred)){ touchCorner(); isBrick[i][j]=0; } if(isBrick[i][j]==0){ score=score+(10*abs(j-8)); setScoreString(); int brick[8]; setcolor(0); brick[0]=brick[6]=brickLeft; brick[1]=brick[3]=brickUp; brick[2]=brick[4]=brickRight; brick[5]=brick[7]=brickDown; setfillstyle(1,0); fillpoly(4,brick); rectangle(brick[0],brick[1],brick[2],brick[5]); drawBricks(); i=0,j=0; } } } } }
void Background :: touchMoved ( int x, int y, int id ) { if( bCenterScreen ) return; if( !bTouchDown ) { touchDown( x, y, id ); // touch down skipped because it was made in center screen, so redo. } // cout << "touchMoved" << endl; bDragging = true; float dragScale; dragScale = 0.5; dragX = ( touchPointLast.x - x ) * dragScale; dragY = ( touchPointLast.y - y ) * dragScale; }
void GestureDetector::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) { CC_UNUSED_PARAM(pEvent); CCPoint tTouchPoint; // CCObject *pObj; // CCNode *pNode; for (CCSetIterator iter = pTouches->begin(); iter != pTouches->end(); iter++) { CCTouch *touch = (CCTouch *) (*iter); if (mIgnoreProceeded && !touch->getProceeded()) { mCurrentTouch = touch; tTouchPoint = mCurrentTouch->getLocation(); touch->setProceeded(touchDown(tTouchPoint, mCurrentTouch->getID())); } // CCARRAY_FOREACH(m_pTrackingNodes, pObj) { // pNode = static_cast<CCNode *>(pObj); // if (Utils::isNodeAtPoint(pNode, tTouchPoint)) { // touchDown(tTouchPoint.x, tTouchPoint.y, pTouch->getID()); // break; // } // } } }
void ofxUICanvas::onTouchDown(ofTouchEventArgs &data) { touchDown(data); }
void TouchInputHandler::handleTouchEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (hasTouch()){ UINT inputCount = LOWORD(wParam); TOUCHINPUT *inputs = new TOUCHINPUT[inputCount]; if (touchInfo((HTOUCHINPUT) lParam, inputCount, inputs, sizeof(TOUCHINPUT))) { for (UINT i = 0; i < inputCount; i++) { int id = 0; //here we map the windows touch id to the ppsspp internal touch id //currently we ignore the fact that the mouse uses touch id 0, so that //the mouse could possibly interfere with the mapping so for safety //the maximum amount of touch points is MAX_POINTERS-1 std::map<int, int>::const_iterator it = touchTranslate.find(inputs[i].dwID); if (it != touchTranslate.end()) //check if we already mapped this touch id { id = it->second; } else { if (touchTranslate.size() + 1 >= MAX_POINTERS) //check if we're tracking too many points { touchUp(touchTranslate.begin()->second, 0, 0); touchTranslate.erase(touchTranslate.begin()); } //finding first free internal touch id and map this windows id to an internal id bool *first_free = std::find(input_state.pointer_down, input_state.pointer_down + MAX_POINTERS, false); id = (int)(first_free - input_state.pointer_down) / (int)sizeof(bool); touchTranslate[inputs[i].dwID] = id; } POINT point; point.x = TOUCH_COORD_TO_PIXEL(inputs[i].x); point.y = TOUCH_COORD_TO_PIXEL(inputs[i].y); if (ScreenToClient(hWnd, &point)){ if (inputs[i].dwFlags & TOUCHEVENTF_DOWN) { touchDown(id, point.x, point.y); } if (inputs[i].dwFlags & TOUCHEVENTF_MOVE) { touchMove(id, point.x, point.y); } if (inputs[i].dwFlags & TOUCHEVENTF_UP) { touchUp(id, point.x, point.y); touchTranslate.erase(touchTranslate.find(inputs[i].dwID)); } } } closeTouch((HTOUCHINPUT) lParam); } else { // GetLastError() and error handling. } delete [] inputs; } }
//-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ if (m_multitouch.isSetup()) return; touchDown(x,y,-1); }