Skip to content

Commit

Permalink
feat(client): ✨ Add platform vendor shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp committed Sep 28, 2024
1 parent de1d9e1 commit 18bc500
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
25 changes: 25 additions & 0 deletions alvr/client_core/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,31 @@ pub enum Platform {
Unknown,
}

impl Platform {
pub const fn is_quest(&self) -> bool {
matches!(
self,
Platform::Quest1
| Platform::Quest2
| Platform::Quest3
| Platform::Quest3S
| Platform::QuestPro
| Platform::QuestUnknown
)
}

pub const fn is_pico(&self) -> bool {
matches!(self, Platform::PicoNeo3 | Platform::Pico4)
}

pub const fn is_vive(&self) -> bool {
matches!(
self,
Platform::Focus3 | Platform::XRElite | Platform::ViveUnknown
)
}
}

impl Display for Platform {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let name = match self {
Expand Down
19 changes: 5 additions & 14 deletions alvr/client_openxr/src/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn initialize_interaction(
{
alvr_client_core::try_get_permission("com.oculus.permission.EYE_TRACKING")
}
if config.combined_eye_gaze && matches!(platform, Platform::Pico4 | Platform::PicoNeo3) {
if config.combined_eye_gaze && platform.is_pico() {
alvr_client_core::try_get_permission("com.picovr.permission.EYE_TRACKING")
}
if config.face_tracking_fb && matches!(platform, Platform::QuestPro) {
Expand All @@ -79,10 +79,8 @@ pub fn initialize_interaction(
#[cfg(target_os = "android")]
if let Some(config) = &body_tracking_sources {
if (config.body_tracking_fb.enabled())
&& matches!(
platform,
Platform::Quest2 | Platform::Quest3 | Platform::Quest3S | Platform::QuestPro
)
&& platform.is_quest()
&& platform != Platform::Quest1
{
alvr_client_core::try_get_permission("com.oculus.permission.BODY_TRACKING")
}
Expand All @@ -100,17 +98,10 @@ pub fn initialize_interaction(
}

let controllers_profile_path = match platform {
Platform::Quest1
| Platform::Quest2
| Platform::Quest3
| Platform::Quest3S
| Platform::QuestPro
| Platform::QuestUnknown => QUEST_CONTROLLER_PROFILE_PATH, // todo: create new controller profile for quest pro and 3
p if p.is_quest() => QUEST_CONTROLLER_PROFILE_PATH, // todo: create new controller profile for quest pro and 3
Platform::PicoNeo3 => PICO_NEO3_CONTROLLER_PROFILE_PATH,
Platform::Pico4 => PICO4_CONTROLLER_PROFILE_PATH,
Platform::Focus3 | Platform::XRElite | Platform::ViveUnknown => {
FOCUS3_CONTROLLER_PROFILE_PATH
}
p if p.is_vive() => FOCUS3_CONTROLLER_PROFILE_PATH,
Platform::Yvr => YVR_CONTROLLER_PROFILE_PATH,
_ => QUEST_CONTROLLER_PROFILE_PATH,
};
Expand Down
8 changes: 2 additions & 6 deletions alvr/client_openxr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub fn entry_point() {

let loader_suffix = match platform {
Platform::Quest1 => "_quest1",
Platform::PicoNeo3 | Platform::Pico4 => "_pico",
p if p.is_pico() => "_pico",
Platform::Yvr => "_yvr",
Platform::Lynx => "_lynx",
_ => "",
Expand Down Expand Up @@ -358,11 +358,7 @@ pub fn entry_point() {
// combined_eye_gaze is a setting that needs to be enabled at session
// creation. Since HTC headsets don't support session reinitialization, skip
// all elements that need it, that is face and eye tracking.
if parsed_stream_config.as_ref() != Some(&new_config)
&& !matches!(
platform,
Platform::Focus3 | Platform::XRElite | Platform::ViveUnknown
)
if parsed_stream_config.as_ref() != Some(&new_config) && !platform.is_vive()
{
parsed_stream_config = Some(new_config);

Expand Down
3 changes: 1 addition & 2 deletions alvr/client_openxr/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ impl StreamContext {
format,
config.foveated_encoding_config.clone(),
platform != Platform::Lynx
&& !((platform == Platform::Pico4 || platform == Platform::PicoNeo3)
&& config.encoder_config.enable_hdr),
&& !((platform.is_pico()) && config.encoder_config.enable_hdr),
!config.encoder_config.enable_hdr,
config.encoder_config.encoding_gamma,
);
Expand Down

0 comments on commit 18bc500

Please sign in to comment.