VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtDeviceMapping Class Reference

Detailed Description

This class manages the mapping between raw device inputs and logical actions using evaluators. It maintains the current state of device inputs and processes incoming input events, forwarding them to the appropriate evaluators.

#include <deviceMapping.h>

Classes

struct  InputMapping
 

Public Types

using DeviceState = std::unordered_map<int, float>
 
using EvaluatorMap = std::unordered_map<int, std::vector<std::unique_ptr<DtInputEvaluator>>>
 

Public Member Functions

 DtDeviceMapping (DtVreInputManager &mgr, const std::string &group, DtInitTable *config)
 
virtual ~DtDeviceMapping ()
 
 DtDeviceMapping (const DtDeviceMapping &mapping)=delete
 
DtDeviceMappingoperator= (const DtDeviceMapping &)=delete
 
virtual void initialize ()
 
virtual bool processInput (const DtInputData &data)
 
virtual void tick (double dt)
 
virtual const DeviceStatedeviceState () const
 
virtual std::vector< InputMappinggetInputMappings () const
 
virtual std::string getGroup () const
 

Protected Member Functions

virtual void clearInputState ()
 

Protected Attributes

DeviceState myDeviceState
 
EvaluatorMap myEvaluators
 
std::string myGroup
 
DtVreInputManagermyManager
 

Private Member Functions

std::string createInputDescription (int inputType, int inputId, int inputFlags, int inputModifiers) const
 
std::string inputIdToKeyName (int keyId) const
 
std::string hatFlagsToString (int hatFlags) const
 
std::string axisFlagsToString (int axisFlags) const
 

Member Typedef Documentation

◆ DeviceState

using makVre::DtDeviceMapping::DeviceState = std::unordered_map<int, float>

Type for storing the current state of device inputs.

Maps input IDs to their current values

◆ EvaluatorMap

using makVre::DtDeviceMapping::EvaluatorMap = std::unordered_map<int, std::vector<std::unique_ptr<DtInputEvaluator>>>

Constructor & Destructor Documentation

◆ DtDeviceMapping() [1/2]

makVre::DtDeviceMapping::DtDeviceMapping ( DtVreInputManager & mgr,
const std::string & group,
DtInitTable * config )

Constructor that initializes the device mapping.

Creates a new device mapping with the given input manager and configuration. The configuration defines which evaluators to create and how to map inputs.

Parameters
mgrReference to the input manager that owns this mapping
groupThe input group name for organizing related input mappings
configPointer to the configuration data for this mapping

Referenced by DtDeviceMapping(), and operator=().

◆ ~DtDeviceMapping()

virtual makVre::DtDeviceMapping::~DtDeviceMapping ( )
virtual

Virtual destructor.

Cleans up resources owned by this mapping

◆ DtDeviceMapping() [2/2]

makVre::DtDeviceMapping::DtDeviceMapping ( const DtDeviceMapping & mapping)
delete

Copy constructor (deleted)

Device mappings cannot be copied due to unique ownership of evaluators

References DtDeviceMapping().

Member Function Documentation

◆ operator=()

DtDeviceMapping & makVre::DtDeviceMapping::operator= ( const DtDeviceMapping & )
delete

Assignment operator (deleted)

Device mappings cannot be assigned due to unique ownership of evaluators

References DtDeviceMapping().

◆ initialize()

virtual void makVre::DtDeviceMapping::initialize ( )
virtual

Initialize the mapper and all evaluators.

Resets the device state and initializes all evaluators. Called during construction and can be called again to reset the mapping to its initial state.

◆ processInput()

virtual bool makVre::DtDeviceMapping::processInput ( const DtInputData & data)
virtual

Process an input event from a device.

Updates the device state with the new input value and passes the input to any evaluators registered for that input ID. If any evaluator handles the input, processing stops.

Parameters
dataThe input data structure containing the event information
Returns
True if this mapping handled the input and processing should stop, false otherwise

◆ tick()

virtual void makVre::DtDeviceMapping::tick ( double dt)
virtual

Update method called each frame.

Updates all evaluators, allowing them to check for time-based triggers and other conditions based on the current device state.

Parameters
dtDelta time in seconds since the last frame

◆ deviceState()

virtual const DeviceState & makVre::DtDeviceMapping::deviceState ( ) const
virtual

Get the current state of all device inputs.

Returns a map of input IDs to their current values, representing the current state of the device's inputs.

Returns
Constant reference to the device state map

◆ getInputMappings()

virtual std::vector< InputMapping > makVre::DtDeviceMapping::getInputMappings ( ) const
virtual

Get all input mappings configured for this device.

Returns a list of all input mappings that have been configured for this device, including the input details and associated actions.

Returns
Vector of InputMapping structures describing all configured mappings

◆ getGroup()

virtual std::string makVre::DtDeviceMapping::getGroup ( ) const
inlinevirtual

References myGroup.

◆ clearInputState()

virtual void makVre::DtDeviceMapping::clearInputState ( )
inlineprotectedvirtual

Clear the current device input state.

Virtual method that can be overridden by derived classes to provide custom state clearing behavior.

◆ createInputDescription()

std::string makVre::DtDeviceMapping::createInputDescription ( int inputType,
int inputId,
int inputFlags,
int inputModifiers ) const
private

Helper method to create human-readable input descriptions.

◆ inputIdToKeyName()

std::string makVre::DtDeviceMapping::inputIdToKeyName ( int keyId) const
private

Helper method to convert input ID to key name.

◆ hatFlagsToString()

std::string makVre::DtDeviceMapping::hatFlagsToString ( int hatFlags) const
private

Helper method to convert hat flags to string.

◆ axisFlagsToString()

std::string makVre::DtDeviceMapping::axisFlagsToString ( int axisFlags) const
private

Helper method to convert axis flags to string.

Member Data Documentation

◆ myDeviceState

DeviceState makVre::DtDeviceMapping::myDeviceState
protected

Current state of all device inputs (input ID -> value)

◆ myEvaluators

EvaluatorMap makVre::DtDeviceMapping::myEvaluators
protected

Map of input IDs to their associated evaluators.

Each input ID can have multiple evaluators that process its values

◆ myGroup

std::string makVre::DtDeviceMapping::myGroup
protected

Referenced by getGroup().

◆ myManager

DtVreInputManager& makVre::DtDeviceMapping::myManager
protected

Reference to the input manager that owns this mapping.


The documentation for this class was generated from the following file: