[comp.os.msdos.programmer] "wanted -- c-code fragment to source keys into DOS key buffer"

sondeen@isi.edu (Jeff Sondeen) (09/18/90)

Having succeeded in getting a popup routine to grab some text off the
screen, I'm having trouble sourcing it into DOS's key buffer: I think
I need to replace the interrupt 16 (keyboard services) routine until
all the grabbed chars have been read (stuffing each of them one at a
time into the DOS key buffer), but my attempt locks up my machine
frequently.  Could someone supply an int16 fragment in c, or give me
pointers to books that would explain this?  Thanks, /jeff

Here's my code fragment, using Zortech popup, mouse, interrupt packages:

...

#define MAXBUFFER 80
char chars[MAXBUFFER+1];
char scans[MAXBUFFER+1];
int maxkey, numkey;

volatile int far* kbhead = (int far *) 0x41a;
volatile int far* kbtail = (int far *) 0x41c;
volatile char far* kbbuf = (char far *) 0x400;

...

/* intercept int16, while there are chars and scancodes, putting each
	into the DOS keyboard buffer one at a time */

int cdecl do_keyboard(struct INT_DATA *pd) {

	if (numkey < maxkey) {
		kbbuf[*kbtail] = chars[numkey++];
		kbbuf[*kbtail+1] = scans[numkey];
		*kbtail = *kbtail+2;
		if (*kbtail > 0x3c) *kbtail = 0x1e;
	} else int_restore(0x16);

	return(0);
}

void popmain(popmain)
{
	...

	if (maxkey > 0) int_intercept(0x16, do_keyboard, 512);
		/* if there are keys, intercept int16 */
}
-- 
/jeff	sondeen@isi.edu			"happiness is a non-negative cash flow"