Article View: comp.lang.modula2
Article #3510Re: Help - Dedicating keys
From: Ted K. Warring
Date: Sun, 21 Apr 1996 17:25
Date: Sun, 21 Apr 1996 17:25
80 lines
3531 bytes
3531 bytes
Richard A Creed wrote: > > > In article <4l4ikl$6vj@seagoon.newcastle.edu.au>, Peter Moylan (peter@fourier.newcastle.edu.au) writes: > >Richard A Creed (creed@bigsilver.win-uk.net) wrote: > > > > Using FST 3.5, on a PC running DOS 6.22.... > > >>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). > > I should have said so that they would, in effect, be hotkeys. > > > > >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. > > This is not possible because the program demands user input > continuously, and demands by turns a CARDINAL or a CHAR with a > return key, because the keyed input must be editable. > Checking the input & then storing it in a buffer which emulates > keyboard input won't do the job, becuase the Function key reaction > must be instantaneous, whilst any other user input must be editable > and followed by the return. I would require something similar to > Peter's HotKeys but I am simply not experienced enough to port the > appropriate PMOS modules or bits of them. <-------BIG SNIP---------> Hi Richard! I bet you are feeling a bit overwhelmed looking at semaphores, threads, and interrupt handlers. I think perhaps you don't fully understand the simplicity of Peter's suggestion (or a minor variation thereof). By your response, I am guessing that you are using FST library routines to read from the keyboard? Does FST come with source for those? I would bet you that all the read type procedures use ONE procedure at the core to get a keystroke at a time. Based on PC firmware this is highly probable. There are a couple of ways to approach this: 1. Modify your existing library module or 2. Make a copy of it and rename, then change your programs to use the new on (recommended) OK, now presuming you have chosen one of the above: Make an alteration in the procedure that gets one key at a time from the keyboard, inserting a filter process that calls a procedure you define for your "hot" operation. Thats all it would take, no alteration of your application codes main logic. I hope this was helpful. I don't have FST, or I would give you real code examples. If you need more help, post a reply to me and include your "cardinal and string input" procedures source. Good luck! Ted K. Warring
Technical Details
Message-ID:
<317A6F8C.7028@tribeca.ios.com>Path:
arc1-ca.pugleaf.net!news.ios.com!usenetReferences:
<273@bigsilver.win-uk.net><4l4ikl$6vj@seagoon.newcastle.edu.au> <278@bigsilver.win-uk.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.ios.com!usenet From: "Ted K. Warring" <tkwarr@tribeca.ios.com> Newsgroups: comp.lang.modula2 Subject: Re: Help - Dedicating keys Date: Sun, 21 Apr 1996 10:25:32 -0700 Organization: Internet Online Services Message-ID: <317A6F8C.7028@tribeca.ios.com> References: <273@bigsilver.win-uk.net><4l4ikl$6vj@seagoon.newcastle.edu.au> <278@bigsilver.win-uk.net> NNTP-Posting-Host: ppp-11.ts-1.phx.idt.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.01 (Win16; I)