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