juanito88 wrote on Sunday, February 23, 2014:
Hi all,
I wan to take inputs from the keyboard using GLFW (ver 2.7).
Keys are read as expected, except for one issue:
Suppose I’m moving to the left (with the left key pressed). Then, if I press the up key (keeping the left key pressed), I’m able to jump, but I stopped moving to the left.
If I release the left key and then press it back, I’m able to continue moving to the left.
How can I solve this issue?
Below there is a fragment that shows the main parts of the code:
:::python
# //global variable
# World world;
#
# //callback function
# void readKey( int key, int action ) {
# world.moveGuy(key,action );
# }
# int main( int argc, char **argv ) {
#
# //...
# glfwEnable( GLFW_KEY_REPEAT );
# glfwEnable( GLFW_STICKY_KEYS );
#
# glfwSetKeyCallback( readKey );
# do {
# //...
#
# } while( !world.closeWindow);
# return error;
# }
# void World::moveGuy( int key, int action ) {
# if( action != GLFW_PRESS )
# return;
# if( key==GLFW_KEY_LEFT)
# //move left
# if( key==GLFW_KEY_RIGHT)
# //move right
# if( key==GLFW_KEY_UP)
# //jump
#}
Any help would be much appreciated!