Remove model enum, change Quest default power mode

Store all quirks in the hmd_traits object
This commit is contained in:
Patrick Nicolas
2026-05-10 19:11:17 +02:00
committed by xytovl
parent 209145ce0d
commit d8fbbb23ab
12 changed files with 290 additions and 479 deletions
+5 -33
View File
@@ -749,8 +749,7 @@ void application::initialize_vulkan()
instance_extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
}
if (!strcmp(i.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) and
guess_model() != model::oculus_quest) // Quest 1 lies, the extension won't load
if (!strcmp(i.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) and hmd_traits.vk_debug_ext_allowed)
{
debug_utils_found = true;
instance_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
@@ -1006,21 +1005,8 @@ void application::initialize_actions()
profile.available = std::ranges::all_of(profile.required_extensions, [&](auto & ext) { return xr_instance.has_extension(ext); }) and
profile.min_version <= api_version;
if (profile.profile_name.ends_with("khr/simple_controller"))
{
switch (guess_model())
{
// Quest hand tracking creates a fake khr/simple_controller when hand tracking
// is enabled, this messes with native hand tracking
case model::meta_quest_3:
case model::meta_quest_pro:
case model::meta_quest_3s:
case model::oculus_quest_2:
profile.available = false;
default:
break;
}
}
if (profile.profile_name.ends_with("khr/simple_controller") and not hmd_traits.bind_simple_controller)
profile.available = false;
if (!profile.available)
continue;
@@ -1028,21 +1014,8 @@ void application::initialize_actions()
// Patch profile to add grip_surface or palm_ext
bool add_palms = true;
if (profile.profile_name.ends_with("ext/hand_interaction_ext"))
{
switch (guess_model())
{
// Quest breaks spec and does not support grip_surface for ext/hand_interaction_ext
case model::meta_quest_3:
case model::meta_quest_pro:
case model::meta_quest_3s:
case model::oculus_quest_2:
case model::oculus_quest:
add_palms = false;
break;
default:
break;
}
}
add_palms = hmd_traits.hand_interaction_grip_surface;
if (add_palms)
{
if ((api_version >= XR_MAKE_VERSION(1, 1, 0) or xr_instance.has_extension(XR_KHR_MAINTENANCE1_EXTENSION_NAME)) //
@@ -1465,7 +1438,6 @@ application::application(application_info info) :
app_info(std::move(info))
{
initialize_runtime_hmd_traits();
#ifdef __ANDROID__
// https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html
+2 -25
View File
@@ -70,7 +70,7 @@ bool configuration::check_feature(feature f) const
}
}
#ifdef __ANDROID__
return check_permission(permission_name_for_hmd(runtime_hmd_traits(), f));
return check_permission(hmd_traits.permissions[f]);
#else
return true;
#endif
@@ -81,7 +81,7 @@ void configuration::set_feature(feature f, bool state)
#ifdef __ANDROID__
if (state)
{
request_permission(permission_name_for_hmd(runtime_hmd_traits(), f), [this, f](bool granted) {
request_permission(hmd_traits.permissions[f], [this, f](bool granted) {
{
std::lock_guard lock(mutex);
features[f] = granted;
@@ -103,29 +103,6 @@ configuration::configuration(xr::system & system, xr::session & session)
{
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
features[feature::hand_tracking] = system.hand_tracking_supported();
switch (guess_model())
{
case model::oculus_quest:
case model::oculus_quest_2:
case model::meta_quest_pro:
case model::meta_quest_3:
case model::meta_quest_3s:
high_power_mode = false;
break;
case model::pico_neo_3:
case model::pico_4:
case model::pico_4s:
case model::pico_4_pro:
case model::pico_4_enterprise:
case model::htc_vive_focus_3:
case model::htc_vive_xr_elite:
case model::htc_vive_focus_vision:
case model::lynx_r1:
case model::samsung_galaxy_xr:
case model::unknown:
high_power_mode = true;
break;
}
const auto & rates = session.get_refresh_rates();
for (auto rate: rates)
+1 -1
View File
@@ -80,7 +80,7 @@ public:
float override_foveation_pitch = -10 * M_PI / 180;
float override_foveation_distance = 3;
bool high_power_mode;
bool high_power_mode = true;
uint32_t fps_divider = 1;
// Allow unsafe config values
+178 -263
View File
@@ -25,7 +25,6 @@
#include <cstring>
#include <glm/ext/quaternion_trigonometric.hpp>
#include <limits>
#include <stdexcept>
#include <string>
#include <spdlog/spdlog.h>
@@ -35,12 +34,13 @@
#include <sys/system_properties.h>
static std::string get_property(const char * property)
static std::optional<std::string> get_property(const char * property)
{
auto info = __system_property_find(property);
std::string result;
if (not info)
return result;
return std::nullopt;
std::string result;
wrap_lambda cb = [&result](const char * name, const char * value, uint32_t serial) {
result = value;
};
@@ -50,300 +50,215 @@ static std::string get_property(const char * property)
}
#endif
static model guess_model_()
static std::optional<std::string> env_string(const char * env_name, const char * android_sysprop_name)
{
#ifdef __ANDROID__
return get_property(android_sysprop_name);
#else
const char * value = std::getenv(env_name);
if (value)
return value;
return std::nullopt;
#endif
}
static std::optional<uint32_t> env_u32(const char * env_name, const char * android_sysprop_name)
{
const auto value = env_string(env_name, android_sysprop_name);
if (not value)
return std::nullopt;
try
{
const unsigned long parsed = std::stoul(*value);
if (parsed > std::numeric_limits<uint32_t>::max())
return std::nullopt;
return static_cast<uint32_t>(parsed);
}
catch (std::runtime_error & e)
{
spdlog::warn("failed to parse {} (value: {}: {}",
#ifdef __ANDROID__
android_sysprop_name,
#else
env_name,
#endif
*value,
e.what()
);
return std::nullopt;
}
}
static std::optional<bool> env_bool(const char * env_name, const char * android_sysprop_name)
{
const auto value = env_string(env_name, android_sysprop_name);
if (not value)
return std::nullopt;
if (strcmp(value->c_str(), "1") == 0 || strcasecmp(value->c_str(), "true") == 0 || strcasecmp(value->c_str(), "yes") == 0 || strcasecmp(value->c_str(), "on") == 0)
return true;
if (strcmp(value->c_str(), "0") == 0 || strcasecmp(value->c_str(), "false") == 0 || strcasecmp(value->c_str(), "no") == 0 || strcasecmp(value->c_str(), "off") == 0)
return false;
return std::nullopt;
}
const hmd_traits_t hmd_traits = [] {
hmd_traits_t traits{};
#ifdef __ANDROID__
const auto device = get_property("ro.product.device");
const auto manufacturer = get_property("ro.product.manufacturer");
const auto model = get_property("ro.product.model");
spdlog::info("Guessing HMD model from:");
spdlog::info(" ro.product.device = \"{}\":", device);
spdlog::info(" ro.product.manufacturer = \"{}\":", manufacturer);
spdlog::info(" ro.product.model = \"{}\":", model);
spdlog::info(" ro.product.device = \"{}\":", device.value_or("<unset>"));
spdlog::info(" ro.product.manufacturer = \"{}\":", manufacturer.value_or("<unset>"));
spdlog::info(" ro.product.model = \"{}\":", model.value_or("<unset>"));
if (device == "monterey")
return model::oculus_quest;
if (device == "hollywood")
return model::oculus_quest_2;
if (device == "seacliff")
return model::meta_quest_pro;
if (device == "eureka")
return model::meta_quest_3;
if (device == "panther")
return model::meta_quest_3s;
if (model == "Lynx-R1")
return model::lynx_r1;
traits.permissions[feature::microphone] = "android.permission.RECORD_AUDIO";
if (manufacturer == "Pico")
if (manufacturer == "Oculus")
{
traits.permissions[feature::eye_gaze] = "com.oculus.permission.EYE_TRACKING";
traits.permissions[feature::face_tracking] = "com.oculus.permission.FACE_TRACKING";
// Quest hand tracking creates a fake khr/simple_controller when hand tracking
// is enabled, this messes with native hand tracking
traits.bind_simple_controller = false;
// Quest breaks spec and does not support grip_surface for ext/hand_interaction_ext
traits.hand_interaction_grip_surface = false;
if (device == "monterey") // Quest 1
{
traits.panel_width_override = 1440;
traits.controller_profile = "oculus-touch-v2";
traits.vk_debug_ext_allowed = false; // Quest 1 lies, the extension won't load
}
else if (device == "hollywood") // Quest 2
{
traits.panel_width_override = 1832;
traits.controller_profile = "oculus-touch-v3";
}
else if (device == "seacliff")
{
traits.panel_width_override = 1800; // Quest pro
traits.controller_profile = "meta-quest-touch-pro";
}
else if (device == "eureka")
{
traits.panel_width_override = 2064; // Quest 3
traits.controller_profile = "meta-quest-touch-plus";
}
else if (device == "panther") // Quest 3S
{
traits.panel_width_override = 1832;
traits.controller_profile = "meta-quest-touch-plus";
}
}
else if (model == "Lynx-R1")
{
traits.needs_srgb_conversion = false;
}
else if (manufacturer == "Pico")
{
traits.permissions[feature::eye_gaze] = "com.picovr.permission.EYE_TRACKING";
traits.permissions[feature::face_tracking] = "com.picovr.permission.FACE_TRACKING";
traits.view_locate = false;
const auto pico_model = get_property("pxr.vendorhw.product.model");
spdlog::info(" pxr.vendorhw.product.model = \"{}\":", pico_model);
spdlog::info(" pxr.vendorhw.product.model = \"{}\":", pico_model.value_or("<unset>"));
if (pico_model == "Pico Neo 3")
return model::pico_neo_3;
{
traits.panel_width_override = 1832;
traits.controller_profile = "pico-neo3";
}
if (pico_model == "PICO 4")
return model::pico_4;
else if (pico_model and pico_model->starts_with("PICO 4"))
{
traits.panel_width_override = 2160;
if (pico_model == "PICO 4 Ultra")
traits.controller_profile = "pico-4u";
else
traits.controller_profile = "pico-4";
if (pico_model == "PICO 4 Ultra")
return model::pico_4s;
if (pico_model == "PICO 4 Pro")
return model::pico_4_pro;
if (pico_model == "PICO 4 Enterprise")
return model::pico_4_enterprise;
spdlog::info("manufacturer={}, model={}, device={}, pico_model={} assuming Pico 4", manufacturer, model, device, pico_model);
return model::pico_4;
if (pico_model == "PICO 4 Pro" or pico_model == "PICO 4 Enterprise")
traits.pico_face_tracker = true;
}
}
if (manufacturer == "HTC")
{
// Accepts OpenXR 1.1 but doesn't actually implement it
traits.max_openxr_api_version = XR_API_VERSION_1_0;
// Doesn't handle additive blend, so needs specific ray model
traits.controller_ray_model = "assets://ray-htc.glb";
traits.controller_profile = "htc-vive-focus-3";
if (model == "VIVE Focus 3")
return model::htc_vive_focus_3;
traits.panel_width_override = 2448;
if (model == "VIVE Focus Vision")
return model::htc_vive_focus_vision;
traits.panel_width_override = 2448;
if (model == "VIVE XR Series")
return model::htc_vive_xr_elite;
traits.panel_width_override = 1920;
}
if (manufacturer == "samsung")
{
if (model == "SM-I610")
return model::samsung_galaxy_xr;
}
spdlog::info("Unknown model, manufacturer={}, model={}, device={}", manufacturer, model, device);
#endif
return model::unknown;
}
model guess_model()
{
static model m = guess_model_();
return m;
}
const char * permission_name_for_hmd(const hmd_traits & traits, const feature f)
{
if (f == feature::microphone)
return "android.permission.RECORD_AUDIO";
if (!traits.permissions)
return nullptr;
return (*traits.permissions)[f];
}
static std::optional<uint32_t> env_u32(const char * env_name, const char * android_sysprop_name)
{
#ifdef __ANDROID__
const std::string value = get_property(android_sysprop_name);
#else
const char * env_value = std::getenv(env_name);
const std::string value = (env_value != nullptr) ? std::string(env_value) : std::string();
#endif
if (value.empty())
return std::nullopt;
char * end = nullptr;
const unsigned long parsed = std::strtoul(value.c_str(), &end, 10);
if (end == value.c_str() || *end != '\0')
return std::nullopt;
if (parsed > std::numeric_limits<uint32_t>::max())
return std::nullopt;
return static_cast<uint32_t>(parsed);
}
static std::optional<bool> env_bool(const char * env_name, const char * android_sysprop_name)
{
#ifdef __ANDROID__
const std::string value = get_property(android_sysprop_name);
#else
const char * env_value = std::getenv(env_name);
const std::string value = (env_value != nullptr) ? std::string(env_value) : std::string();
#endif
if (value.empty())
return std::nullopt;
if (strcmp(value.c_str(), "1") == 0 || strcasecmp(value.c_str(), "true") == 0 || strcasecmp(value.c_str(), "yes") == 0 || strcasecmp(value.c_str(), "on") == 0)
return true;
if (strcmp(value.c_str(), "0") == 0 || strcasecmp(value.c_str(), "false") == 0 || strcasecmp(value.c_str(), "no") == 0 || strcasecmp(value.c_str(), "off") == 0)
return false;
return std::nullopt;
}
static std::optional<std::string> env_string(const char * env_name, const char * android_sysprop_name)
{
#ifdef __ANDROID__
const std::string value = get_property(android_sysprop_name);
if (!value.empty())
return value;
return std::nullopt;
#else
const char * value = std::getenv(env_name);
if (value != nullptr)
return std::string(value);
return std::nullopt;
#endif
}
static const hmd_permissions permission_quest = [] {
hmd_permissions permissions{};
permissions[feature::eye_gaze] = "com.oculus.permission.EYE_TRACKING";
permissions[feature::face_tracking] = "com.oculus.permission.FACE_TRACKING";
return permissions;
}();
static const hmd_permissions permission_pico = [] {
hmd_permissions permissions{};
permissions[feature::eye_gaze] = "com.picovr.permission.EYE_TRACKING";
permissions[feature::face_tracking] = "com.picovr.permission.FACE_TRACKING";
return permissions;
}();
static const hmd_permissions permission_samsung = [] {
hmd_permissions permissions{};
permissions[feature::hand_tracking] = "android.permission.HAND_TRACKING";
permissions[feature::eye_gaze] = "android.permission.EYE_TRACKING_FINE";
permissions[feature::face_tracking] = "android.permission.FACE_TRACKING";
return permissions;
}();
static const hmd_permissions permission_quest_body = [] {
hmd_permissions permissions{};
permissions[feature::eye_gaze] = "com.oculus.permission.EYE_TRACKING";
permissions[feature::face_tracking] = "com.oculus.permission.FACE_TRACKING";
permissions[feature::body_tracking] = "com.oculus.permission.BODY_TRACKING";
return permissions;
}();
static hmd_traits get_hmd_traits(const model m)
{
hmd_traits traits{};
switch (m)
{
case model::oculus_quest:
traits.panel_width_override = 1440;
traits.controller_profile = "oculus-touch-v2";
traits.permissions = &permission_quest;
break;
case model::oculus_quest_2:
traits.panel_width_override = 1832;
traits.controller_profile = "oculus-touch-v3";
traits.permissions = &permission_quest;
break;
case model::meta_quest_pro:
traits.panel_width_override = 1800;
traits.controller_profile = "meta-quest-touch-pro";
traits.permissions = &permission_quest;
break;
case model::meta_quest_3:
traits.controller_profile = "meta-quest-touch-plus";
traits.panel_width_override = 2064;
traits.permissions = &permission_quest_body;
break;
case model::meta_quest_3s:
traits.panel_width_override = 1832;
traits.controller_profile = "meta-quest-touch-plus";
traits.permissions = &permission_quest_body;
break;
case model::pico_neo_3:
traits.panel_width_override = 1832;
traits.controller_profile = "pico-neo3";
traits.permissions = &permission_pico;
break;
case model::pico_4:
case model::pico_4_pro:
case model::pico_4_enterprise:
traits.panel_width_override = 2160;
traits.controller_profile = "pico-4";
traits.permissions = &permission_pico;
break;
case model::pico_4s:
traits.panel_width_override = 2160;
traits.controller_profile = "pico-4u";
traits.permissions = &permission_pico;
break;
case model::htc_vive_focus_3:
traits.panel_width_override = 2448;
traits.max_openxr_api_version = XR_API_VERSION_1_0;
traits.controller_profile = "htc-vive-focus-3";
traits.controller_ray_model = "assets://ray-htc.glb";
break;
case model::htc_vive_xr_elite:
traits.panel_width_override = 1920;
traits.max_openxr_api_version = XR_API_VERSION_1_0;
traits.controller_profile = "htc-vive-focus-3";
traits.controller_ray_model = "assets://ray-htc.glb";
break;
case model::htc_vive_focus_vision:
traits.panel_width_override = 2448;
traits.max_openxr_api_version = XR_API_VERSION_1_0;
traits.controller_profile = "htc-vive-focus-3";
traits.controller_ray_model = "assets://ray-htc.glb";
break;
case model::lynx_r1:
traits.needs_srgb_conversion = false;
break;
case model::samsung_galaxy_xr:
if (model == "SM-I610") // Galaxy XR
{
traits.panel_width_override = 3552;
traits.controller_profile = "samsung-galaxyxr";
traits.permissions = &permission_samsung;
break;
case model::unknown:
break;
traits.permissions[feature::hand_tracking] = "android.permission.HAND_TRACKING";
traits.permissions[feature::eye_gaze] = "android.permission.EYE_TRACKING_FINE";
traits.permissions[feature::face_tracking] = "android.permission.FACE_TRACKING";
}
}
#endif
if (auto panel_width = env_u32("WIVRN_QUIRK_PANEL_WIDTH", "debug.wivrn.quirk_panel_width"))
{
spdlog::info("panel width override: {} -> {}", traits.panel_width_override, *panel_width);
traits.panel_width_override = *panel_width;
}
return traits;
}
if (auto disable_openxr_1_1 = env_bool("WIVRN_QUIRK_DISABLE_OPENXR_1_1", "debug.wivrn.quirk_disable_openxr_1_1"))
{
auto old = traits.max_openxr_api_version;
traits.max_openxr_api_version = *disable_openxr_1_1 ? XR_API_VERSION_1_0 : XR_API_VERSION_1_1;
spdlog::info("max OpenXR version override: {} -> {}", xr::to_string(old), xr::to_string(traits.max_openxr_api_version));
}
namespace
{
hmd_traits g_hmd_traits;
std::string g_controller_override_storage;
} // namespace
if (auto srgb = env_bool("WIVRN_QUIRK_SRGB_CONVERSION", "debug.wivrn.quirk_srgb_conversion"))
{
spdlog::info("srgb conversion override: {} -> {}", traits.needs_srgb_conversion, *srgb);
traits.needs_srgb_conversion = *srgb;
}
if (auto controller = env_string("WIVRN_CONTROLLER", "debug.wivrn.controller"))
{
spdlog::info("controller override: {} -> {}", traits.controller_profile, *controller);
traits.controller_profile = *controller;
}
void initialize_runtime_hmd_traits()
{
hmd_traits q = get_hmd_traits(guess_model());
const std::optional<uint32_t> panel_width = env_u32("WIVRN_QUIRK_PANEL_WIDTH", "debug.wivrn.quirk_panel_width");
const bool had_panel_override = panel_width.has_value();
q.panel_width_override = panel_width.value_or(q.panel_width_override);
const std::optional<bool> disable_openxr_1_1_override = env_bool("WIVRN_QUIRK_DISABLE_OPENXR_1_1", "debug.wivrn.quirk_disable_openxr_1_1");
const bool disable_openxr_1_1 = disable_openxr_1_1_override.value_or(q.max_openxr_api_version < XR_API_VERSION_1_1);
q.max_openxr_api_version = disable_openxr_1_1 ? XR_API_VERSION_1_0 : XR_API_VERSION_1_1;
const std::optional<bool> srgb_override = env_bool("WIVRN_QUIRK_SRGB_CONVERSION", "debug.wivrn.quirk_srgb_conversion");
const bool srgb = srgb_override.value_or(q.needs_srgb_conversion);
const bool had_srgb_override = srgb_override.has_value();
q.needs_srgb_conversion = srgb;
g_controller_override_storage = env_string("WIVRN_CONTROLLER", "debug.wivrn.controller").value_or(std::string(q.controller_profile));
const bool had_controller_override = g_controller_override_storage != q.controller_profile;
q.controller_profile = g_controller_override_storage.c_str();
spdlog::info("Initialized HMD traits: profile={}, ray_model={}, panel_width_override={}, max_openxr_api={}, needs_srgb_conversion={}",
q.controller_profile,
q.controller_ray_model,
q.panel_width_override,
xr::to_string(q.max_openxr_api_version),
q.needs_srgb_conversion);
spdlog::info("HMD trait overrides: panel_width={}, disable_openxr_1_1={}, srgb_conversion={}, controller_profile={}",
had_panel_override,
disable_openxr_1_1_override.has_value(),
had_srgb_override,
had_controller_override);
q.is_initialized = true;
g_hmd_traits = q;
}
traits.controller_profile,
traits.controller_ray_model,
traits.panel_width_override,
xr::to_string(traits.max_openxr_api_version),
traits.needs_srgb_conversion);
const hmd_traits & runtime_hmd_traits()
{
// runtime_hmd_traits() must only be accessed after initialization has completed.
assert(g_hmd_traits.is_initialized && "runtime_hmd_traits() accessed before initialize_runtime_hmd_traits() completed");
return g_hmd_traits;
}
return traits;
}();
std::string model_name()
{
#ifdef __ANDROID__
const auto manufacturer = get_property("ro.product.manufacturer");
const auto model = get_property("ro.product.model");
const auto manufacturer = get_property("ro.product.manufacturer").value_or("");
const auto model = get_property("ro.product.model").value_or("");
return manufacturer + " " + model;
#else
@@ -360,14 +275,14 @@ static XrViewConfigurationView scale_view(XrViewConfigurationView view, uint32_t
return view;
}
XrViewConfigurationView override_view_for_hmd(const hmd_traits & traits, XrViewConfigurationView view)
XrViewConfigurationView hmd_traits_t::override_view_for_hmd(XrViewConfigurationView view) const
{
// Standalone headsets tend to report a lower resolution
// as the GPU can't handle full res.
// Return the panel resolution instead.
spdlog::debug("Recommended image size: {}x{}", view.recommendedImageRectWidth, view.recommendedImageRectHeight);
if (traits.panel_width_override > 0)
return scale_view(view, traits.panel_width_override);
if (panel_width_override > 0)
return scale_view(view, panel_width_override);
return view;
}
+11 -34
View File
@@ -27,26 +27,6 @@
#include <utility>
#include <openxr/openxr.h>
enum class model
{
oculus_quest,
oculus_quest_2,
meta_quest_pro,
meta_quest_3,
meta_quest_3s,
pico_neo_3,
pico_4,
pico_4s,
pico_4_pro,
pico_4_enterprise,
htc_vive_focus_3,
htc_vive_xr_elite,
htc_vive_focus_vision,
lynx_r1,
samsung_galaxy_xr,
unknown
};
enum class feature
{
microphone,
@@ -58,26 +38,23 @@ enum class feature
using hmd_permissions = magic_enum::containers::array<feature, const char *>;
struct hmd_traits
extern const struct hmd_traits_t
{
const char * controller_profile = "generic-trigger-squeeze";
std::string controller_profile = "generic-trigger-squeeze";
const char * controller_ray_model = "assets://ray.glb";
const hmd_permissions * permissions = nullptr;
hmd_permissions permissions{};
XrVersion max_openxr_api_version = XR_API_VERSION_1_1;
uint32_t panel_width_override = 0;
bool needs_srgb_conversion = true;
bool is_initialized = false;
};
bool view_locate = true; // can locate relative to view
bool vk_debug_ext_allowed = true;
bool bind_simple_controller = true;
bool hand_interaction_grip_surface = true;
bool pico_face_tracker = false;
XrViewConfigurationView override_view_for_hmd(XrViewConfigurationView) const;
} hmd_traits;
model guess_model();
std::string model_name();
void initialize_runtime_hmd_traits();
// Initialized once at startup (initialize_runtime_hmd_traits()).
// If the HMD is recognized, returns traits specific to that model; otherwise returns
// default behavior.
// Must only be called after initialize_runtime_hmd_traits().
const hmd_traits & runtime_hmd_traits();
const char * permission_name_for_hmd(const hmd_traits & traits, const feature f);
XrViewConfigurationView override_view_for_hmd(const hmd_traits & traits, XrViewConfigurationView);
std::pair<glm::vec3, glm::quat> controller_offset(std::string_view profile, xr::spaces space);
+1 -1
View File
@@ -306,7 +306,7 @@ input_profile::input_profile(scene & scene, const std::filesystem::path & json_p
else
continue;
auto && [ray_entity, ray_node] = scene.add_gltf(runtime_hmd_traits().controller_ray_model, layer_mask_ray);
auto && [ray_entity, ray_node] = scene.add_gltf(hmd_traits.controller_ray_model, layer_mask_ray);
ray_node.name = (std::string)layout.key + "_ray";
spdlog::debug("Created entity {}", ray_node.name);
+3 -3
View File
@@ -1114,7 +1114,7 @@ void scenes::lobby::on_focused()
auto views = system.view_configuration_views(viewconfig);
assert(views.size() == 2); // FIXME
stream_view = override_view_for_hmd(runtime_hmd_traits(), views[0]);
stream_view = hmd_traits.override_view_for_hmd(views[0]);
width = views[0].recommendedImageRectWidth;
height = views[0].recommendedImageRectHeight;
@@ -1135,10 +1135,10 @@ void scenes::lobby::on_focused()
config.save();
}
const std::string_view profile = runtime_hmd_traits().controller_profile;
const auto & profile = hmd_traits.controller_profile;
input.emplace(
*this,
"assets://controllers/" + std::string(profile) + "/profile.json",
"assets://controllers/" + profile + "/profile.json",
layer_controllers,
layer_rays,
get_action("left_trigger").first,
+29 -36
View File
@@ -217,7 +217,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
{
auto view = self->system.view_configuration_views(self->viewconfig)[0];
view = override_view_for_hmd(runtime_hmd_traits(), view);
view = hmd_traits.override_view_for_hmd(view);
info.render_eye_width = view.recommendedImageRectWidth * config.resolution_scale;
info.render_eye_height = view.recommendedImageRectHeight * config.resolution_scale;
@@ -421,10 +421,10 @@ void scenes::stream::on_focused()
{
gui_status_last_change = instance.now();
const std::string_view profile = runtime_hmd_traits().controller_profile;
const auto & profile = hmd_traits.controller_profile;
input.emplace(
*this,
"assets://controllers/" + std::string(profile) + "/profile.json",
"assets://controllers/" + profile + "/profile.json",
layer_controllers,
layer_rays,
get_action("left_trigger").first,
@@ -684,41 +684,34 @@ void scenes::stream::update_gui_position(xr::spaces controller)
{
std::optional<std::pair<glm::vec3, glm::quat>> aim;
switch (guess_model())
if (hmd_traits.view_locate)
{
case model::pico_4:
case model::pico_4s:
case model::pico_4_pro:
case model::pico_4_enterprise: {
// Pico fails to find its controllers within view space, so use the head position in
// world space as a reference
aim = application::locate_controller(
application::space(controller),
application::space(xr::spaces::world),
predicted_display_time);
auto head_position = application::locate_controller(application::space(xr::spaces::view),
application::space(xr::spaces::world),
predicted_display_time);
if (not aim || not head_position)
return;
aim->first = glm::conjugate(head_position->second) * (aim->first - head_position->first);
aim->second = glm::conjugate(head_position->second) * aim->second;
break;
}
default:
aim = application::locate_controller(
application::space(controller),
application::space(xr::spaces::view),
predicted_display_time);
if (not aim)
return;
break;
aim = application::locate_controller(
application::space(controller),
application::space(xr::spaces::view),
predicted_display_time);
}
else
{
// Pico fails to find its controllers within view space, so use the head position in
// world space as a reference
aim = application::locate_controller(
application::space(controller),
application::space(xr::spaces::world),
predicted_display_time);
auto head_position = application::locate_controller(application::space(xr::spaces::view),
application::space(xr::spaces::world),
predicted_display_time);
if (not(aim and head_position))
return;
aim->first = glm::conjugate(head_position->second) * (aim->first - head_position->first);
aim->second = glm::conjugate(head_position->second) * aim->second;
}
if (not aim)
return;
auto [offset_position, offset_orientation] = input->offset[controller];
+1 -1
View File
@@ -127,7 +127,7 @@ stream_defoveator::pipeline_t & stream_defoveator::ensure_pipeline(size_t view,
// Fragment shader
auto specialization = make_specialization_constants(
int32_t(alpha),
VkBool32(runtime_hmd_traits().needs_srgb_conversion));
VkBool32(hmd_traits.needs_srgb_conversion));
auto fragment_shader = load_shader(device, "reprojection.frag");
vk::pipeline_builder pipeline_info{
+45 -57
View File
@@ -493,36 +493,31 @@ void scenes::stream::tracking()
break;
case wivrn::device_id::EYE_GAZE:
// Eye gaze uses view pose as the origin
switch (guess_model())
if (hmd_traits.view_locate)
tracking.device_poses.push_back(locate_space(item.device, spaces[item.device], spaces[wivrn::device_id::HEAD], tracking.timestamp));
else
{
case model::pico_4_pro:
case model::pico_4_enterprise: {
// Pico headsets fail to locate gaze relative to view
auto gaze = locate_space(item.device, spaces[item.device], world_space, tracking.timestamp);
auto view_pose = locate_space(item.device, view_space, world_space, tracking.timestamp);
glm::quat gaze_quat(gaze.pose.orientation.w, gaze.pose.orientation.x, gaze.pose.orientation.y, gaze.pose.orientation.z);
glm::quat view_quat(view_pose.pose.orientation.w, view_pose.pose.orientation.x, view_pose.pose.orientation.y, view_pose.pose.orientation.z);
gaze_quat = glm::conjugate(view_quat) * gaze_quat;
using flags = from_headset::tracking::flags;
tracking.device_poses.push_back(
from_headset::tracking::pose{
// Zero position and velocities
.pose = {
.orientation = {
.x = gaze_quat.x,
.y = gaze_quat.y,
.z = gaze_quat.z,
.w = gaze_quat.w,
},
},
.device = item.device,
.flags = uint8_t(gaze.flags & view_pose.flags & ~(flags::linear_velocity_valid | flags::angular_velocity_valid)),
});
}
break;
default:
tracking.device_poses.push_back(locate_space(item.device, spaces[item.device], spaces[wivrn::device_id::HEAD], tracking.timestamp));
break;
// Pico headsets fail to locate gaze relative to view
auto gaze = locate_space(item.device, spaces[item.device], world_space, tracking.timestamp);
auto view_pose = locate_space(item.device, view_space, world_space, tracking.timestamp);
glm::quat gaze_quat(gaze.pose.orientation.w, gaze.pose.orientation.x, gaze.pose.orientation.y, gaze.pose.orientation.z);
glm::quat view_quat(view_pose.pose.orientation.w, view_pose.pose.orientation.x, view_pose.pose.orientation.y, view_pose.pose.orientation.z);
gaze_quat = glm::conjugate(view_quat) * gaze_quat;
using flags = from_headset::tracking::flags;
tracking.device_poses.push_back(
from_headset::tracking::pose{
// Zero position and velocities
.pose = {
.orientation = {
.x = gaze_quat.x,
.y = gaze_quat.y,
.z = gaze_quat.z,
.w = gaze_quat.w,
},
},
.device = item.device,
.flags = uint8_t(gaze.flags & view_pose.flags & ~(flags::linear_velocity_valid | flags::angular_velocity_valid)),
});
}
break;
case wivrn::device_id::FACE:
@@ -759,37 +754,30 @@ void scenes::stream::send_derived_pose()
{
// This may happen if the runtime does not support palm ext
// check if we have a device specific offset
switch (guess_model())
if (not hmd_traits.hand_interaction_grip_surface)
{
case model::oculus_quest:
case model::oculus_quest_2:
case model::meta_quest_pro:
case model::meta_quest_3:
case model::meta_quest_3s:
switch (target)
{
case device_id::LEFT_PALM:
case device_id::RIGHT_PALM: {
glm::quat q(glm::vec3(glm::radians(-60.), 0, 0));
network_session->send_control(from_headset::derived_pose{
.source = source,
.target = target,
.relation = {
.orientation = {
.x = q.x,
.y = q.y,
.z = q.z,
.w = q.w,
},
},
});
}
break;
default:
break;
switch (target)
{
case device_id::LEFT_PALM:
case device_id::RIGHT_PALM: {
glm::quat q(glm::vec3(glm::radians(-60.), 0, 0));
network_session->send_control(from_headset::derived_pose{
.source = source,
.target = target,
.relation = {
.orientation = {
.x = q.x,
.y = q.y,
.z = q.z,
.w = q.w,
},
},
});
}
default:
break;
default:
break;
}
}
}
else
+12 -22
View File
@@ -45,18 +45,13 @@ xr::face_tracker_type xr::face_tracker_supported(xr::instance & instance, xr::sy
return xr::face_tracker_type::htc;
}
switch (guess_model())
if (hmd_traits.pico_face_tracker)
{
case model::pico_4_pro:
case model::pico_4_enterprise:
// The extension used by Pico is not published
// it doesn't even need to be requested...
if (instance.has_extension(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME) and
system.eye_gaze_interaction_properties().supportsEyeGazeInteraction)
return xr::face_tracker_type::pico;
break;
default:
break;
// The extension used by Pico is not published
// it doesn't even need to be requested...
if (instance.has_extension(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME) and
system.eye_gaze_interaction_properties().supportsEyeGazeInteraction)
return xr::face_tracker_type::pico;
}
return xr::face_tracker_type::none;
@@ -90,18 +85,13 @@ xr::face_tracker xr::make_face_tracker(xr::instance & instance, xr::system & sys
properties.supportLipFacialTracking);
}
switch (guess_model())
if (hmd_traits.pico_face_tracker)
{
case model::pico_4_pro:
case model::pico_4_enterprise:
// The extension used by Pico is not published
// it doesn't even need to be requested...
if (instance.has_extension(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME) and
system.eye_gaze_interaction_properties().supportsEyeGazeInteraction)
return xr::face_tracker(std::in_place_type_t<xr::pico_face_tracker>(), instance, session);
break;
default:
break;
// The extension used by Pico is not published
// it doesn't even need to be requested...
if (instance.has_extension(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME) and
system.eye_gaze_interaction_properties().supportsEyeGazeInteraction)
return xr::face_tracker(std::in_place_type_t<xr::pico_face_tracker>(), instance, session);
}
return std::monostate();
+2 -3
View File
@@ -100,12 +100,11 @@ static std::pair<XrVersion, XrInstance> create_instance(XrInstanceCreateInfo & i
XR_API_VERSION_1_0,
})
{
const XrVersion max_openxr_api_version = runtime_hmd_traits().max_openxr_api_version;
if (version > max_openxr_api_version)
if (version > hmd_traits.max_openxr_api_version)
{
spdlog::info("skip OpenXR {} due to headset quirk max version {}",
xr::to_string(version),
xr::to_string(max_openxr_api_version));
xr::to_string(hmd_traits.max_openxr_api_version));
continue;
}
std::vector<const char *> extensions;