Plasma Engine  2.0
Loading...
Searching...
No Matches
OpenXRInputDevice.h
1#pragma once
2
3#include <OpenXRPlugin/Basics.h>
4#include <OpenXRPlugin/OpenXRIncludes.h>
5
6#include <GameEngine/XR/XRInputDevice.h>
7#include <GameEngine/XR/XRInterface.h>
8
9class plOpenXR;
10
11PL_DEFINE_AS_POD_TYPE(XrActionSuggestedBinding);
12PL_DEFINE_AS_POD_TYPE(XrActiveActionSet);
13
14class PL_OPENXRPLUGIN_DLL plOpenXRInputDevice : public plXRInputDevice
15{
16 PL_ADD_DYNAMIC_REFLECTION(plOpenXRInputDevice, plXRInputDevice);
17
18public:
19 void GetDeviceList(plHybridArray<plXRDeviceID, 64>& out_devices) const override;
20 plXRDeviceID GetDeviceIDByType(plXRDeviceType::Enum type) const override;
21 const plXRDeviceState& GetDeviceState(plXRDeviceID deviceID) const override;
22 plString GetDeviceName(plXRDeviceID deviceID) const override;
23 plBitflags<plXRDeviceFeatures> GetDeviceFeatures(plXRDeviceID deviceID) const override;
24
25private:
26 friend class plOpenXR;
27 struct Bind
28 {
29 XrAction action;
30 const char* szPath;
31 };
32
33 struct Action
34 {
36 XrAction m_Action;
37 plString m_sKey[2];
38 };
39
40 struct Vec2Action
41 {
42 Vec2Action(plXRDeviceFeatures::Enum feature, XrAction pAction, plStringView sLeft, plStringView sRight);
44 XrAction m_Action;
45 plString m_sKey_negx[2];
46 plString m_sKey_posx[2];
47 plString m_sKey_negy[2];
48 plString m_sKey_posy[2];
49 };
50
52 XrResult CreateActions(XrSession session, XrSpace m_sceneSpace);
53 void DestroyActions();
54
55 XrPath CreatePath(const char* szPath);
56 XrResult CreateAction(plXRDeviceFeatures::Enum feature, const char* actionName, XrActionType actionType, XrAction& out_action);
57 XrResult SuggestInteractionProfileBindings(const char* szInteractionProfile, const char* szNiceName, plArrayPtr<Bind> bindings);
58 XrResult AttachSessionActionSets(XrSession session);
59 XrResult UpdateCurrentInteractionProfile();
60
61 void InitializeDevice() override;
62 void RegisterInputSlots() override;
63 void UpdateInputSlotValues() override {}
64
65 XrResult UpdateActions();
66 void UpdateControllerState();
67
68private:
69 plOpenXR* m_pOpenXR = nullptr;
70 XrInstance m_pInstance = XR_NULL_HANDLE;
71 XrSession m_pSession = XR_NULL_HANDLE;
72
73 plXRDeviceState m_DeviceState[3]; // Hard-coded for now
74 plString m_sActiveProfile[3];
75 plBitflags<plXRDeviceFeatures> m_SupportedFeatures[3];
76 const plInt8 m_iLeftControllerDeviceID = 1;
77 const plInt8 m_iRightControllerDeviceID = 2;
78
79 XrActionSet m_pActionSet = XR_NULL_HANDLE;
80 plHashTable<XrPath, plString> m_InteractionProfileToNiceName;
81
82 plStaticArray<const char*, 2> m_SubActionPrefix;
83 plStaticArray<XrPath, 2> m_SubActionPath;
84
85 plHybridArray<Action, 4> m_BooleanActions;
86 plHybridArray<Action, 4> m_FloatActions;
87 plHybridArray<Vec2Action, 4> m_Vec2Actions;
88 plHybridArray<Action, 4> m_PoseActions;
89
90 XrSpace m_gripSpace[2];
91 XrSpace m_aimSpace[2];
92};
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition HashTable.h:333
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
virtual void InitializeDevice()=0
Override this if you need to do device specific initialization before the first use.
virtual void RegisterInputSlots()=0
Override this to register all the input slots that this device exposes.
Definition OpenXRSingleton.h:25
Definition OpenXRInputDevice.h:15
void UpdateInputSlotValues() override
Override this, if you need to query the state of the hardware to update the input slots.
Definition OpenXRInputDevice.h:63
Wraps a C-style array, which has a fixed size at compile-time, with a more convenient interface.
Definition StaticArray.h:13
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Definition XRInputDevice.h:49
virtual void GetDeviceList(plHybridArray< plXRDeviceID, 64 > &out_devices) const =0
Fills out a list of valid (connected) device IDs.
virtual plString GetDeviceName(plXRDeviceID deviceID) const =0
Returns the device name for a valid device ID.
virtual const plXRDeviceState & GetDeviceState(plXRDeviceID deviceID) const =0
Returns the current device state for a valid device ID.
virtual plBitflags< plXRDeviceFeatures > GetDeviceFeatures(plXRDeviceID deviceID) const =0
Returns the device features for a valid device ID.
virtual plXRDeviceID GetDeviceIDByType(plXRDeviceType::Enum type) const =0
Returns the deviceID for a specific type of device. If the device is not connected,...
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
Enum
Definition Declarations.h:100
A device's pose state.
Definition Declarations.h:80