void
Java_cc_openframeworks_OFAndroid_onTouchDoubleTap(JNIEnv*  env, jclass  thiz, jint id,jfloat x,jfloat y,jfloat pressure){
	ofNotifyMousePressed(x,y,0);
	ofTouchEventArgs touch;
	touch.id = id;
	touch.x = x;
	touch.y = y;
	touch.pressure = pressure;
	ofNotifyEvent(ofEvents.touchDoubleTap,touch);
}
Esempio n. 2
0
//------------------------------------------------------------
void ofxFensterManager::mouse_cb(GLFWwindow* windowP_, int button, int state, int mods) {
	ofLogVerbose("ofxFenster") << "mouse button: " << button;

#ifdef TARGET_OSX
	//we do this as unlike glut, glfw doesn't report right click for ctrl click or middle click for alt click
	if( ofGetKeyPressed(OF_KEY_CONTROL) && button == GLFW_MOUSE_BUTTON_LEFT) {
		button = GLFW_MOUSE_BUTTON_RIGHT;
	}
	if( ofGetKeyPressed(OF_KEY_ALT) && button == GLFW_MOUSE_BUTTON_LEFT) {
		button = GLFW_MOUSE_BUTTON_MIDDLE;
	}
#endif

	switch(button) {
	case GLFW_MOUSE_BUTTON_LEFT:
		button = OF_MOUSE_BUTTON_LEFT;
		break;
	case GLFW_MOUSE_BUTTON_RIGHT:
		button = OF_MOUSE_BUTTON_RIGHT;
		break;
	case GLFW_MOUSE_BUTTON_MIDDLE:
		button = OF_MOUSE_BUTTON_MIDDLE;
		break;
	}

	ofxFensterPtr fenster = get()->getFensterByGlfwHandle(windowP_);

	if (state == GLFW_PRESS) {
		if(fenster == get()->mainWindow)
			ofNotifyMousePressed(ofGetMouseX(), ofGetMouseY(), button);

		fenster->buttonPressed=true;

		ofMouseEventArgs args;
		args.x = fenster->curMouseX;
		args.y = fenster->curMouseY;
		args.type = ofMouseEventArgs::Pressed;
		ofNotifyEvent(fenster->onMousePressed, args);
	} else if (state == GLFW_RELEASE) {
		if(fenster == get()->mainWindow)
			ofNotifyMouseReleased(ofGetMouseX(), ofGetMouseY(), button);

		fenster->buttonPressed=false;

		ofMouseEventArgs args;
		args.x = fenster->curMouseX;
		args.y = fenster->curMouseY;
		args.type = ofMouseEventArgs::Released;
		ofNotifyEvent(fenster->onMouseReleased, args);
	}
	fenster->buttonInUse = button;

}
Esempio n. 3
0
//------------------------------------------------------------
void ofAppGlutWindow::mouse_cb(int button, int state, int x, int y) {

	if (nFrameCount > 0){
		if (state == GLUT_DOWN) {
			ofNotifyMousePressed(x, y, button);
		} else if (state == GLUT_UP) {
			ofNotifyMouseReleased(x, y, button);
		}

		buttonInUse = button;
	}
}
Esempio n. 4
0
//------------------------------------------
void ofNotifyMouseEvent(const ofMouseEventArgs & mouseEvent){
	switch(mouseEvent.type){
		case ofMouseEventArgs::Moved:
			ofNotifyMouseMoved(mouseEvent.x,mouseEvent.y);
			break;
		case ofMouseEventArgs::Dragged:
			ofNotifyMouseDragged(mouseEvent.x,mouseEvent.y,mouseEvent.button);
			break;
		case ofMouseEventArgs::Pressed:
			ofNotifyMousePressed(mouseEvent.x,mouseEvent.y,mouseEvent.button);
			break;
		case ofMouseEventArgs::Released:
			ofNotifyMouseReleased(mouseEvent.x,mouseEvent.y,mouseEvent.button);
			break;
		
	}
}
void
Java_cc_openframeworks_OFAndroid_onTouchDoubleTap(JNIEnv*  env, jclass  thiz, jint id,jfloat x,jfloat y,jfloat pressure){
	ofTouchEventArgs touch;
	touch.id = id;
	touch.x = x;
	touch.y = y;
	touch.pressure = pressure;
	touch.type = ofTouchEventArgs::doubleTap;
	if(threadedTouchEvents){
		ofNotifyMousePressed(x,y,0);
		ofNotifyEvent(ofEvents().touchDoubleTap,touch);
	}else{
		mutex.lock();
		touchEventArgsQueue.push(touch);
		mutex.unlock();
	}
}
Esempio n. 6
0
void Calibration::blobAdded(ofxBlob &_blob)
{
    if(bEnableSendMouseEvent == false) return;

    ofPoint pos = ofPoint((ofGetWidth()/2)-480,(ofGetHeight()/2)-120);


    float pos_cam_calib_x = windowCenter.x - (ps3eye_texture.getWidth()/2);
    float pos_cam_calib_y = windowCenter.y - (ps3eye_texture.getHeight()/2) ;

      printf("blob added %f %f\n", _blob.centroid.x, _blob.centroid.y);

      ofVec4f pos_w = warper.fromScreenToWarpCoord(pos_cam_calib_x + _blob.centroid.x*320, pos_cam_calib_y + _blob.centroid.y*240, 1);


      float calib_pos_x = (pos_w.x/ps3eye.getWidth()) * ofGetWidth();
      float calib_pos_y = (pos_w.y/ps3eye.getHeight()) * ofGetHeight();


      lastBlobPos.x = calib_pos_x;
      lastBlobPos.y = calib_pos_y;

         ofNotifyMousePressed(lastBlobPos.x, lastBlobPos.y, 0);


  //    if ( gedung1.hitTest(hitpos))
  //        {
  //            explode.play();
  //        }



//    ofPoint pos = ofPoint((ofGetWidth()/2)-480,(ofGetHeight()/2)-120);

//    printf("blob added %f %f\n", _blob.centroid.x, _blob.centroid.y);


//    ofVec4f hitpos = warper.fromScreenToWarpCoord(
//                pos.x + _blob.centroid.x* ps3eye.getWidth(),
//                pos.y + _blob.centroid.y* ps3eye.getHeight(),
//                1
//            );

    //ps3 image position for calibration
//    float pos_cam_calib_x = windowCenter.x - (ps3eye_texture.getWidth()/2);
//    float pos_cam_calib_y = windowCenter.y - (ps3eye_texture.getHeight()/2) ;


//    ofRectangle r = _blob.boundingRect;

//    ofVec4f pos_w = warper.fromScreenToWarpCoord(pos_cam_calib_x + r.x, pos_cam_calib_y + r.y, 1);

//    float calib_pos_x = (pos_w.x/ps3eye.getWidth()) * ofGetWidth();
//    float calib_pos_y = (pos_w.y/ps3eye.getHeight()) * ofGetHeight();

//    ofMouseEventArgs test;
//    test.x = calib_pos_x;
//    test.y = calib_pos_y;
//    test.button = 0;

//    ofNotifyMousePressed(calib_pos_x, calib_pos_y, 0);

//    printf("mouse pressed blob %f %f\n", calib_pos_x, calib_pos_y);

}
Esempio n. 7
0
/////////////////////////////////////////////////////////////////
/////////////   Event management    /////////////////////////////
/////////////////////////////////////////////////////////////////
void Touch::tuioAdded(ofxTuioCursor &tuioCursor){
    ofPoint loc = ofPoint(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight());
	ofLog(OF_LOG_VERBOSE) << "Point n" << tuioCursor.getSessionId() << " add at " << loc << endl;
    ofNotifyMousePressed(loc.x, loc.y, 0);
   lastMoved = ofGetUnixTime();
}
/* Call to render the next GL frame */
void
Java_cc_openframeworks_OFAndroid_render( JNIEnv*  env, jclass  thiz )
{

	if(paused || surfaceDestroyed) return;

	if(!threadedTouchEvents){
		mutex.lock();
		queue<ofTouchEventArgs> events = touchEventArgsQueue;
		while(!touchEventArgsQueue.empty()) touchEventArgsQueue.pop();
		mutex.unlock();

		while(!events.empty()){
			switch(events.front().type){
			case ofTouchEventArgs::down:
				ofNotifyMousePressed(events.front().x,events.front().y,0);
				ofNotifyEvent(ofEvents().touchDown,events.front());
				break;
			case ofTouchEventArgs::up:
				ofNotifyMouseReleased(events.front().x,events.front().y,0);
				ofNotifyEvent(ofEvents().touchUp,events.front());
				break;
			case ofTouchEventArgs::move:
				ofNotifyMouseMoved(events.front().x,events.front().y);
				ofNotifyMouseDragged(events.front().x,events.front().y,0);
				ofNotifyEvent(ofEvents().touchMoved,events.front());
				break;
			case ofTouchEventArgs::doubleTap:
				ofNotifyEvent(ofEvents().touchDoubleTap,events.front());
				break;
			case ofTouchEventArgs::cancel:
				ofNotifyEvent(ofEvents().touchCancelled,events.front());
				break;
			}
			events.pop();
		}
	}

	ofNotifyUpdate();


	if(ofGetGLProgrammableRenderer()){
		ofGetGLProgrammableRenderer()->startRender();
	}
	int width, height;

	width  = sWindowWidth;
	height = sWindowHeight;

	height = height > 0 ? height : 1;
	// set viewport, clear the screen
	//glViewport( 0, 0, width, height );
	ofViewport(0, 0, width, height, false);		// used to be glViewport( 0, 0, width, height );
	float * bgPtr = ofBgColorPtr();
	bool bClearAuto = ofbClearBg();

	if ( bClearAuto == true || ofGetFrameNum() < 3){
		ofClear(bgPtr[0]*255,bgPtr[1]*255,bgPtr[2]*255, bgPtr[3]*255);
	}

	if(bSetupScreen) ofSetupScreen();
	ofNotifyDraw();

	if(ofGetGLProgrammableRenderer()){
		ofGetGLProgrammableRenderer()->finishRender();
	}

}
/* Call to render the next GL frame */
void
Java_cc_openframeworks_OFAndroid_render( JNIEnv*  env, jclass  thiz )
{
	unsigned long beginFrameMicros = ofGetElapsedTimeMicros();

	if(paused || surfaceDestroyed) return;

	lastFrameTime = double(beginFrameMicros - previousFrameMicros)/1000000.;

	previousFrameMicros = beginFrameMicros;

	if(!threadedTouchEvents){
		mutex.lock();
		while(!touchEventArgsQueue.empty()){
			switch(touchEventArgsQueue.front().type){
			case ofTouchEventArgs::down:
				ofNotifyMousePressed(touchEventArgsQueue.front().x,touchEventArgsQueue.front().y,0);
				ofNotifyEvent(ofEvents().touchDown,touchEventArgsQueue.front());
				break;
			case ofTouchEventArgs::up:
				ofNotifyMouseReleased(touchEventArgsQueue.front().x,touchEventArgsQueue.front().y,0);
				ofNotifyEvent(ofEvents().touchUp,touchEventArgsQueue.front());
				break;
			case ofTouchEventArgs::move:
				ofNotifyMouseMoved(touchEventArgsQueue.front().x,touchEventArgsQueue.front().y);
				ofNotifyMouseDragged(touchEventArgsQueue.front().x,touchEventArgsQueue.front().y,0);
				ofNotifyEvent(ofEvents().touchMoved,touchEventArgsQueue.front());
				break;
			case ofTouchEventArgs::doubleTap:
				ofNotifyEvent(ofEvents().touchDoubleTap,touchEventArgsQueue.front());
				break;
			case ofTouchEventArgs::cancel:
				ofNotifyEvent(ofEvents().touchCancelled,touchEventArgsQueue.front());
				break;
			}
			touchEventArgsQueue.pop();
		}
		mutex.unlock();
	}

	ofNotifyUpdate();


	int width, height;

	width  = sWindowWidth;
	height = sWindowHeight;

	height = height > 0 ? height : 1;
	// set viewport, clear the screen
	//glViewport( 0, 0, width, height );
	ofViewport(0, 0, width, height, false);		// used to be glViewport( 0, 0, width, height );
	float * bgPtr = ofBgColorPtr();
	bool bClearAuto = ofbClearBg();

	if ( bClearAuto == true || nFrameCount < 3){
		ofClear(bgPtr[0]*255,bgPtr[1]*255,bgPtr[2]*255, bgPtr[3]*255);
	}

	if(bSetupScreen) ofSetupScreen();
	ofNotifyDraw();

	unsigned long currTime = ofGetElapsedTimeMicros();
	unsigned long frameMicros = currTime - beginFrameMicros;

	nFrameCount++;		// increase the overall frame count*/
	frames++;

	if(currTime - onesec>=1000000){
		frameRate = frames;
		frames = 0;
		onesec = currTime;
	}

	if(bFrameRateSet && frameMicros<oneFrameTime) usleep(oneFrameTime-frameMicros);

}