Ejemplo n.º 1
0
// MODIFY THIS FUNCTION
void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
{
  if( !TwEventKeyGLFW(key, action) )  // Send event to AntTweakBar
  {
  }
    // Define your keyboard shortcuts here
}
Ejemplo n.º 2
0
 void GLFW_App::s_keyFunc(GLFWwindow* window, int key, int scancode, int action, int modifier_mask)
 {
     GLFW_App* app = static_cast<GLFW_App*>(glfwGetWindowUserPointer(window));
     if(app->displayTweakBar())
         TwEventKeyGLFW(key, action);
     
     uint32_t buttonMod, keyMod;
     s_getModifiers(window, buttonMod, keyMod);
     
     KeyEvent e(key, key, keyMod);
     
     switch(action)
     {
         case GLFW_PRESS:
         case GLFW_REPEAT:
             app->keyPress(e);
             break;
             
         case GLFW_RELEASE:
             app->keyRelease(e);
             break;
         
         
         default:
             break;
     }
 }
Ejemplo n.º 3
0
void keyboard_Aux(GLFWwindow* pWindow, int key, int codes, int action, int mods)
{
#ifdef USE_ANTTWEAKBAR
    int ant = TwEventKeyGLFW(key, action);
    if (ant != 0)
        return;
#endif
    keyboard(pWindow, key, codes, action, mods);
}
Ejemplo n.º 4
0
	void OGLApp::glfw_key(GLFWwindow * window, int key, int scancode, int action, int mode)
	{
		if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
			glfwSetWindowShouldClose(window, GL_TRUE);

#ifdef USE_ANT
		TwEventKeyGLFW(key, action);
#endif
		app->v_keyCallback(window, key, scancode, action, mode);
	}
Ejemplo n.º 5
0
// Callback function called by GLFW on key event
void GLFWCALL OnKey(int glfwKey, int glfwAction)
{
    if( !TwEventKeyGLFW(glfwKey, glfwAction) )  // Send event to AntTweakBar
    {
        if( glfwKey==GLFW_KEY_ESC && glfwAction==GLFW_PRESS ) // Want to quit?
            glfwCloseWindow();
        else
        {
            // Event has not been handled
            // Do something if needed.
        }
    }
}
static void onKeyDown(GLFWwindow* window, int key, int scancode, int action, int mods)
{
	// AntTweakBar event
	if (TwEventKeyGLFW(key, action))
		return;

	if (key == GLFW_KEY_N && action == GLFW_PRESS){
		g_twVar.sim_step = true;
	}	

	if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS){
		glfwSetWindowShouldClose(window, GL_TRUE);
	}	
}
Ejemplo n.º 7
0
	//////////////////////////////////////////////////////////////////////////
	//	Input Events
	void DebugUIKeyPress(int key, int state)
	{
		switch(key)
		{
		case GLFW_KEY_ENTER:
			key = TW_KEY_RETURN;
			break;
		case GLFW_KEY_BACKSPACE:
			key = TW_KEY_BACKSPACE;
			break;
		}
		TwEventKeyGLFW(key, state);
		TwEventCharGLFW(key, state);
		TW_KEY_RETURN;
	}
Ejemplo n.º 8
0
  void MyWindow::keyboard(MyWindow::KeyCode key, ButtonAction action, int mods, int x, int y)
  {
#ifdef USEANTTWEAKBAR
    // to fix some mapping issues with special keys
    // TODO: find the real Fix...
    if(action == MyWindow::BUTTON_PRESS)
    {
        switch(key)
        {
        case NVPWindow::KEY_HOME:
            if(TwEventSpecialGLUT(106/*GLUT_KEY_HOME*/, x,y) ) { postRedisplay(); return; }
            break;
        case NVPWindow::KEY_END:
            if(TwEventSpecialGLUT(107/*GLUT_KEY_END*/, x,y) ) { postRedisplay(); return; }
            break;
        case NVPWindow::KEY_LEFT:
            if(TwEventSpecialGLUT(100/*GLUT_KEY_LEFT*/, x,y) ) { postRedisplay(); return; }
            break;
        case NVPWindow::KEY_RIGHT:
            if(TwEventSpecialGLUT(102/*GLUT_KEY_RIGHT*/, x,y) ) { postRedisplay(); return; }
            break;
        case NVPWindow::KEY_BACKSPACE:
            if(TwEventKeyboardGLUT(TW_KEY_BACKSPACE, x,y) ) { postRedisplay(); return; }
            break;
        case NVPWindow::KEY_DELETE:
            if(TwEventKeyboardGLUT(TW_KEY_DELETE, x,y) ) { postRedisplay(); return; }
            break;
        case NVPWindow::KEY_ENTER:
        case NVPWindow::KEY_KP_ENTER:
            if(TwEventKeyboardGLUT(TW_KEY_RETURN, x,y)) { postRedisplay(); return; }
            break;
        case NVPWindow::KEY_ESCAPE:
            //postQuit();
            break;
        }
    }
    TwEventMousePosGLFW(x,y);
    if(TwEventKeyGLFW(key, action) ) {
    //if(TwEventSpecialGLUT(key, x,y) ) {
		postRedisplay();
        return;
	}
#endif
    WindowInertiaCamera::keyboard(key, action, mods, x, y);
  }
Ejemplo n.º 9
0
void GLFWCALL keyPressListener( int key, int action )
{
	if( !running ) return;
	if(key == GLFW_KEY_ESC)
	{
		running = false;
	}
	if(key == GLFW_KEY_TAB && action == GLFW_PRESS)
	{
		app->_mouseFree = true;
		glfwDisable( GLFW_MOUSE_CURSOR );
	}
	if(key == GLFW_KEY_LSHIFT && action == GLFW_PRESS)
	{
		app->_mouseFree = false;
		glfwEnable( GLFW_MOUSE_CURSOR);
	}
	if(app->_mouseFree == true)
	{
		if( action == GLFW_PRESS )
		{
			int width = appWidth, height = appHeight;
			
			switch (key)
			{
			case GLFW_KEY_SPACE:
				app->keyPressEvent( key );
				break;
			default:
				app->keyPressEvent( key );
				break;
			}
		}

		if( key >= 0 ) app->keyStateChange( key, action == GLFW_PRESS );
	}
	else
	{
		//Pass the key into AntTweakBar
		TwEventKeyGLFW(key,action);
	}
}
Ejemplo n.º 10
0
TW_API int TW_CDECL_CALL TwEventKeyGLFWcdecl(int glfwKey, int glfwAction)
{
    return TwEventKeyGLFW(glfwKey, glfwAction);
}
Ejemplo n.º 11
0
void myTwEventKeyGLFW(GLFWwindow* window, int key, int scancode, int action, int mods)
{
	TwEventKeyGLFW(key, action);
	//TwEventKeyGLFW(key, GLFW_KEY_DOWN);
}
Ejemplo n.º 12
0
void TwEventKeyGLFW3(GLFWwindow* window, int key, int scancode, int action, int mods){TwEventKeyGLFW(key, action);}
Ejemplo n.º 13
0
void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mod) {
    int tweak = TwEventKeyGLFW(key, action);
}