PDA

View Full Version : What is "Enter" key value?



Binqay
05-27-2001, 06:35 AM
Hai!

What is "Enter" key value? And where to put it(special func or keyboard func)?

Example: Ecs=27 (keyboard func)
Up Arrow=GLUT_KEY_UP (special func)
Enter=?? (?? func)

I hope this can be understand.

Teofuzz
05-27-2001, 09:36 AM
If it is a "keyboard func", it must be 13.
tFz

Binqay
05-28-2001, 04:26 AM
Thanks Teofuzz http://www.opengl.org/discussion_boards/ubb/smile.gif

Err...How about space bar? http://www.opengl.org/discussion_boards/ubb/smile.gif

Bob
05-28-2001, 05:22 AM
32 if I remember correctly.

john
05-28-2001, 02:44 PM
Howdy,

yep, we could all throw ascii values around until the cows come home (or, until we've covered all 255 of them, and then we can move onto java's 16bit character. heh heh)

You don't need to do



char c;
if(c==(char)32)

because you can just do:



char c;
if(c=='\n') { /* press ENTER' */ }
else if(c==' ') { /* press SPACE' */ }
else if(c=='A') { /* press .. er... uhm... */
}

and so on. Also, if you REALLY want to know the magically cool keys, like the cursors, then you can easily write a simple program to print out the value your glut keyboard function is called with, and then just look at the numbers... =)

cheers
John




[This message has been edited by john (edited 05-28-2001).]

Binqay
05-29-2001, 05:06 AM
Hello!

Thanks to all. This really help me! But did all the keys has their ascii value? For example SHIFT key?

Bob
05-29-2001, 05:33 AM
All keys that has a direct character mapped to it has an ascii code. Shift is a, uuh, what's it called, dead/silent key (?). Never mind. Shift does not work alone, like 'A' and Enter. It has a scan code (the code generated by the keyboard which is, in turn, translated to a character), but no ascii code. This is why you have to use GLUT's special key function.

Binqay
05-29-2001, 07:02 AM
Hai! This will maybe out off the original topic. http://www.opengl.org/discussion_boards/ubb/smile.gif

I create a first person camera walking in a world using the UP,DOWN,LEFT,RIGHT key. When the user press the 'R' key, the camera will move faster.

I use glutIgnoreKeyRepeat to make my app runs faster. Each time a key is pressed, it will return a TRUE value and when the key is released, it will return a FALSE value.

Here's my pseudecode:

void keyboardPress(...)
{ if(key=='R')R_key_pressed=TRUE; }

void keyboardRelease(...)
{ if(key=='R')R_key_pressed=FALSE; }

void specialPress() {...}
void specialRelease() {...}

void idle()
{ int speed=10;
if(R_key_pressed)speed=20;
if(Up_key_pressed)moveMeFlat*speed;
...
glutPostRedisplay();
}

My question is, how can I change the 'R' key to SHIFT key? Can anybody show me the code?

05-29-2001, 08:02 AM
Might Try VK_SHIFT or I DONT KNOW WHAT THIS IS REALLY FOR but it might work GLUT_ACTIVE_SHIFT