Skip to content

Commit 5c4b3e8

Browse files
author
hare_ware
committed
Corrected values based on official drivers
1 parent b73df64 commit 5c4b3e8

File tree

6 files changed

+136
-96
lines changed

6 files changed

+136
-96
lines changed

src/input/profiles.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
pub mod hp_motion_controller;
21
pub mod knuckles;
3-
pub mod ms_motion_controller;
2+
43
pub mod oculus_touch;
5-
pub mod samsung_odyssey_controller;
4+
65
pub mod simple_controller;
76
pub mod vive_controller;
7+
pub mod wmr;
8+
89
#[cfg(feature = "monado")]
910
pub mod vive_tracker;
11+
1012
use super::{
1113
action_manifest::ControllerType, legacy::LegacyBindings, skeletal::SkeletalInputBindings,
1214
};
1315
use crate::openxr_data::Hand;
14-
use samsung_odyssey_controller::SamsungOdysseyController;
1516
use glam::Mat4;
16-
use hp_motion_controller::ReverbG2Controller;
1717
use knuckles::Knuckles;
18-
use ms_motion_controller::HolographicController;
1918
use oculus_touch::Touch;
2019
use openxr as xr;
2120
use simple_controller::SimpleController;
2221
use std::ffi::CStr;
2322
use vive_controller::ViveWands;
23+
use wmr::{
24+
hp_motion_controller::ReverbG2Controller, ms_motion_controller::HolographicController,
25+
samsung_odyssey_controller::SamsungOdysseyController,
26+
};
2427

2528
#[allow(private_interfaces)]
2629
pub trait InteractionProfile: Sync + Send {

src/input/profiles/samsung_odyssey_controller.rs

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/input/profiles/hp_motion_controller.rs renamed to src/input/profiles/wmr/hp_motion_controller.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
use super::{
1+
use super::super::{
22
InteractionProfile, MainAxisType, PathTranslation, ProfileProperties, Property,
33
SkeletalInputBindings, StringToPath,
44
};
5+
56
use crate::button_mask_from_ids;
67
use crate::input::legacy;
78
use crate::input::legacy::button_mask_from_id;
89
use crate::input::legacy::LegacyBindings;
10+
use crate::input::profiles::wmr;
911
use crate::openxr_data::Hand;
1012
use glam::Mat4;
1113
use glam::Quat;
@@ -17,21 +19,24 @@ pub struct ReverbG2Controller;
1719
impl InteractionProfile for ReverbG2Controller {
1820
fn properties(&self) -> &'static ProfileProperties {
1921
static DEVICE_PROPERTIES: ProfileProperties = ProfileProperties {
20-
model: Property::BothHands(c"WindowsMR"), // "VAC-151B" controllers
22+
model: Property::PerHand {
23+
left:c"WindowsMR: 0x045E/0x066A/0/1",
24+
right: c"WindowsMR: 0x045E/0x066A/0/2",
25+
},
2126
openvr_controller_type: c"hpmotioncontroller",
22-
render_model_name: Property::BothHands(c"hpmotioncontroller"),
27+
render_model_name: Property::PerHand {
28+
left: c"C:\\Users\\steamuser\\AppData\\Local\\Microsoft/Windows/OpenVR\\controller_1642_1118_1\\controller.obj",
29+
right: c"C:\\Users\\steamuser\\AppData\\Local\\Microsoft/Windows/OpenVR\\controller_1642_1118_2\\controller.obj"
30+
},
2331
main_axis: MainAxisType::Thumbstick,
24-
// TODO: I'm not certain whether that's correct here, THIS IS A GUESS
32+
// The official drivers don't seem to return anything for this:
2533
registered_device_type: Property::PerHand {
26-
left: c"WindowsMR/hpmotioncontrollerLHR-00000001",
27-
right: c"WindowsMR/hpmotioncontrollerLHR-00000002",
28-
},
29-
serial_number: Property::PerHand {
30-
left: c"hpmotioncontrollerLHR-00000001",
31-
right: c"hpmotioncontrollerLHR-00000002",
34+
left: c"WindowsMR/MRSOURCE0",
35+
right: c"WindowsMR/MRSOURCE1",
3236
},
33-
tracking_system_name: c"WindowsMR", // TODO: Not sure if this is right, THIS IS A GUESS
34-
manufacturer_name: c"WindowsMR",
37+
serial_number: wmr::SERIAL_NUMBER,
38+
tracking_system_name: wmr::TRACKING_SYSTEM_NAME,
39+
manufacturer_name: c"WindowsMR: 0x045E",
3540
legacy_buttons_mask: button_mask_from_ids!(
3641
System,
3742
ApplicationMenu,

src/input/profiles/wmr/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use std::ffi::CStr;
2+
3+
use crate::input::legacy::button_mask_from_id;
4+
use crate::{button_mask_from_ids, input::profiles::Property};
5+
use openvr::EVRButtonId::{ApplicationMenu, Axis0, Axis1, Axis2, Grip, System, A};
6+
7+
pub mod hp_motion_controller;
8+
pub mod ms_motion_controller;
9+
pub mod samsung_odyssey_controller;
10+
11+
const TRACKING_SYSTEM_NAME: &'static CStr = c"holographic";
12+
const SERIAL_NUMBER: Property<&'static CStr> = Property::PerHand {
13+
left: c"MRSOURCE0",
14+
right: c"MRSOURCE1",
15+
};
16+
const OG_OPENVR_CONTROLLER_TYPE: &'static CStr = c"holographic_controller";
17+
const OG_LEGACY_BUTTONS_MASK: u64 =
18+
button_mask_from_ids!(System, ApplicationMenu, Grip, Axis0, Axis1, Axis2, A);

src/input/profiles/ms_motion_controller.rs renamed to src/input/profiles/wmr/ms_motion_controller.rs

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,38 @@
1-
use super::{
1+
use super::super::{
22
InteractionProfile, MainAxisType, PathTranslation, ProfileProperties, Property,
33
SkeletalInputBindings, StringToPath,
44
};
5-
use crate::button_mask_from_ids;
65
use crate::input::legacy;
7-
use crate::input::legacy::button_mask_from_id;
86
use crate::input::legacy::LegacyBindings;
7+
use crate::input::profiles::wmr;
98
use crate::openxr_data::Hand;
109
use glam::Mat4;
1110
use glam::Vec3;
12-
use openvr::EVRButtonId::{ApplicationMenu, Axis0, Axis1, Axis2, Grip, System, A};
1311

1412
pub struct HolographicController;
1513

1614
impl InteractionProfile for HolographicController {
1715
fn properties(&self) -> &'static ProfileProperties {
1816
static DEVICE_PROPERTIES: ProfileProperties = ProfileProperties {
19-
model: Property::BothHands(c"WindowsMR"), // "VAC-151B" controllers
20-
openvr_controller_type: c"holographic_controller",
21-
render_model_name: Property::BothHands(c"holographic_controller"),
17+
model: Property::PerHand {
18+
left:c"WindowsMR: 0x045E/0x065B/0/1",
19+
right: c"WindowsMR: 0x045E/0x065B/0/2",
20+
},
21+
openvr_controller_type: wmr::OG_OPENVR_CONTROLLER_TYPE,
22+
render_model_name: Property::PerHand {
23+
left: c"C:\\Users\\steamuser\\AppData\\Local\\Microsoft/Windows/OpenVR\\controller_1627_1118_1\\controller.obj",
24+
right: c"C:\\Users\\steamuser\\AppData\\Local\\Microsoft/Windows/OpenVR\\controller_1627_1118_2\\controller.obj"
25+
},
2226
main_axis: MainAxisType::Thumbstick,
23-
// TODO: I'm not certain whether that's correct here, THIS IS A GUESS
27+
// The official driver doesn't seem return any thing for this?
2428
registered_device_type: Property::PerHand {
25-
left: c"WindowsMR/holographic_controllerLHR-00000001",
26-
right: c"WindowsMR/holographic_controllerLHR-00000002",
27-
},
28-
serial_number: Property::PerHand {
29-
left: c"holographic_controllerLHR-00000001",
30-
right: c"holographic_controllerLHR-00000002",
29+
left: c"WindowsMR: 0x045E/0x065B/0/1",
30+
right: c"WindowsMR: 0x045E/0x065B/0/2",
3131
},
32-
tracking_system_name: c"WindowsMR", // TODO: Not sure if this is right, THIS IS A GUESS
33-
manufacturer_name: c"WindowsMR",
34-
legacy_buttons_mask: button_mask_from_ids!(
35-
System,
36-
ApplicationMenu,
37-
Grip,
38-
Axis0,
39-
Axis1,
40-
Axis2,
41-
A
42-
),
32+
serial_number: wmr::SERIAL_NUMBER,
33+
tracking_system_name: wmr::TRACKING_SYSTEM_NAME,
34+
manufacturer_name: c"WindowsMR: 0x045E",
35+
legacy_buttons_mask: wmr::OG_LEGACY_BUTTONS_MASK,
4336
};
4437
&DEVICE_PROPERTIES
4538
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
use super::super::{
2+
InteractionProfile, PathTranslation, ProfileProperties, SkeletalInputBindings, StringToPath,
3+
};
4+
use super::ms_motion_controller::HolographicController;
5+
use crate::input::legacy::LegacyBindings;
6+
use crate::input::profiles::{wmr, MainAxisType, Property};
7+
use crate::openxr_data::Hand;
8+
use glam::Mat4;
9+
use glam::Vec3;
10+
11+
pub struct SamsungOdysseyController;
12+
13+
impl InteractionProfile for SamsungOdysseyController {
14+
fn properties(&self) -> &'static ProfileProperties {
15+
static DEVICE_PROPERTIES: ProfileProperties = ProfileProperties {
16+
model: Property::PerHand {
17+
left:c"WindowsMR: 0x04E8/0x065D/0/1",
18+
right: c"WindowsMR: 0x04E8/0x065D/0/2",
19+
},
20+
openvr_controller_type: wmr::OG_OPENVR_CONTROLLER_TYPE,
21+
render_model_name: Property::PerHand {
22+
left: c"C:\\Users\\steamuser\\AppData\\Local\\Microsoft/Windows/OpenVR\\controller_1629_1256_1\\controller.obj",
23+
right: c"C:\\Users\\steamuser\\AppData\\Local\\Microsoft/Windows/OpenVR\\controller_1629_1256_2\\controller.obj"
24+
},
25+
main_axis: MainAxisType::Thumbstick,
26+
// The official driver doesn't seem return any thing for this?
27+
registered_device_type: Property::PerHand {
28+
left: c"WindowsMR/MRSOURCE0",
29+
right: c"WindowsMR/MRSOURCE1",
30+
},
31+
serial_number: wmr::SERIAL_NUMBER,
32+
tracking_system_name: wmr::TRACKING_SYSTEM_NAME,
33+
manufacturer_name: c"WindowsMR: 0x04E8",
34+
legacy_buttons_mask: wmr::OG_LEGACY_BUTTONS_MASK,
35+
};
36+
&DEVICE_PROPERTIES
37+
}
38+
fn profile_path(&self) -> &'static str {
39+
"/interaction_profiles/samsung/odyssey_controller"
40+
}
41+
fn translate_map(&self) -> &'static [PathTranslation] {
42+
HolographicController.translate_map()
43+
}
44+
45+
fn legacy_bindings(&self, stp: &dyn StringToPath) -> LegacyBindings {
46+
HolographicController.legacy_bindings(stp)
47+
}
48+
49+
fn skeletal_input_bindings(&self, stp: &dyn StringToPath) -> SkeletalInputBindings {
50+
HolographicController.skeletal_input_bindings(stp)
51+
}
52+
53+
fn legal_paths(&self) -> Box<[String]> {
54+
HolographicController.legal_paths()
55+
}
56+
57+
fn offset_grip_pose(&self, _hand: Hand) -> Mat4 {
58+
Mat4::from_translation(Vec3::new(
59+
// From the models found here https://www.microsoft.com/en-us/download/details.aspx?id=56414
60+
0.0, 0.079738, -0.035449,
61+
))
62+
}
63+
}
64+
65+
#[cfg(test)]
66+
mod tests {
67+
use super::{InteractionProfile, SamsungOdysseyController};
68+
use crate::input::profiles::wmr::ms_motion_controller;
69+
70+
#[test]
71+
fn verify_bindings() {
72+
ms_motion_controller::tests::base_verify_bindings(SamsungOdysseyController.profile_path());
73+
}
74+
}

0 commit comments

Comments
 (0)