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

Detailed Description

This class manages the input device lifecycle, input processing, and mapping of device inputs to logical actions. It provides a layered approach to input configuration, allowing multiple mapping configurations to be active simultaneously with priority handling.

#include <vreInputManager.h>

Inheritance diagram for makVre::DtVreInputManager:
[legend]

Classes

struct  MappingLayer
 

Public Types

using DeviceList = std::vector<std::unique_ptr<DtInputDevice>>
 
using MappingStack = std::deque<MappingLayer>
 
using DtValueTransformFactory = DtFactory<DtValueTransform>
 

Public Member Functions

 DtVreInputManager (DtPlayerStationApp &app)
 
virtual ~DtVreInputManager () override
 
 DtVreInputManager (const DtVreInputManager &mapping)=delete
 
DtVreInputManageroperator= (const DtVreInputManager &)=delete
 
virtual DtValueTransformFactoryvalueTransformFactory () const
 
virtual bool realizeHardwareHandlers (const std::vector< std::string > &hardwareHandlerList)
 
virtual bool shutdown ()
 
virtual bool addMappingLayer (const std::string &configName, const std::string &group, bool alwaysOnTop, bool alwaysEnabled)
 
virtual void removeMappingLayer (const std::string &configName, const std::string &group)
 
virtual void setRawInputHandler (const DtInputDelegate &inputDelegate)
 
virtual void removeRawInputHandler ()
 
virtual void tick (double dt)
 
virtual bool processInput (const DtInputData &data)
 
virtual const std::unique_ptr< DtInputDevice > & findDevice (int id) const
 
virtual const DeviceListdeviceList () const
 
virtual std::string inputSettingsPath () const
 
virtual double simulationTime () const
 
DtPlayerStationAppapp () const
 
virtual void addActionHandler (const std::string &group, const std::string &action, const DtActionDelegate &handler)
 
virtual void removeActionHandler (const std::string &group, const std::string &action)
 
virtual bool isActionApplicable (const std::string &group, const std::string &action) const
 
virtual void handleAction (const DtAction &action)
 
virtual bool isPlayerControlsEnabled () const
 
virtual void setPlayerControlsEnabled (bool enabled)
 
virtual bool loggingEvents () const
 
virtual void debugMenuCallback ()
 
const ActionHandlerMapgetActionHandlers () const
 
const MappingStackgetMappingStack () const
 

Protected Attributes

DtPlayerStationAppmyApp
 
DeviceList myDevices
 
MappingStack myMappingStack
 
ActionHandlerMap myActionHandlers
 
DtInputDelegate myRawInputHandler
 
DtValueTransformFactory myValueTransformFactory
 
std::string myInputSettingsPath
 
bool myPlayerControlsEnabled
 
bool myIsPlaying
 
bool myLoggingEvents
 
int myLastEventDebugId
 
std::map< int, std::string > myLatestEventLog
 
bool myLoggingDirectActions
 
std::map< int, std::vector< std::string > > myLatestDirectActionLog
 
std::deque< std::string > myLatestsTickedActionLog
 
std::unique_ptr< DtInputConfigViewermyInputConfigViewer
 

Member Typedef Documentation

◆ DeviceList

using makVre::DtVreInputManager::DeviceList = std::vector<std::unique_ptr<DtInputDevice>>

List type for storing managed input devices.

◆ MappingStack

Stack type for managing priority-ordered input mapping layers.

◆ DtValueTransformFactory

Factory type for creating value transform objects.

Constructor & Destructor Documentation

◆ DtVreInputManager() [1/2]

makVre::DtVreInputManager::DtVreInputManager ( DtPlayerStationApp & app)

Constructor for the input manager.

Initializes the input manager with the player station application context, sets up value transform factories, and configures debug facilities.

Parameters
appReference to the player station application that owns this manager

References app().

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

◆ ~DtVreInputManager()

virtual makVre::DtVreInputManager::~DtVreInputManager ( )
overridevirtual

Virtual destructor.

Cleans up debug callbacks and resources owned by the input manager.

◆ DtVreInputManager() [2/2]

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

Copy constructor (deleted)

Input manager cannot be copied due to unique ownership of resources.

References DtVreInputManager().

Member Function Documentation

◆ operator=()

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

Assignment operator (deleted)

Input manager cannot be assigned due to unique ownership of resources.

References DtVreInputManager().

◆ valueTransformFactory()

virtual DtValueTransformFactory & makVre::DtVreInputManager::valueTransformFactory ( ) const
virtual

Access the value transform factory used by device mappers.

Provides access to the factory that creates value transformation objects used to modify input values (like scaling, inversion, etc.)

Returns
Reference to the value transform factory

◆ realizeHardwareHandlers()

virtual bool makVre::DtVreInputManager::realizeHardwareHandlers ( const std::vector< std::string > & hardwareHandlerList)
virtual

Creates and initializes input devices from the provided list of device types.

This method should be called once at application startup to instantiate all the input devices that will be used. Each device is created using the input device factory and then initialized with this manager as context.

Parameters
hardwareHandlerListList of device type names to create and initialize
Returns
True if all devices were created successfully, false otherwise

◆ shutdown()

virtual bool makVre::DtVreInputManager::shutdown ( )
virtual

Shuts down the input manager and releases all resources.

Clears all mapping layers, disconnects action handlers, and shuts down all input devices. This should be called before application exit.

Returns
True if shutdown was successful, false otherwise

◆ addMappingLayer()

virtual bool makVre::DtVreInputManager::addMappingLayer ( const std::string & configName,
const std::string & group,
bool alwaysOnTop,
bool alwaysEnabled )
virtual

Creates and adds an input mapping layer to the mapping stack.

Loads mapping configuration from the specified config file and group, and adds it to the mapping stack with the specified priority parameters. If a layer with the same config and group already exists, it will not be added again.

Parameters
configNameName of the configuration file (without path) to load
groupGroup name within the configuration to activate
alwaysOnTopIf true, layer will be kept at the top of the stack
alwaysEnabledIf true, layer will remain active even when player controls are disabled
Returns
True if the layer was added successfully, false otherwise

◆ removeMappingLayer()

virtual void makVre::DtVreInputManager::removeMappingLayer ( const std::string & configName,
const std::string & group )
virtual

Removes a mapping layer from the stack.

Finds and removes a mapping layer with the specified configuration and group name. If no matching layer is found, this operation has no effect.

Parameters
configNameName of the configuration file that was used to create the layer
groupGroup name within the configuration to remove

◆ setRawInputHandler()

virtual void makVre::DtVreInputManager::setRawInputHandler ( const DtInputDelegate & inputDelegate)
virtual

Sets a raw input data handler.

This handler will be called before any mapping layer processing occurs, allowing for pre-processing or interception of raw input data.

Parameters
inputDelegateDelegate to be called with input data before mapping occurs

◆ removeRawInputHandler()

virtual void makVre::DtVreInputManager::removeRawInputHandler ( )
virtual

Removes the previously set raw input handler.

After this call, raw input will no longer be pre-processed and will go directly to the mapping layers.

◆ tick()

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

Updates the input system for the current frame.

This method should be called once per frame to allow devices and mappings to update their state and process time-dependent operations.

Parameters
dtDelta time in seconds since the last frame

◆ processInput()

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

Processes raw input data from a device.

Called by input devices when they receive input to be processed. This method handles passing the data to the raw input handler (if set) and through the mapping layers based on device type and name until it is processed or falls through.

Parameters
dataThe input data structure containing all input information
Returns
True if the input was processed by a handler, false if it was not handled

◆ findDevice()

virtual const std::unique_ptr< DtInputDevice > & makVre::DtVreInputManager::findDevice ( int id) const
virtual

Finds an input device by its numeric ID.

Parameters
idThe numeric ID of the device to find
Returns
Reference to the unique pointer containing the device

◆ deviceList()

virtual const DeviceList & makVre::DtVreInputManager::deviceList ( ) const
virtual

Gets the list of all input devices.

Returns
Reference to the list of all input devices managed by this manager

◆ inputSettingsPath()

virtual std::string makVre::DtVreInputManager::inputSettingsPath ( ) const
virtual

Gets the full path to the input settings directory.

Returns the directory where input configuration files are stored. This path is resolved based on the application's path configuration.

Returns
String containing the full path to the input settings directory

◆ simulationTime()

virtual double makVre::DtVreInputManager::simulationTime ( ) const
virtual

Gets the current simulation time.

Returns
Current simulation time in seconds

◆ app()

DtPlayerStationApp & makVre::DtVreInputManager::app ( ) const

Gets the player station application associated with this manager.

Returns
Reference to the player station application

Referenced by DtVreInputManager().

◆ addActionHandler()

virtual void makVre::DtVreInputManager::addActionHandler ( const std::string & group,
const std::string & action,
const DtActionDelegate & handler )
virtual

Registers a handler for a named action.

Associates the specified action name with a delegate that will be called whenever that action is triggered by input mappings. The group and action name combination uniquely identifies the handler in the system.

Parameters
groupGroup name for categorizing the action (e.g., "movement", "combat", "ui")
actionName of the action to register a handler for
handlerDelegate to be called when the action is triggered

◆ removeActionHandler()

virtual void makVre::DtVreInputManager::removeActionHandler ( const std::string & group,
const std::string & action )
virtual

Removes a previously registered action handler.

Removes the handler associated with the specified group and action name. If no handler is registered for the action, this has no effect.

Parameters
groupGroup name for categorizing the action
actionName of the action to remove the handler for

◆ isActionApplicable()

virtual bool makVre::DtVreInputManager::isActionApplicable ( const std::string & group,
const std::string & action ) const
virtual

Checks if an action has a registered handler.

Determines whether the specified group and action name combination has a handler registered.

Parameters
groupGroup name for categorizing the action
actionName of the action to check
Returns
True if the action has a handler, false otherwise

◆ handleAction()

virtual void makVre::DtVreInputManager::handleAction ( const DtAction & action)
virtual

Processes an action by calling its registered handler.

This is called by input mapping evaluators when an action is triggered. The method assumes that the action is applicable (has a registered handler). Logs actions for debugging if action logging is enabled.

Parameters
actionThe action structure containing the name and value

◆ isPlayerControlsEnabled()

virtual bool makVre::DtVreInputManager::isPlayerControlsEnabled ( ) const
virtual

Checks if player controls are currently enabled.

When player controls are disabled, only mapping layers with alwaysEnabled=true will be processed.

Returns
True if player controls are enabled, false otherwise

◆ setPlayerControlsEnabled()

virtual void makVre::DtVreInputManager::setPlayerControlsEnabled ( bool enabled)
virtual

Sets whether player controls are enabled.

Enables or disables player controls, affecting which mapping layers are active.

Parameters
enabledTrue to enable player controls, false to disable

◆ loggingEvents()

virtual bool makVre::DtVreInputManager::loggingEvents ( ) const
virtual

Checks if input event logging is enabled.

Returns
True if input events are being logged, false otherwise

◆ debugMenuCallback()

virtual void makVre::DtVreInputManager::debugMenuCallback ( )
virtual

Callback for the debug menu.

Renders debug UI options for the input system when accessed through the debug menu (Shift-F4). Allows toggling of input event logging and viewing input event history.

◆ getActionHandlers()

const ActionHandlerMap & makVre::DtVreInputManager::getActionHandlers ( ) const
inline

Gets the action handlers map (for debugging/configuration purposes)

Returns
Constant reference to the action handlers map

References myActionHandlers.

◆ getMappingStack()

const MappingStack & makVre::DtVreInputManager::getMappingStack ( ) const
inline

Gets the mapping stack (for debugging/configuration purposes)

Returns
Constant reference to the mapping stack

References myMappingStack.

Member Data Documentation

◆ myApp

DtPlayerStationApp& makVre::DtVreInputManager::myApp
protected

Reference to the parent player station application.

◆ myDevices

DeviceList makVre::DtVreInputManager::myDevices
protected

List of all input devices managed by this manager.

◆ myMappingStack

MappingStack makVre::DtVreInputManager::myMappingStack
protected

Stack of mapping layers in priority order (front = highest priority)

Referenced by getMappingStack().

◆ myActionHandlers

ActionHandlerMap makVre::DtVreInputManager::myActionHandlers
protected

Map of action names to their handler delegates.

Referenced by getActionHandlers().

◆ myRawInputHandler

DtInputDelegate makVre::DtVreInputManager::myRawInputHandler
protected

Optional delegate for handling raw input before mapping.

◆ myValueTransformFactory

DtValueTransformFactory makVre::DtVreInputManager::myValueTransformFactory
protected

Factory for creating value transformation objects.

◆ myInputSettingsPath

std::string makVre::DtVreInputManager::myInputSettingsPath
protected

Path to the directory containing input configuration files.

◆ myPlayerControlsEnabled

bool makVre::DtVreInputManager::myPlayerControlsEnabled
protected

Flag indicating if player controls are currently enabled.

◆ myIsPlaying

bool makVre::DtVreInputManager::myIsPlaying
protected

Flag indicating if the simulation is currently playing.

◆ myLoggingEvents

bool makVre::DtVreInputManager::myLoggingEvents
protected

Flag indicating if input event logging is enabled.

◆ myLastEventDebugId

int makVre::DtVreInputManager::myLastEventDebugId
protected

Counter for assigning unique IDs to logged events.

◆ myLatestEventLog

std::map<int, std::string> makVre::DtVreInputManager::myLatestEventLog
protected

Map of event IDs to their log messages.

◆ myLoggingDirectActions

bool makVre::DtVreInputManager::myLoggingDirectActions
protected

Flag indicating if direct action logging is enabled.

◆ myLatestDirectActionLog

std::map<int, std::vector<std::string> > makVre::DtVreInputManager::myLatestDirectActionLog
protected

Map of event IDs to their direct action log messages.

◆ myLatestsTickedActionLog

std::deque<std::string> makVre::DtVreInputManager::myLatestsTickedActionLog
protected

Queue of tick-based action log messages.

◆ myInputConfigViewer

std::unique_ptr<DtInputConfigViewer> makVre::DtVreInputManager::myInputConfigViewer
protected

Input configuration viewer instance.


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