home *** CD-ROM | disk | FTP | other *** search
- #ifndef _KEYBOARD_HPP
- #define _KEYBOARD_HPP
-
- //---------------------------------------------------------------------------
- // File: KEYBOARD.HPP
- // Path: ...\REHACK\EVENT\KEYBOARD.HPP
- // Version: 1.00
- // Author: Bob Provencher
- // CIS Id: 71621,2632
- // Created On: 7/6/93
- // Modified On:
- // Description:
- // Tabs: 5
- //---------------------------------------------------------------------------
-
- #include <dos.h>
-
- #ifndef _EVENT_HPP
- #include "..\event\eventq.hpp"
- #endif
-
- const char charUndef = 0x00, charBkSpc = 0x08, charTab = 0x09,
- charEnter = 0x0D, charUp = 0x18, charDown = 0x19,
- charRight = 0x1A, charLeft = 0x1B;
-
- const byte scanESC = 0x01, scanF1 = 0x3B, scanF2 = 0x3C,
- scanF3 = 0x3D, scanF4 = 0x3E, scanF5 = 0x3F,
- scanF6 = 0x40, scanF7 = 0x41, scanF8 = 0x42,
- scanF9 = 0x43, scanF10 = 0x44, scanF11 = 0x57,
- scanF12 = 0x58, scanScrLk = 0x46, scanIns = 0x52,
- scanHome = 0x47, scanPgUp = 0x49, scanDel = 0x53,
- scanEnd = 0x4F, scanPgDn = 0x51, scanNum = 0x45,
- scanCaps = 0x3A, scanScrl = 0x46, scanCtrl = 0x1D,
- scanLCtrl = 0x1D, scanRCtrl = 0x10, scanLShft = 0x2A,
- scanRShft = 0x36, scanAlt = 0x38;
-
- const byte stateRShft = 0x01, stateLShft = 0x02,
- stateShift = 0x03, stateCtrl = 0x04,
- stateAlt = 0x08, stateScrl = 0x10,
- stateNum = 0x20, stateCaps = 0x40;
-
- const byte dataPort = 0x60;
-
- class Keyboard
- {
-
- protected:
-
- static bool installed, extended, keyDown;
-
- static bool inKeyCaps, inKeyScroll, inKeyNum;
-
- static Event curEvent;
-
- static void interrupt (*oldhandler)(...);
-
- static byte FAR* const pState; // pointer to BIOS key state
-
- static const char keyToChar[ 89 ][ 2 ];
-
- static void read( byte& );
-
- static void setState( byte, bool = true );
- static void resetState( byte b ) { setState( b, false ); }
-
- static bool testState( byte b ) { return bool( *pState & b ); }
-
- static void toggleState( const byte );
-
- static bool test( byte );
-
- public:
-
- static void install();
- static void remove();
-
- static bool isInstalled() { return installed; }
-
- static void interrupt handler(...);
-
- virtual ~Keyboard();
-
- };
-
- inline void Keyboard::setState( byte b, bool flag )
- {
- if ( flag )
- *pState |= b;
- else
- *pState &= ~b;
- }
-
- inline void Keyboard::toggleState( const byte b )
- {
- *pState ^= b;
- }
-
- inline void Keyboard::read( byte& b )
- {
- b = inport( dataPort );
- }
-
- #endif // _KEYBOARD_HPP
-