13#include <unordered_map>
15#include <condition_variable>
21#include "openvr_driver.h"
29 using ContextPtr = std::shared_ptr<Context>;
31 vr::ITrackedDeviceServerDriver *driver;
33 const std::string &steam_install;
36 vr::ITrackedDeviceServerDriver *p_driver,
38 const std::string &p_stream_install)
39 : ctx{p_ctx}, driver{p_driver}, serial{p_serial}, steam_install{p_stream_install}
51 Property(vr::PropertyTypeTag_t tag,
void *buffer, uint32_t bufferSize);
53 vr::PropertyTypeTag_t tag;
54 std::vector<uint8_t> buffer;
66 get_input_from_name(std::string_view
name);
72 update_pose(
const vr::DriverPose_t &newPose)
const;
78 vr::ETrackedPropertyError
79 handle_properties(
const vr::PropertyWrite_t *batch, uint32_t count);
81 vr::ETrackedPropertyError
82 handle_read_properties(vr::PropertyRead_t *batch, uint32_t count);
93 std::shared_ptr<Context> ctx;
94 vr::PropertyContainerHandle_t container_handle{0};
95 std::unordered_map<vr::ETrackedDeviceProperty, Property> properties;
96 std::unordered_map<std::string_view, xrt_input *> inputs_map;
97 std::vector<xrt_input> inputs_vec;
98 inline static xrt_pose chaperone = XRT_POSE_IDENTITY;
100 std::string manufacturer;
102 float vsync_to_photon_ns{0.f};
103 bool provides_battery_status{
false};
104 bool charging{
false};
107 vr::ETrackedPropertyError
108 handle_generic_property_write(
const vr::PropertyWrite_t &prop);
109 vr::ETrackedPropertyError
110 handle_generic_property_read(vr::PropertyRead_t &prop);
112 virtual vr::ETrackedPropertyError
113 handle_property_write(
const vr::PropertyWrite_t &prop);
116 vr::ITrackedDeviceServerDriver *driver;
117 uint64_t current_frame{0};
119 std::mutex frame_mutex;
122 init_chaperone(
const std::string &steam_install);
133 vr::IVRDisplayComponent *display;
148 SetDisplayEyeToHead(uint32_t unWhichDevice,
149 const vr::HmdMatrix34_t &eyeToHeadLeft,
150 const vr::HmdMatrix34_t &eyeToHeadRight);
154 uint64_t at_timestamp_ns,
164 set_hmd_parts(std::unique_ptr<Parts> parts);
178 std::unique_ptr<Parts> hmd_parts{
nullptr};
180 vr::ETrackedPropertyError
181 handle_property_write(
const vr::PropertyWrite_t &prop)
override;
184 set_nominal_frame_interval(uint64_t interval_ns);
186 std::condition_variable hmd_parts_cv;
187 std::mutex hmd_parts_mut;
188 float brightness{1.0f};
189 AnalogGainRange analog_gain_range{};
202 set_haptic_handle(vr::VRInputComponentHandle_t handle);
208 get_finger_from_name(std::string_view
name);
212 int64_t desired_timestamp_ns,
214 int64_t *out_timestamp_ns);
224 set_input_class(
const InputClass *input_class);
227 vr::VRInputComponentHandle_t haptic_handle{0};
228 std::unique_ptr<xrt_output> output{
nullptr};
229 bool has_index_hand_tracking{
false};
230 std::vector<IndexFingerInput> finger_inputs_vec;
231 std::unordered_map<std::string_view, IndexFingerInput *> finger_inputs_map;
232 uint64_t hand_tracking_timestamp;
237 vr::ETrackedPropertyError
238 handle_property_write(
const vr::PropertyWrite_t &prop)
override;
Definition: context.hpp:57
Definition: device.hpp:194
Definition: device.hpp:58
void get_pose(uint64_t at_timestamp_ns, xrt_space_relation *out_relation)
Helper to use the m_relation_history member.
Definition: device.cpp:469
xrt_result_t update_inputs()
Update any attached inputs.
Definition: device.cpp:435
virtual xrt_result_t get_tracked_pose(xrt_input_name name, uint64_t at_timestamp_ns, xrt_space_relation *out_relation)=0
Maps to xrt_device::get_tracked_pose.
Definition: device.hpp:126
Definition: device.hpp:49
SteamVR driver context - implements xrt_tracking_origin and IVRDriverContext.
VIVE_VARIANT
Headset variant.
Definition: vive_common.h:42
xrt_hand
Enumeration for left and right hand.
Definition: xrt_defines.h:1370
xrt_input_name
Every internal input source known to monado with a baked in type.
Definition: xrt_defines.h:1314
enum xrt_result xrt_result_t
Result type used across Monado.
xrt_output_name
Name of a output with a baked in type.
Definition: xrt_defines.h:1944
Small utility for keeping track of the history of an xrt_space_relation, ie.
Definition: device.hpp:28
Definition: device.hpp:137
Definition: device.hpp:131
Definition: m_relation_history.cpp:49
A single HMD or input device.
Definition: xrt_device.h:282
xrt_result_t(* set_output)(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value)
Set a output value.
Definition: xrt_device.h:461
xrt_result_t(* compute_distortion)(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result)
Compute the distortion at a single point.
Definition: xrt_device.h:587
xrt_result_t(* get_hand_tracking)(struct xrt_device *xdev, enum xrt_input_name name, int64_t desired_timestamp_ns, struct xrt_hand_joint_set *out_value, int64_t *out_timestamp_ns)
Get relationship of hand joints to the tracking origin space as the base space.
Definition: xrt_device.h:383
xrt_result_t(* set_brightness)(struct xrt_device *xdev, float brightness, bool relative)
Set the display brightness.
Definition: xrt_device.h:666
xrt_result_t(* get_battery_status)(struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge)
Get battery status information.
Definition: xrt_device.h:642
xrt_result_t(* get_view_poses)(struct xrt_device *xdev, const struct xrt_vec3 *default_eye_relation, int64_t at_timestamp_ns, uint32_t view_count, struct xrt_space_relation *out_head_relation, struct xrt_fov *out_fovs, struct xrt_pose *out_poses)
Get the per-view pose in relation to the view space.
Definition: xrt_device.h:565
xrt_result_t(* get_brightness)(struct xrt_device *xdev, float *out_brightness)
Get the current display brightness.
Definition: xrt_device.h:654
enum xrt_device_name name
Enum identifier of the device.
Definition: xrt_device.h:284
xrt_result_t(* get_tracked_pose)(struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, struct xrt_space_relation *out_relation)
Get relationship of a tracked device to the tracking origin space as the base space.
Definition: xrt_device.h:355
Describes a projection matrix fov.
Definition: xrt_defines.h:484
Joint set type used for hand tracking.
Definition: xrt_defines.h:1413
All of the device components that deals with interfacing to a users head.
Definition: xrt_device.h:92
A union of all output types.
Definition: xrt_defines.h:2069
A pose composed of a position and orientation.
Definition: xrt_defines.h:464
A relation with two spaces, includes velocity and acceleration.
Definition: xrt_defines.h:655
Represents a uv triplet for distortion, basically just three xrt_vec2.
Definition: xrt_defines.h:264
A 3 element vector with single floats.
Definition: xrt_defines.h:274
Common things like defines for Vive and Index.
Header defining an xrt display or controller device.