2
$Id: wincrt.pp,v 1.6 2005/02/14 17:13:32 peter Exp $
3
This file is part of the Free Pascal run time library.
4
Copyright (c) 1999-2000 by Florian Klaempfl
5
member of the Free Pascal development team
7
This is unit implements some of the crt functionality
8
for the gui win32 graph unit implementation
10
See the file COPYING.FPC, included in this distribution,
11
for details about the copyright.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
**********************************************************************}
22
function readkey : char;
23
function keypressed : boolean;
24
procedure delay(ms : word);
27
procedure textmode(mode : integer);
29
{ plays the windows standard sound }
30
{ hz is ignored (at least on win95 }
31
procedure sound(hz : word);
38
directvideo : boolean;
52
keyboardhandling : TCriticalSection;
53
keybuffer : array[1..keybuffersize] of char;
54
nextfree,nexttoread : longint;
56
procedure inccyclic(var i : longint);
60
if i>keybuffersize then
64
procedure addchar(c : char);
67
EnterCriticalSection(keyboardhandling);
68
keybuffer[nextfree]:=c;
71
if nexttoread=nextfree then
73
// special keys are started by #0
74
// so we've to remove two chars
75
if keybuffer[nexttoread]=#0 then
76
inccyclic(nexttoread);
77
inccyclic(nexttoread);
79
LeaveCriticalSection(keyboardhandling);
82
function readkey : char;
87
EnterCriticalSection(keyboardhandling);
88
if nexttoread<>nextfree then
90
readkey:=keybuffer[nexttoread];
91
inccyclic(nexttoread);
92
LeaveCriticalSection(keyboardhandling);
95
LeaveCriticalSection(keyboardhandling);
96
{ give other threads a chance }
101
function keypressed : boolean;
104
EnterCriticalSection(keyboardhandling);
105
keypressed:=nexttoread<>nextfree;
106
LeaveCriticalSection(keyboardhandling);
109
procedure delay(ms : word);
115
procedure textmode(mode : integer);
120
procedure sound(hz : word);
123
Windows.Beep(hz,500);
131
procedure addextchar(c : char);
139
altkey : boolean = false;
140
ctrlkey : boolean = false;
141
shiftkey : boolean = false;
143
function msghandler(Window: HWnd; AMessage:UInt; WParam : WParam; LParam: LParam): Longint; stdcall;
149
addchar(chr(wparam));
177
addextchar(chr(wparam+24))
179
addextchar(chr(wparam+34))
181
addextchar(chr(wparam-11));
207
oldexitproc : pointer;
209
procedure myexitproc;
212
exitproc:=oldexitproc;
213
charmessagehandler:=nil;
214
DeleteCriticalSection(keyboardhandling);
218
charmessagehandler:=@msghandler;
221
InitializeCriticalSection(keyboardhandling);
222
oldexitproc:=exitproc;
223
exitproc:=@myexitproc;
228
Revision 1.6 2005/02/14 17:13:32 peter