1: #include <X/mit-copyright.h>
   2: 
   3: /* Copyright    Massachusetts Institute of Technology    1985	*/
   4: 
   5: /* This file is device dependent, but is common to several devices */
   6: 
   7: #ifndef lint
   8: static char *rcsid_lk201_c = "$Header: lk201.c,v 10.6 86/02/01 15:16:27 tony Rel $";
   9: #endif
  10: 
  11: #include <sys/types.h>
  12: #include "vsinput.h"
  13: 
  14: #define KEYDOWN_ERROR   0x3d
  15: #define POWERUP_ERROR   0x3e
  16: #define BASEKEY     0x41
  17: #define MINSPECIAL  0xb3
  18: #define ALLUPS      0xb3
  19: #define METRONOME   0xb4
  20: #define OUTPUT_ERROR    0xb5
  21: #define INPUT_ERROR     0xb6
  22: #define MAXSPECIAL  0xba
  23: 
  24: static u_char lastkey;
  25: 
  26: #define NUMDIVS 14
  27: static u_char divbeg[NUMDIVS] = {0xbf, 0x91, 0xbc, 0xbd, 0xb0, 0xad, 0xa6,
  28:                  0xa9, 0x88, 0x56, 0x63, 0x6f, 0x7b, 0x7e};
  29: static u_char divend[NUMDIVS] = {0xff, 0xa5, 0xbc, 0xbe, 0xb2, 0xaf, 0xa8,
  30:                  0xac, 0x90, 0x62, 0x6e, 0x7a, 0x7d, 0x87};
  31: /* initially set for keyboard defaults */
  32: static int keymodes[8] = {0, 0, 0, 0, 0, 0x0000c000, 0, 0}; /* down/up keys */
  33: static int keys[8]; /* down/up keys that are currently down */
  34: 
  35: /* Handle keyboard/button input from LK201/mouse */
  36: 
  37: ProcessInput (ev)
  38:     register vsEvent *ev;
  39: {
  40:     register int idx, key, bits;
  41: 
  42:     if (ev->vse_direction != VSE_KBTRAW) {
  43:         Deal_with_input (ev);
  44:         return;
  45:     }
  46:     key = ev->vse_key;
  47:     if (key > MAXSPECIAL || (key >= BASEKEY && key < MINSPECIAL)) {
  48:         lastkey = key;
  49:         idx = key >> 5;
  50:         key &= 0x1f;
  51:         key = 1 << key;
  52:         if (!(keymodes[idx] & key) || ((keys[idx] ^= key) & key))
  53:         ev->vse_direction = VSE_KBTDOWN;
  54:         else
  55:         ev->vse_direction = VSE_KBTUP;
  56:         Deal_with_input (ev);
  57:     } else {
  58:         switch (key) {
  59:         case METRONOME:
  60:             ev->vse_direction = VSE_KBTDOWN;
  61:             ev->vse_key = lastkey;
  62:             Deal_with_input (ev);
  63:             break;
  64:         case ALLUPS:
  65:             idx = 7;
  66:             ev->vse_direction = VSE_KBTUP;
  67:             do {
  68:             if (bits = keys[idx]) {
  69:                 keys[idx] = 0;
  70:                 key = 0;
  71:                 do {
  72:                 if (bits & 1) {
  73:                     ev->vse_key = (idx << 5) | key;
  74:                     Deal_with_input (ev);
  75:                 }
  76:                 key++;
  77:                 } while (bits >>= 1);
  78:             }
  79:             } while (--idx >= 0);
  80:             break;
  81:         case POWERUP_ERROR:
  82:         case KEYDOWN_ERROR:
  83:         case OUTPUT_ERROR:
  84:         case INPUT_ERROR:
  85:             DeviceError ("keyboard error");
  86:             break;
  87:         }
  88:     }
  89: }
  90: 
  91: /* Put keyboard in autorepeat mode and return control command string.
  92:  * autorepeat/down: main keyboard, numeric keypad, delete, cursors
  93:  * up/down: all others
  94:  */
  95: 
  96: char *AutoRepeatLKMode ()
  97: {
  98:     ResetLKModes (0x3f38);
  99:     return ("\212\222\232\246\256\266\272\302\316\326\336\346\356\366");
 100: }
 101: 
 102: /* Put all of keyboard in down/up mode and return control command string */
 103: 
 104: char *UpDownLKMode ()
 105: {
 106:     ResetLKModes (0x3fff);
 107:     return ("\216\226\236\246\256\266\276\306\316\326\336\346\356\366");
 108: }
 109: 
 110: ResetLKModes (modes)
 111:     register int modes;
 112: {
 113:     register int i = 0;
 114:     register int key, last;
 115: 
 116:     bzero ((caddr_t) keymodes, sizeof (keymodes));
 117:     do {
 118:         if (modes & 1) {
 119:         for (key = divbeg[i], last = divend[i]; key <= last; key++)
 120:             keymodes[key >> 5] |= 1 << (key & 0x1f);
 121:         }
 122:         modes >>= 1;
 123:     } while (++i < NUMDIVS);
 124: }

Defined functions

AutoRepeatLKMode defined in line 96; never used
ProcessInput defined in line 37; used 1 times
ResetLKModes defined in line 110; used 2 times
UpDownLKMode defined in line 104; never used

Defined variables

keymodes defined in line 32; used 4 times
keys defined in line 33; used 3 times
rcsid_lk201_c defined in line 8; never used

Defined macros

ALLUPS defined in line 18; never used
BASEKEY defined in line 16; used 1 times
  • in line 47
INPUT_ERROR defined in line 21; never used
KEYDOWN_ERROR defined in line 14; never used
MAXSPECIAL defined in line 22; used 1 times
  • in line 47
METRONOME defined in line 19; never used
MINSPECIAL defined in line 17; used 1 times
  • in line 47
NUMDIVS defined in line 26; used 3 times
OUTPUT_ERROR defined in line 20; never used
POWERUP_ERROR defined in line 15; never used
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1149
Valid CSS Valid XHTML 1.0 Strict