-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCEInputMessage.pas
More file actions
140 lines (109 loc) · 3.82 KB
/
Copy pathCEInputMessage.pas
File metadata and controls
140 lines (109 loc) · 3.82 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
(******************************************************************************
Pascal Game Development Community Engine (PGDCE)
The contents of this file are subject to the license defined in the file
'licence.md' which accompanies this file; you may not use this file except
in compliance with the license.
This file is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
either express or implied. See the license for the specific language governing
rights and limitations under the license.
The Original Code is CEInputMessage.pas
The Initial Developer of the Original Code is documented in the accompanying
help file PGDCE.chm. Portions created by these individuals are Copyright (C)
2014 of these individuals.
******************************************************************************)
{
@abstract(PGDCE input message unit)
The unit contains input message classes
@author(George Bakhtadze (avagames@gmail.com))
}
{$I PGDCE.inc}
unit CEInputMessage;
interface
uses CEMessage, CEBaseTypes, CEBaseInput;
type
// Base class for user-input messages
TInputMessage = class(TCEMessage)
public
end;
// Base class for motion-related messages
TMotionMsg = class(TInputMessage)
public
// coordinates related to event. Depending on source type may be absolute or relative.
X, Y: Single;
// AX, AY - coordinates related to event. Depending on source type may be absolute or relative.
constructor Create(AX, AY: Single);
end;
// The message is sent to <b>core handler</b> when the mouse pointer moves
TMouseMoveMsg = class(TMotionMsg)
end;
// Mouse button event
TMouseButtonMsg = class(TMotionMsg)
public
// Action (only baDown and baUp are expected)
Action: TInputAction;
// Button in action
Button: TMouseButton;
constructor Create(AX, AY: Single; const AAction: TInputAction; const AButton: TMouseButton);
end;
// Touch event. Inherits from mouse button message for compatibility with touch-unaware applications.
TTouchMsg = class(TMouseButtonMsg)
public
// Pointer (e.g. finger for touch screens) ID. Unique and persistent between
PointerId: Integer;
constructor Create(AX, AY: Single; const AAction: TInputAction; const AButton: TMouseButton; APointerId: Integer);
end;
// Keyboard event
TKeyboardMsg = class(TInputMessage)
public
// Action (only baDown and baUp are expected)
Action: TInputAction;
// Virtual key code
Key: TCEVirtualKey;
// Scan code of the key as come from hardware/API
Code: Integer;
constructor Create(AAction: TInputAction; AKey: TCEVirtualKey; ACode: Integer);
end;
// Message for a character input
TCharInputMsg = class(TInputMessage)
public
// Scan code of the key as come from hardware/API. May be not specified (-$FFFF).
Code: Integer;
// Code of the character
Character: Char;
// <b>AChar</b> - code of the character, <b>AKey</b> - scan code
constructor Create(AChar: Char; ACode: Integer);
end;
implementation
{ TMouseMsg }
constructor TMotionMsg.Create(AX, AY: Single);
begin
X := AX;
Y := AY;
end;
{ TMouseButtonMsg }
constructor TMouseButtonMsg.Create(AX, AY: Single; const AAction: TInputAction; const AButton: TMouseButton);
begin
inherited Create(AX, AY);
Action := AAction;
Button := AButton;
end;
{ TTouchEvent }
constructor TTouchMsg.Create(AX, AY: Single; const AAction: TInputAction; const AButton: TMouseButton; APointerId: Integer);
begin
inherited Create(AX, AY, AAction, AButton);
PointerId := APointerId;
end;
{ TKeyboardMsg }
constructor TKeyboardMsg.Create(AAction: TInputAction; AKey: TCEVirtualKey; ACode: Integer);
begin
Action := AAction;
Key := AKey;
Code := ACode;
end;
{ TCharInputMsg }
constructor TCharInputMsg.Create(AChar: Char; ACode: Integer);
begin
Character := AChar;
Code := ACode;
end;
end.