-
-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client_openxr): 🐛 Fix crash on unsupported eye tracking permissio…
…n on Pico (#2618)
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
alvr/client_openxr/src/extra_extensions/eye_gaze_interaction.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use openxr::{self as xr, sys}; | ||
use std::ptr; | ||
|
||
fn get_props<G, T>(session: &xr::Session<G>, system: xr::SystemId, default_struct: T) -> Option<T> { | ||
let instance = session.instance(); | ||
|
||
let mut props = default_struct; | ||
let mut system_properties = sys::SystemProperties::out((&mut props as *mut T).cast()); | ||
let result = unsafe { | ||
(instance.fp().get_system_properties)( | ||
instance.as_raw(), | ||
system, | ||
system_properties.as_mut_ptr(), | ||
) | ||
}; | ||
(result.into_raw() >= 0).then_some(props) | ||
} | ||
|
||
pub fn supports_eye_gaze_interaction<G>(session: &xr::Session<G>, system: xr::SystemId) -> bool { | ||
if session.instance().exts().ext_eye_gaze_interaction.is_none() { | ||
return false; | ||
} | ||
|
||
get_props( | ||
session, | ||
system, | ||
sys::SystemEyeGazeInteractionPropertiesEXT { | ||
ty: sys::SystemEyeGazeInteractionPropertiesEXT::TYPE, | ||
next: ptr::null_mut(), | ||
supports_eye_gaze_interaction: sys::FALSE, | ||
}, | ||
) | ||
.map(|props| props.supports_eye_gaze_interaction.into()) | ||
.unwrap_or(false) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters