PDA

View Full Version : Glut Keys?



dabeav
06-06-2002, 07:09 AM
2 questions. First what are the glut key values for keys like "space", "enter", "tab"? I know about the glut special keys, like up, down, left and right, but I havent found anything about space or anything else. Also I want to read the user configurated keys from an outside file, do the special keys map to integer values, this would make it much easier to read those values in. And last but not least, when i set up a normal keys function to test if a key is down each time, i set a flag using this
bool NormalKeysDown[256];
Special keys can be done the same way, but how many keys are there? i dont know how big to make the bool, or how to set the keys once pressed. Currently i set it with
NormalKeysDown[key] = 1; but, im not aware of how many special keys there are, nore am i sure if they map out that way. Sorry if im too confusing, i have had a very long day. Thanks for your help in advance.

reubenhawkins
06-06-2002, 07:53 AM
look up ascii values and scan codes. each time you press a key it sends a ascii and a scan code. Enter is 13 I think, Esc is 27 and space I think is 32...

jmathies
06-06-2002, 08:38 AM
Originally posted by dabeav:
2 questions. First what are the glut key values for keys like "space", "enter", "tab"? I know about the glut special keys, like up, down, left and right, but I havent found anything about space or anything else. Also I want to read the user configurated keys from an outside file, do the special keys map to integer values, this would make it much easier to read those values in. And last but not least, when i set up a normal keys function to test if a key is down each time, i set a flag using this
bool NormalKeysDown[256];
Special keys can be done the same way, but how many keys are there? i dont know how big to make the bool, or how to set the keys once pressed. Currently i set it with
NormalKeysDown[key] = 1; but, im not aware of how many special keys there are, nore am i sure if they map out that way. Sorry if im too confusing, i have had a very long day. Thanks for your help in advance.

1) GLUT hands you ascii key codes - there are 256 of these.
2) an array of 256 bools will suffice
3) to test, use a single quote character:

array[' ']
array['a']
array['\t'] (tab)

Some information on this is available in the
OpenGL Toolkit FAQ (http://www.mathies.com/glfaq) .
Regards
Jim