Jump to content
  • Advertisement

Archived

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

TT

Really basic Linux question

This topic is 6174 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

Hello everybody, I''m a C++ programmer, but I''m having issues with a Linux program I''m writing. I need to get unbuffered feedback from the keyboard, a task not well suited for the stdio library, since it''s buffered. My goal is to get real-time feedback, since the program is kind of a soccer game, really. On windows it would be just as easy as reading port 60h or something like that, but I don''t really have any idea on how to do it on Linux. Does somebody know how? Thank you!

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I could be wrong, but isn''t there a function in one of the c/c++ header files that would work for this?

Share this post


Link to post
Share on other sites
Well, assuming you don''t want to use an input library, setting the correct terminal capabilities is what you need. I''d tell you how to do it here, but the description is kind of long (though not complicated), and it has been a while since I''ve done it, so my information might be wrong. Basically though, what you need to find information on is the termios functions (mainly tcsetattr). There is a structure called ''termios'' that has various flags and setting that control the way input is handled on the terminal. I''m pretty sure what you want to do is enable canonical mode, and set MIN & TIME to 0. That should allow you to read the keyboard instantly.



Hrm.. now that I think about it, that won''t be suitable for most games though, as it will only return one key at a time, and won''t give you very precice control. Bleh. You might want to look into SDL (www.libsdl.org). It is mainly a graphics API, but it contains methods for getting raw keyboard/mouse/joystick/etc access. You might want to check around for a raw-keyboard library too.. I''m sure one exists.

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!