28 #include <scolPlugin.h> 29 #include <boost/thread/thread.hpp> 30 #include <boost/bind.hpp> 32 #include "openvr/openvr.h" 34 #define USE_VR_INPUT 0 36 #ifdef USE_VIVE_GESTURE 37 # include "interface_gesture.hpp" 38 #define MAX_VR_CONTROLLERS 10 40 #define MAX_VR_CONTROLLERS 8 60 CLASSIC_CONTROLLER = 0,
61 TRACKER_CONTROLLER = 1,
66 vr::IVRSystem* mHmdSystem;
67 unsigned int mDeviceId;
69 VrControllerSide mSide;
71 vr::VRControllerState_t mControllerState;
72 std::vector<vr::EVRButtonId> mButtonsToHandle;
73 std::vector<bool> mButtonsStates;
81 vr::VRInputValueHandle_t mSource;
82 vr::VRActionHandle_t mActionPose;
83 vr::VRActionHandle_t mActionHaptic;
84 vr::VRActionHandle_t mPadAxis;
85 vr::VRActionHandle_t mTriggerAxis;
87 std::vector<vr::VRActionHandle_t> mActionsToHandle;
90 #ifdef USE_VIVE_GESTURE 91 GestureType mLastGesture;
105 void Update(vr::TrackedDevicePose_t* trackedPoses,
unsigned int deviceId);
107 #ifdef USE_VIVE_GESTURE 108 void UpdateGesture(GestureResult result,
unsigned int deviceId);
109 GestureType GetLastGesture();
113 void SetState(
bool state);
114 void SetSide(VrControllerSide side);
115 VrControllerSide GetSide();
116 void SetType(ControllerType type);
117 ControllerType GetType();
122 void Rumble(
float value);
123 std::vector<bool> GetButtonsState();
137 vr::IVRSystem* mHMDSystem;
138 vr::HmdError mHMDError;
139 vr::TrackedDevicePose_t mTrackedPoses[vr::k_unMaxTrackedDeviceCount];
140 std::array<vr::VRTextureBounds_t, 2> mTexturesBounds;
141 std::array<vr::Texture_t, 2> mTextures;
144 std::array<sOpenvrController*, MAX_VR_CONTROLLERS> mControllers;
145 vr::IVRTrackedCamera* mCamera;
146 vr::TrackedCameraHandle_t mTrackedCameraHandle;
147 uint32_t mCameraWidth;
148 uint32_t mCameraHeight;
149 uint32_t mCameraFrameBufferSize;
150 uint8_t* mCameraFrameBuffer;
151 uint32_t mCameraLastFrameId;
156 vr::VRActionSetHandle_t mActionSet;
157 std::string mInputPath;
160 #ifdef USE_VIVE_GESTURE 161 bool mGestureInterface;
162 GestureOption mGestureOption;
163 int mLastGestureFrameIndex;
176 static Matrix4 getMatrix4FromSteamVRMatrix34(
const vr::HmdMatrix34_t& mat);
184 bool GetHmdPosition(
Vector3 &vec);
186 std::string GetHmdName();
187 bool GetProjectionMatrix(vr::EVREye eye,
float nearclip,
float farclip,
Matrix4 &mat);
188 bool GetStereoTextureSize(
unsigned int &w,
unsigned int &h);
189 float GetStereoConfigAspect();
190 float GetStereoConfigFovY();
191 float GetStereoIPD();
193 void UpdateTextures(
void* leftTexture,
void* rightTexture, vr::ETextureType type);
198 bool IsCameraEnable();
199 void GetCameraSize(uint32_t &w, uint32_t &h);
202 bool GetCameraFrame(PtrObjBitmap scolBitmap);
206 void ProcessEvents();
207 void ProcessTrackedDevices();
218 SConvertBuffer(uchar* _srcBuff, uchar* _srcBuffa,
void* _dstBuff,
const int &_width,
const int &_height,
const int &_sbpl,
const int &_abpl,
const int &_dbpl,
const int &_bpp) :
248 static void BuffToBitmap(
const int start,
const int end,
const SConvertBuffer &conv);
sOpenvrController(vr::IVRSystem *hmdSystem, unsigned int id)