Skip to content

Commit

Permalink
fix(client_openxr): 🐛 Fix Pico controllers (#1820)
Browse files Browse the repository at this point in the history
* fix(client_openxr): 🐛 Fix Pico controllers

* bindings for pico4 interaction profile

* Fixed pico 4 client crash, added thumbrests back

---------

Co-authored-by: galister <22305755+galister@users.noreply.github.com>
Co-authored-by: PLYSHKA <leruop@gmail.com>
  • Loading branch information
3 people committed Sep 3, 2023
1 parent 2cc89bc commit 43f2c18
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 37 deletions.
4 changes: 4 additions & 0 deletions alvr/client_core/src/lib.rs
Expand Up @@ -81,6 +81,10 @@ pub enum ClientCoreEvent {
},
}

pub fn device_model() -> String {
platform::device_model()
}

pub fn manufacturer_name() -> String {
platform::manufacturer_name()
}
Expand Down
53 changes: 24 additions & 29 deletions alvr/client_openxr/src/interaction.rs
Expand Up @@ -29,7 +29,8 @@ pub struct ButtonBindingInfo {
}

const QUEST_CONTROLLER_PROFILE: &str = "/interaction_profiles/oculus/touch_controller";
const PICO_CONTROLLER_PROFILE: &str = "/interaction_profiles/pico/neo3_controller";
const PICO_NEO3_CONTROLLER_PROFILE: &str = "/interaction_profiles/bytedance/pico_neo3_controller";
const PICO4_CONTROLLER_PROFILE: &str = "/interaction_profiles/bytedance/pico4_controller";
const FOCUS3_CONTROLLER_PROFILE: &str = "/interaction_profiles/htc/vive_focus3_controller";
const YVR_CONTROLLER_PROFILE: &str = "/interaction_profiles/yvr/touch_controller";

Expand Down Expand Up @@ -271,31 +272,24 @@ fn get_button_bindings(platform: Platform) -> HashMap<u64, ButtonBindingInfo> {
);

// Tweak bindings if other platforms
if platform == Platform::Pico {
map.insert(
*MENU_CLICK_ID, // faked as oculus menu button
ButtonBindingInfo {
name: "back_click".into(),
binding_path: BACK_CLICK_PATH.into(),
binding_type: BindingType::Binary,
},
);
map.remove(&*LEFT_THUMBREST_TOUCH_ID);
map.remove(&*RIGHT_THUMBREST_TOUCH_ID);
} else if platform == Platform::Vive {
map.remove(&*A_TOUCH_ID);
map.remove(&*B_TOUCH_ID);
map.remove(&*X_TOUCH_ID);
map.remove(&*Y_TOUCH_ID);
map.remove(&*LEFT_SQUEEZE_CLICK_ID);
map.remove(&*LEFT_TRIGGER_CLICK_ID);
map.remove(&*LEFT_THUMBREST_TOUCH_ID);
map.remove(&*RIGHT_SQUEEZE_CLICK_ID);
map.remove(&*RIGHT_TRIGGER_CLICK_ID);
map.remove(&*RIGHT_THUMBREST_TOUCH_ID);
} else if platform == Platform::Yvr {
map.remove(&*LEFT_SQUEEZE_VALUE_ID);
map.remove(&*RIGHT_SQUEEZE_VALUE_ID);
match platform {
Platform::Focus3 => {
map.remove(&*A_TOUCH_ID);
map.remove(&*B_TOUCH_ID);
map.remove(&*X_TOUCH_ID);
map.remove(&*Y_TOUCH_ID);
map.remove(&*LEFT_SQUEEZE_CLICK_ID);
map.remove(&*LEFT_TRIGGER_CLICK_ID);
map.remove(&*LEFT_THUMBREST_TOUCH_ID);
map.remove(&*RIGHT_SQUEEZE_CLICK_ID);
map.remove(&*RIGHT_TRIGGER_CLICK_ID);
map.remove(&*RIGHT_THUMBREST_TOUCH_ID);
}
Platform::Yvr => {
map.remove(&*LEFT_SQUEEZE_VALUE_ID);
map.remove(&*RIGHT_SQUEEZE_VALUE_ID);
}
_ => {}
}

map
Expand Down Expand Up @@ -400,8 +394,9 @@ pub fn initialize_hands_interaction(

let controller_profile = match platform {
Platform::Quest => QUEST_CONTROLLER_PROFILE,
Platform::Pico => PICO_CONTROLLER_PROFILE,
Platform::Vive => FOCUS3_CONTROLLER_PROFILE,
Platform::PicoNeo3 => PICO_NEO3_CONTROLLER_PROFILE,
Platform::Pico4 => PICO4_CONTROLLER_PROFILE,
Platform::Focus3 => FOCUS3_CONTROLLER_PROFILE,
Platform::Yvr => YVR_CONTROLLER_PROFILE,
Platform::Other => QUEST_CONTROLLER_PROFILE,
};
Expand Down Expand Up @@ -569,7 +564,7 @@ fn emulate_missing_button_click(
) -> Option<ButtonEntry> {
let value = ButtonValue::Binary(state > 0.5);

if platform == Platform::Vive {
if platform == Platform::Focus3 {
if value_action_id == *LEFT_SQUEEZE_VALUE_ID {
Some(ButtonEntry {
path_id: *LEFT_SQUEEZE_CLICK_ID,
Expand Down
21 changes: 13 additions & 8 deletions alvr/client_openxr/src/lib.rs
Expand Up @@ -31,8 +31,9 @@ const DECODER_MAX_TIMEOUT_MULTIPLIER: f32 = 0.8;
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum Platform {
Quest,
Pico,
Vive,
PicoNeo3,
Pico4,
Focus3,
Yvr,
Other,
}
Expand Down Expand Up @@ -353,19 +354,23 @@ fn update_streaming_input(ctx: &mut StreamingInputContext) {
pub fn entry_point() {
alvr_client_core::init_logging();

let platform = match alvr_client_core::manufacturer_name().as_str() {
"Oculus" => Platform::Quest,
"Pico" => Platform::Pico,
"HTC" => Platform::Vive,
"YVR" => Platform::Yvr,
let platform = match (
alvr_client_core::manufacturer_name().as_str(),
alvr_client_core::device_model().as_str(),
) {
("Oculus", _) => Platform::Quest,
("Pico", "Pico Neo 3") => Platform::PicoNeo3,
("Pico", _) => Platform::Pico4,
("HTC", _) => Platform::Focus3,
("YVR", _) => Platform::Yvr,
_ => Platform::Other,
};

let xr_entry = match platform {
Platform::Quest => unsafe {
xr::Entry::load_from(Path::new("libopenxr_loader_quest.so")).unwrap()
},
Platform::Pico => unsafe {
Platform::PicoNeo3 | Platform::Pico4 => unsafe {
xr::Entry::load_from(Path::new("libopenxr_loader_pico.so")).unwrap()
},
Platform::Yvr => unsafe {
Expand Down

0 comments on commit 43f2c18

Please sign in to comment.