Mail Archives: djgpp/1998/01/09/09:22:30
(0) I found just now that why I wasn't getting any djgpp messages was that I
subscribed "subscribe <username> djgpp" and that isn't accepted any more, I
must put "subscribe djgpp" now. Sorry. I have now resubscribed correctly.
(1)
/* If this assembler subroutine was put in DJGPP\SRC\LIBC\GO32\EXCEPTN.S and
called from the start of any interrupt 9 hook routines (___djgpp_kbd_hdlr and
___djgpp_kbd_hdlr_pc98, etc) called automatically by djgpp C/C++ programs, it
should save the raw keyboard events in a circular buffer which the user could
read without having to re-hook interrupt 9 himself. This should help djgpp
users with laptops, since I find that re-hooking interrupt 9 in a djgpp C/C++
prrogram on a laptop causes various system malfunctions after the program has
exited, perhaps from something clashing with the laptop's extra keyboard
software that translates `Fn' key combinations into imitations of presses and
releases of desktop keys which are missing on laptops. */
.global _keyeventbuf
.global _keyeventbufip
.global _keyeventbufop
// Circular buffer. Buffer pointers are byte vars, so wraparound is automatic.
_keyeventbuf: .space 256 // unsigned char keyeventbuf[256];
_keyeventbufip: .byte 0 // unsigned char keyeventbufip=0;
_keyeventbufop: .byte 0 // unsigned char keyeventbufop=0;
.align 4
_keyboardeventsaver: // void keyboardeventsaver() {
pushl %eax // register unsigned char E;
pushl %ebx // register unsigned char P;
inb $0x60,%al // E = the keyboard event;
movb _keyeventbufip,%bl // P = keyeventbufip;
movzbl %bl,%ebx
movb %al,_keyeventbuf(%ebx) // keyeventbuf[P] = E;
incb _keyeventbufip // keyeventbufip++;
incb %al // P++;
cmpb %bl,_keyeventbufop // if(P == keyeventbufop)
jne NOTFULL // {
decb _keyeventbufip // keyeventbufip--;
decb %bl // P--;
decb %bl // P--;
// movzbl %bl,%ebx //// not needed,
// as the high 24 bits of EBX will still be all zero after the previous movzbl
movb $255,_keyeventbuf(%ebx) // keyeventbuf[P]=255;
NOTFULL: // }
popl %ebx //// 255 in the buffer == "here the buffer got full"
popl %eax
ret // }
/* This line should be put in some suitable #include file:-
extern unsigned char keyeventbuf[256],keyeventbufip,keyeventbufop;
//----- Get a raw keyboard event code. Returns 0 if the buffer was empty.
unsigned char get_keyevent(){ /* does not treat 0xe0 specially */
return if(keyeventbufip==keyeventbufop) ?0: keyeventbuf[++keyeventbufop];}
//----- Empty the keyboard event buffer
inline void emptykeyboardbuf(){keyeventbufip=keyeventbufop=0;}
//----- Put an event in the keyboard event buffer yourself:-
int injectkeyboardevent(unsigned char E){
keyboardbuf[keyboardbufip++]=E;
if(keyboardbufip!=keyboardbufop) return 1;
keyboardbuf[(--keyboardbufip)-1]=0xff; return 0;}
*/
- Raw text -