Article View: comp.lang.pascal.borland
Article #457Re: ASCII Codes...
From: Pedt Scragg
Date: Thu, 17 Sep 1998 00:00
Date: Thu, 17 Sep 1998 00:00
90 lines
3251 bytes
3251 bytes
In article <3600FFBD.518F@GECM.COM>, Ian W.Derrick
<Ian.Derrick@GECM.COM> writes
>As a follow on ..... (perhaps not related)
>
>A while ago I was trying something along these lines but I could not
>detect F11 and F12 from my keyboard F1 through F10 were OK. Is there
>something different about these two keys,
The F11 and F12 keys were not provided in the original keyboard and thus
not in the original BIOS using Int $16 function $00 to read the keyboard
which ReadKey uses.
There are other keyboard combinations that are also not detectable by
this interrupt.
AT (286 machines) and above usually have enhanced BIOS which, with the
new sub-function $10, can detect these enhanced keycodes.
Although there are *probably* very few pre-AT machines and BIOS's around
nowadays, I use the unit code following (rather snipped) to auto-detect
and provide extended support.
Note that some of the codes use $E0 (dec. 224) to indicate some of the
extended codes.
I've rewritten this using Intr calls for those with earlier than TP6
versions that no not accept inline assembler.
Keycode returns both codes at once (unlike readkey that needs two reads
for extended keystrokes).
unit pkey;
Interface
uses DOS;
procedure KeyCode(var firstcode,extendedcode : char);
Function IsEnhanced : Boolean;
Implementation
var
KeyStatusBits : byte absolute $0040:$0017;
EnhancedKeyboard : boolean;
FUNCTION IsEnhanced : Boolean;
VAR StateFrom16 : Byte;
var regs : registers;
BEGIN
IsEnhanced := FALSE;
regs.ah := $12;
intr($16,regs);
statefrom16 := regs.al;
IF StateFrom16 <> ShiftState THEN Exit;
ShiftState := ShiftState XOR $20;
regs.ah := $12;
intr($16,regs);
statefrom16 := regs.al;
IsEnhanced := StateFrom16 = ShiftState;
ShiftState := ShiftState XOR $20;
END;
procedure keycode(var firstcode,extendedcode : char);
var regs:registers;
begin
if enhancedkeyboard then regs.ah := $10 else regs.ah := $00;
Intr($16,regs);
if regs.al = 224 then regs.al := $00;
if regs.al > $00 then regs.ah := $00;
if regs.ax = 0 then regs.al := 224;
firstcode := chr(regs.al);
extendedcode := chr(regs.ah);
end;
begin
EnhancedKeyboard := IsEnhanced;
end.
Incidentally, comp.lang.pascal is now defunct so removed from the
newsgroups line.
--
Pedt Scragg
No-one is completely useless, they can always be a bad example.
Technical Details
Message-ID:
<Y36aWFAoLVA2Ywpv@pedt.demon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<6ton52$ip0$1@news3.cableinet.co.uk> <yT_L1.1904$VW6.13569796@news.magma.ca> <3600FFBD.518F@GECM.COM>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 108ebd,6641efc813030989 X-Google-Attributes: gid108ebd,public X-Google-Thread: 111659,6641efc813030989 X-Google-Attributes: gid111659,public From: Pedt Scragg <newsmaster@pedt.demon.co.uk> Subject: Re: ASCII Codes... Date: 1998/09/17 Message-ID: <Y36aWFAoLVA2Ywpv@pedt.demon.co.uk> X-Deja-AN: 392184689 X-NNTP-Posting-Host: pedt.demon.co.uk:194.222.191.220 References: <6ton52$ip0$1@news3.cableinet.co.uk> <yT_L1.1904$VW6.13569796@news.magma.ca> <3600FFBD.518F@GECM.COM> X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 906066840 nnrp-04:1374 NO-IDENT pedt.demon.co.uk:194.222.191.220 Organization: Ty Llyffant Web MIME-Version: 1.0 Newsgroups: comp.lang.pascal.borland,borland.public.turbopascal