is certain key pressed at the moment ??
hi, guys !!
i'm new to linux programming, and trying to write the tetris game. i know that's useless, but that's the way i can learn c under linux. i need the way to find out if key is down or not at the moment. i don't need to wait for user input (like scanf() or getch() in ncurses). i just need to know if the key is pressed at the moment. i hope you will help me find the solution. thanks any way ;) alex. |
|
Are you using a GUI API? If so which one? For instance, if you were using SDL, there is a function called SDL_GetKeyState() you could use.
In Windows there is an API called GetAsyncKeyState. There is probably something similar in Xlib, but I don't know it offhand. If you are just creating your tetris game as a text based game instead of as an X game, then you'll probably just want to check the links that Hko provided. |
yep, i'm doing all that in text mode using ncurses. i'm checking the links right now ...
|
thanks for those links. finally i used new thread which has a infinite loop to read char from the keyboard using ncurses' getch().
|
All times are GMT -5. The time now is 06:44 PM. |