delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/23/04:56:45

From: pfister_ AT hotmail DOT com (jim crawford)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: keyboard handler
Date: Sun, 22 Nov 1998 00:08:23 GMT
Organization: CTS Network Services
Lines: 54
Message-ID: <36575282.6814796@news2.cts.com>
References: <734mek$ana$1 AT nnrp1 DOT dejanews DOT com>
NNTP-Posting-Host: wagasa.cts.com
X-Newsreader: Forte Free Agent 1.11/32.235
Cache-Post-Path: wagasa.cts.com!unknown AT putc3156200 DOT cts DOT com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019