-
Keyboard Input ?
I'm making a text/ASCII graphic game and there are times where I need to "Cancel input" from the keyboard to allow the user to watch something happen. Where if you hit enter 3 times during it and enter takes you out of the screen at the end you are taken out because I use the getch() command to input. Is there any way to temporarily cease input from the keyboard if using the getch() command? Thanks guys.
-
use kbhit ()... kbhit () checks the keyboard buffer if there's an available keystroke and getch () returns it... if no keystrokes exist, getch () waits until you press something into the keyboard buffer and retrieves it...
so, check if a keystroke exists and return it with getch (), if it is not available, don't return getch () and return zero [or some other flag value]... any ?uestions?
-hth
-
Awesome, thanks man
Hey man, thanks for that advice, it worked! I'm not a very good programmer yet but that command will come in handy =). Thanks again!
-
only problem with kbhit() is that it is not part of either the c or c++ standards therefore not all compilers have this facility.
-
oh... well good anyway... coindentally i use the interrupt so i can get the ASCII and scan codes both... but what is the standardized alternative then SC? thank you!
-
Unfortuneately there isn't one DA. This is because it is highly operating system specific. In dos as you know you use interrupts.In windows you use GetAsyncKeyState().In linux/unix you use ____________ (salem please fill in the blank!):p .Sorry I'm a windows guy!
-
i would have thought the protocols for such a thing were more closely tied to the hw...
speaking of which, all software does use hw interrupts? right? i'm pretty sure... else what links the hw to the sw? hmmm.