Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

keybd.c

Go to the documentation of this file.
00001 /*************************************************************************
00002 *   FILE: keybd.c
00003 * AUTHOR: CAL
00004 * DATE: 18 April 1993
00005 * PURPOSE:
00006 *   Keybd class serves as an interface between the UI and the
00007 *   keyboard.  It generates messages based on keyboard events
00008 *   containing character codes and scan codes.
00009 **************************************************************************/
00010 
00011 
00012 #include "keybd.h"
00013 #include <conio.h>
00014 
00015 
00016 Message Keybd::Event (void)
00017 {
00018   if (! kbhit())
00019     return NullMsg;
00020   else
00021   {
00022     Message msg (KeyMsg, KeyPressed, getch ());
00023     if (msg.d1 == 0)
00024       msg.d2 = getch ();
00025     return msg;
00026   }
00027 }
00028 
00029 
00030 Message Keybd::WaitForAnyEvent (void)
00031 {
00032   Message msg;
00033 
00034   do msg = Event();
00035   while (msg.code == Idle);
00036 
00037   return msg;
00038 }
00039 
00040 
00041 Message Keybd::WaitForEvent (Message& msg)
00042 {
00043   Message try;
00044 
00045   do try = Event ();
00046   while (try != msg);
00047 
00048   return try;
00049 }
00050 
00051 
00052 void Keybd::Flush (void)
00053 {
00054   Message m;
00055   do {
00056     m = Event ();
00057   } while (m != NullMsg);
00058 }
00059 
00060 
00061 

Generated on Sun Jul 6 23:07:15 2003 for Scotland Yard by doxygen1.2.15