Skip to content

Commit

Permalink
6DoF profile for HVR controllers
Browse files Browse the repository at this point in the history
The new SDK & runtime for HVR devices will include a specific profile
for 6DoF controllers. This new profile also comes with some specific
fixes for thumbsticks that no longer require specific adjustments. The
only required adjustment is that we have to invert the y coordinate
coming from thumbsticks to make it coherent with other OpenXR
implementations.

Apart from that the new SDK will fix some other previous issues like
right/left inverted controllers and also some issues wrt to controller
poses that allow us to remove some workarounds.
  • Loading branch information
svillar committed Apr 5, 2022
1 parent 7a619c8 commit 7c19eab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
29 changes: 14 additions & 15 deletions app/src/openxr/cpp/OpenXRInputMappings.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@ namespace crow {
Iterator end() const { return Iterator(static_cast<int>(T::enum_count)); }
};

#ifdef HVR
// Workaround for SDK bug
constexpr const char* kPathLeftHand { "/user/hand/right" };
constexpr const char* kPathRightHand { "/user/hand/left" };
#else
constexpr const char* kPathLeftHand { "/user/hand/left" };
constexpr const char* kPathRightHand { "/user/hand/right" };
#endif
constexpr const char* kPathGripPose { "input/grip/pose" };
constexpr const char* kPathAimPose { "input/aim/pose" };
constexpr const char* kPathTrigger { "input/trigger" };
Expand Down Expand Up @@ -194,23 +188,28 @@ namespace crow {
};

const OpenXRInputMapping Hvr6DOF {
"/interaction_profiles/huawei/controller",
"/interaction_profiles/huawei/6dof_controller",
"Haliday: G3HMD by Huawei",
"hvr_6dof_left.obj",
"hvr_6dof_right.obj",
device::OculusQuest,
std::vector<OpenXRInputProfile> { "oculus-touch-v3", "oculus-touch-v2", "oculus-touch", "generic-trigger-squeeze-thumbstick" },
std::vector<OpenXRButton> {
{ OpenXRButtonType::Trigger, kPathTrigger, OpenXRButtonFlags::ClickValue, OpenXRHandFlags::Both },
{ OpenXRButtonType::Squeeze, "input/grip", OpenXRButtonFlags::ClickValue, OpenXRHandFlags::Both },
{ OpenXRButtonType::Thumbstick, kPathThumbstick, OpenXRButtonFlags::Click, OpenXRHandFlags::Both },
{ OpenXRButtonType::ButtonX, "input/ax", OpenXRButtonFlags::Click, OpenXRHandFlags::Both },
{ OpenXRButtonType::ButtonY, "input/by", OpenXRButtonFlags::Click, OpenXRHandFlags::Left, ControllerDelegate::Button::BUTTON_APP },
{ OpenXRButtonType::ButtonY, "input/by", OpenXRButtonFlags::Click, OpenXRHandFlags::Right },
{ OpenXRButtonType::Menu, "input/home", OpenXRButtonFlags::Click, OpenXRHandFlags::Left, ControllerDelegate::Button::BUTTON_APP, true }
{ OpenXRButtonType::ButtonX, kPathButtonX, OpenXRButtonFlags::ClickTouch, OpenXRHandFlags::Left },
{ OpenXRButtonType::ButtonY, kPathButtonY, OpenXRButtonFlags::ClickTouch, OpenXRHandFlags::Left },
{ OpenXRButtonType::Menu, kPathMenu, OpenXRButtonFlags::Click, OpenXRHandFlags::Left },

{ OpenXRButtonType::ButtonA, kPathButtonA, OpenXRButtonFlags::ClickTouch, OpenXRHandFlags::Right },
{ OpenXRButtonType::ButtonB, kPathButtonB, OpenXRButtonFlags::ClickTouch, OpenXRHandFlags::Right },
{ OpenXRButtonType::Menu, "input/home", OpenXRButtonFlags::Click, OpenXRHandFlags::Right, ControllerDelegate::Button::BUTTON_APP, true },

{ OpenXRButtonType::Trigger, kPathTrigger, OpenXRButtonFlags::ClickValue | OpenXRButtonFlags::Touch, OpenXRHandFlags::Both },
{ OpenXRButtonType::Thumbstick, kPathThumbstick, OpenXRButtonFlags::ClickTouch, OpenXRHandFlags::Both },

{ OpenXRButtonType::Squeeze,"input/grip", OpenXRButtonFlags::ClickValue | OpenXRButtonFlags::Touch, OpenXRHandFlags::Both }
},
std::vector<OpenXRAxis> {
{ OpenXRAxisType::Thumbstick, "input/trackpad/value", OpenXRHandFlags::Both },
{ OpenXRAxisType::Thumbstick, kPathThumbstick, OpenXRHandFlags::Both },
}
};

Expand Down
8 changes: 4 additions & 4 deletions app/src/openxr/cpp/OpenXRInputSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ std::optional<XrVector2f> OpenXRInputSource::GetAxis(OpenXRAxisType axisType) co
return std::nullopt;

#if HVR
// axes must be between -1 and 1
axis.x = axis.x * 2 - 1;
axis.y = -(axis.y * 2 - 1);

// Workaround for HVR controller precision issues
const float kPrecision = 0.16;
if (abs(axis.x) < kPrecision && abs(axis.y) < kPrecision) {
Expand Down Expand Up @@ -530,7 +526,11 @@ void OpenXRInputSource::Update(const XrFrameState& frameState, XrSpace localSpac
}
} else if (axis.type == OpenXRAxisType::Thumbstick) {
axesContainer[device::kImmersiveAxisThumbstickX] = state->x;
#ifdef HVR_6DOF
axesContainer[device::kImmersiveAxisThumbstickY] = state->y;
#else
axesContainer[device::kImmersiveAxisThumbstickY] = -state->y;
#endif
delegate.SetScrolledDelta(mIndex, state->x, state->y);
} else {
axesContainer.push_back(state->x);
Expand Down

0 comments on commit 7c19eab

Please sign in to comment.