From cde3a9046ee505bb2c2f65aae5c20d781fef3597 Mon Sep 17 00:00:00 2001 From: r57zone Date: Fri, 6 Oct 2023 16:05:24 +0400 Subject: [PATCH] Fixes: Button codes and OpenXR, Unity movement by HadesVR --- .../samples/driver_sample/driver_sample.cpp | 29 ++++++++++++++++--- .../samples/driver_sample/driver_sample.cpp | 29 ++++++++++++++++--- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/OpenVR/FreeTrack/samples/driver_sample/driver_sample.cpp b/OpenVR/FreeTrack/samples/driver_sample/driver_sample.cpp index 06179ae..6d43bd2 100644 --- a/OpenVR/FreeTrack/samples/driver_sample/driver_sample.cpp +++ b/OpenVR/FreeTrack/samples/driver_sample/driver_sample.cpp @@ -242,8 +242,8 @@ int KeyNameToKeyCode(std::string KeyName) { else if (KeyName == "I") return 'I'; else if (KeyName == "O") return 'O'; else if (KeyName == "P") return 'P'; - else if (KeyName == "[") return '['; - else if (KeyName == "]") return ']'; + else if (KeyName == "[") return 219; + else if (KeyName == "]") return 221; else if (KeyName == "A") return 'A'; else if (KeyName == "S") return 'S'; else if (KeyName == "D") return 'D'; @@ -253,8 +253,8 @@ int KeyNameToKeyCode(std::string KeyName) { else if (KeyName == "J") return 'J'; else if (KeyName == "K") return 'K'; else if (KeyName == "L") return 'L'; - else if (KeyName == ";") return 186; - else if (KeyName == "'") return 222; + else if (KeyName == ":") return 186; + else if (KeyName == "APOSTROPHE") return 222; else if (KeyName == "\\") return 220; else if (KeyName == "Z") return 'Z'; else if (KeyName == "X") return 'X'; @@ -369,6 +369,24 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, Prop_ModelNumber_String, m_sModelNumber.c_str() ); vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, Prop_RenderModelName_String, m_sModelNumber.c_str() ); + + vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, Prop_SerialNumber_String, m_sSerialNumber.c_str()); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_WillDriftInYaw_Bool, false); + vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, Prop_ManufacturerName_String, "OpenVR-OpenTrack"); + vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, Prop_TrackingFirmwareVersion_String, "1.0"); + vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, Prop_HardwareRevision_String, "1.0"); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_DeviceIsWireless_Bool, false); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_DeviceIsCharging_Bool, false); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_CanUnifyCoordinateSystemWithHmd_Bool, true); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_ContainsProximitySensor_Bool, false); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_DeviceCanPowerOff_Bool, false); + vr::VRProperties()->SetInt32Property(m_ulPropertyContainer, vr::Prop_DeviceClass_Int32, vr::TrackedDeviceClass_HMD); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, vr::Prop_HasCamera_Bool, false); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, vr::Prop_Firmware_ForceUpdateRequired_Bool, false); + vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, vr::Prop_RegisteredDeviceType_String, "HMD"); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, vr::Prop_NeverTracked_Bool, false); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, vr::Prop_Identifiable_Bool, false); + vr::VRProperties()->SetFloatProperty( m_ulPropertyContainer, Prop_UserIpdMeters_Float, m_flIPD ); vr::VRProperties()->SetFloatProperty( m_ulPropertyContainer, Prop_UserHeadToEyeDepthMeters_Float, 0.f ); vr::VRProperties()->SetFloatProperty( m_ulPropertyContainer, Prop_DisplayFrequency_Float, m_flDisplayFrequency ); @@ -549,6 +567,9 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV pose.qWorldFromDriverRotation = HmdQuaternion_Init(1, 0, 0, 0); pose.qDriverFromHeadRotation = HmdQuaternion_Init(1, 0, 0, 0); + pose.shouldApplyHeadModel = true; + pose.poseTimeOffset = 0; + pose.willDriftInYaw = false; if (HMDConnected) { //Set head tracking rotation diff --git a/OpenVR/UDP/samples/driver_sample/driver_sample.cpp b/OpenVR/UDP/samples/driver_sample/driver_sample.cpp index 0704b05..d5b5b2f 100644 --- a/OpenVR/UDP/samples/driver_sample/driver_sample.cpp +++ b/OpenVR/UDP/samples/driver_sample/driver_sample.cpp @@ -206,8 +206,8 @@ int KeyNameToKeyCode(std::string KeyName) { else if (KeyName == "I") return 'I'; else if (KeyName == "O") return 'O'; else if (KeyName == "P") return 'P'; - else if (KeyName == "[") return '['; - else if (KeyName == "]") return ']'; + else if (KeyName == "[") return 219; + else if (KeyName == "]") return 221; else if (KeyName == "A") return 'A'; else if (KeyName == "S") return 'S'; else if (KeyName == "D") return 'D'; @@ -217,8 +217,8 @@ int KeyNameToKeyCode(std::string KeyName) { else if (KeyName == "J") return 'J'; else if (KeyName == "K") return 'K'; else if (KeyName == "L") return 'L'; - else if (KeyName == ";") return 186; - else if (KeyName == "'") return 222; + else if (KeyName == ":") return 186; + else if (KeyName == "APOSTROPHE") return 222; else if (KeyName == "\\") return 220; else if (KeyName == "Z") return 'Z'; else if (KeyName == "X") return 'X'; @@ -329,6 +329,24 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, Prop_ModelNumber_String, m_sModelNumber.c_str() ); vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, Prop_RenderModelName_String, m_sModelNumber.c_str() ); + + vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, Prop_SerialNumber_String, m_sSerialNumber.c_str()); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_WillDriftInYaw_Bool, false); + vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, Prop_ManufacturerName_String, "OpenVR-OpenTrack"); + vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, Prop_TrackingFirmwareVersion_String, "1.0"); + vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, Prop_HardwareRevision_String, "1.0"); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_DeviceIsWireless_Bool, false); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_DeviceIsCharging_Bool, false); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_CanUnifyCoordinateSystemWithHmd_Bool, true); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_ContainsProximitySensor_Bool, false); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_DeviceCanPowerOff_Bool, false); + vr::VRProperties()->SetInt32Property(m_ulPropertyContainer, vr::Prop_DeviceClass_Int32, vr::TrackedDeviceClass_HMD); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, vr::Prop_HasCamera_Bool, false); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, vr::Prop_Firmware_ForceUpdateRequired_Bool, false); + vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, vr::Prop_RegisteredDeviceType_String, "HMD"); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, vr::Prop_NeverTracked_Bool, false); + vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, vr::Prop_Identifiable_Bool, false); + vr::VRProperties()->SetFloatProperty( m_ulPropertyContainer, Prop_UserIpdMeters_Float, m_flIPD ); vr::VRProperties()->SetFloatProperty( m_ulPropertyContainer, Prop_UserHeadToEyeDepthMeters_Float, 0.f ); vr::VRProperties()->SetFloatProperty( m_ulPropertyContainer, Prop_DisplayFrequency_Float, m_flDisplayFrequency ); @@ -511,6 +529,9 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV pose.qWorldFromDriverRotation = HmdQuaternion_Init(1, 0, 0, 0); pose.qDriverFromHeadRotation = HmdQuaternion_Init(1, 0, 0, 0); + pose.shouldApplyHeadModel = true; + pose.poseTimeOffset = 0; + pose.willDriftInYaw = false; //Set head tracking rotation pose.qRotation = EulerAngleToQuaternion(Roll, -Yaw, Pitch);