Mail Archives: djgpp/1998/11/23/04:56:45
On Fri, 20 Nov 1998 21:20:37 GMT, deus AT mpsi DOT net wrote:
>I'm trying to port some of my code from Watcom C/C++ to DJGPP.
>I seem to be stuck on how to convert my keyboard handler.
i did the same not so long ago. here's what i eventually came up
with:
#include <dpmi.h>
#include <go32.h>
volatile keyboard[128];
static _go32_dpmi_seginfo oldkbhandler;
static void kbhandler()
{
unsigned char in;
in=inportb(0x60);
if(in>128) keyboard[in-128]=0;
else keyboard[in]=1;
outportb(0x20,0x20);
return;
}
void installkbhandler()
{
static _go32_dpmi_seginfo kb;
kb.pm_selector = _my_cs();
kb.pm_offset = (unsigned long)(&kbhandler);
_go32_dpmi_allocate_iret_wrapper(&kb);
_go32_dpmi_get_real_mode_interrupt_vector(0x09, &oldkbhandler);
_go32_dpmi_set_protected_mode_interrupt_vector(0x09, &kb);
}
void deinstallkbhandler()
{
_go32_dpmi_set_real_mode_interrupt_vector(0x09, &oldkbhandler);
}
as you can see, the process is a bit more involved, but once you have
a setvect wrapper done, it's much the same.
(i wonder why this sort of low-level keyboard support wasn't coded
into the bios or operating system. it would've taken maybe 20 bytes
of code and 16 bytes of ram to do it)
--
pf / lightspeed / green grapes
i use hotmail. don't hate me!
- Raw text -