fix(server): 🐛 Fix various controller bindings bugs

This commit is contained in:
Riccardo Zaglia 2023-09-10 04:48:52 +08:00
parent 8e32e09fd1
commit 365101ec3e
7 changed files with 134 additions and 110 deletions

View File

@ -141,41 +141,48 @@ void Controller::RegisterButton(uint64_t id) {
}
if (buttonInfo.type == ButtonType::Binary) {
vr::VRDriverInput()->CreateBooleanComponent(
this->prop_container, buttonInfo.steamvr_path, &m_buttonHandles[id]);
for (auto path : buttonInfo.steamvr_paths) {
vr::VRDriverInput()->CreateBooleanComponent(
this->prop_container, path, &m_buttonHandles[PathStringToHash(path)]);
}
} else {
auto scalarType = buttonInfo.type == ButtonType::ScalarOneSided
? vr::VRScalarUnits_NormalizedOneSided
: vr::VRScalarUnits_NormalizedTwoSided;
vr::VRDriverInput()->CreateScalarComponent(this->prop_container,
buttonInfo.steamvr_path,
&m_buttonHandles[id],
vr::VRScalarType_Absolute,
scalarType);
for (auto path : buttonInfo.steamvr_paths) {
vr::VRDriverInput()->CreateScalarComponent(this->prop_container,
path,
&m_buttonHandles[PathStringToHash(path)],
vr::VRScalarType_Absolute,
scalarType);
}
}
}
void Controller::SetButton(uint64_t id, FfiButtonValue value) {
for (auto id : ALVR_TO_STEAMVR_PATH_IDS[id]) {
if (value.type == BUTTON_TYPE_BINARY) {
vr::VRDriverInput()->UpdateBooleanComponent(
m_buttonHandles[id], (bool)value.binary, 0.0);
} else {
vr::VRDriverInput()->UpdateScalarComponent(m_buttonHandles[id], value.scalar, 0.0);
}
if (value.type == BUTTON_TYPE_BINARY) {
vr::VRDriverInput()->UpdateBooleanComponent(m_buttonHandles[id], (bool)value.binary, 0.0);
} else {
vr::VRDriverInput()->UpdateScalarComponent(m_buttonHandles[id], value.scalar, 0.0);
}
// todo: remove when moving inferred controller hand skeleton to rust
if (id == LEFT_A_TOUCH_ID || id == LEFT_B_TOUCH_ID || id == LEFT_X_TOUCH_ID ||
id == LEFT_Y_TOUCH_ID || id == LEFT_TRACKPAD_TOUCH_ID || id == LEFT_THUMBSTICK_TOUCH_ID ||
id == LEFT_THUMBREST_TOUCH_ID || id == RIGHT_A_TOUCH_ID || id == RIGHT_B_TOUCH_ID ||
id == RIGHT_TRACKPAD_TOUCH_ID || id == RIGHT_THUMBSTICK_TOUCH_ID ||
id == RIGHT_THUMBREST_TOUCH_ID) {
m_currentThumbTouch = value.binary;
} else if (id == LEFT_TRIGGER_TOUCH_ID || id == RIGHT_TRIGGER_TOUCH_ID) {
m_currentTriggerTouch = value.binary;
} else if (id == LEFT_TRIGGER_VALUE_ID || id == RIGHT_TRIGGER_VALUE_ID) {
m_triggerValue = value.scalar;
} else if (id == LEFT_SQUEEZE_VALUE_ID || id == RIGHT_SQUEEZE_VALUE_ID) {
m_gripValue = value.scalar;
// todo: remove when moving inferred controller hand skeleton to rust
if (id == LEFT_A_TOUCH_ID || id == LEFT_B_TOUCH_ID || id == LEFT_X_TOUCH_ID ||
id == LEFT_Y_TOUCH_ID || id == LEFT_TRACKPAD_TOUCH_ID ||
id == LEFT_THUMBSTICK_TOUCH_ID || id == LEFT_THUMBREST_TOUCH_ID ||
id == RIGHT_A_TOUCH_ID || id == RIGHT_B_TOUCH_ID || id == RIGHT_TRACKPAD_TOUCH_ID ||
id == RIGHT_THUMBSTICK_TOUCH_ID || id == RIGHT_THUMBREST_TOUCH_ID) {
m_currentThumbTouch = value.binary;
} else if (id == LEFT_TRIGGER_TOUCH_ID || id == RIGHT_TRIGGER_TOUCH_ID) {
m_currentTriggerTouch = value.binary;
} else if (id == LEFT_TRIGGER_VALUE_ID || id == RIGHT_TRIGGER_VALUE_ID) {
m_triggerValue = value.scalar;
} else if (id == LEFT_SQUEEZE_VALUE_ID || id == RIGHT_SQUEEZE_VALUE_ID) {
m_gripValue = value.scalar;
}
}
}
@ -258,16 +265,6 @@ bool Controller::onPoseUpdate(float predictionS,
handSkeleton->jointRotations[24].z) *
0.67f;
// switch (Settings::Instance().m_controllerMode) {
// case 1:
// case 3:
// case 7:
// vr_driver_input->UpdateBooleanComponent(
// m_buttonHandles[LEFT_THUMBSTICK_TOUCH_ID], rotThumb > 0.7f, 0.0);
// vr_driver_input->UpdateBooleanComponent(
// m_buttonHandles[ALVR_INPUT_TRIGGER_TOUCH], rotIndex > 0.7f, 0.0);
// }
vr_driver_input->UpdateScalarComponent(
m_buttonHandles[ALVR_INPUT_FINGER_INDEX], rotIndex, 0.0);
vr_driver_input->UpdateScalarComponent(

View File

@ -7,6 +7,7 @@ uint64_t RIGHT_HAND_ID;
std::map<uint64_t, ButtonInfo> LEFT_CONTROLLER_BUTTON_MAPPING;
std::map<uint64_t, ButtonInfo> RIGHT_CONTROLLER_BUTTON_MAPPING;
std::map<uint64_t, std::vector<uint64_t>> ALVR_TO_STEAMVR_PATH_IDS;
uint64_t LEFT_A_TOUCH_ID;
uint64_t LEFT_B_TOUCH_ID;
@ -17,7 +18,6 @@ uint64_t LEFT_THUMBSTICK_TOUCH_ID;
uint64_t LEFT_THUMBREST_TOUCH_ID;
uint64_t LEFT_TRIGGER_TOUCH_ID;
uint64_t LEFT_TRIGGER_VALUE_ID;
uint64_t LEFT_SQUEEZE_TOUCH_ID;
uint64_t LEFT_SQUEEZE_VALUE_ID;
uint64_t RIGHT_A_TOUCH_ID;
uint64_t RIGHT_B_TOUCH_ID;
@ -26,7 +26,6 @@ uint64_t RIGHT_THUMBSTICK_TOUCH_ID;
uint64_t RIGHT_THUMBREST_TOUCH_ID;
uint64_t RIGHT_TRIGGER_TOUCH_ID;
uint64_t RIGHT_TRIGGER_VALUE_ID;
uint64_t RIGHT_SQUEEZE_TOUCH_ID;
uint64_t RIGHT_SQUEEZE_VALUE_ID;
void init_paths() {
@ -39,129 +38,143 @@ void init_paths() {
RIGHT_HAND_ID = PathStringToHash("/user/hand/right");
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/system/click"),
{"/input/system/click", ButtonType::Binary}});
{{"/input/system/click"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/system/touch"),
{"/input/system/touch", ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/menu/click"),
{"/input/application_menu/click", ButtonType::Binary}});
{{"/input/system/touch"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/left/input/menu/click"),
{{"/input/system/click", "/input/application_menu/click"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/a/click"),
{"/input/a/click", ButtonType::Binary}});
{{"/input/a/click"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/a/touch"),
{"/input/a/touch", ButtonType::Binary}});
{{"/input/a/touch"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/b/click"),
{"/input/b/click", ButtonType::Binary}});
{{"/input/b/click"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/b/touch"),
{"/input/b/touch", ButtonType::Binary}});
{{"/input/b/touch"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/x/click"),
{"/input/x/click", ButtonType::Binary}});
{{"/input/x/click"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/x/touch"),
{"/input/x/touch", ButtonType::Binary}});
{{"/input/x/touch"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/y/click"),
{"/input/y/click", ButtonType::Binary}});
{{"/input/y/click"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/y/touch"),
{"/input/y/touch", ButtonType::Binary}});
{{"/input/y/touch"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/squeeze/click"),
{"/input/grip/click", ButtonType::Binary}});
{{"/input/grip/click"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/squeeze/touch"),
{"/input/grip/touch", ButtonType::Binary}});
{{"/input/grip/touch"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/squeeze/value"),
{"/input/grip/click", ButtonType::ScalarOneSided}});
{{"/input/grip/value"}, ButtonType::ScalarOneSided}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/squeeze/force"),
{"/input/grip/force", ButtonType::ScalarOneSided}});
{{"/input/grip/force"}, ButtonType::ScalarOneSided}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/trigger/click"),
{"/input/trigger/click", ButtonType::Binary}});
{{"/input/trigger/click"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/trigger/value"),
{"/input/trigger/value", ButtonType::ScalarOneSided}});
{{"/input/trigger/value"}, ButtonType::ScalarOneSided}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/trigger/touch"),
{"/input/trigger/touch", ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/thumbstick/x"),
{"/input/joystick/x", ButtonType::ScalarTwoSided}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/thumbstick/y"),
{"/input/joystick/y", ButtonType::ScalarTwoSided}});
{{"/input/trigger/touch"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/left/input/thumbstick/x"),
{{"/input/joystick/x", "/input/thumbstick/x"}, ButtonType::ScalarTwoSided}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/left/input/thumbstick/y"),
{{"/input/joystick/y", "/input/thumbstick/y"}, ButtonType::ScalarTwoSided}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/left/input/thumbstick/click"),
{"/input/joystick/click", ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/left/input/thumbstick/click"),
{"/input/joystick/click", ButtonType::Binary}});
{{"/input/joystick/click", "/input/thumbstick/click"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/left/input/thumbstick/touch"),
{"/input/joystick/touch", ButtonType::Binary}});
{{"/input/joystick/touch", "/input/thumbstick/touch"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/trackpad/x"),
{"/input/trackpad/x", ButtonType::ScalarTwoSided}});
{{"/input/trackpad/x"}, ButtonType::ScalarTwoSided}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/trackpad/y"),
{"/input/trackpad/y", ButtonType::ScalarTwoSided}});
{{"/input/trackpad/y"}, ButtonType::ScalarTwoSided}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/trackpad/click"),
{"/input/trackpad/click", ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/trackpad/force"),
{"/input/trackpad/force", ButtonType::ScalarOneSided}});
{{"/input/trackpad/click"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/left/input/trackpad/force"),
{{"/input/trackpad/force"}, ButtonType::ScalarOneSided}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/left/input/trackpad/touch"),
{"/input/trackpad/touch", ButtonType::Binary}});
{{"/input/trackpad/touch"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/left/input/thumbrest/touch"),
{"/input/thumbrest/touch", ButtonType::Binary}});
{{"/input/thumbrest/touch"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/right/input/system/click"),
{"/input/system/click", ButtonType::Binary}});
{{"/input/system/click"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/right/input/system/touch"),
{"/input/system/touch", ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/right/input/menu/click"),
{"/input/application_menu/click", ButtonType::Binary}});
{{"/input/system/touch"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/menu/click"),
{{"/input/system/click", "/input/application_menu/click"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/right/input/a/click"),
{"/input/a/click", ButtonType::Binary}});
{{"/input/a/click"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/right/input/a/touch"),
{"/input/a/touch", ButtonType::Binary}});
{{"/input/a/touch"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/right/input/b/click"),
{"/input/b/click", ButtonType::Binary}});
{{"/input/b/click"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/right/input/b/touch"),
{"/input/b/touch", ButtonType::Binary}});
{{"/input/b/touch"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/squeeze/click"),
{"/input/grip/click", ButtonType::Binary}});
{{"/input/grip/click"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/squeeze/touch"),
{"/input/grip/touch", ButtonType::Binary}});
{{"/input/grip/touch"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/squeeze/value"),
{"/input/grip/value", ButtonType::ScalarOneSided}});
{{"/input/grip/value"}, ButtonType::ScalarOneSided}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/squeeze/force"),
{"/input/grip/force", ButtonType::ScalarOneSided}});
{{"/input/grip/force"}, ButtonType::ScalarOneSided}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/trigger/click"),
{"/input/trigger/click", ButtonType::Binary}});
{{"/input/trigger/click"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/trigger/value"),
{"/input/trigger/value", ButtonType::ScalarOneSided}});
{{"/input/trigger/value"}, ButtonType::ScalarOneSided}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/trigger/touch"),
{"/input/trigger/touch", ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/right/input/thumbstick/x"),
{"/input/joystick/x", ButtonType::ScalarTwoSided}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/right/input/thumbstick/y"),
{"/input/joystick/y", ButtonType::ScalarTwoSided}});
{{"/input/trigger/touch"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/thumbstick/x"),
{{"/input/joystick/x", "/input/thumbstick/x"}, ButtonType::ScalarTwoSided}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/thumbstick/y"),
{{"/input/joystick/y", "/input/thumbstick/y"}, ButtonType::ScalarTwoSided}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/thumbstick/click"),
{"/input/joystick/click", ButtonType::Binary}});
{{"/input/joystick/click", "/input/thumbstick/click"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/thumbstick/touch"),
{"/input/joystick/touch", ButtonType::Binary}});
{{"/input/joystick/touch", "/input/thumbstick/touch"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/right/input/trackpad/x"),
{"/input/trackpad/x", ButtonType::ScalarTwoSided}});
{{"/input/trackpad/x"}, ButtonType::ScalarTwoSided}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert({PathStringToHash("/user/hand/right/input/trackpad/y"),
{"/input/trackpad/y", ButtonType::ScalarTwoSided}});
{{"/input/trackpad/y"}, ButtonType::ScalarTwoSided}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/trackpad/click"),
{"/input/trackpad/click", ButtonType::Binary}});
{{"/input/trackpad/click"}, ButtonType::Binary}});
LEFT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/trackpad/force"),
{"/input/trackpad/force", ButtonType::ScalarOneSided}});
{{"/input/trackpad/force"}, ButtonType::ScalarOneSided}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/trackpad/touch"),
{"/input/trackpad/touch", ButtonType::Binary}});
{{"/input/trackpad/touch"}, ButtonType::Binary}});
RIGHT_CONTROLLER_BUTTON_MAPPING.insert(
{PathStringToHash("/user/hand/right/input/thumbrest/touch"),
{"/input/thumbrest/touch", ButtonType::Binary}});
{{"/input/thumbrest/touch"}, ButtonType::Binary}});
for (auto hand : {LEFT_CONTROLLER_BUTTON_MAPPING, RIGHT_CONTROLLER_BUTTON_MAPPING}) {
for (auto info : hand) {
std::vector<uint64_t> ids;
for (auto path : info.second.steamvr_paths) {
ids.push_back(PathStringToHash(path));
}
ALVR_TO_STEAMVR_PATH_IDS.insert({info.first, ids});
}
}
LEFT_A_TOUCH_ID = PathStringToHash("/user/hand/left/input/a/touch");
LEFT_B_TOUCH_ID = PathStringToHash("/user/hand/left/input/b/touch");
@ -172,7 +185,6 @@ void init_paths() {
LEFT_THUMBREST_TOUCH_ID = PathStringToHash("/user/hand/left/input/thumbrest/touch");
LEFT_TRIGGER_TOUCH_ID = PathStringToHash("/user/hand/left/input/trigger/touch");
LEFT_TRIGGER_VALUE_ID = PathStringToHash("/user/hand/left/input/trigger/value");
LEFT_SQUEEZE_TOUCH_ID = PathStringToHash("/user/hand/left/input/squeeze/touch");
LEFT_SQUEEZE_VALUE_ID = PathStringToHash("/user/hand/left/input/squeeze/value");
RIGHT_A_TOUCH_ID = PathStringToHash("/user/hand/right/input/a/touch");
RIGHT_B_TOUCH_ID = PathStringToHash("/user/hand/right/input/b/touch");
@ -181,6 +193,5 @@ void init_paths() {
RIGHT_THUMBREST_TOUCH_ID = PathStringToHash("/user/hand/right/input/thumbrest/touch");
RIGHT_TRIGGER_TOUCH_ID = PathStringToHash("/user/hand/right/input/trigger/touch");
RIGHT_TRIGGER_VALUE_ID = PathStringToHash("/user/hand/right/input/trigger/value");
RIGHT_SQUEEZE_TOUCH_ID = PathStringToHash("/user/hand/right/input/squeeze/touch");
RIGHT_SQUEEZE_VALUE_ID = PathStringToHash("/user/hand/right/input/squeeze/value");
}

View File

@ -1,7 +1,7 @@
#pragma once
#include <cstdint>
// #include <vector>
#include <vector>
#include <map>
#include "openvr_driver.h"
@ -17,13 +17,14 @@ enum class ButtonType {
};
struct ButtonInfo {
const char *steamvr_path;
std::vector<const char *> steamvr_paths;
ButtonType type;
};
// Map button ID to SteamVR button info
extern std::map<uint64_t, ButtonInfo> LEFT_CONTROLLER_BUTTON_MAPPING;
extern std::map<uint64_t, ButtonInfo> RIGHT_CONTROLLER_BUTTON_MAPPING;
extern std::map<uint64_t, std::vector<uint64_t>> ALVR_TO_STEAMVR_PATH_IDS;
void init_paths();

View File

@ -79,9 +79,11 @@ pub fn contruct_openvr_config() -> OpenvrConfig {
let settings = data_manager_lock.settings().clone();
let mut controller_is_tracker = false;
let mut _controller_profile = 0;
let controllers_enabled = if let Switch::Enabled(config) = settings.headset.controllers {
controller_is_tracker =
matches!(config.emulation_mode, ControllersEmulationMode::ViveTracker);
_controller_profile = config.emulation_mode as i32;
true
} else {
@ -184,6 +186,7 @@ pub fn contruct_openvr_config() -> OpenvrConfig {
nvenc_enable_weighted_prediction: nvenc_overrides.enable_weighted_prediction,
capture_frame_dir: settings.capture.capture_frame_dir,
amd_bitrate_corruption_fix: settings.video.bitrate.image_corruption_fix,
_controller_profile,
..old_config
}
}

View File

@ -560,7 +560,7 @@ impl ButtonMappingManager {
}
if let Some(mappings) = self.mappings.get(&source_id) {
for mapping in mappings {
'mapping: for mapping in mappings {
let destination_value = match (&mapping.mapping_type, source_value) {
(MappingType::Passthrough, value) => value,
(MappingType::HysteresisThreshold(threshold), ButtonValue::Scalar(value)) => {
@ -577,12 +577,13 @@ impl ButtonMappingManager {
*state = true;
} else {
// No change needed
return;
continue;
}
ButtonValue::Binary(*state)
}
(MappingType::BinaryToScalar(levels), ButtonValue::Binary(value)) => {
error!("binary to scalar");
if value {
ButtonValue::Scalar(levels.on)
} else {
@ -590,12 +591,13 @@ impl ButtonMappingManager {
}
}
(MappingType::Remap(range), ButtonValue::Scalar(value)) => {
error!("remap");
let value = (value - range.start) / (range.end - range.start);
ButtonValue::Scalar(value.clamp(0.0, 1.0))
}
_ => {
error!("Failed to map button!");
return;
continue;
}
};
@ -606,10 +608,16 @@ impl ButtonMappingManager {
.copied()
.unwrap_or(false)
{
return;
continue 'mapping;
}
}
let button_name = BUTTON_INFO
.get(&mapping.destination)
.map(|info| info.path)
.unwrap_or("Unknown");
error!("setting {button_name}: {destination_value:?}");
let destination_value = match destination_value {
ButtonValue::Binary(value) => FfiButtonValue {
type_: crate::FfiButtonType_BUTTON_TYPE_BINARY,

View File

@ -94,6 +94,10 @@ pub struct OpenvrConfig {
pub nvenc_enable_weighted_prediction: bool,
pub capture_frame_dir: String,
pub amd_bitrate_corruption_fix: bool,
// these settings are not used on the C++ side, but we need them to correctly trigger a SteamVR
// restart
pub _controller_profile: i32,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]

View File

@ -581,7 +581,7 @@ pub struct FaceTrackingConfig {
pub sink: FaceTrackingSinkConfig,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[derive(SettingsSchema, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub enum ControllersEmulationMode {
#[schema(strings(display_name = "Quest 2 Touch"))]
Quest2Touch,
@ -1215,7 +1215,7 @@ pub fn session_settings_default() -> SettingsDefault {
value: 0.1,
deviation: 0.05,
},
force_threshold: 0.2,
force_threshold: 0.8,
},
steamvr_pipeline_frames: 3.0,
linear_velocity_cutoff: 0.05,