www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/17/08:30:53

From: George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Keyboard
Date: 17 Jun 1998 08:51:10 GMT
Organization: Oxford University, England
Lines: 41
Message-ID: <6m801u$m1k$1@news.ox.ac.uk>
References: <009901bd995b$035026a0$0a4e08c3 AT arthur>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Tue, 16 Jun 1998 19:55:44 +0100 in comp.os.msdos.djgpp Arthur
<arfa AT clara DOT net> wrote:

: Can anyone tell me how to patch the keyboard a la Allegro? I would like an
: array or bitfield of, say, 128 elements which would show which keys were
: pressed at which time.

"at which time" or "at the time you test them"?  The latter is
simpler.

At the basic level, you need to hook the keyboard interrupt and do
something sensible.  "Something sensible" generally involves reading a
byte from I/O port 0x60 and then setting or unsetting the flag for the
corresponding key.  Most keys have almost unique scancodes in the
range from 1 to about 88.  The value you read is generally the
scancode of the key, in the bottom 7 bits, and a press/release flag in
the top bit.  The flag is set if this is a key-release event, unset if
the key is being pressed.  So all you need to do is set or unset your
array element corresponding to the scancode in the bottom 7 bits.
Finally you send 0x20 to port 0x20 to clear the interrupt.

That's a simplistic view; some keys on the keyboard are special, and
these are communicated to you in different ways.  If you want to know
in more detail what to do, you should either refer to some
documentation or to some existing source code.  There are several in
the v2tk directory of the djgpp distribution -- see readme.1st for
details. 

: Why can't I just use Allegro? 'Cos I don't like using librarys (see my other
: posting Re: C vs C++).

I don't fully understand your feelings here so perhaps you don't want
to do this, but you might consider looking at its keyboard handler
anyway.  It's in the file allegro/src/djgpp/keyboard.c.  You shouldn't
feel ashamed to use or study other people's code; Allegro's handler
will probably tell you much more than I did above.

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

xu do tavla fo la lojban  --  http://xiron.pc.helsinki.fi/lojban/lojban.html

- Raw text -


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