Skip to content

Commit

Permalink
Fixes: Button codes and OpenXR, Unity movement by HadesVR
Browse files Browse the repository at this point in the history
  • Loading branch information
r57zone committed Oct 6, 2023
1 parent 5575bb2 commit cde3a90
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
29 changes: 25 additions & 4 deletions OpenVR/FreeTrack/samples/driver_sample/driver_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand Down
29 changes: 25 additions & 4 deletions OpenVR/UDP/samples/driver_sample/driver_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit cde3a90

Please sign in to comment.