VR-Engage  2.2
Loading...
Searching...
No Matches
commanderControlLogic.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file commanderControlLogic.h
7//! \brief Defines the DtCommanderControlLogic component for controlling commander sensor systems.
8//!
9//! This component provides functionality for orienting and controlling sensor systems used by
10//! vehicle commanders, including azimuth, elevation, zoom, and sensor mode switching capabilities.
11//!
12//! \ingroup vreCommonComponents
13
14#pragma once
15
17
19
20namespace makVre
21{
23{
24//! \ingroup RoleConfigParams
25//! \defgroup CommanderControlLogicRoleParams Commander Control Logic Role Parameters
26//! \roleInherits{EntityControlLogicRoleParams}
27//! Configuration Options for commander control logic role.
28//! @{
29
30//! \vreRoleParam{enableZoom,bool,false,commanderControlLogic,Determines whether zoom functionality is available in out the hatch mode.}
31constexpr const char* enableZoom = "enableZoom";
32
33//! \vreRoleParam{maxZoom,double,32.0,commanderControlLogic,Maximum allowable zoom magnification level for the sensor system.}
34constexpr const char* maxZoom = "maxZoom";
35
36//! \vreRoleParam{minZoom,double,1.0,commanderControlLogic,Minimum allowable zoom magnification level for the sensor system.}
37constexpr const char* minZoom = "minZoom";
38
39//! \vreRoleParam{outTheHatchMode,bool,false,commanderControlLogic,Enables out the hatch mode where sensor control directly affects observer view rather than sending joystick messages.}
40constexpr const char* outTheHatchMode = "outTheHatchMode";
41
42//! @}
43} // namespace CommanderControlLogicConfig
44
45//! \brief Type identifier for DtCommanderControlLogic component
46constexpr const char* DtCommanderControlLogicType = "DtCommanderControlLogic";
47
48//! \brief Component for controlling commander sensor systems in vehicles
49//!
50//! The DtCommanderControlLogic provides control functionality for vehicle commander
51//! sensor systems, supporting orientation in azimuth and elevation, zoom control,
52//! and the ability to switch between different sensor modes (e.g., IR, NVG, visual).
53//!
54//! Input handler details (for configuring in an SMS input configuration file):
55//!
56//! This class has the following input handler functions that may be configured
57//! to map to input devices in role input configuration files:
58//! - "sensor-azimuth": Controls horizontal rotation of the sensor
59//! - "sensor-elevation": Controls vertical tilt of the sensor
60//! - "sensor-zoom-in": Increases sensor magnification
61//! - "sensor-zoom-out": Decreases sensor magnification
62//! - "sensor-zoom": Combined zoom in/out based on positive/negative values
63//! - "next-sensor": Cycles through available sensor modes
64//!
65//! The group name is provided in the role configuration file and is used to
66//! distinguish input handlers when multiple handlers are present on the entity.
68{
69public:
70 //! \brief Constructor for DtCommanderControlLogic
71 //!
72 //! Initializes the component with the name "DtCommanderControlLogic" and default values.
73 //! Also checks out the required VR Engage Ground license.
75
76 //! \brief Virtual destructor for DtCommanderControlLogic
77 virtual ~DtCommanderControlLogic() override;
78
79 //! \brief Initializes the component with configuration from Lua
80 //!
81 //! Sets up input handlers, zoom limits, and initializes state attributes needed
82 //! for sensor control. Configures the component based on provided configuration.
83 //!
84 //! \param player Pointer to the player station this component belongs to
85 //! \param config Configuration table containing initialization parameters
86 //! \return True if initialization succeeds, false otherwise
88
89 //! \brief Performs post-initialization setup
90 //!
91 //! Sets up input handler callbacks after all components have been initialized.
92 //!
93 //! \return True if post-initialization succeeds, false otherwise
94 virtual bool postInitialize() override;
95
96 //! \brief Updates the component state
97 //!
98 //! Called each frame to handle sensor control logic, particularly
99 //! handling special cases like "out the hatch" mode.
100 //!
101 //! \param dt Delta time in seconds since the last tick
102 virtual void tick(double dt) override;
103
104 //! \brief Shuts down the component
105 //!
106 //! Cleans up resources and disconnects input handlers.
107 virtual void shutdown() override;
108
109 //! \brief Returns the component type identifier
110 //! \return The component type string
111 virtual const char* type() const override;
112
113 //! \brief Input handler for sensor azimuth (horizontal) control
114 //!
115 //! Controls the horizontal rotation of the sensor. In normal mode, sends joystick
116 //! messages scaled by the current zoom level. In "out the hatch" mode, stores the
117 //! input value for processing during tick().
118 //!
119 //! \param val The azimuth input value, typically from -1.0 to 1.0
120 virtual void azimuth(double val);
121
122 //! \brief Input handler for sensor elevation (vertical) control
123 //!
124 //! Controls the vertical tilt of the sensor. In normal mode, sends joystick
125 //! messages scaled by the current zoom level. In "out the hatch" mode, stores the
126 //! input value for processing during tick().
127 //!
128 //! \param val The elevation input value, typically from -1.0 to 1.0
129 virtual void elevation(double val);
130
131 //! \brief Input handler for zoom in functionality
132 //!
133 //! Increases the sensor's magnification level by a factor of 2, up to the
134 //! configured maximum zoom level.
135 //!
136 //! \param val The zoom in input value, positive values trigger zoom
137 virtual void zoomIn(double val);
138
139 //! \brief Input handler for zoom out functionality
140 //!
141 //! Decreases the sensor's magnification level by a factor of 0.5, down to the
142 //! configured minimum zoom level.
143 //!
144 //! \param val The zoom out input value, positive values trigger zoom
145 virtual void zoomOut(double val);
146
147 //! \brief Combined input handler for zoom functionality
148 //!
149 //! Routes to zoomIn or zoomOut based on whether the input value is positive or negative.
150 //!
151 //! \param val The zoom input value, positive for zoom in, negative for zoom out
152 virtual void zoom(float val);
153
154 //! \brief Input handler for cycling through sensor modes
155 //!
156 //! Cycles to the next available sensor mode (e.g., visual, NVG, thermal) when triggered.
157 //!
158 //! \param val The input value, a value of 1.0 triggers the sensor change
159 virtual void nextSensor(double val);
160
161 //! \brief Handles menu action messages
162 //!
163 //! Processes menu actions, particularly the "cycleSensor" action which
164 //! triggers the nextSensor functionality.
165 //!
166 //! \param msg The message to process
167 //! \return HANDLED if the message was processed, IGNORED otherwise
169
170protected:
171 //! \brief Input handler logic for processing input device events
173
174 //! \brief Main control group name from configuration
175 //!
176 //! Used to identify the function group when sending joystick messages.
178
179 //! \brief Flag indicating whether "out the hatch" mode is active
180 //!
181 //! When true, sensor control directly affects the observer view rather
182 //! than sending joystick messages to control a vehicle sensor.
184
185 //! \brief Current azimuth input value for "out the hatch" mode
187
188 //! \brief Current elevation input value for "out the hatch" mode
190
191 //! \brief Maximum allowed zoom level
193
194 //! \brief Minimum allowed zoom level
197};
198} // namespace makVre
virtual void zoom(float val)
Combined input handler for zoom functionality.
virtual ~DtCommanderControlLogic() override
Virtual destructor for DtCommanderControlLogic.
virtual void shutdown() override
Shuts down the component.
DtInputLogic myInputLogic
Input handler logic for processing input device events.
Definition commanderControlLogic.h:172
virtual void zoomOut(double val)
Input handler for zoom out functionality.
bool myOutTheHatchMode
Flag indicating whether "out the hatch" mode is active.
Definition commanderControlLogic.h:183
float myMaxZoom
Maximum allowed zoom level.
Definition commanderControlLogic.h:192
virtual makVre::DtVreMessageResult handleMenuMessage(makVre::DtVreMessage *msg)
Handles menu action messages.
virtual const char * type() const override
Returns the component type identifier.
float myAzimuthInput
Current azimuth input value for "out the hatch" mode.
Definition commanderControlLogic.h:186
DtCommanderControlLogic()
Constructor for DtCommanderControlLogic.
virtual void tick(double dt) override
Updates the component state.
virtual bool postInitialize() override
Performs post-initialization setup.
float myElevationInput
Current elevation input value for "out the hatch" mode.
Definition commanderControlLogic.h:189
virtual void zoomIn(double val)
Input handler for zoom in functionality.
virtual bool initialize(makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
Initializes the component with configuration from Lua.
virtual void elevation(double val)
Input handler for sensor elevation (vertical) control.
float myMinZoom
Minimum allowed zoom level.
Definition commanderControlLogic.h:195
virtual void azimuth(double val)
Input handler for sensor azimuth (horizontal) control.
std::string myMainControlGroup
Main control group name from configuration.
Definition commanderControlLogic.h:177
virtual void nextSensor(double val)
Input handler for cycling through sensor modes.
bool myEnableZoom
Definition commanderControlLogic.h:196
Component that provides entity control functionality.
Definition entityControlLogic.h:60
Table-based access to Lua state for configuration data.
Definition initializer.h:38
Class for managing input configuration and handling in VR-Engage.
Definition inputLogic.h:35
virtual DtPlayerStation & player()
Gets the player station.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines the logic for controlling entities in VR-Engage.
constexpr const char * minZoom
Definition commanderControlLogic.h:37
constexpr const char * maxZoom
Definition commanderControlLogic.h:34
constexpr const char * enableZoom
Definition commanderControlLogic.h:31
constexpr const char * outTheHatchMode
Definition commanderControlLogic.h:40
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Definition commanderControlLogic.h:23
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtCommanderControlLogicType
Type identifier for DtCommanderControlLogic component.
Definition commanderControlLogic.h:46
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33