1 /* Thanks to Alex Russell for example code */
2 /* Thanks to Gary Neal for example code */
\r
3 #include "src\lib\dos_comm.h"
\r
7 byte keer[128]; /* key pressed */
8 byte keep[128]; /* key released */
10 #ifdef __cplusplus /* Functions must be declared C style */
\r
13 extern void interrupt (far *oldkb)(void) = NULL; /* BIOS keyboard handler */
17 /*****************NEW KEYBOARD 09h ISR***********************/
\r
18 void interrupt newkb(void){
\r
21 kee = inp(0x60); /* Read the keyboard scan code */
23 /* Clear keyboard controller on XT machines */
\r
30 /* Interpret the scan code and set our flags */
\r
32 keep[kee & 0x7F] = 0;
\r
34 keep[kee] = keer[kee] = 1;
39 /* ---------------------- init_keyboard() ---------------- April 17,1993 */
\r
40 /* restore the bios keyboard handler */
\r
41 /* ---------------------- deinit_keyboard() -------------- April 17,1993 */
\r
43 if(!vq){ // deinitiation
44 /* Abort if our function pointer has no valid address */
\r
45 if(oldkb == NULL) return;
46 /* Set address in our function pointer in interrupt vector table */
47 _dos_setvect(9, oldkb);
48 /* Reset our function pointer to contain no valid address */
\r
50 }else if(vq == 1){ // initiation
51 int i; /* Index variable */
54 /* Abort if our function pointer has a valid address. */
\r
55 if(oldkb != NULL) return;
\r
57 /* Clear the keyboard buttons state arrays */
\r
58 for(i = 0; i < 128; i++)
\r
59 keep[i] = keer[i] = 0;
61 /* save old BIOS key board handler */
\r
62 oldkb = _dos_getvect(9);
\r
64 // turn off num-lock via BIOS
\r
65 lock_key = MK_FP(0x040, 0x017); //wtf is going on here?
\r
66 *lock_key&=(~(16 | 32 | 64)); // toggle off the lock keys
\r
67 oldkb(); // call BIOS keyhandler to change keyboard lights
\r
69 /* setup our own handler */
\r
70 _dos_setvect(9, newkb);
\r
74 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
\r
77 * Returns the status of the key requested. *
\r
78 * The status is 1 if the key is pressed or has been pressed since the *
\r
79 * last call to this function for that particular key. *
\r
80 \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
\r
82 register char retVal;
\r
84 /* Key value in range of keyboard keys available */
\r
87 /* Get the status of the key requested */
\r
88 retVal = keep[c] | keer[c];
\r
90 /* Reset the was pressed status for the requested key */
\r
93 /* Return the requested key's state */
\r
99 //if(keyp(kee)) printf("%c %03d %03x\n", kee, kee, kee);
\r