🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3499

Re: Help - Dedicating keys

#3499
From: Peter Moylan
Date: Thu, 18 Apr 1996 05:06
35 lines
2049 bytes
Richard A Creed (creed@bigsilver.win-uk.net) wrote:

>I would like to make one or more function keys availiable in a game
>program I have written, sort of:       F1 - Help (opens & a window)
>                                       F2 - Rules (opens a window)
>                                       F3 - Exit Programme
>(and perhaps make the esc key availiable to close the windows). 

One traditional solution is to put the KeuPressed() call in
your main loop, or somewhere where it's going to be executed
frequently while the program is doing its other things, and
then when a key is pressed you save the character value
somewhere, and take a look at the saved value at some
appropriate later place - probably at a place where you were
going to get some keyboard input anyway.

A superior solution is to write a separate thread for keyboard
input, so that you can deal with keypresses asynchronously
with other work.

The most flexible approach is to write your own keyboard
handler, including your own interrupt routine, but of course
it's a fair amount of work to get that right.

You can get some hints by looking at the PMOS source code,
available by following the links in my signature below.
Look particularly at modules Keyboard and MultiScreen.

--
Peter Moylan                           peter@ee.newcastle.edu.au
                  http://www.eng.newcastle.edu.au/ee/Moylan.html
OS/2 freeware list at 
      http://www.eng.newcastle.edu.au/ee/Moylan/os2/os2info.html
Modula-2 information at
      http://www.eng.newcastle.edu.au/ee/Moylan/m2/Modula2.html
Technical Details
Message-ID: <4l4ikl$6vj@seagoon.newcastle.edu.au>
Path: arc1-ca.pugleaf.net!fourier.newcastle.edu.au!peter
References: <273@bigsilver.win-uk.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fourier.newcastle.edu.au!peter
From: peter@fourier.newcastle.edu.au (Peter Moylan)
Newsgroups: comp.lang.modula2
Subject: Re: Help - Dedicating keys
Date: 18 Apr 1996 05:06:29 GMT
Organization: The University of Newcastle
Message-ID: <4l4ikl$6vj@seagoon.newcastle.edu.au>
References: <273@bigsilver.win-uk.net>
Reply-To: peter@tesla.newcastle.edu.au
NNTP-Posting-Host: fourier.newcastle.edu.au
X-Newsreader: TIN [version 1.2 PL2]