Add hand/*/pinch and hand/*/poke devices;

This commit is contained in:
bjorn 2023-07-31 18:11:36 -07:00
parent 5fddd28137
commit 715edfd431
3 changed files with 77 additions and 2 deletions

View File

@ -28,6 +28,10 @@ StringEntry lovrDevice[] = {
[DEVICE_HAND_RIGHT_GRIP] = ENTRY("hand/right/grip"),
[DEVICE_HAND_LEFT_POINT] = ENTRY("hand/left/point"),
[DEVICE_HAND_RIGHT_POINT] = ENTRY("hand/right/point"),
[DEVICE_HAND_LEFT_PINCH] = ENTRY("hand/left/pinch"),
[DEVICE_HAND_RIGHT_PINCH] = ENTRY("hand/right/pinch"),
[DEVICE_HAND_LEFT_POKE] = ENTRY("hand/left/poke"),
[DEVICE_HAND_RIGHT_POKE] = ENTRY("hand/right/poke"),
[DEVICE_ELBOW_LEFT] = ENTRY("elbow/left"),
[DEVICE_ELBOW_RIGHT] = ENTRY("elbow/right"),
[DEVICE_SHOULDER_LEFT] = ENTRY("shoulder/left"),

View File

@ -45,6 +45,10 @@ typedef enum {
DEVICE_HAND_RIGHT_GRIP,
DEVICE_HAND_LEFT_POINT,
DEVICE_HAND_RIGHT_POINT,
DEVICE_HAND_LEFT_PINCH,
DEVICE_HAND_RIGHT_PINCH,
DEVICE_HAND_LEFT_POKE,
DEVICE_HAND_RIGHT_POKE,
DEVICE_ELBOW_LEFT,
DEVICE_ELBOW_RIGHT,
DEVICE_SHOULDER_LEFT,

View File

@ -125,6 +125,8 @@ XR_FOREACH(XR_DECLARE)
XR_FOREACH_PLATFORM(XR_DECLARE)
enum {
ACTION_PINCH_POSE,
ACTION_POKE_POSE,
ACTION_GRIP_POSE,
ACTION_POINTER_POSE,
ACTION_TRACKER_POSE,
@ -204,6 +206,7 @@ static struct {
bool controllerModel;
bool depth;
bool gaze;
bool handInteraction;
bool handTracking;
bool handTrackingAim;
bool handTrackingElbow;
@ -323,6 +326,12 @@ static XrAction getPoseActionForDevice(Device device) {
case DEVICE_HAND_LEFT_GRIP:
case DEVICE_HAND_RIGHT_GRIP:
return state.actions[ACTION_GRIP_POSE];
case DEVICE_HAND_LEFT_PINCH:
case DEVICE_HAND_RIGHT_PINCH:
return state.features.handInteraction ? state.actions[ACTION_PINCH_POSE] : XR_NULL_HANDLE;
case DEVICE_HAND_LEFT_POKE:
case DEVICE_HAND_RIGHT_POKE:
return state.features.handInteraction ? state.actions[ACTION_POKE_POSE] : XR_NULL_HANDLE;
case DEVICE_HAND_LEFT_POINT:
case DEVICE_HAND_RIGHT_POINT:
return state.actions[ACTION_POINTER_POSE];
@ -496,6 +505,7 @@ static bool openxr_init(HeadsetConfig* config) {
{ "XR_KHR_convert_timespec_time", NULL, true },
#endif
{ "XR_EXT_eye_gaze_interaction", &state.features.gaze, true },
{ "XR_EXT_hand_interaction", &state.features.handInteraction, true },
{ "XR_EXT_hand_tracking", &state.features.handTracking, true },
{ "XR_EXT_local_floor", &state.features.localFloor, true },
{ "XR_BD_controller_interaction", &state.features.picoController, true },
@ -635,8 +645,14 @@ static bool openxr_init(HeadsetConfig* config) {
XR_INIT(xrStringToPath(state.instance, "/user/hand/left", &state.actionFilters[DEVICE_HAND_LEFT]), "Failed to create path");
XR_INIT(xrStringToPath(state.instance, "/user/hand/right", &state.actionFilters[DEVICE_HAND_RIGHT]), "Failed to create path");
state.actionFilters[DEVICE_HAND_LEFT_POINT] = state.actionFilters[DEVICE_HAND_LEFT_GRIP] = state.actionFilters[DEVICE_HAND_LEFT];
state.actionFilters[DEVICE_HAND_RIGHT_POINT] = state.actionFilters[DEVICE_HAND_RIGHT_GRIP] = state.actionFilters[DEVICE_HAND_RIGHT];
state.actionFilters[DEVICE_HAND_LEFT_GRIP] = state.actionFilters[DEVICE_HAND_LEFT];
state.actionFilters[DEVICE_HAND_LEFT_POINT] = state.actionFilters[DEVICE_HAND_LEFT];
state.actionFilters[DEVICE_HAND_LEFT_PINCH] = state.actionFilters[DEVICE_HAND_LEFT];
state.actionFilters[DEVICE_HAND_LEFT_POKE] = state.actionFilters[DEVICE_HAND_LEFT];
state.actionFilters[DEVICE_HAND_RIGHT_GRIP] = state.actionFilters[DEVICE_HAND_RIGHT];
state.actionFilters[DEVICE_HAND_RIGHT_POINT] = state.actionFilters[DEVICE_HAND_RIGHT];
state.actionFilters[DEVICE_HAND_RIGHT_PINCH] = state.actionFilters[DEVICE_HAND_RIGHT];
state.actionFilters[DEVICE_HAND_RIGHT_POKE] = state.actionFilters[DEVICE_HAND_RIGHT];
if (state.features.viveTrackers) {
XR_INIT(xrStringToPath(state.instance, "/user/vive_tracker_htcx/role/left_elbow", &state.actionFilters[DEVICE_ELBOW_LEFT]), "Failed to create path");
@ -674,6 +690,8 @@ static bool openxr_init(HeadsetConfig* config) {
};
XrActionCreateInfo actionInfo[] = {
{ 0, NULL, "pinch_pose", XR_ACTION_TYPE_POSE_INPUT, 2, hands, "Pinch Pose" },
{ 0, NULL, "poke_pose", XR_ACTION_TYPE_POSE_INPUT, 2, hands, "Poke Pose" },
{ 0, NULL, "grip_pose", XR_ACTION_TYPE_POSE_INPUT, 2, hands, "Grip Pose" },
{ 0, NULL, "pointer_pose", XR_ACTION_TYPE_POSE_INPUT, 2, hands, "Pointer Pose" },
{ 0, NULL, "tracker_pose", XR_ACTION_TYPE_POSE_INPUT, 12, trackers, "Tracker Pose" },
@ -757,6 +775,10 @@ static bool openxr_init(HeadsetConfig* config) {
Binding* bindings[] = {
[PROFILE_SIMPLE] = (Binding[]) {
{ ACTION_PINCH_POSE, "/user/hand/left/pinch_ext/pose" },
{ ACTION_PINCH_POSE, "/user/hand/right/pinch_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/left/poke_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/right/poke_ext/pose" },
{ ACTION_GRIP_POSE, "/user/hand/left/input/grip/pose" },
{ ACTION_GRIP_POSE, "/user/hand/right/input/grip/pose" },
{ ACTION_POINTER_POSE, "/user/hand/left/input/aim/pose" },
@ -770,6 +792,10 @@ static bool openxr_init(HeadsetConfig* config) {
{ 0, NULL }
},
[PROFILE_VIVE] = (Binding[]) {
{ ACTION_PINCH_POSE, "/user/hand/left/pinch_ext/pose" },
{ ACTION_PINCH_POSE, "/user/hand/right/pinch_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/left/poke_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/right/poke_ext/pose" },
{ ACTION_GRIP_POSE, "/user/hand/left/input/grip/pose" },
{ ACTION_GRIP_POSE, "/user/hand/right/input/grip/pose" },
{ ACTION_POINTER_POSE, "/user/hand/left/input/aim/pose" },
@ -795,6 +821,10 @@ static bool openxr_init(HeadsetConfig* config) {
{ 0, NULL }
},
[PROFILE_TOUCH] = (Binding[]) {
{ ACTION_PINCH_POSE, "/user/hand/left/pinch_ext/pose" },
{ ACTION_PINCH_POSE, "/user/hand/right/pinch_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/left/poke_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/right/poke_ext/pose" },
{ ACTION_GRIP_POSE, "/user/hand/left/input/grip/pose" },
{ ACTION_GRIP_POSE, "/user/hand/right/input/grip/pose" },
{ ACTION_POINTER_POSE, "/user/hand/left/input/aim/pose" },
@ -834,6 +864,10 @@ static bool openxr_init(HeadsetConfig* config) {
{ 0, NULL }
},
[PROFILE_GO] = (Binding[]) {
{ ACTION_PINCH_POSE, "/user/hand/left/pinch_ext/pose" },
{ ACTION_PINCH_POSE, "/user/hand/right/pinch_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/left/poke_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/right/poke_ext/pose" },
{ ACTION_GRIP_POSE, "/user/hand/left/input/grip/pose" },
{ ACTION_GRIP_POSE, "/user/hand/right/input/grip/pose" },
{ ACTION_POINTER_POSE, "/user/hand/left/input/aim/pose" },
@ -851,6 +885,10 @@ static bool openxr_init(HeadsetConfig* config) {
{ 0, NULL }
},
[PROFILE_INDEX] = (Binding[]) {
{ ACTION_PINCH_POSE, "/user/hand/left/pinch_ext/pose" },
{ ACTION_PINCH_POSE, "/user/hand/right/pinch_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/left/poke_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/right/poke_ext/pose" },
{ ACTION_GRIP_POSE, "/user/hand/left/input/grip/pose" },
{ ACTION_GRIP_POSE, "/user/hand/right/input/grip/pose" },
{ ACTION_POINTER_POSE, "/user/hand/left/input/aim/pose" },
@ -896,6 +934,10 @@ static bool openxr_init(HeadsetConfig* config) {
{ 0, NULL }
},
[PROFILE_WMR] = (Binding[]) {
{ ACTION_PINCH_POSE, "/user/hand/left/pinch_ext/pose" },
{ ACTION_PINCH_POSE, "/user/hand/right/pinch_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/left/poke_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/right/poke_ext/pose" },
{ ACTION_GRIP_POSE, "/user/hand/left/input/grip/pose" },
{ ACTION_GRIP_POSE, "/user/hand/right/input/grip/pose" },
{ ACTION_POINTER_POSE, "/user/hand/left/input/aim/pose" },
@ -929,6 +971,10 @@ static bool openxr_init(HeadsetConfig* config) {
{ 0, NULL }
},
[PROFILE_ML2] = (Binding[]) {
{ ACTION_PINCH_POSE, "/user/hand/left/pinch_ext/pose" },
{ ACTION_PINCH_POSE, "/user/hand/right/pinch_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/left/poke_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/right/poke_ext/pose" },
{ ACTION_GRIP_POSE, "/user/hand/left/input/grip/pose" },
{ ACTION_GRIP_POSE, "/user/hand/right/input/grip/pose" },
{ ACTION_POINTER_POSE, "/user/hand/left/input/aim/pose" },
@ -954,6 +1000,10 @@ static bool openxr_init(HeadsetConfig* config) {
{ 0, NULL }
},
[PROFILE_PICO_NEO3] = (Binding[]) {
{ ACTION_PINCH_POSE, "/user/hand/left/pinch_ext/pose" },
{ ACTION_PINCH_POSE, "/user/hand/right/pinch_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/left/poke_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/right/poke_ext/pose" },
{ ACTION_GRIP_POSE, "/user/hand/left/input/grip/pose" },
{ ACTION_GRIP_POSE, "/user/hand/right/input/grip/pose" },
{ ACTION_POINTER_POSE, "/user/hand/left/input/aim/pose" },
@ -991,6 +1041,10 @@ static bool openxr_init(HeadsetConfig* config) {
{ 0, NULL }
},
[PROFILE_PICO4] = (Binding[]) {
{ ACTION_PINCH_POSE, "/user/hand/left/pinch_ext/pose" },
{ ACTION_PINCH_POSE, "/user/hand/right/pinch_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/left/poke_ext/pose" },
{ ACTION_POKE_POSE, "/user/hand/right/poke_ext/pose" },
{ ACTION_GRIP_POSE, "/user/hand/left/input/grip/pose" },
{ ACTION_GRIP_POSE, "/user/hand/right/input/grip/pose" },
{ ACTION_POINTER_POSE, "/user/hand/left/input/aim/pose" },
@ -1068,6 +1122,19 @@ static bool openxr_init(HeadsetConfig* config) {
bindings[PROFILE_GAZE][0].path = NULL;
}
// For this to work, pinch/poke need to be the first paths in the interaction profile
if (!state.features.handInteraction) {
bindings[PROFILE_SIMPLE] += 4;
bindings[PROFILE_VIVE] += 4;
bindings[PROFILE_TOUCH] += 4;
bindings[PROFILE_GO] += 4;
bindings[PROFILE_INDEX] += 4;
bindings[PROFILE_WMR] += 4;
if (state.features.ml2Controller) bindings[PROFILE_ML2] += 4;
if (state.features.picoController) bindings[PROFILE_PICO_NEO3] += 4;
if (state.features.picoController) bindings[PROFILE_PICO4] += 4;
}
XrPath path;
XrActionSuggestedBinding suggestedBindings[64];
for (uint32_t i = 0, count = 0; i < MAX_PROFILES; i++, count = 0) {