VR-Engage  2.3
Loading...
Searching...
No Matches
DtVirtualRealityEventManager.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file DtVirtualRealityEventManager.h
7//! \brief Defines the base class for VR controller event management
8//!
9//! This file contains the definition of the DtVirtualRealityEventManager base class,
10//! which is responsible for managing VR controller states and processing controller
11//! events. It maintains a list of event processors that can respond to controller
12//! events and dispatches events to these processors when they occur.
13
14#pragma once
15
18
19#include <vrvUtil/DtVirtualBaseClass.h>
20
21namespace makVrv
22{
23class DtVirtualRealityDriver;
25
26//! \brief List type for storing event processor pointers
27//!
28//! This type is used to maintain an ordered list of event processors that will
29//! receive controller events in sequence during event dispatch.
30using EventProcessorList = std::list<DtVirtualRealityEventProcessorInterface*>;
31
32//! \brief Base class for managing virtual reality controller events
33//!
34//! This abstract base class defines the interface and common functionality for
35//! VR controller event management. It maintains the current state of all connected
36//! controllers, processes events from the VR system, and dispatches these events
37//! to registered event processors.
38//!
39//! Specific VR platforms (Oculus, OpenVR, etc.) implement derived classes that
40//! handle the platform-specific details of retrieving controller state information.
41//!
42//! \note This class is created automatically by the DtVirtualRealityDriver
43//! and is not intended to be instantiated directly by users.
44class DT_DLL_VRVVRCTLR DtVirtualRealityEventManager : public DtVirtualBaseClass
45{
46private:
47 //! \brief Unused default constructor
48 //!
49 //! Private constructor to prevent direct instantiation. Use the instance()
50 //! method to get the singleton instance instead.
52
53public:
54 //! \brief Map type that associates controller IDs with their state objects
55 //!
56 //! This map associates controller identifiers (unsigned integers) with
57 //! pointers to controller state objects that contain the controller's
58 //! position, orientation, and input states.
59 using ControllerStateMap = std::map<unsigned int, DtVirtualRealityControllerState*>;
60
61 //! \brief Gets the singleton instance of the appropriate event manager
62 //! \param de Reference to the display engine
63 //! \return Reference to the singleton instance
64 //! \throws DtCorruptedState if it is unable to get the instance
65 //!
66 //! Returns the singleton instance of the appropriate VR event manager for
67 //! the current VR system (e.g., Oculus, OpenVR), creating it if it doesn't
68 //! already exist. This method is called by the VR driver during initialization.
70
71 //! \brief Virtual destructor
72 //!
73 //! Cleans up event manager resources, including all registered event processors
74 //! and controller state objects.
76
77
78 //! \brief Registers an event processor at the front of the event processing queue
79 //! \param processor Pointer to the event processor to register
80 //!
81 //! Adds the specified event processor to the front of the event processing queue.
82 //! Event processors at the front of the queue receive events before those at the back.
83 //! This is useful when an event processor needs to handle events before others,
84 //! potentially intercepting and canceling events for other processors.
86
87 //! \brief Registers an event processor at the back of the event processing queue
88 //! \param processor Pointer to the event processor to register
89 //!
90 //! Adds the specified event processor to the back of the event processing queue.
91 //! Event processors at the back of the queue receive events after those at the front.
92 //! This is the default and most common way to register event processors.
94
95 //! \brief Unregisters an event processor
96 //! \param processor Pointer to the event processor to unregister
97 //!
98 //! Removes the specified event processor from the event processing queue.
99 //! After removal, the processor will no longer receive controller events.
100 //! If the processor is not in the queue, this method has no effect.
102
103 //! \brief const access the event processor list
105
106 //! \brief non-const access to the event processor list
108
109 //! \brief Access the Controller State map containing the most recent state of all controllers.
110 //! Map is indexed by controller id.
112
113 // //! \brief get/set the deadzone for the given axis of the given controller.
114 // virtual DtVector2f deadZone(DtVirtualRealityControllerState::Controller,
115 // DtVirtualRealityControllerState::Axis) const; virtual void
116 // setDeadZone(DtVirtualRealityControllerState::Controller, DtVirtualRealityControllerState::Axis, const
117 // DtVector2f&);
118
119protected:
120 //! \brief CTOR
121 // Only called by registerInstance for default
123
124 //! \brief dispatch controller event to any active event handlers
126
127 //! \brief called every frame by the system. Calls the processVREvents for the specific system
128 virtual void tick();
129
130 //! \brief collects and dispatches events from the VR system to any active event processors.
131 // This is used by the DtVirtualRealityDriver and not intended to be called directly by users.
132 virtual void processVrEvents() = 0;
133
134protected:
135 DtDe& myDe;
136 DtVirtualRealityDriver* myVrDriver;
139};
140} // namespace makVrv
Defines a class that encapsulates VR controller events.
Encapsulates a virtual reality controller event.
Definition DtVirtualRealityControllerEvent.h:29
std::map< unsigned int, DtVirtualRealityControllerState * > ControllerStateMap
Map type that associates controller IDs with their state objects.
Definition DtVirtualRealityEventManager.h:59
virtual void tick()
called every frame by the system. Calls the processVREvents for the specific system
virtual EventProcessorList & eventProccesorList()
non-const access to the event processor list
DtDe & myDe
Definition DtVirtualRealityEventManager.h:135
virtual ~DtVirtualRealityEventManager() override
Virtual destructor.
static DtVirtualRealityEventManager & instance(DtDe &de)
Gets the singleton instance of the appropriate event manager.
DtVirtualRealityEventManager()
Unused default constructor.
virtual void addEventProcessorToFront(DtVirtualRealityEventProcessorInterface *processor)
Registers an event processor at the front of the event processing queue.
ControllerStateMap myControllerStates
Definition DtVirtualRealityEventManager.h:138
virtual const EventProcessorList & eventProccesorList() const
const access the event processor list
virtual void removeEventProcessor(DtVirtualRealityEventProcessorInterface *processor)
Unregisters an event processor.
virtual void dispatchControllerEvent(DtVirtualRealityControllerEvent &event)
dispatch controller event to any active event handlers
virtual void addEventProcessorToBack(DtVirtualRealityEventProcessorInterface *processor)
Registers an event processor at the back of the event processing queue.
const ControllerStateMap & controllerStateMap() const
Access the Controller State map containing the most recent state of all controllers....
virtual void processVrEvents()=0
collects and dispatches events from the VR system to any active event processors.
EventProcessorList myEventProcessors
Definition DtVirtualRealityEventManager.h:137
DtVirtualRealityDriver * myVrDriver
Definition DtVirtualRealityEventManager.h:136
Interface for processing virtual reality controller events.
Definition DtVirtualRealityEventProcessorInterface.h:29
Definition appLauncherComponent.h:28
std::list< DtVirtualRealityEventProcessorInterface * > EventProcessorList
List type for storing event processor pointers.
Definition DtVirtualRealityEventManager.h:30
makVrv::DtDe * de()
Gets the display element pointer used by the plugin.
Main header file for the VRV Virtual Reality Controller module.