home *** CD-ROM | disk | FTP | other *** search
- unit STI_KEYS; { unit to provide access to all}
- { the special keys }
- interface
-
- uses Dos;
-
- type
- KeyRec = string[3]; { KeyRec[1] = ascii code }
- { KeyRec[2] = F1 etc }
- { KeyRec[3] = GRPH etc }
-
-
-
- function STI_StopPressed : boolean; { check for stop key }
- function STI_CopyPressed : boolean; { check for copy key }
- function STI_EscapePressed : boolean; { check for escape }
- function STI_ControlPressed : boolean; { check for control key }
- function STI_CapsPressed : boolean; { check for caps key }
- function STI_ShiftPressed : boolean; { check for shift key }
- function STI_KanaPressed : boolean; { check for kana key }
- function STI_GrphPressed : boolean; { check for graph key }
- function STI_NferPressed : boolean; { check for nfer key }
- function STI_XferPressed : boolean; { check for xfer key }
- function STI_InKey : char; { return a single key stroke }
- function STI_InKey2 : KeyRec; { return GRPH,CTRL,SHIFT combos }
- function STI_InKey3 : KeyRec; { return any combination }
-
- implementation
-
- {---------------------------------------------------------------------------}
-
- type
- key_type = (STOP_Key,COPY_Key,ESC_Key,CTRL_Key,CAPS_Key,
- SHIFT_Key,KANA_Key,GRPH_Key,NFER_Key,XFER_Key);
- key_table = record
- n : key_type;
- g : byte;
- b : byte;
- end;
-
- const
- KT : array[0..9] of key_table = (
- (n:STOP_Key; g:12; b:1),
- (n:COPY_Key; g:12; b:2),
- (n:ESC_Key; g:0; b:1),
- (n:CTRL_Key; g:14; b:16),
- (n:CAPS_Key; g:14; b:2),
- (n:SHIFT_Key; g:14; b:1),
- (n:KANA_Key; g:14; b:4),
- (n:GRPH_Key; g:14; b:8),
- (n:NFER_Key; g:10; b:2),
- (n:XFER_Key; g:6; b:32)
- );
-
- {---------------------------------------------------------------------------}
-
- function Scan_KeyCode(group : byte) : byte; { check for a keycode }
-
- Var
- r : registers;
-
- begin
- r.ah := 4; { check the key funtion }
- r.al := group;
- intr(24,r); {18h} { BIOS call }
- Scan_KeyCode := r.ah;
- end;
-
- {---------------------------------------------------------------------------}
-
- function SpecialKeyPressed(K : key_type) : boolean;
-
- begin
- if Scan_KeyCode(KT[ord(k)].g) and KT[ord(k)].b <> 0 then
- SpecialKeyPressed := TRUE
- else
- SpecialKeyPressed := FALSE;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_StopPressed : boolean;
-
- begin
- STI_StopPressed := SpecialKeyPressed(STOP_Key);
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_CopyPressed : boolean;
-
- begin
- STI_CopyPressed := SpecialKeyPressed(COPY_Key);
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_EscapePressed : boolean;
-
- begin
- STI_EscapePressed := SpecialKeyPressed(ESC_Key);
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_ControlPressed : boolean;
-
- begin
- STI_ControlPressed := SpecialKeyPressed(CTRL_Key);
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_CapsPressed : boolean;
-
- begin
- STI_CapsPressed := SpecialKeyPressed(CAPS_Key);
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_ShiftPressed : boolean;
-
- begin
- STI_ShiftPressed := SpecialKeyPressed(SHIFT_Key);
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_KanaPressed : boolean;
-
- begin
- STI_KanaPressed := SpecialKeyPressed(KANA_Key);
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_GrphPressed : boolean;
-
- begin
- STI_GrphPressed := SpecialKeyPressed(GRPH_Key);
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_NferPressed : boolean;
-
- begin
- STI_NferPressed := SpecialKeyPressed(NFER_Key);
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_XferPressed : boolean;
-
- begin
- STI_XferPressed := SpecialKeyPressed(XFER_Key);
- end;
-
- {--------- Read a character from the Keyboard (No Display) -----------------}
-
- Function STI_InKey : Char;
-
- var
- regs : registers;
-
- begin
- regs.ah := $03;
- intr($18,regs);
- { regs.ah := $41; } { this causes problems with the }
- { intr($18,regs); } { TP graphics unit }
- regs.ah := 00;
- intr($18,regs);
- STI_InKey := char(regs.al);
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_InKey2 : KeyRec; { this only checks for CAPS,GRPH }
- { and CTRL }
- var
- DumB : byte;
- Dummy : KeyRec;
- regs : registers;
-
- begin
- Dummy := #0#0#0;
- regs.ah := $03;
- intr($18,regs);
- { regs.ah := $41;} { causes problems with the }
- { intr($18,regs); } { graphics unit in TP }
- regs.ah := 00;
- intr($18,regs);
- Dummy[1] := char(regs.al); { assign lo byte to Dummy[1] }
- if Dummy[1] = #0 then
- Dummy[2] := char(regs.ah); { this is the extended code }
- DumB := 0;
- if STI_ControlPressed then inc(DumB,1);
- if STI_ShiftPressed then inc(DumB,10);
- if STI_GrphPressed then inc(DumB,100);
- Dummy[3] := char(DumB);
- STI_InKey2 := Dummy;
- end;
-
- {---------------------------------------------------------------------------}
-
- function STI_InKey3 : KeyRec; { this checks for everything }
-
- var
- DumB : byte;
- Dummy : KeyRec;
- regs : registers;
-
- begin
- Dummy := #0#0#0;
- regs.ah := $03;
- intr($18,regs);
- { regs.ah := $41;} { causes problems with the }
- { intr($18,regs); } { graphics unit in TP }
- regs.ah := 00;
- intr($18,regs);
- Dummy[1] := char(regs.al); { assign lo byte to Dummy[1] }
- if Dummy[1] = #0 then
- Dummy[2] := char(regs.ah); { this is the extended code }
- DumB := 0;
- if STI_ControlPressed then inc(DumB,1);
- if STI_StopPressed then inc(DumB,2);
- if STI_CopyPressed then inc(DumB,3);
- if STI_EscapePressed then inc(DumB,4);
- if STI_CapsPressed then inc(DumB,5);
- if STI_KanaPressed then inc(DumB,6);
- if STI_NferPressed then inc(DumB,7);
- if STI_XferPressed then inc(DumB,8);
- if STI_ShiftPressed then inc(DumB,10);
- if STI_GrphPressed then inc(DumB,100);
- Dummy[3] := char(DumB);
- STI_InKey3 := Dummy;
- end;
-
- {---------------------------------------------------------------------------}
-
- begin
- end.
-
-