mirror of
https://github.com/WiVRn/WiVRn.git
synced 2026-11-20 09:01:39 -08:00
Send interaction profiles
This commit is contained in:
1 parent
ad9020193d
commit
5151acaad2
3 files changed
+83
-2
No files matched your search
@@ -77,6 +77,7 @@ private:
|
||||
std::thread network_thread;
|
||||
std::mutex tracking_control_mutex;
|
||||
to_headset::tracking_control tracking_control{};
|
||||
std::array<std::atomic<interaction_profile>, 2> interaction_profiles; // left and right hand
|
||||
std::atomic<bool> recenter_requested = false;
|
||||
std::atomic<XrDuration> display_time_phase = 0;
|
||||
std::atomic<XrDuration> display_time_period = 0;
|
||||
|
||||
@@ -178,6 +178,7 @@ void scenes::stream::tracking()
|
||||
XrTime next_battery_check = 0;
|
||||
const XrDuration battery_check_interval = 30'000'000'000; // 30s
|
||||
#endif
|
||||
|
||||
std::vector<std::pair<device_id, XrSpace>> spaces = {
|
||||
{device_id::HEAD, application::space(xr::spaces::view)},
|
||||
{device_id::LEFT_AIM, application::space(xr::spaces::aim_left)},
|
||||
@@ -358,7 +359,10 @@ void scenes::stream::tracking()
|
||||
size_t size = serialized_size(item);
|
||||
if (size + current_size > 1400)
|
||||
{
|
||||
merged_tracking.emplace_back();
|
||||
merged_tracking.emplace_back().interaction_profiles = {
|
||||
interaction_profiles[0].load(),
|
||||
interaction_profiles[1].load(),
|
||||
};
|
||||
current_size = 0;
|
||||
}
|
||||
current_size += size;
|
||||
@@ -420,7 +424,7 @@ void scenes::stream::operator()(to_headset::tracking_control && packet)
|
||||
tracking_control.min_offset = std::min(tracking_control.min_offset, tracking_control.max_offset);
|
||||
}
|
||||
|
||||
void scenes::stream::on_interaction_profile_changed(const XrEventDataInteractionProfileChanged & event)
|
||||
void scenes::stream::on_interaction_profile_changed(const XrEventDataInteractionProfileChanged &)
|
||||
{
|
||||
auto now = instance.now();
|
||||
for (auto [target, space]: {
|
||||
@@ -465,4 +469,51 @@ void scenes::stream::on_interaction_profile_changed(const XrEventDataInteraction
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
std::array path = {
|
||||
"/user/hand/left",
|
||||
"/user/hand/right",
|
||||
};
|
||||
#define DO_PROFILE(vendor, name) \
|
||||
if (profile == "/interaction_profiles/" #vendor "/" #name) \
|
||||
{ \
|
||||
interaction_profiles[i] = interaction_profile::vendor##_##name; \
|
||||
continue; \
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 2; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto profile = session.get_current_interaction_profile(path[i]);
|
||||
spdlog::info("interaction profile for {}: {}", path[i], profile);
|
||||
DO_PROFILE(khr, simple_controller)
|
||||
DO_PROFILE(bd, pico_neo3_controller)
|
||||
DO_PROFILE(bd, pico4_controller)
|
||||
DO_PROFILE(bd, pico_g3_controller)
|
||||
DO_PROFILE(google, daydream_controller)
|
||||
DO_PROFILE(hp, mixed_reality_controller)
|
||||
DO_PROFILE(htc, vive_controller)
|
||||
DO_PROFILE(htc, vive_cosmos_controller)
|
||||
DO_PROFILE(htc, vive_focus3_controller)
|
||||
DO_PROFILE(htc, vive_pro)
|
||||
DO_PROFILE(ml, ml2_controller)
|
||||
DO_PROFILE(microsoft, motion_controller)
|
||||
DO_PROFILE(microsoft, xbox_controller)
|
||||
DO_PROFILE(oculus, go_controller)
|
||||
DO_PROFILE(oculus, touch_controller)
|
||||
DO_PROFILE(meta, touch_pro_controller)
|
||||
DO_PROFILE(meta, touch_plus_controller)
|
||||
DO_PROFILE(meta, touch_controller_rift_cv1)
|
||||
DO_PROFILE(meta, touch_controller_quest_1_rift_s)
|
||||
DO_PROFILE(meta, touch_controller_quest_2)
|
||||
DO_PROFILE(samsung, odyssey_controller)
|
||||
DO_PROFILE(valve, index_controller)
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
spdlog::warn("Failed to get current interation profile: {}", e.what());
|
||||
}
|
||||
interaction_profiles[i] = interaction_profile::none;
|
||||
}
|
||||
}
|
||||
@@ -83,6 +83,33 @@ enum class device_id : uint8_t
|
||||
EYE_GAZE, // /user/eyes_ext/input/gaze_ext/pose
|
||||
};
|
||||
|
||||
enum class interaction_profile : uint8_t
|
||||
{
|
||||
none,
|
||||
khr_simple_controller,
|
||||
bd_pico_neo3_controller,
|
||||
bd_pico4_controller,
|
||||
bd_pico_g3_controller,
|
||||
google_daydream_controller,
|
||||
hp_mixed_reality_controller,
|
||||
htc_vive_controller,
|
||||
htc_vive_cosmos_controller,
|
||||
htc_vive_focus3_controller,
|
||||
htc_vive_pro,
|
||||
ml_ml2_controller,
|
||||
microsoft_motion_controller,
|
||||
microsoft_xbox_controller,
|
||||
oculus_go_controller,
|
||||
oculus_touch_controller,
|
||||
meta_touch_pro_controller,
|
||||
meta_touch_plus_controller,
|
||||
meta_touch_controller_rift_cv1,
|
||||
meta_touch_controller_quest_1_rift_s,
|
||||
meta_touch_controller_quest_2,
|
||||
samsung_odyssey_controller,
|
||||
valve_index_controller,
|
||||
};
|
||||
|
||||
enum video_codec
|
||||
{
|
||||
h264,
|
||||
@@ -228,6 +255,8 @@ struct tracking
|
||||
|
||||
struct trackings
|
||||
{
|
||||
// /user/hand/left and /user/hand/right
|
||||
std::array<interaction_profile, 2> interaction_profiles;
|
||||
std::vector<tracking> items;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user