summaryrefslogtreecommitdiff
path: root/rtl/os2/tests/testkbd.pas
blob: 095ab8dce1fddebe83aa7388e3b361391feccf7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
program TestKBD;
{$X+}

{$IFNDEF OS2}
 Sorry, this code is for OS/2 only...
{$ENDIF}

uses
{$IFDEF FPC}
 KbdCalls;
{$ELSE}
 {$IFDEF VIRTUALPASCAL}
 Os2Base;
 {$ELSE}
  {$IFDEF SPEED}
 BseSub;
  {$ELSE}
 Os2Subs;
  {$ENDIF}
 {$ENDIF}
{$ENDIF}

function ExtKeyPressed: boolean;       (* 'key' is here as well e.g. a shift *)
var
{$IFNDEF VER70} (* patched Borland Pascal *)
 KI: KbdKeyInfo;
 K: KbdInfo;
{$ELSE}
 KI: TKbdKeyInfo;
 K: TKbdInfo;
{$ENDIF}
 B: boolean;
begin
 B := false;
 K.cb := SizeOf (K);
 KbdGetStatus (K, 0);
 KbdPeek (KI, 0);
 if (KI.fbStatus and $FE <> 0) or (K.fsState and $FF0F <> 0) then
 begin
  ExtKeyPressed := true;
  if KI.fbStatus and $FE <> 0 then KbdCharIn (KI, IO_NOWAIT, 0);
 end else ExtKeyPressed := false;
end;

begin
 repeat until not (ExtKeyPressed);
 WriteLn (#13#10'Press _any_ key to continue (including shifts etc.) ...');
 repeat until ExtKeyPressed;
end.