2
This file is part of the Free Pascal run time library.
3
Copyright (c) 1999-2000 by Florian Klaempfl
4
member of the Free Pascal development team
6
This is unit implements some of the crt functionality
7
for the gui win32 graph unit implementation
9
See the file COPYING.FPC, included in this distribution,
10
for details about the copyright.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
**********************************************************************}
21
function readkey : char;
22
function keypressed : boolean;
23
procedure delay(ms : word);
26
procedure textmode(mode : integer);
28
{ plays the windows standard sound }
29
{ hz is ignored (at least on win95 }
30
procedure sound(hz : word);
37
directvideo : boolean;
51
keyboardhandling : TCriticalSection;
52
keybuffer : array[1..keybuffersize] of char;
53
nextfree,nexttoread : longint;
55
procedure inccyclic(var i : longint);
59
if i>keybuffersize then
63
procedure addchar(c : char);
66
EnterCriticalSection(keyboardhandling);
67
keybuffer[nextfree]:=c;
70
if nexttoread=nextfree then
72
// special keys are started by #0
73
// so we've to remove two chars
74
if keybuffer[nexttoread]=#0 then
75
inccyclic(nexttoread);
76
inccyclic(nexttoread);
78
LeaveCriticalSection(keyboardhandling);
81
function readkey : char;
86
EnterCriticalSection(keyboardhandling);
87
if nexttoread<>nextfree then
89
readkey:=keybuffer[nexttoread];
90
inccyclic(nexttoread);
91
LeaveCriticalSection(keyboardhandling);
94
LeaveCriticalSection(keyboardhandling);
95
{ give other threads a chance }
100
function keypressed : boolean;
103
EnterCriticalSection(keyboardhandling);
104
keypressed:=nexttoread<>nextfree;
105
LeaveCriticalSection(keyboardhandling);
108
procedure delay(ms : word);
114
procedure textmode(mode : integer);
119
procedure sound(hz : word);
122
Windows.Beep(hz,500);
130
procedure addextchar(c : char);
138
altkey : boolean = false;
139
ctrlkey : boolean = false;
140
shiftkey : boolean = false;
142
function msghandler(Window: HWnd; AMessage:UInt; WParam : WParam; LParam: LParam): Longint; stdcall;
148
addchar(chr(wparam));
176
addextchar(chr(wparam+24))
178
addextchar(chr(wparam+34))
180
addextchar(chr(wparam-11));
206
oldexitproc : pointer;
208
procedure myexitproc;
211
exitproc:=oldexitproc;
212
charmessagehandler:=nil;
213
DeleteCriticalSection(keyboardhandling);
217
charmessagehandler:=@msghandler;
220
InitializeCriticalSection(keyboardhandling);
221
oldexitproc:=exitproc;
222
exitproc:=@myexitproc;