File tree Expand file tree Collapse file tree 4 files changed +45
-2
lines changed
Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Original file line number Diff line number Diff line change 1+ use openxr:: { self as xr, sys} ;
2+ use std:: ptr;
3+
4+ fn get_props < G , T > ( session : & xr:: Session < G > , system : xr:: SystemId , default_struct : T ) -> Option < T > {
5+ let instance = session. instance ( ) ;
6+
7+ let mut props = default_struct;
8+ let mut system_properties = sys:: SystemProperties :: out ( ( & mut props as * mut T ) . cast ( ) ) ;
9+ let result = unsafe {
10+ ( instance. fp ( ) . get_system_properties ) (
11+ instance. as_raw ( ) ,
12+ system,
13+ system_properties. as_mut_ptr ( ) ,
14+ )
15+ } ;
16+ ( result. into_raw ( ) >= 0 ) . then_some ( props)
17+ }
18+
19+ pub fn supports_eye_gaze_interaction < G > ( session : & xr:: Session < G > , system : xr:: SystemId ) -> bool {
20+ if session. instance ( ) . exts ( ) . ext_eye_gaze_interaction . is_none ( ) {
21+ return false ;
22+ }
23+
24+ get_props (
25+ session,
26+ system,
27+ sys:: SystemEyeGazeInteractionPropertiesEXT {
28+ ty : sys:: SystemEyeGazeInteractionPropertiesEXT :: TYPE ,
29+ next : ptr:: null_mut ( ) ,
30+ supports_eye_gaze_interaction : sys:: FALSE ,
31+ } ,
32+ )
33+ . map ( |props| props. supports_eye_gaze_interaction . into ( ) )
34+ . unwrap_or ( false )
35+ }
Original file line number Diff line number Diff line change 11mod body_tracking_fb;
2+ mod eye_gaze_interaction;
23mod eye_tracking_social;
34mod face_tracking2_fb;
45mod facial_tracking_htc;
@@ -7,6 +8,7 @@ mod passthrough_fb;
78mod passthrough_htc;
89
910pub use body_tracking_fb:: * ;
11+ pub use eye_gaze_interaction:: * ;
1012pub use eye_tracking_social:: * ;
1113pub use face_tracking2_fb:: * ;
1214pub use facial_tracking_htc:: * ;
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ pub struct InteractionContext {
116116impl InteractionContext {
117117 pub fn new (
118118 xr_session : xr:: Session < xr:: OpenGlEs > ,
119+ xr_system : xr:: SystemId ,
119120 platform : Platform ,
120121 supports_multimodal : bool ,
121122 ) -> Self {
@@ -270,9 +271,13 @@ impl InteractionContext {
270271 )
271272 . unwrap ( ) ;
272273
273- let combined_eyes_source = if xr_instance. exts ( ) . ext_eye_gaze_interaction . is_some ( )
274- && !platform. is_quest ( )
274+ // Pico headsets require calling get_system_properties to test for extensions, because all
275+ // extensions function pointers are available even if the feature is not supported by the
276+ // hardware. The full checks are done in supports_eye_gaze_interaction. This is required
277+ // to avoid a crash when requesting the EYE_TRACKING permission.
278+ let combined_eyes_source = if !platform. is_quest ( )
275279 && !platform. is_vive ( )
280+ && extra_extensions:: supports_eye_gaze_interaction ( & xr_session, xr_system)
276281 {
277282 #[ cfg( target_os = "android" ) ]
278283 if platform. is_pico ( ) {
Original file line number Diff line number Diff line change @@ -267,6 +267,7 @@ pub fn entry_point() {
267267
268268 let interaction_context = Arc :: new ( RwLock :: new ( InteractionContext :: new (
269269 xr_session. clone ( ) ,
270+ xr_system,
270271 platform,
271272 exts. other
272273 . contains ( & META_SIMULTANEOUS_HANDS_AND_CONTROLLERS_EXTENSION_NAME . to_owned ( ) ) ,
You can’t perform that action at this time.
0 commit comments