VR-Engage  2.2
Loading...
Searching...
No Matches
inputEvaluator.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies, Inc.
3** All rights reserved.
4******************************************************************************/
5
6//! \file
7//! \brief Defines evaluators that convert input data to actions
8
9#pragma once
10
11#include "vreInput/export.h"
12
13#include <string>
14#include <vector>
15#include <memory>
16
17namespace makVre
18{
19//! Forward declarations
22class DtInitTable;
23struct DtInputData;
24struct DtAction;
25
26//! \brief Evaluates input data and converts it to actions
27//!
28//! This class evaluates input data from devices and determines if it should
29//! trigger an action. It applies transformations to the input values and
30//! handles features like input repetition and smoothing.
32{
33public:
34 //! \brief Constructor that initializes the evaluator
35 //!
36 //! Creates a new input evaluator with the given configuration.
37 //!
38 //! \param mapper Reference to the input manager
39 //! \param group The input group name for organizing related evaluators
40 //! \param config Pointer to the configuration data for this evaluator
41 DtInputEvaluator(DtVreInputManager& mapper, const std::string& group, DtInitTable* config);
42
43 //! \brief Virtual destructor
45
46 //! \brief Copy constructor (deleted)
47 //!
48 //! Input evaluators cannot be copied due to unique ownership of transforms
49 DtInputEvaluator(const DtInputEvaluator& mapping) = delete;
50
51 //! \brief Assignment operator (deleted)
52 //!
53 //! Input evaluators cannot be assigned due to unique ownership of transforms
55
56 //! \brief Evaluates input data to determine if an action should be triggered
57 //!
58 //! Processes the input data by applying transformations and determining
59 //! if it should trigger the associated action. If an action is triggered,
60 //! it creates an Action event and dispatches it to the event manager.
61 //!
62 //! \param data The input data structure containing the event information
63 //! \return True if an action was triggered, false otherwise
64 virtual bool evaluate(const DtInputData& data);
65
66 //! \brief Initializes or reinitializes the evaluator
67 //!
68 //! Resets the state of the evaluator to its initial values. May be called
69 //! multiple times to reset the evaluator's state during runtime.
70 virtual void initialize();
71
72 //! \brief Updates time-based functionality for input evaluation
73 //!
74 //! Handles time-based evaluations such as input repetition based on
75 //! the configured repeat rate. Should be called once per frame.
76 //!
77 //! \param dt Delta time in seconds since the last frame
78 virtual void tick(double dt);
79
80 //! \brief Checks if the action associated with this evaluator can be triggered
81 //!
82 //! Determines whether an action handler is registered for this evaluator's action.
83 //! If no handler is registered, the action cannot be evaluated or triggered.
84 //!
85 //! \return True if the action can be evaluated (has a registered handler), false otherwise
86 virtual bool canEvaluate() const;
87
88 //! \brief Gets the action name associated with this evaluator
89 //!
90 //! Returns the name of the action that this evaluator triggers when
91 //! its input conditions are met.
92 //!
93 //! \return String containing the action name
94 virtual const std::string& getActionName() const { return myAction; }
95
96 //! \brief Executes the associated action with the given value
97 //!
98 //! Passes the transformed input value to the registered action handler,
99 //! triggering the action in the system.
100 //!
101 //! \param value The final transformed value to pass to the action handler
102 virtual void executeAction(float value);
103
104protected:
105 //! \brief Reference to the input manager that owns this evaluator
107
108 //! \brief Group name this evaluator's action is part of.
109 std::string myGroup;
110
111 //! \brief Name of the action associated with this evaluator
112 std::string myAction;
113
114 //! \brief List of value transformations to apply to input values
115 std::vector<std::unique_ptr<DtValueTransform>> myTransforms;
116
117 //! \brief Current input value after processing
119
120 //! \brief Flag indicating if input should be repeated when held
122
123 //! \brief Rate at which input should be repeated (in Hz)
125
126 //! \brief Simulation time when the next repeated input should occur
128
129 //! \brief Flag indicating if input smoothing is enabled
131
132 //! \brief Buffer for smoothing input values
134};
135
136} // namespace makVre
Table-based access to Lua state for configuration data.
Definition initializer.h:38
bool myRepeatInput
Flag indicating if input should be repeated when held.
Definition inputEvaluator.h:121
std::vector< std::unique_ptr< DtValueTransform > > myTransforms
List of value transformations to apply to input values.
Definition inputEvaluator.h:115
DtInputEvaluator & operator=(const DtInputEvaluator &)=delete
Assignment operator (deleted)
DtVreInputManager & myManager
Reference to the input manager that owns this evaluator.
Definition inputEvaluator.h:106
virtual const std::string & getActionName() const
Gets the action name associated with this evaluator.
Definition inputEvaluator.h:94
std::string myGroup
Group name this evaluator's action is part of.
Definition inputEvaluator.h:109
virtual bool evaluate(const DtInputData &data)
Evaluates input data to determine if an action should be triggered.
std::string myAction
Name of the action associated with this evaluator.
Definition inputEvaluator.h:112
double myNextRepeatTime
Simulation time when the next repeated input should occur.
Definition inputEvaluator.h:127
virtual bool canEvaluate() const
Checks if the action associated with this evaluator can be triggered.
float myInputValue
Current input value after processing.
Definition inputEvaluator.h:118
virtual void initialize()
Initializes or reinitializes the evaluator.
DtInputEvaluator(DtVreInputManager &mapper, const std::string &group, DtInitTable *config)
Constructor that initializes the evaluator.
float myInputBuffer
Buffer for smoothing input values.
Definition inputEvaluator.h:133
virtual ~DtInputEvaluator()
Virtual destructor.
DtInputEvaluator(const DtInputEvaluator &mapping)=delete
Copy constructor (deleted)
float myRepeatRate
Rate at which input should be repeated (in Hz)
Definition inputEvaluator.h:124
bool mySmoothing
Flag indicating if input smoothing is enabled.
Definition inputEvaluator.h:130
virtual void executeAction(float value)
Executes the associated action with the given value.
virtual void tick(double dt)
Updates time-based functionality for input evaluation.
Abstract base class for transforming input values.
Definition valueTransform.h:24
Central manager for input device handling, action mapping, and input processing.
Definition vreInputManager.h:81
Defines DLL export/import macros for the vreInput library.
#define VREINPUT_DLL
DLL export/import macro for the vreInput library.
Definition export.h:25
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
Structure representing an input action with a name and value.
Definition vreInputManager.h:39
Structure for transferring input data through the input system.
Definition inputData.h:89