home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
13
/
COMMIO0B.ZIP
/
_INPUT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-05-14
|
3KB
|
85 lines
unit _input;
{
This unit is a companion to the COMMIO communications unit.
Written by Jason Morriss a.k.a. Lief O'Pardy
Copyright (C) 1995,1996 by Jason Morriss
This unit was actually written a long time ago for my own programs. But
it is needed by the SysKeys unit in order to be able to read the F11 & F12
keys, since the TP readkey does not reconize those keys. So i included
it JUST FOR YOOOOOOOOOOOOOOOOOOOOUUUUWWWwwwww! ;>
If you use the CRT unit along with this unit in your program, make sure
THIS unit comes AFTER the CRT unit in the main USES statement.
ie: uses crt,_INPUT,...;
Since the names of some of the routines in here have the same name as the
TP counterparts, this assures that these are used instead of the CRT ones.
if you (for some ungodly reason) want to use the CRT ones at some point
you can by doing: ch:=crt.readkey; ... got it? good.
NOTE: these are only LOCAL based IO (ofcourse).
}
Interface
Type
KeyToggles = (RShift,LShift,Ctrl,Alt,ScrollLock,NumLock,CapsLock,Ins);
Status = Set of KeyToggles;
Var
KeyStatus : Status Absolute $40:$17;
{ CheckBreak : Boolean;{}
(*
You can turn the 3 leds on the keyboard ON and OFF with the KeyStatus
Variable! It works like this:
exclude(KeyStatus,NumLock); {turn numlock off}
or KeyStatus:=Keystatus-Numlock;
include(KeyStatus,CapsLock); {turn CapsLock on}
or KeyStatus:=Keystatus+CapsLock;
As the online help in TP's IDE states: the Exclude & Include statements
produce more efficient code, then the other 2 methods.
*)
function KeyPressed : Boolean;
{^ For some reason I found that this function will not reconize <control>
characters. I will probably update this soon. }
function ReadKey : Char;
function AltDown : boolean;
function ShiftDown : boolean;
Implementation
(***************************************************************************)
Function KeyPressed : Boolean;
{ This function will also be TRUE for F11, F12, 5 (keypad w/ numlock off),
unlike TP's keypressed. }
Var
IsThere : Byte;
begin
Inline($B4/$0B/$CD/$21/$88/$86/>ISTHERE);
KeyPressed := (IsThere = $FF);
end;
(***************************************************************************)
Function ReadKey : Char;
{ This function also reconizes F11, F12, 5 (keypad w/ numlock off), unlike
TP's Readkey. }
Var
chrout : Char;
begin
Inline($B4/$07/$CD/$21/$88/$86/>CHROUT);
{ if CheckBreak and (chrout = #3) then Inline($CD/$23); { do ^C int }
ReadKey := chrout;
end;
(***************************************************************************)
function AltDown : boolean;
begin
altdown:=(Alt in keystatus);
end;
(***************************************************************************)
function ShiftDown : boolean;
begin
ShiftDown:=(LShift in KeyStatus) or (RShift in KeyStatus);
end;
(***************************************************************************)
end.