openVROverlay.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #ifndef _OPENVROVERLAY_H_
  2. #define _OPENVROVERLAY_H_
  3. #ifndef _GUIOFFSCREENCANVAS_H_
  4. #include "gui/core/guiOffscreenCanvas.h"
  5. #endif
  6. #ifndef _OPENVRDEVICE_H_
  7. #include "platform/input/openVR/openVRProvider.h"
  8. #endif
  9. #ifndef _COLLISION_H_
  10. #include "collision/collision.h"
  11. #endif
  12. typedef vr::VROverlayInputMethod OpenVROverlayInputMethod;
  13. typedef vr::VROverlayTransformType OpenVROverlayTransformType;
  14. typedef vr::EGamepadTextInputMode OpenVRGamepadTextInputMode;
  15. typedef vr::EGamepadTextInputLineMode OpenVRGamepadTextInputLineMode;
  16. typedef vr::ETrackingResult OpenVRTrackingResult;
  17. typedef vr::ETrackingUniverseOrigin OpenVRTrackingUniverseOrigin;
  18. typedef vr::EOverlayDirection OpenVROverlayDirection;
  19. typedef vr::EVRState OpenVRState;
  20. class OpenVROverlay : public GuiOffscreenCanvas
  21. {
  22. public:
  23. typedef GuiOffscreenCanvas Parent;
  24. enum OverlayType
  25. {
  26. OVERLAYTYPE_OVERLAY,
  27. OVERLAYTYPE_DASHBOARD,
  28. };
  29. vr::VROverlayHandle_t mOverlayHandle;
  30. vr::VROverlayHandle_t mThumbOverlayHandle;
  31. // Desired OpenVR state
  32. U32 mOverlayFlags;
  33. F32 mOverlayWidth;
  34. vr::VROverlayTransformType mOverlayTransformType;
  35. MatrixF mTransform;
  36. vr::TrackedDeviceIndex_t mTransformDeviceIndex;
  37. String mTransformDeviceComponent;
  38. vr::VROverlayInputMethod mInputMethod;
  39. Point2F mMouseScale;
  40. vr::ETrackingUniverseOrigin mTrackingOrigin;
  41. vr::TrackedDeviceIndex_t mControllerDeviceIndex;
  42. GFXTexHandle mStagingTexture; ///< Texture used by openvr
  43. LinearColorF mOverlayColor;
  44. bool mOverlayTypeDirty; ///< Overlay type is dirty
  45. bool mOverlayDirty; ///< Overlay properties are dirty
  46. bool mManualMouseHandling;
  47. OverlayType mOverlayType;
  48. //
  49. OpenVROverlay();
  50. virtual ~OpenVROverlay();
  51. static void initPersistFields();
  52. DECLARE_CONOBJECT(OpenVROverlay);
  53. bool onAdd();
  54. void onRemove();
  55. void resetOverlay();
  56. void updateOverlay();
  57. void showOverlay();
  58. void hideOverlay();
  59. bool isOverlayVisible();
  60. bool isOverlayHoverTarget();
  61. bool isGamepadFocussed();
  62. bool isActiveDashboardOverlay();
  63. MatrixF getTransformForOverlayCoordinates(const Point2F &pos);
  64. bool castRay(const Point3F &origin, const Point3F &direction, RayInfo *info);
  65. void moveGamepadFocusToNeighbour();
  66. void handleOpenVREvents();
  67. void updateTextControl(GuiControl* ctrl);
  68. void onFrameRendered();
  69. virtual void enableKeyboardTranslation();
  70. virtual void disableKeyboardTranslation();
  71. virtual void setNativeAcceleratorsEnabled(bool enabled);
  72. };
  73. typedef OpenVROverlay::OverlayType OpenVROverlayType;
  74. DefineEnumType(OpenVROverlayType);
  75. #endif