Reputation:
I'm trying to make a c++ snake game in linux using ansi escape codes but i can't figure out a way to get async keyboard input. Im a beginner and i'm currently reading a c++ book, so i didn't cover multithreading yet. Is there any chance to achieve this result in a "simple" way.(and standard if it's possible, i saw the kbhit solution) How to use kbhit and getch (C programming) . Can i solve the problem reading from the /dev/input event files?
Thank you guys.
Upvotes: 2
Views: 2157
Reputation: 11440
C++ does not offer a standard way to asynchronously read the keyboard status.
boost asio, as in read from keyboard using boost async_read and posix::stream_descriptor is one way. Some people consider boost like a "standard" or "normal" C++ extension.
Another way is to use a game library like SDL or SFML. You include their headers and you link with their libs.
Upvotes: 1