@@ -33,6 +33,7 @@ pub struct ButtonBindingInfo {
33
33
// popularity, all OpenXR runtimes should support binding to the oculus touch controller.
34
34
const OCULUS_TOUCH_CONTROLLER_PROFILE : & str = "/interaction_profiles/oculus/touch_controller" ;
35
35
const PICO_CONTROLLER_PROFILE : & str = "/interaction_profiles/pico/neo3_controller" ;
36
+ const YVR_CONTROLLER_PROFILE : & str = "/interaction_profiles/yvr/touch_controller" ;
36
37
37
38
fn get_button_bindings ( platform : Platform ) -> HashMap < u64 , ButtonBindingInfo > {
38
39
let mut list = vec ! [
@@ -320,6 +321,65 @@ fn get_button_bindings(platform: Platform) -> HashMap<u64, ButtonBindingInfo> {
320
321
] ) ;
321
322
}
322
323
324
+ if platform == Platform :: Yvr {
325
+ list. extend ( [
326
+ (
327
+ * LEFT_SQUEEZE_CLICK_ID ,
328
+ ButtonBindingInfo {
329
+ name : "left_squeeze_click" . into ( ) ,
330
+ binding_path : "/user/hand/left/input/squeeze" . into ( ) ,
331
+ binding_type : BindingType :: Binary ,
332
+ } ,
333
+ ) ,
334
+ (
335
+ * LEFT_TRIGGER_CLICK_ID ,
336
+ ButtonBindingInfo {
337
+ name : "left_trigger_click" . into ( ) ,
338
+ binding_path : "/user/hand/left/input/trigger" . into ( ) ,
339
+ binding_type : BindingType :: Binary ,
340
+ } ,
341
+ ) ,
342
+ (
343
+ * LEFT_THUMBREST_TOUCH_ID ,
344
+ ButtonBindingInfo {
345
+ name : "left_thumbrest_touch" . into ( ) ,
346
+ binding_path : LEFT_THUMBREST_TOUCH_PATH . into ( ) ,
347
+ binding_type : BindingType :: Binary ,
348
+ } ,
349
+ ) ,
350
+ (
351
+ * RIGHT_SQUEEZE_CLICK_ID ,
352
+ ButtonBindingInfo {
353
+ name : "right_squeeze_click" . into ( ) ,
354
+ binding_path : "/user/hand/right/input/squeeze" . into ( ) ,
355
+ binding_type : BindingType :: Binary ,
356
+ } ,
357
+ ) ,
358
+ (
359
+ * RIGHT_TRIGGER_CLICK_ID ,
360
+ ButtonBindingInfo {
361
+ name : "right_trigger_click" . into ( ) ,
362
+ binding_path : "/user/hand/right/input/trigger" . into ( ) ,
363
+ binding_type : BindingType :: Binary ,
364
+ } ,
365
+ ) ,
366
+ (
367
+ * RIGHT_THUMBREST_TOUCH_ID ,
368
+ ButtonBindingInfo {
369
+ name : "right_thumbrest_touch" . into ( ) ,
370
+ binding_path : RIGHT_THUMBREST_TOUCH_PATH . into ( ) ,
371
+ binding_type : BindingType :: Binary ,
372
+ } ,
373
+ ) ,
374
+ ] ) ;
375
+
376
+ let disable_paths = vec ! [ * LEFT_SQUEEZE_VALUE_ID , * RIGHT_SQUEEZE_VALUE_ID ] ;
377
+ list = list
378
+ . into_iter ( )
379
+ . filter ( |x| !disable_paths. contains ( & x. 0 ) )
380
+ . collect :: < Vec < _ > > ( ) ;
381
+ }
382
+
323
383
list. into_iter ( ) . collect ( )
324
384
}
325
385
@@ -421,10 +481,12 @@ pub fn initialize_streaming_interaction(
421
481
422
482
// Apply bindings:
423
483
424
- let controller_profile = if platform == Platform :: Pico {
425
- PICO_CONTROLLER_PROFILE
426
- } else {
427
- OCULUS_TOUCH_CONTROLLER_PROFILE
484
+ let controller_profile = match platform {
485
+ Platform :: Quest => OCULUS_TOUCH_CONTROLLER_PROFILE ,
486
+ Platform :: Pico => PICO_CONTROLLER_PROFILE ,
487
+ Platform :: Vive => OCULUS_TOUCH_CONTROLLER_PROFILE ,
488
+ Platform :: Yvr => YVR_CONTROLLER_PROFILE ,
489
+ Platform :: Other => OCULUS_TOUCH_CONTROLLER_PROFILE ,
428
490
} ;
429
491
430
492
xr_instance
@@ -531,7 +593,18 @@ pub fn get_hand_motion(
531
593
}
532
594
}
533
595
596
+ fn fix_yvr_squeeze_value ( action_id : u64 , state : bool ) {
597
+ let scalar_value = if state { 1_f32 } else { 0_f32 } ;
598
+
599
+ if action_id == * LEFT_SQUEEZE_CLICK_ID {
600
+ alvr_client_core:: send_button ( * LEFT_SQUEEZE_VALUE_ID , ButtonValue :: Scalar ( scalar_value) ) ;
601
+ } else if action_id == * RIGHT_SQUEEZE_CLICK_ID {
602
+ alvr_client_core:: send_button ( * RIGHT_SQUEEZE_VALUE_ID , ButtonValue :: Scalar ( scalar_value) ) ;
603
+ }
604
+ }
605
+
534
606
pub fn update_buttons (
607
+ platform : Platform ,
535
608
xr_session : & xr:: Session < xr:: AnyGraphics > ,
536
609
button_actions : & HashMap < u64 , ButtonAction > ,
537
610
) -> StrResult {
@@ -542,6 +615,9 @@ pub fn update_buttons(
542
615
543
616
if state. changed_since_last_sync {
544
617
alvr_client_core:: send_button ( * id, ButtonValue :: Binary ( state. current_state ) ) ;
618
+ if platform == Platform :: Yvr {
619
+ fix_yvr_squeeze_value ( * id, state. current_state ) ;
620
+ }
545
621
}
546
622
}
547
623
ButtonAction :: Scalar ( action) => {
0 commit comments