VR-Engage  2.2
Loading...
Searching...
No Matches
vreRtdTraitJoyControllerExtension.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreRtdTraitJoyControllerExtension.h
7//! \ingroup vreVrfRtd
8//! \brief Extension trait for joystick controllers in VREngage
9//!
10//! This file defines the DtVreRtdTraitJoyControllerExtension class, which provides
11//! common functionality for joystick controllers in the VREngage RTD system,
12//! including joystick state management and port creation.
13
14#pragma once
16
17class DtBooleanOutputPort;
18
19namespace vreRtd
20{
21//! \brief Extension trait for joystick controllers in VREngage
22//!
23//! This class provides common functionality for joystick controllers in the
24//! VREngage RTD system. It handles joystick state management, port creation,
25//! and state transitions for controllers. This trait is used by both fixed-wing
26//! and rotary-wing joystick controllers to share common functionality.
27class RTD_VRF_BACKEND_PLUGIN_EXPORT DtVreRtdTraitJoyControllerExtension
28{
29public:
30 //! \brief Constructor
31 //!
32 //! Initializes a new joystick controller extension trait with default values.
34
35 //! \brief Virtual destructor
36 //!
37 //! Cleans up resources used by the joystick controller extension trait.
39
40 //! \brief Performs per-frame processing
41 //! \param myJoystickEnabled Whether the joystick is currently enabled
42 //!
43 //! Called once per simulation frame to update the joystick controller state.
44 //! This function handles state transitions when joystick control is enabled
45 //! or disabled.
46 virtual void tick(bool myJoystickEnabled);
47
48 //! \brief Creates the joystick enabled output port
49 //! \return True if the port was successfully created, false otherwise
50 //!
51 //! Creates the output port that indicates whether joystick control is enabled.
52 //! This port can be connected to other components to synchronize control states.
54
55#if RTD_VRF_PLUGIN_VER < 440
56 //! \brief Processes a joystick device switch message
57 //! \param msg The message to process
58 //!
59 //! Processes a message that indicates a change in the joystick device state.
60 //! This function is only available in RTD VRF plugin versions earlier than 4.40.
61 virtual void processSetJoyDeviceSwitch(DtSimMessage* msg);
62#endif
63
64 //! \brief Disables the joystick controller
65 //!
66 //! Disables joystick input processing, usually when player
67 //! control is deactivated.
68 virtual void disable();
69
70 //! \brief Enables the joystick controller
71 //!
72 //! Enables joystick input processing, usually when player
73 //! control is activated.
74 virtual void enable();
75
76 //! \brief Sets the enabled state of the joystick controller
77 //! \param yes True to enable the controller, false to disable
78 //!
79 //! Directly sets the enabled state of the joystick controller.
80 virtual void setIsEnabled(bool yes);
81
82protected:
83 //! \brief Output port for joystick enabled state
84 //!
85 //! Port that indicates whether the joystick is currently enabled.
86 DtBooleanOutputPort* myJoystickEnabledPort;
87
88 //! \brief Flag indicating whether this is the first tick
89 //!
90 //! Used to handle initialization during the first simulation frame.
92
93 //! \brief Previous joystick state
94 //!
95 //! Stores the joystick state from the previous frame to detect state changes.
97};
98
99} // namespace vreRtd
virtual void processSetJoyDeviceSwitch(DtSimMessage *msg)
Processes a joystick device switch message.
DtBooleanOutputPort * myJoystickEnabledPort
Output port for joystick enabled state.
Definition vreRtdTraitJoyControllerExtension.h:86
bool myPreviousJoystickState
Previous joystick state.
Definition vreRtdTraitJoyControllerExtension.h:96
virtual void setIsEnabled(bool yes)
Sets the enabled state of the joystick controller.
virtual bool createJoystickEnabledPort()
Creates the joystick enabled output port.
virtual ~DtVreRtdTraitJoyControllerExtension()
Virtual destructor.
virtual void tick(bool myJoystickEnabled)
Performs per-frame processing.
bool myFirstTick
Flag indicating whether this is the first tick.
Definition vreRtdTraitJoyControllerExtension.h:91
virtual void enable()
Enables the joystick controller.
virtual void disable()
Disables the joystick controller.
Definition vreRtdConfigFileReader.h:18
Common definitions for the RTD backend library.