From 06faf2aa88658c9c943fe2899f5a9c7978fd9aaf Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Sun, 20 Mar 2016 10:58:29 +0000 Subject: [PATCH] Added Tail wheel lock, Water rudder and Float functions Improved search functionality --- G940LEDControl/Forms/ButtonFunctionFrm.dfm | 26 ++-- G940LEDControl/Forms/ButtonFunctionFrm.pas | 112 ++++++++++++++---- G940LEDControl/G940LEDControl.dproj | 9 +- G940LEDControl/G940LEDControl.res | Bin 28540 -> 28540 bytes G940LEDControl/Units/FSXLEDFunction.pas | 104 ++++++++++++++-- .../Units/FSXLEDFunctionProvider.pas | 4 + G940LEDControl/Units/FSXLEDFunctionWorker.pas | 96 +++++++++++++++ G940LEDControl/Units/FSXResources.pas | 38 ++++++ 8 files changed, 347 insertions(+), 42 deletions(-) diff --git a/G940LEDControl/Forms/ButtonFunctionFrm.dfm b/G940LEDControl/Forms/ButtonFunctionFrm.dfm index eddd84b..68959e6 100644 --- a/G940LEDControl/Forms/ButtonFunctionFrm.dfm +++ b/G940LEDControl/Forms/ButtonFunctionFrm.dfm @@ -13,10 +13,14 @@ object ButtonFunctionForm: TButtonFunctionForm Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] + KeyPreview = True OldCreateOrder = False Position = poMainFormCenter OnCreate = FormCreate OnDestroy = FormDestroy + OnKeyDown = FormKeyDown + OnKeyPress = FormKeyPress + OnShow = FormShow PixelsPerInch = 96 TextHeight = 13 object bvlHeader: TBevel @@ -69,7 +73,6 @@ object ButtonFunctionForm: TButtonFunctionForm Width = 75 Height = 25 Anchors = [akTop, akRight] - Cancel = True Caption = 'Cancel' ModalResult = 2 TabOrder = 1 @@ -240,9 +243,6 @@ object ButtonFunctionForm: TButtonFunctionForm Align = alLeft BevelOuter = bvNone TabOrder = 3 - ExplicitLeft = 265 - ExplicitTop = 52 - ExplicitHeight = 458 object vstFunctions: TVirtualStringTree Left = 0 Top = 29 @@ -266,8 +266,6 @@ object ButtonFunctionForm: TButtonFunctionForm OnGetText = vstFunctionsGetText OnPaintText = vstFunctionsPaintText OnIncrementalSearch = vstFunctionsIncrementalSearch - ExplicitTop = 8 - ExplicitHeight = 450 Columns = < item Position = 0 @@ -294,13 +292,21 @@ object ButtonFunctionForm: TButtonFunctionForm Font.Style = [] ParentFont = False TabOrder = 0 - Text = 'Search...' + Text = 'Search (Ctrl+F)...' OnChange = edtSearchChange OnEnter = edtSearchEnter OnExit = edtSearchExit - ExplicitLeft = 72 - ExplicitTop = 216 - ExplicitWidth = 121 + OnKeyDown = edtSearchKeyDown + OnKeyUp = edtSearchKeyUp + end + end + object ActionList: TActionList + Left = 40 + Top = 136 + object actSearch: TAction + Caption = 'actSearch' + ShortCut = 16454 + OnExecute = actSearchExecute end end end diff --git a/G940LEDControl/Forms/ButtonFunctionFrm.pas b/G940LEDControl/Forms/ButtonFunctionFrm.pas index 495691a..f1f7f10 100644 --- a/G940LEDControl/Forms/ButtonFunctionFrm.pas +++ b/G940LEDControl/Forms/ButtonFunctionFrm.pas @@ -16,7 +16,7 @@ uses LEDColorIntf, LEDFunctionIntf, LEDStateIntf, - Profile; + Profile, Vcl.ActnList; type @@ -45,17 +45,25 @@ type bvlFooter: TBevel; pnlFunctions: TPanel; edtSearch: TEdit; + ActionList: TActionList; + actSearch: TAction; - procedure FormCreate(Sender: TObject); - procedure FormDestroy(Sender: TObject); - procedure vstFunctionsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string); - procedure vstFunctionsPaintText(Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType); - procedure vstFunctionsFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex); - procedure vstFunctionsIncrementalSearch(Sender: TBaseVirtualTree; Node: PVirtualNode; const SearchText: string; var Result: Integer); + procedure actSearchExecute(Sender: TObject); procedure btnOKClick(Sender: TObject); procedure edtSearchChange(Sender: TObject); procedure edtSearchEnter(Sender: TObject); procedure edtSearchExit(Sender: TObject); + procedure edtSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure edtSearchKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure FormKeyPress(Sender: TObject; var Key: Char); + procedure FormShow(Sender: TObject); + procedure vstFunctionsFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex); + procedure vstFunctionsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string); + procedure vstFunctionsIncrementalSearch(Sender: TBaseVirtualTree; Node: PVirtualNode; const SearchText: string; var Result: Integer); + procedure vstFunctionsPaintText(Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType); private FProfile: TProfile; FButtonIndex: Integer; @@ -70,6 +78,7 @@ type procedure LoadFunctions; procedure ApplyFilter(const AFilter: string); + procedure EnsureSelection; procedure SetFunction(AProvider: ILEDFunctionProvider; AFunction: ILEDFunction); procedure LoadStates(AProvider: ILEDFunctionProvider; AFunction: ILEDMultiStateFunction); @@ -172,6 +181,31 @@ begin end; +procedure TButtonFunctionForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); +begin + if Key = VK_ESCAPE then + begin + if (ActiveControl = edtSearch) and (Length(Trim(edtSearch.Text)) > 0) then + edtSearch.Text := '' + else + ModalResult := mrCancel; + end; +end; + + +procedure TButtonFunctionForm.FormKeyPress(Sender: TObject; var Key: Char); +begin + if Key = Chr(VK_ESCAPE) then + Key := #0; +end; + + +procedure TButtonFunctionForm.FormShow(Sender: TObject); +begin + ActiveControl := vstFunctions; +end; + + procedure TButtonFunctionForm.LoadFunctions; var categoryNodes: TDictionary; @@ -227,12 +261,17 @@ begin nodeData^.LEDFunction := ledFunction; if isCurrentProvider and Assigned(CurrentFunction) and (ledFunction.GetUID = CurrentFunction.GetUID) then + begin + vstFunctions.FocusedNode := node; vstFunctions.Selected[node] := True; + end; end; end; finally FreeAndNil(categoryNodes); end; + + EnsureSelection; finally vstFunctions.EndUpdate; end; @@ -262,32 +301,47 @@ begin begin nodeData := vstFunctions.GetNodeData(functionNode); if nodeData^.NodeType = ntFunction then - begin - if hasFilter and (not ContainsText(nodeData^.LEDFunction.GetDisplayName, AFilter)) then - Exclude(functionNode^.States, vsVisible) - else - Include(functionNode^.States, vsVisible); - end; + vstFunctions.IsVisible[functionNode] := (not hasFilter) or ContainsText(nodeData^.LEDFunction.GetDisplayName, AFilter); - if vsVisible in functionNode^.States then + if vstFunctions.IsVisible[functionNode] then hasVisibleChildren := True; functionNode := vstFunctions.GetNextSibling(functionNode); end; - if hasVisibleChildren then - Include(categoryNode^.States, vsVisible) - else - Exclude(categoryNode^.States, vsVisible); - + vstFunctions.IsVisible[categoryNode] := hasVisibleChildren; categoryNode := vstFunctions.GetNextSibling(categoryNode); end; + + EnsureSelection; finally vstFunctions.EndUpdate; end; end; +procedure TButtonFunctionForm.EnsureSelection; +begin + if (not Assigned(vstFunctions.FocusedNode)) or + (not vstFunctions.IsVisible[vstFunctions.FocusedNode]) then + begin + vstFunctions.FocusedNode := vstFunctions.IterateSubtree(nil, + procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Data: Pointer; var Abort: Boolean) + begin + Abort := (PFunctionNodeData(Sender.GetNodeData(Node))^.NodeType = ntFunction); + end, + nil, + [vsVisible]); + + if Assigned(vstFunctions.FocusedNode) then + vstFunctions.Selected[vstFunctions.FocusedNode] := True; + end; + + if Assigned(vstFunctions.FocusedNode) then + vstFunctions.ScrollIntoView(vstFunctions.FocusedNode, False); +end; + + procedure TButtonFunctionForm.SetFunction(AProvider: ILEDFunctionProvider; AFunction: ILEDFunction); var multiStateFunction: ILEDMultiStateFunction; @@ -427,6 +481,12 @@ begin end; +procedure TButtonFunctionForm.actSearchExecute(Sender: TObject); +begin + ActiveControl := edtSearch; +end; + + procedure TButtonFunctionForm.btnOKClick(Sender: TObject); var multiStateFunction: ILEDMultiStateFunction; @@ -557,13 +617,25 @@ begin if Length(Trim(edtSearch.Text)) = 0 then begin edtSearch.Tag := 1; - edtSearch.Text := 'Search...'; + edtSearch.Text := 'Search (Ctrl+F)...'; edtSearch.Font.Color := clGrayText; end else edtSearch.Tag := 0; end; +procedure TButtonFunctionForm.edtSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); +begin + if (Key in [VK_UP, VK_DOWN]) and (Shift = []) then + SendMessage(vstFunctions.Handle, WM_KEYDOWN, Key, 0); +end; + + +procedure TButtonFunctionForm.edtSearchKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); +begin + if (Key in [VK_UP, VK_DOWN]) and (Shift = []) then + SendMessage(vstFunctions.Handle, WM_KEYUP, Key, 0); +end; { TStateControlInfo } constructor TStateControlInfo.Create(AState: ILEDState; AStateLabel: TLabel; AComboBox: TComboBox); diff --git a/G940LEDControl/G940LEDControl.dproj b/G940LEDControl/G940LEDControl.dproj index 5fe4868..08594ef 100644 --- a/G940LEDControl/G940LEDControl.dproj +++ b/G940LEDControl/G940LEDControl.dproj @@ -8,7 +8,7 @@ VCL 13.4 True - Debug + Release Win32 1 Application @@ -49,7 +49,8 @@ true - 4 + 1 + 5 1 rtl;dbrtl;$(DCC_UsePackage) Lib @@ -59,7 +60,7 @@ None G940LEDControl_Icon.ico Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;System.Win;$(DCC_Namespace) - CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.1.4.0;InternalName=;LegalCopyright=© 2011 - 2015 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.1;Comments= + CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.1.5.1;InternalName=;LegalCopyright=© 2011 - 2015 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.1;Comments= 1033 @@ -67,6 +68,7 @@ $(BDS)\bin\default_app.manifest + CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.1.5.1;InternalName=;LegalCopyright=© 2011 - 2016 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.1;Comments= false false false @@ -81,6 +83,7 @@ RELEASE;$(DCC_Define) + CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.1.5.1;InternalName=;LegalCopyright=© 2011 - 2016 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.1;Comments= $(BDS)\bin\default_app.manifest diff --git a/G940LEDControl/G940LEDControl.res b/G940LEDControl/G940LEDControl.res index 71877325e97dff5098f178d85a588d412fa4192d..6590ad1f67e14e5b40feea75019c7e9934c4bf55 100644 GIT binary patch delta 33 pcmex!kMYkv#t9|Nj0~(B%Xt}DO&RnU3@3Lo+B2GMKFPQ_7XZi33c~;Z delta 33 pcmex!kMYkv#t9|N3=AwA%Xt}DO&IhT3?_Fn+B2GNKFPQ_7XZh83cdgU diff --git a/G940LEDControl/Units/FSXLEDFunction.pas b/G940LEDControl/Units/FSXLEDFunction.pas index c30c565..6332825 100644 --- a/G940LEDControl/Units/FSXLEDFunction.pas +++ b/G940LEDControl/Units/FSXLEDFunction.pas @@ -107,6 +107,27 @@ type function GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; override; end; + TFSXTailWheelLockFunction = class(TCustomFSXSystemsFunction) + protected + procedure RegisterStates; override; + function GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; override; + end; + + TFSXCustomFloatFunction = class(TCustomFSXSystemsFunction) + protected + procedure RegisterStates; override; + end; + + TFSXFloatLeftFunction = class(TFSXCustomFloatFunction) + protected + function GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; override; + end; + + TFSXFloatRightFunction = class(TFSXCustomFloatFunction) + protected + function GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; override; + end; + { Instruments } TFSXPitotOnOffFunction = class(TCustomFSXOnOffFunction) @@ -183,6 +204,13 @@ type function GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; override; end; + TFSXWaterRudderFunction = class(TCustomFSXFunction) + protected + function GetCategoryName: string; override; + procedure RegisterStates; override; + function GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; override; + end; + { Lights } TCustomFSXLightFunction = class(TCustomFSXOnOffFunction) @@ -535,6 +563,43 @@ begin end; +{ TFSXTailWheelLockFunction } +procedure TFSXTailWheelLockFunction.RegisterStates; +begin + RegisterState(TLEDState.Create(FSXStateUIDTailWheelLocked, FSXStateDisplayNameTailWheelLocked, lcGreen)); + RegisterState(TLEDState.Create(FSXStateUIDTailWheelUnlocked, FSXStateDisplayNameTailWheelUnlocked, lcRed)); +end; + + +function TFSXTailWheelLockFunction.GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; +begin + Result := TFSXTailWheelLockFunctionWorker; +end; + + +{ TFSXCustomFloatFunction } +procedure TFSXCustomFloatFunction.RegisterStates; +begin + RegisterState(TLEDState.Create(FSXStateUIDFloatRetracted, FSXStateDisplayNameFloatRetracted, lcRed)); + RegisterState(TLEDState.Create(FSXStateUIDFloatBetween, FSXStateDisplayNameFloatBetween, lcAmber)); + RegisterState(TLEDState.Create(FSXStateUIDFloatExtended, FSXStateDisplayNameFloatExtended, lcGreen)); +end; + + +{ TFSXFloatLeftFunction } +function TFSXFloatLeftFunction.GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; +begin + Result := TFSXFloatLeftFunctionWorker; +end; + + +{ TFSXFloatRightFunction } +function TFSXFloatRightFunction.GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; +begin + Result := TFSXFloatRightFunctionWorker; +end; + + { TFSXPitotOnOffFunction } function TFSXPitotOnOffFunction.GetCategoryName: string; begin @@ -557,17 +622,17 @@ end; procedure TFSXPitotWarningFunction.RegisterStates; begin - RegisterState(TLEDState.Create(FSXStateUIDPitotOffIceNone, FSXStateDisplayNamePitotOffIceNone, lcRed)); - RegisterState(TLEDState.Create(FSXStateUIDPitotOffIce25to50, FSXStateDisplayNamePitotOffIce25to50, lcFlashingAmberNormal)); - RegisterState(TLEDState.Create(FSXStateUIDPitotOffIce50to75, FSXStateDisplayNamePitotOffIce50to75, lcFlashingAmberFast)); + RegisterState(TLEDState.Create(FSXStateUIDPitotOffIceNone, FSXStateDisplayNamePitotOffIceNone, lcRed)); + RegisterState(TLEDState.Create(FSXStateUIDPitotOffIce25to50, FSXStateDisplayNamePitotOffIce25to50, lcFlashingAmberNormal)); + RegisterState(TLEDState.Create(FSXStateUIDPitotOffIce50to75, FSXStateDisplayNamePitotOffIce50to75, lcFlashingAmberFast)); RegisterState(TLEDState.Create(FSXStateUIDPitotOffIce75to100, FSXStateDisplayNamePitotOffIce75to100, lcFlashingAmberFast)); - RegisterState(TLEDState.Create(FSXStateUIDPitotOffIceFull, FSXStateDisplayNamePitotOffIceFull, lcFlashingRedFast)); + RegisterState(TLEDState.Create(FSXStateUIDPitotOffIceFull, FSXStateDisplayNamePitotOffIceFull, lcFlashingRedFast)); - RegisterState(TLEDState.Create(FSXStateUIDPitotOnIceFull, FSXStateDisplayNamePitotOnIceFull, lcFlashingRedNormal)); - RegisterState(TLEDState.Create(FSXStateUIDPitotOnIce75to100, FSXStateDisplayNamePitotOnIce75to100, lcAmber)); - RegisterState(TLEDState.Create(FSXStateUIDPitotOnIce50to75, FSXStateDisplayNamePitotOnIce50to75, lcAmber)); - RegisterState(TLEDState.Create(FSXStateUIDPitotOnIce25to50, FSXStateDisplayNamePitotOnIce25to50, lcAmber)); - RegisterState(TLEDState.Create(FSXStateUIDPitotOnIceNone, FSXStateDisplayNamePitotOnIceNone, lcGreen)); + RegisterState(TLEDState.Create(FSXStateUIDPitotOnIceFull, FSXStateDisplayNamePitotOnIceFull, lcFlashingRedNormal)); + RegisterState(TLEDState.Create(FSXStateUIDPitotOnIce75to100, FSXStateDisplayNamePitotOnIce75to100, lcAmber)); + RegisterState(TLEDState.Create(FSXStateUIDPitotOnIce50to75, FSXStateDisplayNamePitotOnIce50to75, lcAmber)); + RegisterState(TLEDState.Create(FSXStateUIDPitotOnIce25to50, FSXStateDisplayNamePitotOnIce25to50, lcAmber)); + RegisterState(TLEDState.Create(FSXStateUIDPitotOnIceNone, FSXStateDisplayNamePitotOnIceNone, lcGreen)); end; @@ -769,6 +834,27 @@ begin end; +{ TFSXWaterRudderFunction } +function TFSXWaterRudderFunction.GetCategoryName: string; +begin + Result := FSXCategoryControlSurfaces; +end; + + +procedure TFSXWaterRudderFunction.RegisterStates; +begin + RegisterState(TLEDState.Create(FSXStateUIDWaterRudderRetracted, FSXStateDisplayNameWaterRudderRetracted, lcGreen)); + RegisterState(TLEDState.Create(FSXStateUIDWaterRudderBetween, FSXStateDisplayNameWaterRudderBetween, lcAmber)); + RegisterState(TLEDState.Create(FSXStateUIDWaterRudderExtended, FSXStateDisplayNameWaterRudderExtended, lcRed)); +end; + + +function TFSXWaterRudderFunction.GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; +begin + Result := TFSXWaterRudderFunctionWorker; +end; + + { TFSXLightFunction } function TCustomFSXLightFunction.GetCategoryName: string; begin diff --git a/G940LEDControl/Units/FSXLEDFunctionProvider.pas b/G940LEDControl/Units/FSXLEDFunctionProvider.pas index c7495bc..51c2251 100644 --- a/G940LEDControl/Units/FSXLEDFunctionProvider.pas +++ b/G940LEDControl/Units/FSXLEDFunctionProvider.pas @@ -144,6 +144,9 @@ begin RegisterFunction(TFSXAutoBrakeFunction.Create( Self, FSXFunctionDisplayNameAutoBrake, FSXFunctionUIDAutoBrake)); RegisterFunction(TFSXPressDumpSwitchFunction.Create( Self, FSXFunctionDisplayNamePressDumpSwitch, FSXFunctionUIDPressDumpSwitch)); RegisterFunction(TFSXTailHookFunction.Create( Self, FSXFunctionDisplayNameTailHook, FSXFunctionUIDTailHook)); + RegisterFunction(TFSXTailWheelLockFunction.Create( Self, FSXFunctionDisplayNameTailWheelLock, FSXFunctionUIDTailWheelLock)); + RegisterFunction(TFSXFloatLeftFunction.Create( Self, FSXFunctionDisplayNameFloatLeft, FSXFunctionUIDFloatLeft)); + RegisterFunction(TFSXFloatRightFunction.Create( Self, FSXFunctionDisplayNameFloatRight, FSXFunctionUIDFloatRight)); { Instruments } RegisterFunction(TFSXPitotOnOffFunction.Create( Self, FSXFunctionDisplayNamePitotOnOff, FSXFunctionUIDPitotOnOff)); @@ -160,6 +163,7 @@ begin RegisterFunction(TFSXFlapsHandlePercentageFunction.Create(Self, FSXFunctionDisplayNameFlapsHandlePercentage, FSXFunctionUIDFlapsHandlePercentage)); RegisterFunction(TFSXSpoilersFunction.Create( Self, FSXFunctionDisplayNameSpoilers, FSXFunctionUIDSpoilers)); RegisterFunction(TFSXSpoilersArmedFunction.Create( Self, FSXFunctionDisplayNameSpoilersArmed, FSXFunctionUIDSpoilersArmed)); + RegisterFunction(TFSXWaterRudderFunction.Create( Self, FSXFunctionDisplayNameWaterRudder, FSXFunctionUIDWaterRudder)); { Lights } RegisterFunction(TFSXBeaconLightsFunction.Create( Self, FSXFunctionDisplayNameBeaconLights, FSXFunctionUIDBeaconLights)); diff --git a/G940LEDControl/Units/FSXLEDFunctionWorker.pas b/G940LEDControl/Units/FSXLEDFunctionWorker.pas index 5f77390..d401ccd 100644 --- a/G940LEDControl/Units/FSXLEDFunctionWorker.pas +++ b/G940LEDControl/Units/FSXLEDFunctionWorker.pas @@ -68,6 +68,26 @@ type procedure HandleData(AData: Pointer); override; end; + TFSXTailWheelLockFunctionWorker = class(TCustomFSXOnOffFunctionWorker) + protected + procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override; + end; + + TFSXCustomFloatFunctionWorker = class(TCustomFSXFunctionWorker) + protected + procedure HandleData(AData: Pointer); override; + end; + + TFSXFloatLeftFunctionWorker = class(TFSXCustomFloatFunctionWorker) + protected + procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override; + end; + + TFSXFloatRightFunctionWorker = class(TFSXCustomFloatFunctionWorker) + protected + procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override; + end; + { Instruments } TFSXPitotOnOffFunctionWorker = class(TCustomFSXOnOffFunctionWorker) @@ -133,6 +153,12 @@ type procedure HandleData(AData: Pointer); override; end; + TFSXWaterRudderFunctionWorker = class(TCustomFSXFunctionWorker) + protected + procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override; + procedure HandleData(AData: Pointer); override; + end; + { Lights } TFSXLightStatesFunctionWorker = class(TCustomFSXFunctionWorker) @@ -342,6 +368,42 @@ begin end; +{ TFSXCustomFloatFunctionWorker } +procedure TFSXCustomFloatFunctionWorker.HandleData(AData: Pointer); +type + PFloatData = ^TFloatData; + TFloatData = packed record + PercentageExtended: Double; + end; + +var + floatData: PFloatData; + +begin + floatData := AData; + + case Trunc(floatData^.PercentageExtended) of + 0: SetCurrentState(FSXStateUIDFloatRetracted); + 95..100: SetCurrentState(FSXStateUIDFloatExtended); + else SetCurrentState(FSXStateUIDFloatBetween); + end; +end; + + +{ TFSXFloatLeftFunctionWorker } +procedure TFSXFloatLeftFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); +begin + ADefinition.AddVariable('RETRACT LEFT FLOAT EXTENDED', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); +end; + + +{ TFSXFloatRightFunctionWorker } +procedure TFSXFloatRightFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); +begin + ADefinition.AddVariable('RETRACT RIGHT FLOAT EXTENDED', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); +end; + + { TFSXParkingBrakeFunctionWorker } procedure TFSXParkingBrakeFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin @@ -403,6 +465,13 @@ begin end; +{ TFSXTailWheelLockFunctionWorker } +procedure TFSXTailWheelLockFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); +begin + ADefinition.AddVariable('TAILWHEEL LOCK ON', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); +end; + + { TFSXPitotOnOffFunctionWorker } procedure TFSXPitotOnOffFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin @@ -826,6 +895,33 @@ begin end; +{ TFSXWaterRudderFunctionWorker } +procedure TFSXWaterRudderFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); +begin + ADefinition.AddVariable('WATER RUDDER HANDLE POSITION', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); +end; + + +procedure TFSXWaterRudderFunctionWorker.HandleData(AData: Pointer); +type + PWaterRudderData = ^TWaterRudderData; + TWaterRudderData = packed record + WaterRudderHandlePercent: Double; + end; + +var + waterRudderData: PWaterRudderData; + +begin + waterRudderData := AData; + + case Trunc(WaterRudderData^.WaterRudderHandlePercent) of + 0..5: SetCurrentState(FSXStateUIDWaterRudderRetracted); + 95..100: SetCurrentState(FSXStateUIDWaterRudderExtended); + else SetCurrentState(FSXStateUIDWaterRudderBetween); + end; +end; + { TFSXLightStatesFunctionWorker } procedure TFSXLightStatesFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); diff --git a/G940LEDControl/Units/FSXResources.pas b/G940LEDControl/Units/FSXResources.pas index 0202250..34b8ced 100644 --- a/G940LEDControl/Units/FSXResources.pas +++ b/G940LEDControl/Units/FSXResources.pas @@ -75,6 +75,22 @@ const FSXStateDisplayNameGearSpeedExceeded = 'Speed exceeded'; FSXStateDisplayNameGearDamageBySpeed = 'Damage by speed'; + + FSXFunctionUIDFloatLeft = 'floatLeft'; + FSXFunctionDisplayNameFloatLeft = 'Float (left)'; + + FSXStateUIDFloatRetracted = 'retracted'; + FSXStateUIDFloatBetween = 'between'; + FSXStateUIDFloatExtended = 'extended'; + + FSXStateDisplayNameFloatRetracted = 'Retracted'; + FSXStateDisplayNameFloatBetween = 'Extending / retracting'; + FSXStateDisplayNameFloatExtended = 'Extended'; + + FSXFunctionUIDFloatRight = 'floatRight'; + FSXFunctionDisplayNameFloatRight = 'Float (right)'; + + FSXFunctionUIDLeftGear = 'leftGear'; FSXFunctionDisplayNameLeftGear = 'Left main landing gear'; @@ -141,6 +157,16 @@ const FSXStateDisplayNameTailHookExtended = 'Extended'; + FSXFunctionUIDTailWheelLock = 'tailWheelLock'; + FSXFunctionDisplayNameTailWheelLock = 'Tail wheel lock'; + + FSXStateUIDTailWheelUnlocked = FSXStateUIDOff; + FSXStateUIDTailWheelLocked = FSXStateUIDOn; + + FSXStateDisplayNameTailWheelUnlocked = 'Unlocked'; + FSXStateDisplayNameTailWheelLocked = 'Locked'; + + FSXFunctionUIDFlaps = 'flaps'; FSXFunctionDisplayNameFlaps = 'Flaps'; @@ -225,6 +251,18 @@ const FSXStateDisplayNameSpoilersExtended = 'Extended'; + FSXFunctionUIDWaterRudder = 'waterRudder'; + FSXFunctionDisplayNameWaterRudder = 'Water rudder'; + + FSXStateUIDWaterRudderRetracted = 'retracted'; + FSXStateUIDWaterRudderBetween = 'between'; + FSXStateUIDWaterRudderExtended = 'extended'; + + FSXStateDisplayNameWaterRudderRetracted = 'Retracted'; + FSXStateDisplayNameWaterRudderBetween = 'Extending / retracting'; + FSXStateDisplayNameWaterRudderExtended = 'Extended'; + + FSXFunctionUIDBatteryMaster = 'batteryMaster'; FSXFunctionDisplayNameBatteryMaster = 'Battery master';