----------------------------------------------------------------------------- Purpose: This is never called by vrserver in recent OpenVR versions, but is useful for giving data to vr::VRServerDriverHost::TrackedDevicePoseUpdated. -----------------------------------------------------------------------------
| 145 | // but is useful for giving data to vr::VRServerDriverHost::TrackedDevicePoseUpdated. |
| 146 | //----------------------------------------------------------------------------- |
| 147 | vr::DriverPose_t MyHMDControllerDeviceDriver::GetPose() |
| 148 | { |
| 149 | // Let's retrieve the Hmd pose to base our controller pose off. |
| 150 | |
| 151 | // First, initialize the struct that we'll be submitting to the runtime to tell it we've updated our pose. |
| 152 | vr::DriverPose_t pose = { 0 }; |
| 153 | |
| 154 | // These need to be set to be valid quaternions. The device won't appear otherwise. |
| 155 | pose.qWorldFromDriverRotation.w = 1.f; |
| 156 | pose.qDriverFromHeadRotation.w = 1.f; |
| 157 | |
| 158 | pose.qRotation.w = 1.f; |
| 159 | |
| 160 | pose.vecPosition[ 0 ] = 0.0f; |
| 161 | pose.vecPosition[ 1 ] = sin( frame_number_ * 0.01 ) * 0.1f + 1.0f; // slowly move the hmd up and down. |
| 162 | pose.vecPosition[ 2 ] = 0.0f; |
| 163 | |
| 164 | // The pose we provided is valid. |
| 165 | // This should be set is |
| 166 | pose.poseIsValid = true; |
| 167 | |
| 168 | // Our device is always connected. |
| 169 | // In reality with physical devices, when they get disconnected, |
| 170 | // set this to false and icons in SteamVR will be updated to show the device is disconnected |
| 171 | pose.deviceIsConnected = true; |
| 172 | |
| 173 | // The state of our tracking. For our virtual device, it's always going to be ok, |
| 174 | // but this can get set differently to inform the runtime about the state of the device's tracking |
| 175 | // and update the icons to inform the user accordingly. |
| 176 | pose.result = vr::TrackingResult_Running_OK; |
| 177 | |
| 178 | // For HMDs we want to apply rotation/motion prediction |
| 179 | pose.shouldApplyHeadModel = true; |
| 180 | |
| 181 | return pose; |
| 182 | } |
| 183 | |
| 184 | void MyHMDControllerDeviceDriver::MyPoseUpdateThread() |
| 185 | { |
nothing calls this directly
no outgoing calls
no test coverage detected