|
VR-Engage
2.2
|
This class represents the state of a VR controller at a specific point in time, including its position, orientation, button states, touch states, and analog input values. It also tracks which aspects of the controller state have changed since the last update cycle, making it easier for event handlers to respond to specific types of input events (e.g., button presses, controller movements).
#include <DtVirtualRealityControllerState.h>
Public Types | |
| enum | DeviceType { Type_Undefined = 0 , Type_Left = 1 << 1 , Type_Right = 1 << 2 , Type_Tracked = 1 << 3 , Type_Input = 1 << 4 , Type_HMD = 1 | Type_Tracked , Type_LeftHand = Type_Left | Type_Input | Type_Tracked , Type_RightHand = Type_Right | Type_Input | Type_Tracked } |
| enum | ButtonId { Button_System = 1 << 0 , Button_Menu = 1 << 1 , Button_Trigger = 1 << 2 , Button_Grip = 1 << 3 , Button_A = 1 << 4 , Button_B = 1 << 5 , Button_Thumb = 1 << 6 , Button_Left = 1 << 7 , Button_Up = 1 << 8 , Button_Right = 1 << 9 , Button_Down = 1 << 10 } |
| enum | TouchId { Touch_Trigger = 1 << 0 , Touch_Grip = 1 << 1 , Touch_A = 1 << 2 , Touch_B = 1 << 3 , Touch_Thumb = 1 << 4 } |
| enum | AxisId { Axis_Thumb = 0 , Axis_Trigger = 1 , Axis_Grip = 2 , Axis_3 = 3 , Axis_4 = 4 } |
| enum | ControllerEventType { NoEvent = 0 , ControllerDiscovered , ControllerLost , StateChanged } |
| using | Bitfield = unsigned long long |
| using | ControllerId = unsigned int |
| using | DtVector2f = DtVector2<float32> |
Public Member Functions | |
| DtVirtualRealityControllerState () | |
| DtVirtualRealityControllerState (const DtVirtualRealityControllerState &orig) | |
| virtual | ~DtVirtualRealityControllerState () |
| DtVirtualRealityControllerState & | operator= (const DtVirtualRealityControllerState &rhs) |
| virtual ControllerId | controllerId () const |
| virtual void | setControllerId (ControllerId) |
| virtual Bitfield | controllerType () const |
| virtual void | setControllerType (Bitfield) |
| virtual DtVector | position () const |
| virtual void | setPosition (const DtVector &pos) |
| virtual DtQuat | orientation () const |
| virtual void | setOrientation (const DtQuat &ori) |
| virtual Bitfield | buttonStates () const |
| virtual void | setButtonStates (Bitfield buttonStates) |
| virtual bool | buttonState (ButtonId buttonId) const |
| virtual void | setButtonState (ButtonId buttonId, bool down) |
| virtual Bitfield | touchStates () const |
| virtual void | setTouchStates (Bitfield touchStates) |
| virtual bool | touchState (TouchId touchId) const |
| virtual void | setTouchState (TouchId touchId, bool touched) |
| virtual DtVector2f | axisPosition (AxisId axisId) const |
| virtual void | setAxisPosition (AxisId axisId, const DtVector2f &value) |
| virtual DtVector2f | axisDeadZone (AxisId axisId) const |
| virtual void | setAxisDeadZone (AxisId axisId, const DtVector2f &value) |
| virtual void | setControllerAsLost () |
| virtual bool | controllerWasLost () const |
| virtual Bitfield | buttonsChanged () const |
| virtual bool | buttonChanged (ButtonId buttonId) const |
| virtual bool | buttonPressed (ButtonId buttonId) const |
| virtual bool | buttonReleased (ButtonId buttonId) const |
| virtual Bitfield | touchChanged () const |
| virtual bool | touchChanged (TouchId touchid) const |
| virtual bool | touchStarted (TouchId touchId) const |
| virtual bool | touchEnded (TouchId touchId) const |
| virtual Bitfield | axesChanged () const |
| virtual bool | axisChanged (AxisId axisId) const |
| virtual bool | controllerMoved () const |
| virtual ControllerEventType | controllerEvent () const |
| virtual void | clearEvent () |
Static Public Member Functions | |
| static unsigned int | MaxAxes () |
| static Bitfield | bit (unsigned int n) |
Static Public Attributes | |
| static const ControllerId | NoId = ControllerId(-1) |
Protected Member Functions | |
| virtual void | markStateChanged () |
Protected Attributes | |
| ControllerId | myControllerId |
| Bitfield | myControllerType |
| DtVector | myPosition |
| DtQuat | myOrientation |
| Bitfield | myButtonStates |
| Bitfield | myTouchStates |
| std::vector< DtVector2f > | myAxisStates |
| std::vector< DtVector2f > | myAxisDeadZones |
| ControllerEventType | myEventType |
| Bitfield | myButtonsChanged |
| Bitfield | myTouchChanged |
| Bitfield | myAxesChanged |
| bool | myControllerMoved |
| using makVrv::DtVirtualRealityControllerState::Bitfield = unsigned long long |
Type used for bit flags throughout the class.
This type is used for representing sets of buttons, touch surfaces, or axes as bit flags, where each bit corresponds to a specific item.
| using makVrv::DtVirtualRealityControllerState::ControllerId = unsigned int |
Type used for controller identification.
This type is used to uniquely identify controllers in the VR system.
| using makVrv::DtVirtualRealityControllerState::DtVector2f = DtVector2<float32> |
Type used for 2D vector values.
This type is used for representing 2D analog input values, such as thumbstick or touchpad positions.
Overall status of this controller.
The first time a controller is added to the map, the event type will be ControllerDiscovered, and all change flags will be true. When a controller is lost, it will appear for one more event with type ControllerLost, with the last known state. All change flags will be false, and the controller will be removed from the map after the event is processed.
During normal operation, the event type for a controller will be either NoEvent or StateChanged, indicating whether there has been any change in the state of this controller. If event type is StateChanged, individual change flags can be used to determine what component or components have changed since the last event cycle.
| Enumerator | |
|---|---|
| NoEvent | |
| ControllerDiscovered | |
| ControllerLost | |
| StateChanged | |
| makVrv::DtVirtualRealityControllerState::DtVirtualRealityControllerState | ( | ) |
Default constructor.
Initializes a new controller state with default values. The controller ID is set to NoId, event type is set to NoEvent, and all state values and change flags are initialized to zero/false.
Referenced by DtVirtualRealityControllerState(), and operator=().
| makVrv::DtVirtualRealityControllerState::DtVirtualRealityControllerState | ( | const DtVirtualRealityControllerState & | orig | ) |
Copy constructor.
| orig | The controller state to copy |
Creates a new controller state that is a copy of the original.
References DtVirtualRealityControllerState().
|
virtual |
Virtual destructor.
Cleans up any resources associated with the controller state.
|
static |
Gets the maximum number of analog axes supported by the system.
Returns the maximum number of analog axes that can be tracked for a controller. Not all controllers will have this many axes, but the system allocates space for this many to accommodate all supported controller types.
|
static |
Converts an integer to the corresponding bit in a bitfield.
| n | The bit position (0-63) |
This convenience function converts an integer n to a bitfield with only the nth bit set (equivalent to 1 << n). This is useful for working with the various bitfields used throughout this class.
| DtVirtualRealityControllerState & makVrv::DtVirtualRealityControllerState::operator= | ( | const DtVirtualRealityControllerState & | rhs | ) |
Assignment operator.
| rhs | The controller state to copy |
Assigns the contents of another controller state to this one.
References DtVirtualRealityControllerState().
|
virtual |
Unique integer identifier for this VR Controller device.
|
virtual |
|
virtual |
Bitfield of controller DeviceType properties.
|
virtual |
|
virtual |
Current position of this controller. This is an East-North-Up coordinate system with respect to the observer.
|
virtual |
|
virtual |
Current orientation of this controller. This is an East-North-Up coordinate system with respect to the observer.
|
virtual |
|
virtual |
Bitfield of all the button states of the controller. Each bit represents a button state, as 1 << buttonId. See ButtonId enum for known button IDs.
Referenced by setButtonStates().
|
virtual |
References buttonStates().
|
virtual |
Get an individual button state by unique buttonId. true == button down, buttonId must be < number of bits in long long.
|
virtual |
|
virtual |
Bitfield of all the touch surface states of the controller. Each bit represents a surface state, as 1 << touchId. See TouchId enum for known touch surface IDs.
Referenced by setTouchStates().
|
virtual |
References touchStates().
|
virtual |
Get an individual surface state by unique touchId. true == touched, touchId must be < number of bits in long long.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Marks this controller as lost; event type is set to ControllerLost. Is is expected that this controller state will be deleted after the event processor has processed this final state.
|
virtual |
|
virtual |
Returns a bitfield identifying all the buttons which have changed since the last event cycle. Each bit represents a button that changed, as 1 << buttonId. See enum ButtonId for known button IDs.
|
virtual |
Returns whether a particular button with specified ID has changed state since the last event cycle.
|
virtual |
Returns whether the button with specified ID was pressed/released since the last event cycle.
|
virtual |
|
virtual |
Returns a bitfield identifying all the surfaces which have changed touch state since the last event cycle. Each bit represents a touch surface that changed, as 1 << touchId. See enum TouchId for known button IDs.
|
virtual |
Returns whether a particular surface with specified ID has changed touch state since the last event cycle.
|
virtual |
Returns whether the specified touch surface was touched or un-touched since the last event cycle.
|
virtual |
|
virtual |
Returns bitfield identifying all axes which have changed since the last event cycle. Each bit represents an axis, as 1 << axisId. See enum AxisId for known axes.
|
virtual |
Returns whether a particular axis with specified ID has had a value changed since the last event cycle.
|
virtual |
Returns whether there has been any change to the tracked position or orientation of this controller since the last event cycle.
|
virtual |
Returns ControllerEventType describing the state of this controller after the most recent update.
|
virtual |
Resets all change flags to 0/false and event type to NoEvent. This should be called after the event processor has processed the current state of events, before this controller state is updated.
|
inlineprotectedvirtual |
|
static |
Special value indicating no controller ID.
This constant is used to indicate that a controller ID is not set or not applicable in the current context.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |