//------------------------------------------
void ofNotifyKeyEvent(const ofKeyEventArgs & keyEvent){
	switch(keyEvent.type){
		case ofKeyEventArgs::Pressed:
			ofNotifyKeyPressed(keyEvent.key);
			break;
		case ofKeyEventArgs::Released:
			ofNotifyKeyReleased(keyEvent.key);
			break;
		
	}
}
Exemple #2
0
//------------------------------------------------------------
void ofAppGlutWindow::special_key_up_cb(int key, int x, int y) {
	ofNotifyKeyReleased(key | OF_KEY_MODIFIER);
}
Exemple #3
0
//------------------------------------------------------------
void ofAppGlutWindow::keyboard_up_cb(unsigned char key, int x, int y){
	ofNotifyKeyReleased(key);
}
//------------------------------------------------------------
void ofxFensterManager::keyboard_cb(GLFWwindow* windowP_, int key, int scancode, unsigned int codepoint, int action, int mods) {

	ofLogVerbose("ofxFenster") << "key: " << key << " state: " << action;

	switch (key) {
	case GLFW_KEY_ESCAPE:
		key = OF_KEY_ESC;
		break;
	case GLFW_KEY_F1:
		key = OF_KEY_F1;
		break;
	case GLFW_KEY_F2:
		key = OF_KEY_F2;
		break;
	case GLFW_KEY_F3:
		key = OF_KEY_F3;
		break;
	case GLFW_KEY_F4:
		key = OF_KEY_F4;
		break;
	case GLFW_KEY_F5:
		key = OF_KEY_F5;
		break;
	case GLFW_KEY_F6:
		key = OF_KEY_F6;
		break;
	case GLFW_KEY_F7:
		key = OF_KEY_F7;
		break;
	case GLFW_KEY_F8:
		key = OF_KEY_F8;
		break;
	case GLFW_KEY_F9:
		key = OF_KEY_F9;
		break;
	case GLFW_KEY_F10:
		key = OF_KEY_F10;
		break;
	case GLFW_KEY_F11:
		key = OF_KEY_F11;
		break;
	case GLFW_KEY_F12:
		key = OF_KEY_F12;
		break;
	case GLFW_KEY_LEFT:
		key = OF_KEY_LEFT;
		break;
	case GLFW_KEY_RIGHT:
		key = OF_KEY_RIGHT;
		break;
	case GLFW_KEY_UP:
		key = OF_KEY_UP;
		break;
	case GLFW_KEY_DOWN:
		key = OF_KEY_DOWN;
		break;
	case GLFW_KEY_PAGE_UP:
		key = OF_KEY_PAGE_UP;
		break;
	case GLFW_KEY_PAGE_DOWN:
		key = OF_KEY_PAGE_DOWN;
		break;
	case GLFW_KEY_HOME:
		key = OF_KEY_HOME;
		break;
	case GLFW_KEY_END:
		key = OF_KEY_END;
		break;
	case GLFW_KEY_INSERT:
		key = OF_KEY_INSERT;
		break;
	case GLFW_KEY_LEFT_SHIFT:
		key = OF_KEY_LEFT_SHIFT;
		break;
	case GLFW_KEY_LEFT_CONTROL:
		key = OF_KEY_LEFT_CONTROL;
		break;
	case GLFW_KEY_LEFT_ALT:
		key = OF_KEY_LEFT_ALT;
		break;
	case GLFW_KEY_LEFT_SUPER:
		key = OF_KEY_LEFT_SUPER;
		break;
	case GLFW_KEY_RIGHT_SHIFT:
		key = OF_KEY_RIGHT_SHIFT;
		break;
	case GLFW_KEY_RIGHT_CONTROL:
		key = OF_KEY_RIGHT_CONTROL;
		break;
	case GLFW_KEY_RIGHT_ALT:
		key = OF_KEY_RIGHT_ALT;
		break;
	case GLFW_KEY_RIGHT_SUPER:
		key = OF_KEY_RIGHT_SUPER;
		break;
	case GLFW_KEY_BACKSPACE:
		key = OF_KEY_BACKSPACE;
		break;
	case GLFW_KEY_DELETE:
		key = OF_KEY_DEL;
		break;
	case GLFW_KEY_ENTER:
		key = OF_KEY_RETURN;
		break;
	case GLFW_KEY_KP_ENTER:
		key = OF_KEY_RETURN;
		break;
	case GLFW_KEY_TAB:
		key = OF_KEY_TAB;
		break;
	default:
		break;
	}

	//GLFW defaults to uppercase - OF users are used to lowercase
	//we look and see if shift is being held to toggle upper/lowecase
	if( key >= 65 && key <= 90 && !ofGetKeyPressed(OF_KEY_SHIFT) ) {
		key += 32;
	}

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

	if(action == GLFW_PRESS || action == GLFW_REPEAT) {
		if(fenster == get()->mainWindow)
			ofNotifyKeyPressed(key);
			
		ofKeyEventArgs args;
		args.key = key;
		args.type = ofKeyEventArgs::Pressed;
		ofNotifyEvent(fenster->onKeyPressed, args);
			
		if (key == OF_KEY_ESC) {				// "escape"
			ofExit();
		}
	} else if (action == GLFW_RELEASE) {
		if(fenster == get()->mainWindow)
			ofNotifyKeyReleased(key);
			
		ofKeyEventArgs args;
		args.key = key;
		args.type = ofKeyEventArgs::Pressed;
		ofNotifyEvent(fenster->onKeyReleased, args);
	}
}
void
Java_cc_openframeworks_OFAndroid_onKeyUp(JNIEnv*  env, jobject  thiz, jint  keyCode){
	ofNotifyKeyReleased(keyCode);
}