C Board  

Go Back   C Board > General Programming Boards > FAQ Board

 
 
LinkBack Thread Tools Display Modes
Old 11-05-2001, 06:11 PM   #1
Registered User
 
Join Date: Nov 2001
Posts: 9
Question 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.
Malikive is offline  
Old 11-05-2001, 06:33 PM   #2
Linguistic Engineer...
 
doubleanti's Avatar
 
Join Date: Aug 2001
Location: CA
Posts: 2,420
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
__________________
hasafraggin shizigishin oppashigger...
doubleanti is offline  
Old 11-06-2001, 02:48 PM   #3
Registered User
 
Join Date: Nov 2001
Posts: 9
Thumbs up 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!
Malikive is offline  
Old 11-06-2001, 02:53 PM   #4
Skunkmeister
 
Stoned_Coder's Avatar
 
Join Date: Aug 2001
Posts: 2,572
only problem with kbhit() is that it is not part of either the c or c++ standards therefore not all compilers have this facility.
__________________
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Stoned_Coder is offline  
Old 11-06-2001, 06:40 PM   #5
Linguistic Engineer...
 
doubleanti's Avatar
 
Join Date: Aug 2001
Location: CA
Posts: 2,420
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!
__________________
hasafraggin shizigishin oppashigger...
doubleanti is offline  
Old 11-06-2001, 08:08 PM   #6
Skunkmeister
 
Stoned_Coder's Avatar
 
Join Date: Aug 2001
Posts: 2,572
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!) .Sorry I'm a windows guy!
__________________
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Stoned_Coder is offline  
Old 11-07-2001, 09:30 PM   #7
Linguistic Engineer...
 
doubleanti's Avatar
 
Join Date: Aug 2001
Location: CA
Posts: 2,420
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.
__________________
hasafraggin shizigishin oppashigger...
doubleanti is offline  
 

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with keyboard input fighter92 Game Programming 6 03-20-2009 09:41 AM
faq: cached input with mygetch() ichijoji Linux Programming 4 06-18-2008 11:36 PM
Using low-level keyboard for input hdragon C++ Programming 25 12-24-2007 02:13 PM
Stealing Keyboard input zort15 C++ Programming 2 04-16-2007 02:22 PM
Keyboard Input Unregistered C++ Programming 5 07-29-2002 11:41 AM


All times are GMT -6. The time now is 04:27 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22