Jump to content
  • Advertisement
Sign in to follow this  
directNoob

Reading Keystrokes asynchroniously under linux

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

Hi. I need to read key strokes under linux and the os is not running on x86 hardware. Does anyone know how to do that? Thank alex

Share this post


Link to post
Share on other sites
Advertisement
I don't know if this helps, but I found the following with a little searching:

http://www.ibm.com/developerworks/linux/library/l-async/

Share this post


Link to post
Share on other sites
select on unixlikes work on any filedescriptor not just network sockets. You can use stdin as the descriptor in select to allow non-blocking input.

Share this post


Link to post
Share on other sites
Hi.

Thank for your reply.
As you correctly figured out, Im using C/C++, but
@Telastyn:
As Im am a really linux noob, can you specify what you mean?!
Is select a commend line command?

@medevilenemy:
Seams to be a good resource. Thanks.
But I first have to look over it.

Thanks
Alex

Share this post


Link to post
Share on other sites
Quote:
Original post by directNoob
As Im am a really linux noob, can you specify what you mean?!
Is select a commend line command?


select is a system call. man 2 select has more information

You can find a decent tutorial at
http://beej.us/guide/bgnet

Share this post


Link to post
Share on other sites
Quote:
Original post by directNoob
I need to read key strokes under linux and the os is not running on x86 hardware.
Does anyone know how to do that?


Correct answer: write a device driver and add it to the kernel, preferrably as a module.

Using one of the select() family (select(), poll(), epoll(), etc) can be used to read from stdin on some other file descriptor in non-blocking mode. If you read from stdin you're getting input cooked by the tty driver. You can use fcntl() to adjust the tty to deliver raw data instead of cooked data, but you're still not reading keystrokes, you're getting, um, sushi (as in, it's raw data that's been prepared by an expert).

The only way to actually read keystrokes is to talk to the keyboard device directly, which can only be done from kernel mode. Unless you're using, say, a USB keyboard or a dumb terminal over a serial line (remember the days!) or maybe a remote user channeling X over SSH.

My guess is what you really want is a stty()/select() kind of combo to read the raw data from stdin. There are libraries that will do that for you (eg. ncurses, SDL, X11).

Share this post


Link to post
Share on other sites
Hi, thanks.

I tried SDL, direcfb. I need it on the ps3 but I cant compile it due to compile errors.
Im absolutly at the end of everything.
Nothing goes right. Just error messages. And nobody seems to have errors using sdl on ps3 except me.

I just need user response to end the application. But Im absolutely not able to solve this problem. Why?!

Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!