@Hans
in fact I do this for all keys handled so it will automatically set to 1 or 0 the key depending if it is pressed or not
without having to use a switch or if.
Re explaining :
glutspecialfunc( int key, int x, int y ){
DBKeyboard.F1 = ( key == GLUT_KEY_F1 );
DBKeyboard.F2 = ( key == GLUT_KEY_F2 );
// ...
}
After this user can use :
BOOL D = F1Pressed()
will return D = TRUE / 1 if key is pressed or FALSE / 0 if key is not pressed
I was thinking that ( key == GLUT_KEY_F1 ) = 1 if key F1 is pressed and = 0 if key is not pressed. But apparently not.
EDIT.
I've found the correct solution:
it work under glutKeyboardFunc( ... ) and not under glutSpecialFunc( ... ) :
void MyKeyboardFunc( unsigned char k, int x, int y ){
UBYTE *kptr = NULL; kptr = &k;
UBYTE keyB = *kptr;
int key = (int)keyB;
DBKeyboard.Escape = ( key == 27 );
DBKeyboard.F1 = ( key == GLUT_KEY_F1 );
DBKeyboard.F2 = ( key == GLUT_KEY_F2 );
...
}
I will store keys in my structure in the same order than scancode so they can be accessed easyli with commands I'll do like :
int KeyPressed = DEKeyPressed()
int KeyID = DEScanCode( int KeyID )
It now correctly work :)
Regards,
Fred
Edited by freddix on 2009/11/3 13:28:45