-
Notifications
You must be signed in to change notification settings - Fork 3
/
Main.pas
223 lines (192 loc) · 5.35 KB
/
Main.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
unit Main;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Data.DB, Datasnap.DBClient,
System.UITypes, ActiveX,
{ Spec }
uAreaTobii, uXMLDico, EyeXHost, uEyeXThread, uEliteManager, EliteBindingsTools,
uStatusReader, uRegistry;
{ --- EyeXHost window messages notifications }
const WM_EYEX_HOST_STATUS_CHANGED = WM_USER + 0; //not used
WM_REGION_GOT_ACTIVATION_FOCUS = WM_USER + 1;
WM_REGION_ACTIVATED = WM_USER + 2; //not used
type
TMainForm = class(TForm)
Panel1: TPanel;
DelayedStarter: TTimer;
Panel7: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Panel5: TPanel;
Panel6: TPanel;
Panel8: TPanel;
Panel9: TPanel;
Panel10: TPanel;
Panel11: TPanel;
Panel12: TPanel;
Panel13: TPanel;
Panel14: TPanel;
Panel15: TPanel;
Panel16: TPanel;
Panel17: TPanel;
Panel18: TPanel;
Panel19: TPanel;
Panel20: TPanel;
Panel21: TPanel;
Panel22: TPanel;
Panel23: TPanel;
Panel24: TPanel;
Panel25: TPanel;
Panel26: TPanel;
Panel27: TPanel;
Panel28: TPanel;
Panel29: TPanel;
Panel30: TPanel;
Panel31: TPanel;
Panel32: TPanel;
Panel33: TPanel;
Panel34: TPanel;
Panel35: TPanel;
Panel36: TPanel;
Panel37: TPanel;
Panel38: TPanel;
Panel39: TPanel;
Panel40: TPanel;
Panel41: TPanel;
Panel42: TPanel;
Panel43: TPanel;
procedure FormCreate(Sender: TObject);
procedure UpdateActivatableRegions;
procedure FormDestroy(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure FormShow(Sender: TObject);
procedure DelayedStarterTimer(Sender: TObject);
procedure Panel1Click(Sender: TObject);
procedure Panel3Click(Sender: TObject);
private
procedure OnGotActivationFocus(var Msg: TMessage); message WM_REGION_GOT_ACTIVATION_FOCUS;
procedure OnMove(var Msg: TWMMove); message WM_MOVE;
procedure AppUpdate(Sender: TObject);
procedure ContextObserverStart;
public
EyeXHost : TEyeXHost;
AreaTobii : TAreaTobii;
procedure UpdateAreas(Sender: TObject);
end;
var
MainForm: TMainForm;
implementation
uses
EyeX;
{$R *.dfm}
procedure TMainForm.AppUpdate(Sender: TObject);
begin
Update;
end;
procedure TMainForm.ContextObserverStart;
begin
ContextObserver := TContextObserver.Create(AreaTobii);
end;
procedure TMainForm.DelayedStarterTimer(Sender: TObject);
begin
DelayedStarter.Enabled := False;
UpdateActivatableRegions;
AreaTobii.SetEliteStatus(EliteStatus);
{ --- Instancie end start context observer }
ContextObserverStart
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS );
SetForegroundWindow(Handle);
TLauncher.AppInitialize;
AreaTobii := TAreaTobii.Create(Self);
with AreaTobii do begin
OnUpdateAreas := UpdateAreas;
Areas.OnUpdate := AppUpdate;
Context.AreasDefine;
Context.Context_MainMenu;
Repaint
end;
EyeXHost := TEyeXHost.create;
TKeyMessageSender.Initialize;
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
TLauncher.AppFinalize;
TKeyMessageSender.Finalize;
EyeXHost.Free
end;
procedure TMainForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=' ' then eyeXHost.TriggerActivation
end;
procedure TMainForm.FormShow(Sender: TObject);
begin
try
TKeyInventory.Initialize;
TEliteManager.KeyInventoryAssign(KeyInventory);
KeyWrite(AppKey, 'EliteBindingsError', 0)
except
on E:Exception do begin
MessageDlg(E.Message, mtWarning, [mbOK], 0);
Application.Terminate;
end
end;
{ --- l'application est plein écran }
Application.MainForm.WindowState := wsMaximized;
EyeXHost.Init(WindowHandle, WM_EYEX_HOST_STATUS_CHANGED, WM_REGION_GOT_ACTIVATION_FOCUS, WM_REGION_ACTIVATED);
UpdateActivatableRegions;
{ --- démarrage du thread de capture de focus pour les panels }
CallSurveyor.Start;
{ --- on peut rendre l'application transparente }
TransparentColor := True;
DelayedStarter.Enabled := True;
end;
procedure TMainForm.UpdateActivatableRegions;
var
Areas : TActivatableRegions;
i : Integer;
begin
with AreaPanels do begin
{ --- Invoquer ActiveCount permet de reconstruire le tableau ActivPanels }
SetLength(Areas, ActiveCount);
for i := Low(ActivPanels) to High(ActivPanels) do begin
Areas[i].id := ActivPanels[i].Tag;
Areas[i].bounds := GetScreenBounds(ActivPanels[i]);
end;
end;
eyeXHost.SetActivatableRegions( Areas )
end;
procedure TMainForm.UpdateAreas(Sender: TObject);
begin
UpdateActivatableRegions
end;
procedure TMainForm.OnMove(var Msg: TWMMove);
begin
if EyeXHost <> nil then UpdateActivatableRegions
end;
procedure TMainForm.Panel1Click(Sender: TObject);
begin
with AreaPanels do
SelectMode := TSelectMode( (Integer(SelectMode) + 1) mod 4)
end;
procedure TMainForm.Panel3Click(Sender: TObject);
begin
with AreaPanels do NullEnable := not NullEnable
end;
procedure TMainForm.OnGotActivationFocus(var Msg: TMessage);
var id: UINT_PTR;
begin
id := msg.WParam;
with AreaPanels do case BlinkType of
bt_transitory: CallFifo.Poke( id - 1 );
bt_persistent: CallFifo.Poke( id );
end;
update
end;
initialization
CoUninitialize
end.