//chaoskey.h Copyright (C) 1989-92 I.Pedley (CTPP) Sun 03-May-1992 at 19:58:13

//new scan codes for CHAOS

#define     ESC         0x001b
#define     ENTER       0x000d
#define     TAB         0x0009
#define     SHIFTTAB    0x0109
#define     CTLTAB      0x0209
#define     ALTTAB      0x0409
#define     BACKSPACE   0x0008   //BACKSPACE

#define     ALTSPACEBAR     0x0420
#define     ALTCTLSPACEBAR  0x0620

#define     SHIFTESC  0x011b
#define     CTLESC    0x021b
#define     ALTESC    0x041b
#define     F1        0x000f
#define     F2        0x0010
#define     F3        0x0011
#define     F4        0x0012
#define     F5        0x0013
#define     F6        0x0014
#define     F7        0x0015
#define     F8        0x0016
#define     F9        0x0017
#define     F10       0x0018
#define     F11       0x0019
#define     F12       0x001a

//odd-balls
#define     ALTSYSREQ 0x041c    //1c scan code generated only when ALT is down
#define     CTLBREAK  0x0291    //91 scan code generated only when CTRL is down

//Keyboard codes for CURSOR keys proper
#define     NHOME       0x0084
#define     NUCUR       0x0086
#define     NPGUP       0x0088
#define     NLCUR       0x0083
#define     NRCUR       0x008a
#define     NEND        0x0085
#define     NDCUR       0x0087
#define     NPGDN       0x0089
#define     NINS        0x0080
#define     NDEL        0x0082


#define     NUMENTER    0x0081
#define     NUMDIVIDE   0x008b
#define     NLWIN95     0x008c
#define     NRWIN95     0x008d
#define     NMENU       0x008e
#define     NSYSREQ     0x008f      //Print screen key, except when ALT is down
#define     NPAUSE      0x0090      //Pause key, except when CTRL is down
#define     NBREAK      0x0091

//CTPP specials
#define     LCTRLKEY    0x02c0      //CTPP shift keys generate these keypress
#define     LALTKEY     0x04c1      //codes when a shift key is pressed and
#define     LSHIFTKEY   0x01c2      //released


//keyboard state flags built by translatekbd()
#define CAPSLOCK    0x00000004      //keyboard locks corresponding
#define NUMLOCK     0x00000002      //to control bits for keyboard LED
#define SCROLLLOCK  0x00000001      //set/reset indicators command

#define LCTRL       0x08000000      //bit meanings in kbdstate for exact shift
#define RCTRL       0x04000000      //keys down at present
#define LALT        0x02000000
#define RALT        0x01000000
#define LSHIFT      0x00800000
#define RSHIFT      0x00400000
#define INSERT      0x80000000
#define NUMKEYPAD   0x40000000      //reserved for keyboard interrupt internals


//there is no need in ChaOS for heaps of defines for combinations
//as the bottom 16 bits of the keystroke contain the key Or'ed with
//the three major shift states, SHIFT, ALT and CTRL

//so to catch say a CTL+a, do
//  UL key=getkey();       //upper 16 bits of key contain extended shift state
//                         //i.e. LSHIFT,RSHIFT etc,usually you won't need these
//  switch(key&0xffff)     //so mask them out, lower 8 bits contain key code
//      {                  //next 3 bits contain SHIFT and/or CTRL and/or ALT
//       case (CTRL|KEY_a):
//          //got it
//      }

//if you need the exact shift state, say to differentiate between LEFT CTL+a
//and RIGHT CTL+a, use the full 32 bits returned by getkey(), e.g.:
//  switch(getkey())
//      {
//       case (LCTRL|CTRL|KEY_a):
//          //do one thing
//          break;
//       case (RCTRL|CTRL|KEY_a):
//          //do another
//          break;
//      }

//keystroke flags added by addkeystroke
#define SHIFT       0x00000100
#define CTRL        0x00000200
#define ALT         0x00000400


EX  UL  kbdstate;

SL  getkey   (VD);
SL  kbhit    (VD);
SL  optionkey(VD);
SL  dgetkey  (VD);

VD  kpostoff(VD);           //clear msgflags&msgKEY