-
Notifications
You must be signed in to change notification settings - Fork 3
/
uAreaTobii.pas
4766 lines (4217 loc) · 152 KB
/
uAreaTobii.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{*******************************************************}
{ }
{ 08/2020 MaxiDonkey Library }
{ }
{*******************************************************}
unit uAreaTobii;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Winapi.mmSystem, Winapi.shellapi,
Datasnap.DBClient, Clipbrd,
{ Spec }
SendKey32, KeysDef, EliteBindingsTools, uXMLDico, uEliteManager, uStatusReader, EyeXHost,
uEyeXThread;
type
TKindDisplay = ( kd_none, kd_menu, kd_drive, kd_fss, kd_saa,
kd_galaxymap, kd_systemmap, kd_function, kd_pause, kd_mainmenu,
kd_elitemenu, kd_keyboard, kd_params );
TSpeedType = ( ts_25, ts_50, ts_75, ts_100, ts_m25,
ts_m50, ts_m75, ts_m100, ts_0);
TKeyboardKind = ( kk_alpha, kk_num, kk_special, kk_navigation, kk_critik );
TKindPanels = ( kp_none, kp_left, kp_right, kp_bottom );
TKindSpeed = ( ks_speed25, ks_speed50, ks_speed75, ks_speed100 );
TKindMapCall = ( kmc_none, kmc_galaxy, kmc_system );
TKindHud = ( kh_menu, kh_drive );
TContextNotify = procedure of object;
TGearTypeNotify = procedure (const Mode: TLandingGearType) of object;
TCockpitNotify = procedure (const Mode : TCockpitModeType) of object;
TIntegerNotify = procedure (Value : Byte; Tms : Integer = 0) of object;
TIntNotify = procedure (Value : Byte) of object;
TIntANotify = procedure (Value : Integer) of object;
TBoolNotify = procedure (Value : Boolean) of object;
TKeyboardContext = class;
TEliteContext = class;
TAreaTobii = class(TComponent)
private
FForm : TForm;
FContext : TKeyboardContext;
FElite : TEliteContext;
FAreasUpdate : TNotifyEvent;
FDico : TXmlAlternative;
FEliteManager : TEliteManager;
FEliteStatus : TEliteStatus;
FKeyMessageSender : TKeyMessageSender;
function FormRetrieve: TForm;
procedure Initialize;
procedure DoOnTriggerNotify(Sender: TObject; KeyUp: Boolean; ATag: Integer);
procedure DoOnNullSelect(Sender: TObject; ATag: Integer);
procedure DoOnBeforeSelect(Sender: TObject; OldValue, NewValue: Integer);
procedure DoOnUnSelect(Sender: TObject; ATag: Integer);
procedure DoLaunchElite(WithVocal: Boolean);
private
FBorder: Boolean;
{ --- Assessors / mutators }
function GetPanel(index: Integer): TPanel;
function GetCaption(index: Integer): string;
procedure SetCaption(index: Integer; const Value: string);
function GetSelected(index: Integer): Boolean;
function GetAreas: TAreaPanels;
procedure SetBorder(const Value: Boolean);
public
{ --- Creation of zones }
procedure Add(const Panel: TPanel; const ATag: Integer; const AMode: TSelectMode; const ANull: Boolean = False);
{ --- Zone settings }
procedure CaptionUpdate(const Raw: Integer; const Values: array of string);
procedure VisibleUpdate(const Raw: Integer; const Values: array of Boolean; Update: Boolean = False);
procedure SelModeUpdate(const Raw: Integer; const Values: array of TSelectMode);
procedure TagsUpdate(const Raw: Integer; const Values: array of Integer);
procedure NullUpdate(const Raw: Integer; const Values: array of Boolean);
{ --- Setting of an area in the screen matrix }
procedure BoxUpdate(const Raw, Col, ATag: Integer; ACaption: string; AVisible: Boolean; AMode: TSelectMode; ANull: Boolean);
procedure SetEliteStatus(const Value: TEliteStatus);
procedure Repaint;
procedure UpdateZone(const AreasContext: TContextNotify);
{ --- Reset context of areas }
procedure ResetAreas;
{ --- Actions on external components or application }
procedure SendSignal(const k1: string; const k2 : string = ''; const k3: string = '');
{ --- Read-only access to the TAreaPanels instance }
property Areas: TAreaPanels read GetAreas;
{ --- Read-only access to contexts }
property Context: TKeyboardContext read FContext;
{ --- Read-only access to Elite contexts }
property Elite: TEliteContext read FElite;
property Panel[index: Integer]: TPanel read GetPanel;
{ --- Read or modify the panel caption at the index index }
property Caption[index: Integer]: string read GetCaption write SetCaption;
{ --- True if the index zone is selected }
property Selected[index: Integer]: Boolean read GetSelected;
{ --- Border for all areas }
property Border: Boolean read FBorder write SetBorder;
{ --- External update write redraw areas to tobii }
property OnUpdateAreas: TNotifyEvent read FAreasUpdate write FAreasUpdate;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
TEliteContext = class
private
FOwner : TAreaTobii;
FSwitchUpdate : Boolean; // --- Update Switch display after ENTER
FEliteAssistUsed : Boolean; // --- False on app start, True as soon an ED function choosed
FEliteAssistStarted : Boolean; // --- False until an ED function selected (Thread observer process)
FSpeed : TSpeedType; // --- lowcruise Speed flight
{ --- Local Tools }
procedure StepSelector(const ATag: Integer);
procedure DoClicUnique(const Method: TContextNotify); overload;
procedure DoClicUnique(const Method: TGearTypeNotify); overload;
procedure DoClicUnique(const Method: TCockpitNotify); overload;
procedure DoClic(const Method: TContextNotify); overload;
procedure DoClic(const Method: TIntNotify; Value: Integer); overload;
procedure DoClic(const Method: TIntegerNotify; Value: Integer); overload;
procedure NavClic(const SensA: TContextNotify; const SensB: TIntegerNotify); overload;
procedure NavClic(const SensA: TContextNotify; const SensB: TIntANotify); overload;
procedure DoUnicClic(const Method: TIntegerNotify; Value: Integer); overload;
procedure DoUnicClic(const Method: TIntNotify; Value: Integer); overload;
{ --- Elite context }
procedure Context_Elite;
procedure Context_Pause;
procedure Context_EliteMenu;
procedure Context_StepSelect;
procedure Context_EliteDrive;
procedure Context_EliteDriveCombat;
procedure Context_EliteDriveLanding;
procedure Context_EliteDriveVRS;
procedure Context_Func; //Function Header
procedure Context_Func0; //0: Panels area
procedure Context_Func1; //1: DIV area
procedure Context_Func2; //2: Weapons area
procedure Context_Func3; //3: Fighter area
procedure Context_Func4; //4: Camera area
{TODO}
procedure Context_GalaxyMap;
procedure Context_System_Map;
procedure Context_ACS;
procedure Context_DSD;
{ --- UnicStep managment }
procedure DoUnicStep(Value: Integer);
procedure Switch;
procedure AssignFunc(const Index: Integer);
{ --- Retrieve context on app launch : Menu EliteDangerous }
function EliteContextRetrieveOnLaunch(Sender: TKindHud):Boolean;
private
{ --- Ascessors / Mutators }
function GetStep: Integer;
procedure SetStep(const Value: Integer);
function GetIndexFunc: Integer;
procedure SetIndexFunc(const Value: Integer);
function GetIndexMode: Integer;
procedure SetIndexMode(const Value: Integer);
function GetSubIndex: Integer;
procedure SetSubIndex(const Value: Integer);
function GetIndexGMMode: Integer;
procedure SetIndexGMMode(const Value: Integer);
function GetSubGMIndex: Integer;
procedure SetSubGMIndex(const Value: Integer);
function GetGMAllSlide: Boolean;
procedure SetGMAllSlide(const Value: Boolean);
function GetSlideOffms: Integer;
procedure SetSlideOffms(const Value: Integer);
function GetIndexSMMode: Integer;
procedure SetIndexSMMode(const Value: Integer);
function GetSubSMIndex: Integer;
procedure SetSubSMIndex(const Value: Integer);
function GetIndexACSMode: Integer;
procedure SetIndexACSMode(const Value: Integer);
function GetSubACSIndex: Integer;
procedure SetSubACSIndex(const Value: Integer);
function GetSlideAssist: Boolean;
procedure SetSlideAssist(const Value: Boolean);
function GetIndexDSDMode: Integer;
procedure SetIndexDSDMode(const Value: Integer);
function GetSubDSDIndex: Integer;
procedure SetSubDSDIndex(const Value: Integer);
function GetStateBeforePause: TKindDisplay;
procedure SetStateBeforePause(const Value: TKindDisplay);
function GetCurrentDisplay: TKindDisplay;
procedure SetCurrentDisplay(const Value: TKindDisplay);
function GetMapCalled: TKindMapCall;
procedure SetMapCalled(const Value: TKindMapCall);
function GetDisplayBeforeKeyboard: TKindDisplay;
procedure SetDisplayBeforeKeyboard(const Value: TKindDisplay);
function GetComPanelOpened: Boolean;
procedure SetComPanelOpened(const Value: Boolean);
function GetPanelCalled: TKindPanels;
procedure SetPanelCalled(const Value: TKindPanels);
function GetIsDSDOpened: Boolean;
procedure SetIsDSDOpened(const Value: Boolean);
function GetUnicStep: Boolean;
procedure SetUnicStep(const Value: Boolean);
function GetCurrentHud: TKindHud;
procedure SetCurrentHud(const Value: TKindHud);
function GetIndexLandingDrive: Integer;
procedure SetIndexLandingDrive(const Value: Integer);
function GetSubLandingDriveIndex: Integer;
procedure SetSubLandingDriveIndex(const Value: Integer);
function GetIndexOfPitchLanding: Integer;
procedure SetIndexOfPitchLanding(const Value: Integer);
function GetIndexVRSMode: Integer;
procedure SetIndexVRSMode(const Value: Integer);
function GetSubVRSIndex: Integer;
procedure SetSubVRSIndex(const Value: Integer);
function GetIsFSSOpened: Boolean;
procedure SetIsFSSOpened(const Value: Boolean);
function GetVocalAppUsed: Boolean;
procedure SetVocalAppUsed(const Value: Boolean);
function GetReverseForward: Boolean;
procedure SetReverseForward(const Value: Boolean);
function GetLowCruise: Boolean;
public
{ --- Lauch and retieve Elite state }
procedure TryLaunchOnMenuDisplay;
procedure TryLaunchOnDriveDisplay;
procedure Step_display;
procedure Pause_display;
procedure Menu_display;
procedure Drive_display;
procedure Func_display;
procedure GalaxyMap_display;
procedure SystemMap_display;
procedure ACS_display(forced: Boolean);
procedure DSD_display(forced: Boolean);
procedure DoMenuEchap;
procedure DoMenuEnter;
{ --- Elite notifier }
procedure EliteNotify(const ATag: Integer);
{ --- Panels notify actions }
procedure DoMapGalaxyShow(DisplayMap: boolean);
procedure DoMapSystemShow(DisplayMap: boolean);
procedure DoACSShow(DisplayPanel: boolean);
procedure DoLeftPanelShow(DisplayPanel: boolean);
procedure DoRightPanelShow(DisplayPanel: boolean);
procedure DoComPanelShow(DisplayPanel: boolean);
procedure DoRolePanelShow(DisplayPanel: boolean);
procedure DoBackMenuShow;
procedure DoFriendsMenuShow;
procedure DoKeyBoardShow;
procedure DoNavBack(EliteMapClose: Boolean = True);
{ --- Elite main function notify actions }
procedure PauseBack;
procedure PauseFunctionBack;
procedure PauseEnable;
procedure DoTarget12h;
procedure DoOrderPanel;
procedure DoStartFighter;
{ --- VRS drive notify actions }
procedure DoAutoBreak;
procedure DoVRSTurret;
procedure DoShipDismissRecall;
procedure DoVRSSlide; //VRS Slide
procedure DoVRSStep; //VRS Step
procedure DoVRSUpView; //VRS Turret up view
procedure DoVRSDownView; //VRS Turret down view
procedure DoVRSTurnLeft; //VRS Turn left
procedure DoVRSTurnRight; //VRS Turn right
procedure DoVRSVerticalThrust; //VRS Vertical thrust
procedure DoVRSReversePropulsion; //VRS Reverse propulsion
procedure DoVRSDriveAssist; //VRS Drive assist enable/disable
procedure DoVRSShoot1;
procedure DoVRSShoot2;
{ --- Navigation notify actions }
procedure NavLauncher(const MethA: TContextNotify; const MethB: TIntegerNotify;
Index: Integer); overload;
procedure NavLauncherEx(const MethA: TContextNotify; const MethB: TIntegerNotify;
Index: Integer);
procedure NavLauncherVRS(const MethA: TContextNotify; const MethB: TIntANotify;
Index: Integer); overload;
procedure NavLauncherVRS(const MethA: TContextNotify; const MethB: TIntegerNotify;
Index: Integer); overload;
procedure DoNavModeChange;
procedure DoNavSlide;
procedure DoNavNord;
procedure DoNavSud;
procedure DoNavEst;
procedure DoNavOuest;
procedure DoNavPere;
procedure DoNavFils;
procedure DoPrevShip;
procedure DoNextShip;
procedure DoNavNordOuest;
procedure DoNavNordEst;
procedure DoNavSudOuest;
procedure DoNavSudEst;
{ --- Speed selector }
procedure DoSpeedReverse;
procedure DoSetSpeed(Value: TKindSpeed);
procedure DoFlightSpeedNull;
procedure DoSuperNavigation;
procedure DoFSD;
{ --- Galaxy map notify actions }
procedure NavLauncher(const MethA: TContextNotify; const MethB: TIntANotify;
Index: Integer); overload;
procedure NavLauncherThrust(const MethA: TContextNotify; const MethB: TIntANotify;
Index: Integer);
procedure DoGMSlide;
procedure DoGMSteps;
procedure DoGMGoHome;
procedure DoGMBack;
procedure DoGMAllSlide;
procedure DoGMReward;
procedure DoGMUp;
procedure DoGMUpRotate;
procedure DoGMLeft;
procedure DoGMRight;
procedure DoGMDown;
procedure DoGMDownRotate;
procedure DoGMZoomIn;
procedure DoGMLeftRotate;
procedure DoGMForward;
procedure DoGMRightRotate;
procedure DoGMZoomOut;
{ --- System map notify actions }
procedure DoSMSlide;
procedure DoSMSteps;
procedure DoSMZoomIn;
procedure DoSMZoomOut;
procedure DoSMBack;
procedure DoSMGoUp;
procedure DoSMGoDown;
procedure DoSMGoLeft;
procedure DoSMGoRight;
{ --- Exploration FSS notify actions }
procedure DoACSSlide;
procedure DoACSSteps;
procedure DoACSZoomIn;
procedure DoACSAnalyse;
procedure DoACSZoomOut;
procedure DoACSHelp;
procedure DoACSBack;
procedure DoACSRadioDec;
procedure DoACSPitchInc;
procedure DoACSRadioInc;
procedure DoACSYawDec;
procedure DoACSYawInc;
procedure DoACSGetTarget;
procedure DoACSMiniZoomIn;
procedure DoACSPitchDec;
procedure DoACSMiniZoomOut;
{ --- Surface Analyse Area notify actions }
procedure DoDSDSlide;
procedure DoDSDSteps;
procedure DoDSDZoomIn;
procedure DoDSDZoomOut;
procedure DoDSDBack;
procedure DoDSDPitchUp;
procedure DoDSDYawLeft;
procedure DoDSDYawRight;
procedure DoDSDViewChange;
procedure DoDSDPitchDown;
procedure DoDSDFire;
{ --- Drive landing or docking }
procedure DoDriveLandingSlide;
procedure DoDriveLandingStep;
procedure DoDriveLandingPitch;
procedure DoDriveLandingPitchUp;
procedure DoLandingPitchDown;
procedure DoDriveLandingRollLeft;
procedure DoDriveLandingRollRight;
procedure DoDriveLandingYawLeft;
procedure DoDriveLandingYawRight;
procedure DoDriveLandingUpThrust(NotLanding: Boolean = False);
procedure DoDriveLandingDownThrust(NotLanding: Boolean = False);
procedure DoDriveLandingLeftThrust(NotLanding: Boolean = False);
procedure DoDriveLandingRightThrust(NotLanding: Boolean = False);
procedure DoDriveLandingForwardThrust(NotLanding: Boolean = False);
procedure DoDriveLandingBackThrust(NotLanding: Boolean = False);
{ --- Check in vehicle }
function IsFlying:Boolean;
{ --- Check Docked }
function IsDocked:Boolean;
{ --- Check Landed }
function IsLanded:Boolean;
{ --- Check if map opened }
function IsMapOpened:Boolean;
{ --- Is Pause mode enabled }
function IsPause: Boolean;
{ --- LowCruise speed }
property Speed: TSpeedType read FSpeed write FSpeed;
property LowCruise: Boolean read GetLowCruise;
{ --- Menu indexes }
property Step: Integer read GetStep write SetStep;
property UnicStep: Boolean read GetUnicStep write SetUnicStep;
property IndexFunc: Integer read GetIndexFunc write SetIndexFunc;
{ --- Ship drive indexes }
property IndexMode: Integer read GetIndexMode write SetIndexMode;
property SubIndex: Integer read GetSubIndex write SetSubIndex;
{ --- Galaxy map indexes }
property IndexGMMode: Integer read GetIndexGMMode write SetIndexGMMode;
property SubGMIndex: Integer read GetSubGMIndex write SetSubGMIndex;
property GMAllSlide: Boolean read GetGMAllSlide write SetGMAllSlide;
{ --- System map indexes }
property IndexSMMode: Integer read GetIndexSMMode write SetIndexSMMode;
property SubSMIndex: Integer read GetSubSMIndex write SetSubSMIndex;
{ --- Exploration FSS indexes }
property IndexACSMode: Integer read GetIndexACSMode write SetIndexACSMode;
property SubACSIndex: Integer read GetSubACSIndex write SetSubACSIndex;
{ --- SAA indexes}
property IndexDSDMode: Integer read GetIndexDSDMode write SetIndexDSDMode;
property SubDSDIndex: Integer read GetSubDSDIndex write SetSubDSDIndex;
{ --- VRS indexes}
property IndexVRSMode: Integer read GetIndexVRSMode write SetIndexVRSMode;
property SubVRSIndex: Integer read GetSubVRSIndex write SetSubVRSIndex;
{ --- Landing or dicking drive indexes }
property IndexLandingDrive: Integer read GetIndexLandingDrive write SetIndexLandingDrive;
property SubLandingDriveIndex: Integer read GetSubLandingDriveIndex write SetSubLandingDriveIndex;
property IndexOfPitchLanding: Integer read GetIndexOfPitchLanding write SetIndexOfPitchLanding;
{ --- Time slide off }
property SlideOffms: Integer read GetSlideOffms write SetSlideOffms;
{ --- Params }
property SlideAssist: Boolean read GetSlideAssist write SetSlideAssist;
{ --- Com panel opened }
property ComPanelOpened: Boolean read GetComPanelOpened write SetComPanelOpened;
{ --- Kind of display before action }
property DisplayBefore: TKindDisplay read GetStateBeforePause write SetStateBeforePause;
property DisplayBeforeKeyboard: TKindDisplay read GetDisplayBeforeKeyboard write SetDisplayBeforeKeyboard;
{ --- Current kind od display }
property CurrentDisplay: TKindDisplay read GetCurrentDisplay write SetCurrentDisplay;
{ --- Map is call }
property MapCalled: TKindMapCall read GetMapCalled write SetMapCalled;
{ --- Panel called }
property PanelCalled: TKindPanels read GetPanelCalled write SetPanelCalled;
{ --- Indic Opened DSD }
property IsDSDOpened: Boolean read GetIsDSDOpened write SetIsDSDOpened;
{ --- Indic Opened FSS }
property IsFSSOpened: Boolean read GetIsFSSOpened write SetIsFSSOpened;
{ --- Hud selected }
property CurrentHud: TKindHud read GetCurrentHud write SetCurrentHud;
{ --- Indic for Process Thread to update menu SWITH area }
property SwitchUpdate : Boolean read FSwitchUpdate write FSwitchUpdate;
{ --- Indic for a vocal app used }
property VocalAppUsed: Boolean read GetVocalAppUsed write SetVocalAppUsed;
{ --- Indic for reverse forward and backward speed ship }
property ReverseForward: Boolean read GetReverseForward write SetReverseForward;
constructor Create(const AOwner: TAreaTobii);
end;
TKeyboardContext = class
private
FOwner : TAreaTobii;
FTarget : THandle;
FBuffer : string;
FCall : Boolean;
FLastWord : string;
function GetCar(const Car: Char):Char;
private
{ --- Send message text to external component or application }
procedure SendTextTo(const ASt: string);
{ --- Send keyboard combinaison to external component or application }
procedure SendSignal(const k1: string; const k2 : string = ''; const k3: string = '');
{ --- Send keyboard combinaison for internal component of keyboard }
procedure SendMsgTo(const k1: string; const k2 : string = ''; const k3: string = '');
procedure SendMsgToEx(const k1: string; const k2 : string = ''; const k3: string = '');
procedure SendMsgToA(const k1: string; const k2 : string = ''; const k3: string = '');
{ --- Select, copy, cut paste text selection }
procedure SelectAll;
procedure Copy_;
procedure Cut_;
procedure Paste_;
private
{ --- Keyboard methods }
procedure DoUp;
procedure DoDown;
procedure DoHome;
procedure DoEnd;
procedure DoDocHome;
procedure DoDocEnd;
procedure DoPrevWord;
procedure DoNextWord;
procedure DoPageUp;
procedure DoPageDown;
procedure DoSelLeft;
procedure DoSelRight;
procedure DoSelHome;
procedure DoSelEnd;
procedure DoSelPageUp;
procedure DoSelPageDown;
procedure DoSelWordLeft;
procedure DoSelWordRight;
procedure DoSelTop;
procedure DoSelBottom;
procedure DoSelAll;
procedure DoMenuUp;
procedure DoMenuDown;
procedure DoMenuLeft;
procedure DoMenuRight;
procedure DoMenuEnter;
procedure DoMenuEchap;
procedure DoAlt;
procedure DoTab;
procedure DataDico; //Temporary
procedure AltInsert(const Alt: Integer);
procedure DoOnShift;
procedure DoWithCar(const ATag: Integer);
procedure AltDisplay;
procedure DoBackSpace;
procedure DoPrev;
procedure DoNext;
procedure DoAlphaRight;
procedure DoAlphaLeft;
procedure DoKeyBoardBack;
procedure DoMainKeyBoardLaunch;
procedure DoParametersLaunch;
{ --- State indicator management }
procedure DisplaySpecial(AIndex: Integer);
procedure DisplayNumpad;
procedure DisplayAlpha;
procedure DisplayNav(AIndex: Integer);
{ --- Sound indicators }
procedure KeySound;
procedure FunctionSound;
{ --- Buffer clean }
procedure CleanBuffer;
{ --- Reset context of areas }
procedure ResetAreas;
{ --- Refresh context for Alternative's datas }
procedure RepaintKeyboardAlpha;
{ --- all Context of areas for application }
procedure Context_Parameters;
{ --- Keyboard context }
procedure Context_Keyboard;
procedure Context_KeyboardMain;
procedure Context_KeyboardLeft;
procedure Context_KeyboardRight;
procedure Context_KeyboardNumeric;
procedure Context_KeyboardSpecials;
procedure Context_KeyboardSpecials_1;
procedure Context_KeyboardSpecials_2;
procedure Context_KeyboardNavigation_1;
procedure Context_KeyboardNavigation_2;
procedure Context_KeyboardCritik;
procedure Context_ResetAlternative;
procedure Make_Alternative(ASt: string);
procedure MainMenu_display;
private
{ --- Assessors / Mutators }
function GetCapsLock: Boolean;
procedure SetCapsLock(const Value: Boolean);
function GetLeftKeyboard: Boolean;
procedure SetLeftKeyboard(const Value: Boolean);
function GetKeyboardKind: TKeyboardKind;
procedure SetKeyboardKind(const Value: TKeyboardKind);
function GetSpecialIndex: Integer;
procedure SetSpecialIndex(const Value: Integer);
function GetNavIndex: Integer;
procedure SetNavIndex(const Value: Integer);
public
{ --- Areas definition call by mainform }
procedure AreasDefine;
{ --- Display main context call by mainform }
procedure Context_MainMenu;
{ --- Keyboard notifier }
procedure KeyboardNotify(const ATag: Integer);
{ --- Capslock false <-> Upcase, true <-> LowCase }
property CapsLock: Boolean read GetCapsLock write SetCapsLock;
{ --- Left keyboard visible if True else Right keyboard }
property LeftKeyboard: Boolean read GetLeftKeyboard write SetLeftKeyboard;
{ --- Alpha or Numpad or Special or Cursor or Func : mode enabled }
property KeyboardKind: TKeyboardKind read GetKeyboardKind write SetKeyboardKind;
{ --- 0,1,2 mode of specials }
property SpecialIndex: Integer read GetSpecialIndex write SetSpecialIndex;
{ --- 0,1 Index of Func }
property NavIndex: Integer read GetNavIndex write SetNavIndex;
constructor Create(const AOwner: TAreaTobii);
end;
TContextObserver = class(TTHread)
private
ThAreaTobii : TAreaTobii;
FStart : Boolean;
Old_Docked : Boolean;
Old_HardPoints : Boolean;
Old_LandingGear : Boolean;
Old_InSRV : Boolean;
Old_TurretView : Boolean;
Old_GuiValue : TGuiType;
Old_LowCruise : Boolean;
procedure ThDelay(ms: Cardinal);
procedure Process;
public
procedure Execute; override;
constructor Create(const AAreaTobii: TAreaTobii);
end;
var
ContextObserver : TContextObserver;
implementation
uses
Main, uRegistry, StrUtils;
type
TAreaindexedChar = 91010..91092;
TKeyCharArray = array[TAreaindexedChar] of char;
var
KeyCharArray : TKeyCharArray = (
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.', '+', '-', '*', '/',
'.', '@', '_', '(', ')', ',', ';', ':', '[', ']', '\', '%', '$', '{', '}',
'²', '&', '"', '''', '°', '=', '%', '!', '?', '#', '|', '>', '<', '£', 'µ',
'§', 'É', 'È', 'Ê', 'Ù', 'Î', 'Ï', 'À', 'Â', 'Ô', 'Ç', ' ');
function Maj(const Car: char):char;
begin
Result := #0;
case IndexStr(Car, ['É', 'È', 'Ê', 'Ù', 'Î', 'Ï', 'À', 'Â', 'Ô', 'Ç']) of
0 : Result := 'é';
1 : Result := 'è';
2 : Result := 'ê';
3 : Result := 'ù';
4 : Result := 'î';
5 : Result := 'ï';
6 : Result := 'à';
7 : Result := 'â';
8 : Result := 'ô';
9 : Result := 'ç';
end
end;
function IsEliteRunning: Boolean;
begin
Result := FindWindow( PWideChar(ELITE_CLASS), nil ) <> 0
end;
procedure EliteForeGround;
begin
try
SetForegroundWindow( FindWindow( PWideChar(ELITE_CLASS), nil ) )
except
end
end;
procedure Delay(ms: Cardinal);
var
S : Cardinal;
begin
S := GetTickCount + ms;
with Application do repeat
Sleep( 10 )
until Terminated or (GetTickCount > S)
end;
{ TAreaTobii }
procedure TAreaTobii.Add(const Panel: TPanel; const ATag: Integer;
const AMode: TSelectMode; const ANull: Boolean);
begin
Areas.Add(Panel, ATag, AMode, ANull)
end;
procedure TAreaTobii.BoxUpdate(const Raw, Col, ATag: Integer; ACaption: string;
AVisible: Boolean; AMode: TSelectMode; ANull: Boolean);
begin
Areas.BoxUpdate(Raw, Col, ATag, ACaption, AVisible, AMode, ANull)
end;
procedure TAreaTobii.CaptionUpdate(const Raw: Integer;
const Values: array of string);
begin
Areas.CaptionUpdate(Raw, Values)
end;
constructor TAreaTobii.Create(AOwner: TComponent);
begin
inherited;
FForm := FormRetrieve;
Initialize
end;
destructor TAreaTobii.Destroy;
begin
FContext.Free;
FDico.Free;
inherited
end;
procedure TAreaTobii.DoLaunchElite(WithVocal: Boolean);
begin
with Context, FEliteManager, FEliteStatus, Elite do begin
FEliteAssistUsed := WithVocal;
FEliteAssistStarted := True;
CurrentDisplay := kd_elitemenu;
VocalAppUsed := WithVocal;
UpdateZone( Context_Elite );
FunctionSound;
EliteForeGround
end;
end;
procedure TAreaTobii.DoOnBeforeSelect(Sender: TObject; OldValue,
NewValue: Integer);
begin
end;
procedure TAreaTobii.DoOnNullSelect(Sender: TObject; ATag: Integer);
begin
end;
procedure TAreaTobii.DoOnTriggerNotify(Sender: TObject; KeyUp: Boolean;
ATag: Integer);
begin
with Context, Elite do case Atag of
{ --- Main actions }
91000 : Application.MainForm.Close;
91001 : DoMainKeyBoardLaunch;
91002 : ;
91003 : ; //DataDico;
91004 : DoLaunchElite(False);
91005 : DoLaunchElite(True);
91006 : DoParametersLaunch;
91007 : DoKeyBoardBack;
{ --- Keyboard actions }
91008..91156 : KeyboardNotify(ATag);
{ --- Elite actions }
91200..91600 : EliteNotify(ATag);
end
end;
procedure TAreaTobii.DoOnUnSelect(Sender: TObject; ATag: Integer);
begin
end;
function TAreaTobii.FormRetrieve: TForm;
var
X : TComponent;
begin
Result := nil;
X := Owner;
while Assigned(X) and not (X is TForm) do X := X.Owner;
if Assigned(X) and (X is TForm) then Result := TForm(X)
end;
function TAreaTobii.GetAreas: TAreaPanels;
begin
Result := AreaPanels
end;
function TAreaTobii.GetCaption(index: Integer): string;
begin
try
Result := Panel[index].Caption
except
Result := EmptyStr
end
end;
function TAreaTobii.GetPanel(index: Integer): TPanel;
begin
try
Result := AreaPanels.Panels[index]
except
Result := nil
end
end;
function TAreaTobii.GetSelected(index: Integer): Boolean;
begin
Result := AreaPanels.Selected(index)
end;
procedure TAreaTobii.Initialize;
begin
FKeyMessageSender := KeyMessageSender;
FEliteManager := EliteManager;
FContext := TKeyboardContext.Create(Self);
FBorder := AreaPanels.Border;
with AreaPanels do begin
OnBeforeSelect := DoOnBeforeSelect;
OnNullSelect := DoOnNullSelect;
TrigNotify := DoOnTriggerNotify;
OnUnSelect := DoOnUnSelect
end;
FDico := TXmlAlternative.Create;
FElite := TEliteContext.Create(Self)
end;
procedure TAreaTobii.NullUpdate(const Raw: Integer;
const Values: array of Boolean);
begin
Areas.NullUpdate(Raw, Values)
end;
procedure TAreaTobii.Repaint;
begin
Areas.Repaint
end;
procedure TAreaTobii.ResetAreas;
begin
with Context do ResetAreas
end;
procedure TAreaTobii.SelModeUpdate(const Raw: Integer;
const Values: array of TSelectMode);
begin
Areas.SelModeUpdate(Raw, Values)
end;
procedure TAreaTobii.SendSignal(const k1, k2, k3: string);
begin
with FContext do SendSignal(k1, k2, k3)
end;
procedure TAreaTobii.SetBorder(const Value: Boolean);
begin
FBorder := Value;
Areas.Border := Value
end;
procedure TAreaTobii.SetCaption(index: Integer; const Value: string);
begin
try Panel[index].Caption := Value except end
end;
procedure TAreaTobii.SetEliteStatus(const Value: TEliteStatus);
begin
FEliteStatus := Value
end;
procedure TAreaTobii.TagsUpdate(const Raw: Integer;
const Values: array of Integer);
begin
Areas.TagsUpdate(Raw, Values)
end;
procedure TAreaTobii.UpdateZone(const AreasContext: TContextNotify);
begin
if Assigned(AreasContext) then begin
AreasContext;
Repaint;
if Assigned(FAreasUpdate) then FAreasUpdate(Self)
end;
AreaPanels.Unselect
end;
procedure TAreaTobii.VisibleUpdate(const Raw: Integer;
const Values: array of Boolean; Update: Boolean);
begin
Areas.VisibleUpdate(Raw, Values, Update)
end;
{ TKeyboardContext }
procedure TKeyboardContext.AltDisplay;
var
Alt: string;
begin
with FOwner.FDico do begin
if FBuffer <> EmptyStr then begin
Alt := FindAltFrom(FBuffer, CapsLock);
if Alt = EmptyStr then Alt := FindAltOrtho(FBuffer, CapsLock)
end else
Alt := FindAltPost(FLastWord, CapsLock)
end;
Make_Alternative( Alt )
end;
procedure TKeyboardContext.AltInsert(const Alt: Integer);
var
index : Integer;
ASt : string;
begin
index := Alt - 91150;
ASt := FOwner.Caption[index];
FLastWord := ASt;
ASt := Copy(ASt, Length(FBuffer) + 1, Length(ASt) )+ ' ';
FBuffer := EmptyStr;
SendTextTo(ASt);
KeySound;
AreaPanels.Unselect;
RepaintKeyboardAlpha
end;
procedure TKeyboardContext.AreasDefine;
begin
with FOwner, MainForm do begin
Areas.NullEnable := False;
Border := False;
Add(Panel1, 1, sm_none); Add(Panel2, 2, sm_none);
Add(Panel3, 3, sm_none); Add(Panel4, 4, sm_none);
Add(Panel5, 5, sm_none); Add(Panel6, 6, sm_none);
Add(Panel7, 7, sm_none);
Add(Panel8, 8, sm_none); Add(Panel9, 9, sm_none);
Add(Panel10, 10, sm_none); Add(Panel11, 11, sm_none);
Add(Panel12, 12, sm_none); Add(Panel13, 13, sm_none);
Add(Panel14, 14, sm_none);
Add(Panel15, 15, sm_none); Add(Panel16, 16, sm_none);
Add(Panel17, 17, sm_none); Add(Panel18, 18, sm_none);
Add(Panel19, 19, sm_none); Add(Panel20, 20, sm_none);
Add(Panel21, 21, sm_none);
Add(Panel22, 22, sm_none); Add(Panel23, 23, sm_none);
Add(Panel24, 24, sm_none); Add(Panel25, 25, sm_none);
Add(Panel26, 26, sm_none); Add(Panel27, 27, sm_none);
Add(Panel28, 28, sm_none);
Add(Panel29, 29, sm_none); Add(Panel30, 30, sm_none);
Add(Panel31, 31, sm_none); Add(Panel32, 32, sm_none);
Add(Panel33, 33, sm_none); Add(Panel34, 34, sm_none);
Add(Panel35, 35, sm_none);
Add(Panel36, 36, sm_none); Add(Panel37, 37, sm_none);
Add(Panel38, 38, sm_none); Add(Panel39, 39, sm_none);
Add(Panel40, 40, sm_none); Add(Panel41, 41, sm_none);
Add(Panel42, 42, sm_none); Add(Panel43, 0, sm_none)
//Panel43 only serves as a bias
end;
end;
procedure TKeyboardContext.CleanBuffer;
begin
FLastWord := EmptyStr;
FBuffer := EmptyStr
end;
procedure TKeyboardContext.Context_Keyboard;
begin
FTarget := GetForegroundWindow;
case LeftKeyboard of
True : Context_KeyboardLeft;
else Context_KeyboardRight
end
end;
procedure TKeyboardContext.Context_KeyboardCritik;
begin
Context_KeyboardMain;
KeyboardKind := kk_critik;
with FOwner do begin
BoxUpdate(3, 1, 91200, '', True, sm_blinkback, True);
BoxUpdate(3, 2, 91132, 'COPY', True, sm_blinkback, False);
BoxUpdate(3, 3, 91133, 'CUT', True, sm_blinkback, False);
BoxUpdate(3, 4, 91200, '', True, sm_blinkback, True);
BoxUpdate(3, 5, 91138, '↑', True, sm_blinkback, False);
BoxUpdate(3, 6, 91200, '', True, sm_blinkback, True);
BoxUpdate(4, 1, 91200, '', True, sm_blinkback, True);
BoxUpdate(4, 2, 91134, 'PASTE', True, sm_blinkback, False);
BoxUpdate(4, 4, 91139, '←', True, sm_blinkback, False);
BoxUpdate(4, 3, 91135, 'CANCEL', True, sm_blinkback, False);
BoxUpdate(4, 5, 91143, 'ESCAPE', True, sm_blinkback, False);
BoxUpdate(4, 6, 91141, '→', True, sm_blinkback, False);