-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUKEYBRD.PAS
83 lines (68 loc) · 1.47 KB
/
UKEYBRD.PAS
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
UKeyBrd Unit
2022 LRT
}
unit
UKeyBrd;
interface
uses
xcrt, consts, utils, uclasses, types, locale,
uobject, uexc, umsgs;
type
PKeyboard = ^TKeyboard;
TKeyboard = object (TObject)
public
constructor init;
destructor done; virtual;
function getClassName: string; virtual;
function getClassId: word; virtual;
function update: boolean;
function getLastKeyDown: char;
private
_lastKeyDown: char;
end;
var
Keyboard: PKeyboard;
implementation
{ TKeyboard public }
constructor TKeyboard.init;
begin
inherited init;
end;
destructor TKeyboard.done;
begin
inherited done;
end;
function TKeyboard.getClassName: string;
begin
getClassName := 'TKeyboard';
end;
function TKeyboard.getClassId: word;
begin
getClassId := C_CLASS_ID_Keyboard;
end;
function TKeyboard.update: boolean;
var
delegate: PObject;
key: char;
begin
update := false;
delegate := getDelegate;
if delegate = nil then exit;
if keypressed then
begin
key := readkey;
_lastKeyDown := key;
sendMessageWithData(C_MSG_KEYBOARD_KEY_DOWN, delegate, @key, 1);
update := true;
end;
end;
function TKeyboard.getLastKeyDown: char;
begin
getLastKeyDown := _lastKeyDown;
end;
{ TKeyboard private }
{ Other }
begin
Keyboard := new(PKeyboard, init);
end.