Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Mordoch Bob

Input in GLUT

This topic is 5993 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The general form for the GLUT input function is void input(unsigned char key, int x, int y). However, this doesn''t allow for simultaneous pressing of keys (though there are methods for checking whether shift, control, or alt are pressed). Is there a trick of some sort I''m unaware of, or is this just a basic failing of GLUT? ------------------------------------------------ The wind shear alone from a pink golfball can take the head off a 90-pound midget from 300 yards. -Six String Samurai

Share this post

Link to post
Share on other sites
disable key repeat (check the help or the header for the command)
there are 2 messages ''keypressed'' + ''keyreleased'' if a ''key pressed'' message has been sent the key is pressed AND held until the ''key released'' callback gets called.
thus store all the keys states + then when u wanna see if a key is pressed just check the state

eg example bogus code
bool key_state[256];

glut_key_pressed( int char )
key_state[ char ] = true;

glut_key_repressed( int char )
key_state[ char ] = false;

if (key_state[ ''A'' ] ) move left; // 65
if (key_state[ ''B'' ] ) move up;

thus its possible for both A+B to be pressed

also check the keyboards... document here


Share this post

Link to post
Share on other sites
Beware case sensitivity though :

Hold a , then hold SHIFT and finally release a
you get a key-press a and a key-release A

Edit: And while you're at it, consider what to do with people with a different keybord layout than yours

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

[edited by - Fruny on June 25, 2002 7:10:31 AM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!