VR-Engage  2.2
Loading...
Searching...
No Matches
vreFwlJoyController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreFwlJoyController.h
7//! \ingroup vreVrfRtd
8//! \brief Fixed-wing joystick controller for VREngage
9//!
10//! This file defines the DtVreFwlJoyController class, which manages joystick
11//! input for fixed-wing aircraft in VREngage and converts it into appropriate
12//! control surface movements.
13
14#pragma once
15
17
20
21class DtBooleanOutputPort;
22class DtIntegerOutputPort;
23class DtAnalogOutputPort;
24
25namespace makVrf
26{
27class DtArticulatedPartStateRepository;
28}
29
30
31namespace FwlCgfVrf
32{
34
35//! \brief Type string for VREngage fixed-wing joystick controller component
36//!
37//! Constant used to identify this component type in the simulation system.
38const char TS_JoyController[] = "fixedwinglib-cgf-vr-engage-joy-controller";
39//! \brief Fixed-wing joystick controller for VREngage
40//!
41//! This class manages joystick input for fixed-wing aircraft and converts
42//! it into appropriate control surface movements. It handles various input
43//! devices and maps their values to aircraft control ports, providing a bridge
44//! between the physical joystick and the aircraft flight model.
45class RTD_VRF_BACKEND_PLUGIN_EXPORT DtVreFwlJoyController : public makVre::DtFixedWingJoyFlightController,
47{
48public:
49 //! \brief Constructor
50 //! \param name The name of the component
51 //! \param owner The local object this component belongs to
52 //! \param simManager The simulation services manager
53 //! \param desc Component descriptor containing configuration
54 //! \param parentRegistry Parent registry for reader/writer functionality
55 //!
56 //! Initializes a new fixed-wing joystick controller component for VREngage control.
57 DtVreFwlJoyController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
58 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
59
60 //! \brief Virtual destructor
61 //!
62 //! Cleans up resources used by the joystick controller component.
63 virtual ~DtVreFwlJoyController() override;
64
65 //! \brief Initializes the joystick controller
66 //! \return True if initialization was successful
67 //!
68 //! Performs initial setup of the joystick controller, including configuration
69 //! loading and port initialization.
70 virtual bool init() override;
71
72 //! \brief Performs per-frame processing
73 //!
74 //! Called once per simulation frame to calculate new control values
75 //! based on current joystick input and update the output ports.
76 virtual void tick() override;
77
78 //! \brief Calculates and sets port values for a specific joystick function
79 //! \param functionGroup The function group of the joystick input
80 //! \param function The specific function within the group
81 //! \param value The input value from the joystick
82 //! \param repeat Whether this is a repeated input
83 //!
84 //! Maps joystick inputs to the appropriate aircraft control outputs.
86 const DtString& functionGroup, const DtString& function, double value, bool repeat) override;
87
88 //! \brief Creates component ports
89 //! \return True if port creation was successful
90 //!
91 //! Creates output ports for stick, pedals, throttle, landing gear,
92 //! flaps, and other aircraft controls.
93 virtual bool createPorts() override;
94
95 //! \brief Gets the component type
96 //! \return The type string for this component
97 //!
98 //! Returns TS_JoyController as the component type identifier.
99 virtual const char* type() const override;
100
101 //! \brief Disables the joystick controller
102 //!
103 //! Disables joystick input processing, usually when player
104 //! control is deactivated.
105 virtual void disable() override;
106
107 //! \brief Enables the joystick controller
108 //!
109 //! Enables joystick input processing, usually when player
110 //! control is activated.
111 virtual void enable() override;
112
113 //! \brief Sets the enabled state of the joystick controller
114 //! \param yes True to enable the controller, false to disable
115 //!
116 //! Directly sets the enabled state of the joystick controller.
117 virtual void setIsEnabled(bool yes) override;
118
119 //! \brief Component factory function
120 //! \param name The name for the new component
121 //! \param owner The local object the component will belong to
122 //! \param simManager The simulation services manager
123 //! \param desc Component descriptor containing configuration
124 //! \param parentRegistry Parent registry for reader/writer functionality
125 //! \return Pointer to the newly created component
126 //!
127 //! Static factory function used for component creation through the component registry.
128 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
129 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
130
131private:
132 //! \brief Copy constructor (not implemented)
133 //! \param orig The source object
135
136 //! \brief Assignment operator (not implemented)
137 //! \param orig The source object
138 //! \return Reference to this object
140
141 //! \brief Component descriptor containing configuration parameters
143
144 //! \brief Output port for landing gear control
145 DtBooleanOutputPort* myLandingGearOutputPort;
146
147 //! \brief Output port for flap setting
148 DtIntegerOutputPort* myFlapSettingOutputPort;
149
150 //! \brief Output port for air brake control
151 DtAnalogOutputPort* myAirBrakeOutputPort;
152
153 //! \brief Output port for wheel brake control
154 DtAnalogOutputPort* myWheelBrakeOutputPort;
155
156 //! \brief Flag tracking whether landing gear state has changed
158
159 //! \brief Output port for control stick (pitch/roll)
160 DtConstrainedDualAxisAnalogOutputPort* myStickOutputPort;
161
162 //! \brief Output port for rudder pedals (yaw)
163 DtConstrainedAnalogOutputPort* myPedalOutputPort;
164
165 //! \brief Output port for throttle control
166 DtConstrainedAnalogOutputPort* myThrottleOutputPort;
167
168 //! \brief State repository for X-axis articulation
169 makVrf::DtArticulatedPartStateRepository* myXPartRep;
170
171 //! \brief State repository for Y-axis articulation
172 makVrf::DtArticulatedPartStateRepository* myYPartRep;
173};
174
175} // namespace FwlCgfVrf
Fixed-wing joystick controller descriptor for VREngage.
Definition vreFwlJoyControllerDescriptor.h:32
DtAnalogOutputPort * myWheelBrakeOutputPort
Output port for wheel brake control.
Definition vreFwlJoyController.h:154
DtBooleanOutputPort * myLandingGearOutputPort
Output port for landing gear control.
Definition vreFwlJoyController.h:145
virtual bool createPorts() override
Creates component ports.
makVrf::DtArticulatedPartStateRepository * myYPartRep
State repository for Y-axis articulation.
Definition vreFwlJoyController.h:172
DtVreFwlJoyController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
DtConstrainedAnalogOutputPort * myPedalOutputPort
Output port for rudder pedals (yaw)
Definition vreFwlJoyController.h:163
DtAnalogOutputPort * myAirBrakeOutputPort
Output port for air brake control.
Definition vreFwlJoyController.h:151
const DtVreFwlJoyControllerDescriptor * myDesc
Component descriptor containing configuration parameters.
Definition vreFwlJoyController.h:142
bool myLandingGearStateChanged
Flag tracking whether landing gear state has changed.
Definition vreFwlJoyController.h:157
virtual void tick() override
Performs per-frame processing.
DtIntegerOutputPort * myFlapSettingOutputPort
Output port for flap setting.
Definition vreFwlJoyController.h:148
makVrf::DtArticulatedPartStateRepository * myXPartRep
State repository for X-axis articulation.
Definition vreFwlJoyController.h:169
virtual ~DtVreFwlJoyController() override
Virtual destructor.
virtual void disable() override
Disables the joystick controller.
virtual const char * type() const override
Gets the component type.
DtConstrainedAnalogOutputPort * myThrottleOutputPort
Output port for throttle control.
Definition vreFwlJoyController.h:166
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Component factory function.
virtual void calcAndSetPortValues(const DtString &functionGroup, const DtString &function, double value, bool repeat) override
Calculates and sets port values for a specific joystick function.
DtVreFwlJoyController & operator=(const DtVreFwlJoyController &orig)
Assignment operator (not implemented)
virtual void setIsEnabled(bool yes) override
Sets the enabled state of the joystick controller.
virtual bool init() override
Initializes the joystick controller.
DtVreFwlJoyController(const DtVreFwlJoyController &orig)
Copy constructor (not implemented)
virtual void enable() override
Enables the joystick controller.
DtConstrainedDualAxisAnalogOutputPort * myStickOutputPort
Output port for control stick (pitch/roll)
Definition vreFwlJoyController.h:160
Controller for joystick control of fixed wing aircraft.
Definition fixedWingJoyFlightController.h:38
Extension trait for joystick controllers in VREngage.
Definition vreRtdTraitJoyControllerExtension.h:28
Joystick controller for fixed-wing aircraft entities.
Definition vreFwlActuator.h:35
const char TS_JoyController[]
Type string for VREngage fixed-wing joystick controller component.
Definition vreFwlJoyController.h:38
Definition connectorAccessory.h:39
Common definitions for the RTD backend library.
Extension trait for joystick controllers in VREngage.