Skip to content

Commit 9d669f3

Browse files
authored
YVR1/2 support (#1455)
1 parent 6974f4a commit 9d669f3

File tree

5 files changed

+112
-5
lines changed

5 files changed

+112
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This is a fork of [ALVR](https://github.com/polygraphene/ALVR).
1414
| Quest 1/2/Pro | :heavy_check_mark: |
1515
| Pico 4/Neo 3 | :heavy_check_mark: * |
1616
| Vive Focus 3 | :heavy_check_mark: * |
17+
| YVR 1/2 | :heavy_check_mark: * |
1718
| Smartphone/Monado | :construction: ** |
1819
| GearVR | :construction: ** |
1920
| Google Daydream | :construction: ** (maybe) |

alvr/client_openxr/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ actions = ["android.intent.action.MAIN"]
8989
categories = [
9090
"android.intent.category.LAUNCHER",
9191
"com.oculus.intent.category.VR",
92+
"com.yvr.intent.category.VR",
9293
"org.khronos.openxr.intent.category.IMMERSIVE_HMD",
9394
]
9495

@@ -140,3 +141,8 @@ value = "vr"
140141
[[package.metadata.android.application.meta_data]]
141142
name = "handtracking"
142143
value = "1"
144+
145+
# Yvr entries
146+
[[package.metadata.android.application.meta_data]]
147+
name = "com.yvr.intent.category.VR"
148+
value = "vr_only"

alvr/client_openxr/src/interaction.rs

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct ButtonBindingInfo {
3333
// popularity, all OpenXR runtimes should support binding to the oculus touch controller.
3434
const OCULUS_TOUCH_CONTROLLER_PROFILE: &str = "/interaction_profiles/oculus/touch_controller";
3535
const PICO_CONTROLLER_PROFILE: &str = "/interaction_profiles/pico/neo3_controller";
36+
const YVR_CONTROLLER_PROFILE: &str = "/interaction_profiles/yvr/touch_controller";
3637

3738
fn get_button_bindings(platform: Platform) -> HashMap<u64, ButtonBindingInfo> {
3839
let mut list = vec![
@@ -320,6 +321,65 @@ fn get_button_bindings(platform: Platform) -> HashMap<u64, ButtonBindingInfo> {
320321
]);
321322
}
322323

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+
323383
list.into_iter().collect()
324384
}
325385

@@ -421,10 +481,12 @@ pub fn initialize_streaming_interaction(
421481

422482
// Apply bindings:
423483

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,
428490
};
429491

430492
xr_instance
@@ -531,7 +593,18 @@ pub fn get_hand_motion(
531593
}
532594
}
533595

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+
534606
pub fn update_buttons(
607+
platform: Platform,
535608
xr_session: &xr::Session<xr::AnyGraphics>,
536609
button_actions: &HashMap<u64, ButtonAction>,
537610
) -> StrResult {
@@ -542,6 +615,9 @@ pub fn update_buttons(
542615

543616
if state.changed_since_last_sync {
544617
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+
}
545621
}
546622
}
547623
ButtonAction::Scalar(action) => {

alvr/client_openxr/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub enum Platform {
2929
Quest,
3030
Pico,
3131
Vive,
32+
Yvr,
3233
Other,
3334
}
3435

@@ -292,7 +293,11 @@ fn update_streaming_input(ctx: &StreamingInputContext, last_ipd: &mut f32) -> St
292293
right_hand_skeleton,
293294
});
294295

295-
interaction::update_buttons(&ctx.xr_session, &ctx.interaction_context.button_actions)
296+
interaction::update_buttons(
297+
ctx.platform,
298+
&ctx.xr_session,
299+
&ctx.interaction_context.button_actions,
300+
)
296301
}
297302

298303
pub fn entry_point() {
@@ -302,6 +307,7 @@ pub fn entry_point() {
302307
"Oculus" => Platform::Quest,
303308
"Pico" => Platform::Pico,
304309
"HTC" => Platform::Vive,
310+
"YVR" => Platform::Yvr,
305311
_ => Platform::Other,
306312
};
307313

@@ -312,6 +318,9 @@ pub fn entry_point() {
312318
Platform::Pico => unsafe {
313319
xr::Entry::load_from(Path::new("libopenxr_loader_pico.so")).unwrap()
314320
},
321+
Platform::Yvr => unsafe {
322+
xr::Entry::load_from(Path::new("libopenxr_loader_yvr.so")).unwrap()
323+
},
315324
_ => unsafe { xr::Entry::load().unwrap() },
316325
};
317326

alvr/xtask/src/dependencies.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,21 @@ fn get_android_openxr_loaders() {
265265
destination_dir.join("libopenxr_loader_pico.so"),
266266
)
267267
.unwrap();
268+
fs::remove_dir_all(&temp_dir).ok();
269+
270+
// Yvr
271+
command::download_and_extract_zip(
272+
&sh,
273+
"https://developer.yvrdream.com/yvrdoc/sdk/openxr/yvr_openxr_mobile_sdk_1.0.0.zip",
274+
&temp_dir,
275+
)
276+
.unwrap();
277+
fs::copy(
278+
temp_dir
279+
.join("yvr_openxr_mobile_sdk_1.0.0/OpenXR/Libs/Android/arm64-v8a/libopenxr_loader.so"),
280+
destination_dir.join("libopenxr_loader_yvr.so"),
281+
)
282+
.unwrap();
268283
fs::remove_dir_all(temp_dir).ok();
269284
}
270285

0 commit comments

Comments
 (0)