mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-22 12:01:41 +00:00
OpenXR controller mapping fixed
This commit is contained in:
parent
712584eae8
commit
11a849b189
2 changed files with 22 additions and 40 deletions
|
@ -20,8 +20,8 @@
|
||||||
//OpenXR
|
//OpenXR
|
||||||
XrPath leftHandPath;
|
XrPath leftHandPath;
|
||||||
XrPath rightHandPath;
|
XrPath rightHandPath;
|
||||||
XrAction aimPoseAction;
|
XrAction handPoseLeftAction;
|
||||||
XrAction gripPoseAction;
|
XrAction handPoseRightAction;
|
||||||
XrAction indexLeftAction;
|
XrAction indexLeftAction;
|
||||||
XrAction indexRightAction;
|
XrAction indexRightAction;
|
||||||
XrAction menuAction;
|
XrAction menuAction;
|
||||||
|
@ -40,8 +40,6 @@ XrAction vibrateRightFeedback;
|
||||||
XrActionSet runningActionSet;
|
XrActionSet runningActionSet;
|
||||||
XrSpace leftControllerAimSpace = XR_NULL_HANDLE;
|
XrSpace leftControllerAimSpace = XR_NULL_HANDLE;
|
||||||
XrSpace rightControllerAimSpace = XR_NULL_HANDLE;
|
XrSpace rightControllerAimSpace = XR_NULL_HANDLE;
|
||||||
XrSpace leftControllerGripSpace = XR_NULL_HANDLE;
|
|
||||||
XrSpace rightControllerGripSpace = XR_NULL_HANDLE;
|
|
||||||
qboolean inputInitialized = qfalse;
|
qboolean inputInitialized = qfalse;
|
||||||
qboolean useSimpleProfile = qfalse;
|
qboolean useSimpleProfile = qfalse;
|
||||||
|
|
||||||
|
@ -658,9 +656,8 @@ void IN_VRInit( void )
|
||||||
|
|
||||||
OXR(xrStringToPath(engine->appState.Instance, "/user/hand/left", &leftHandPath));
|
OXR(xrStringToPath(engine->appState.Instance, "/user/hand/left", &leftHandPath));
|
||||||
OXR(xrStringToPath(engine->appState.Instance, "/user/hand/right", &rightHandPath));
|
OXR(xrStringToPath(engine->appState.Instance, "/user/hand/right", &rightHandPath));
|
||||||
XrPath handSubactionPaths[2] = {leftHandPath, rightHandPath};
|
handPoseLeftAction = CreateAction(runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "hand_pose_left", NULL, 1, &leftHandPath);
|
||||||
aimPoseAction = CreateAction(runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", NULL, 2, &handSubactionPaths[0]);
|
handPoseRightAction = CreateAction(runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "hand_pose_right", NULL, 1, &rightHandPath);
|
||||||
gripPoseAction = CreateAction(runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", NULL, 2, &handSubactionPaths[0]);
|
|
||||||
|
|
||||||
XrPath interactionProfilePath = XR_NULL_PATH;
|
XrPath interactionProfilePath = XR_NULL_PATH;
|
||||||
XrPath interactionProfilePathTouch = XR_NULL_PATH;
|
XrPath interactionProfilePathTouch = XR_NULL_PATH;
|
||||||
|
@ -738,10 +735,8 @@ void IN_VRInit( void )
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(thumbstickRightClickAction, "/user/hand/right/input/thumbstick/click");
|
bindings[currBinding++] = ActionSuggestedBinding(thumbstickRightClickAction, "/user/hand/right/input/thumbstick/click");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(vibrateLeftFeedback, "/user/hand/left/output/haptic");
|
bindings[currBinding++] = ActionSuggestedBinding(vibrateLeftFeedback, "/user/hand/left/output/haptic");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(vibrateRightFeedback, "/user/hand/right/output/haptic");
|
bindings[currBinding++] = ActionSuggestedBinding(vibrateRightFeedback, "/user/hand/right/output/haptic");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(aimPoseAction, "/user/hand/left/input/aim/pose");
|
bindings[currBinding++] = ActionSuggestedBinding(handPoseLeftAction, "/user/hand/left/input/aim/pose");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(aimPoseAction, "/user/hand/right/input/aim/pose");
|
bindings[currBinding++] = ActionSuggestedBinding(handPoseRightAction, "/user/hand/right/input/aim/pose");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(gripPoseAction, "/user/hand/left/input/grip/pose");
|
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(gripPoseAction, "/user/hand/right/input/grip/pose");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interactionProfilePath == interactionProfilePathKHRSimple) {
|
if (interactionProfilePath == interactionProfilePathKHRSimple) {
|
||||||
|
@ -751,10 +746,8 @@ void IN_VRInit( void )
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(buttonXAction, "/user/hand/right/input/menu/click");
|
bindings[currBinding++] = ActionSuggestedBinding(buttonXAction, "/user/hand/right/input/menu/click");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(vibrateLeftFeedback, "/user/hand/left/output/haptic");
|
bindings[currBinding++] = ActionSuggestedBinding(vibrateLeftFeedback, "/user/hand/left/output/haptic");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(vibrateRightFeedback, "/user/hand/right/output/haptic");
|
bindings[currBinding++] = ActionSuggestedBinding(vibrateRightFeedback, "/user/hand/right/output/haptic");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(aimPoseAction, "/user/hand/left/input/aim/pose");
|
bindings[currBinding++] = ActionSuggestedBinding(handPoseLeftAction, "/user/hand/left/input/aim/pose");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(aimPoseAction, "/user/hand/right/input/aim/pose");
|
bindings[currBinding++] = ActionSuggestedBinding(handPoseRightAction, "/user/hand/right/input/aim/pose");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(gripPoseAction, "/user/hand/left/input/grip/pose");
|
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(gripPoseAction, "/user/hand/right/input/grip/pose");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,8 +778,8 @@ void IN_VRInit( void )
|
||||||
thumbstickRightClickAction,
|
thumbstickRightClickAction,
|
||||||
vibrateLeftFeedback,
|
vibrateLeftFeedback,
|
||||||
vibrateRightFeedback,
|
vibrateRightFeedback,
|
||||||
aimPoseAction,
|
handPoseLeftAction,
|
||||||
gripPoseAction,
|
handPoseRightAction
|
||||||
};
|
};
|
||||||
for (size_t i = 0; i < sizeof(actionsToEnumerate) / sizeof(actionsToEnumerate[0]); ++i) {
|
for (size_t i = 0; i < sizeof(actionsToEnumerate) / sizeof(actionsToEnumerate[0]); ++i) {
|
||||||
XrBoundSourcesForActionEnumerateInfo enumerateInfo = {};
|
XrBoundSourcesForActionEnumerateInfo enumerateInfo = {};
|
||||||
|
@ -869,9 +862,9 @@ static void IN_VRController( qboolean isRightController, XrPosef pose )
|
||||||
QuatToYawPitchRoll(pose.orientation, rotation, vr.offhandangles);
|
QuatToYawPitchRoll(pose.orientation, rotation, vr.offhandangles);
|
||||||
|
|
||||||
///location relative to view
|
///location relative to view
|
||||||
vr.weaponposition[0] = pose.position.x;
|
vr.offhandposition[0] = pose.position.x;
|
||||||
vr.weaponposition[1] = pose.position.y + vr_heightAdjust->value;
|
vr.offhandposition[1] = pose.position.y + vr_heightAdjust->value;
|
||||||
vr.weaponposition[2] = pose.position.z;
|
vr.offhandposition[2] = pose.position.z;
|
||||||
|
|
||||||
VectorCopy(vr.offhandoffset_last[1], vr.offhandoffset_last[0]);
|
VectorCopy(vr.offhandoffset_last[1], vr.offhandoffset_last[0]);
|
||||||
VectorCopy(vr.offhandoffset, vr.offhandoffset_last[1]);
|
VectorCopy(vr.offhandoffset, vr.offhandoffset_last[1]);
|
||||||
|
@ -1342,28 +1335,17 @@ void IN_VRInputFrame( void )
|
||||||
VR_HapticEvent("frame_tick", 0, 0, 0, 0, 0);
|
VR_HapticEvent("frame_tick", 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
if (leftControllerAimSpace == XR_NULL_HANDLE) {
|
if (leftControllerAimSpace == XR_NULL_HANDLE) {
|
||||||
leftControllerAimSpace = CreateActionSpace(aimPoseAction, leftHandPath);
|
leftControllerAimSpace = CreateActionSpace(handPoseLeftAction, leftHandPath);
|
||||||
}
|
}
|
||||||
if (rightControllerAimSpace == XR_NULL_HANDLE) {
|
if (rightControllerAimSpace == XR_NULL_HANDLE) {
|
||||||
rightControllerAimSpace = CreateActionSpace(aimPoseAction, rightHandPath);
|
rightControllerAimSpace = CreateActionSpace(handPoseRightAction, rightHandPath);
|
||||||
}
|
|
||||||
if (leftControllerGripSpace == XR_NULL_HANDLE) {
|
|
||||||
leftControllerGripSpace = CreateActionSpace(gripPoseAction, leftHandPath);
|
|
||||||
}
|
|
||||||
if (rightControllerGripSpace == XR_NULL_HANDLE) {
|
|
||||||
rightControllerGripSpace = CreateActionSpace(gripPoseAction, rightHandPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update input information
|
// update input information
|
||||||
XrAction controller[] = {aimPoseAction, gripPoseAction, aimPoseAction, gripPoseAction};
|
XrAction controller[] = {handPoseLeftAction, handPoseRightAction};
|
||||||
XrPath subactionPath[] = {leftHandPath, leftHandPath, rightHandPath, rightHandPath};
|
XrPath subactionPath[] = {leftHandPath, rightHandPath};
|
||||||
XrSpace controllerSpace[] = {
|
XrSpace controllerSpace[] = {leftControllerAimSpace, rightControllerAimSpace};
|
||||||
leftControllerAimSpace,
|
for (int i = 0; i < 2; i++) {
|
||||||
leftControllerGripSpace,
|
|
||||||
rightControllerAimSpace,
|
|
||||||
rightControllerGripSpace,
|
|
||||||
};
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
if (ActionPoseIsActive(controller[i], subactionPath[i])) {
|
if (ActionPoseIsActive(controller[i], subactionPath[i])) {
|
||||||
LocVel lv = GetSpaceLocVel(controllerSpace[i], VR_GetEngine()->predictedDisplayTime);
|
LocVel lv = GetSpaceLocVel(controllerSpace[i], VR_GetEngine()->predictedDisplayTime);
|
||||||
VR_GetEngine()->appState.TrackedController[i].Active = (lv.loc.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) != 0;
|
VR_GetEngine()->appState.TrackedController[i].Active = (lv.loc.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) != 0;
|
||||||
|
@ -1438,8 +1420,8 @@ void IN_VRInputFrame( void )
|
||||||
//controller pose
|
//controller pose
|
||||||
if (engine->appState.TrackedController[0].Active)
|
if (engine->appState.TrackedController[0].Active)
|
||||||
IN_VRController(qfalse, engine->appState.TrackedController[0].Pose);
|
IN_VRController(qfalse, engine->appState.TrackedController[0].Pose);
|
||||||
if (engine->appState.TrackedController[2].Active)
|
if (engine->appState.TrackedController[1].Active)
|
||||||
IN_VRController(qtrue, engine->appState.TrackedController[2].Pose);
|
IN_VRController(qtrue, engine->appState.TrackedController[1].Pose);
|
||||||
|
|
||||||
lastframetime = in_vrEventTime;
|
lastframetime = in_vrEventTime;
|
||||||
in_vrEventTime = Sys_Milliseconds( );
|
in_vrEventTime = Sys_Milliseconds( );
|
||||||
|
|
|
@ -100,7 +100,7 @@ typedef struct {
|
||||||
|
|
||||||
GLboolean TouchPadDownLastFrame;
|
GLboolean TouchPadDownLastFrame;
|
||||||
ovrRenderer Renderer;
|
ovrRenderer Renderer;
|
||||||
ovrTrackedController TrackedController[4]; // left aim, left grip, right aim, right grip
|
ovrTrackedController TrackedController[2];
|
||||||
} ovrApp;
|
} ovrApp;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue