Support Vive trackers again;

/trackers/1
This commit is contained in:
bjorn 2019-04-18 21:51:48 -07:00
parent ca30991b2a
commit d8581106d4
3 changed files with 25 additions and 2 deletions

View File

@ -31,6 +31,7 @@ const char* Subpaths[] = {
[P_HEAD] = "head",
[P_HAND] = "hand",
[P_EYE] = "eye",
[P_TRACKER] = "tracker",
[P_LEFT] = "left",
[P_RIGHT] = "right",
[P_PROXIMITY] = "proximity",
@ -42,7 +43,15 @@ const char* Subpaths[] = {
[P_A] = "a",
[P_B] = "b",
[P_X] = "x",
[P_Y] = "y"
[P_Y] = "y",
[P_1] = "1",
[P_2] = "2",
[P_3] = "3",
[P_4] = "4",
[P_5] = "5",
[P_6] = "6",
[P_7] = "7",
[P_8] = "8"
};
typedef struct {

View File

@ -26,6 +26,7 @@ typedef enum {
P_HEAD,
P_HAND,
P_EYE,
P_TRACKER,
P_LEFT,
P_RIGHT,
P_PROXIMITY,
@ -37,7 +38,15 @@ typedef enum {
P_A,
P_B,
P_X,
P_Y
P_Y,
P_1,
P_2,
P_3,
P_4,
P_5,
P_6,
P_7,
P_8
} Subpath;
typedef union {

View File

@ -61,6 +61,11 @@ static TrackedDeviceIndex_t getDeviceIndexForPath(Path path) {
return state.system->GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole_TrackedControllerRole_LeftHand);
} else if (PATH_EQ(path, P_HAND, P_RIGHT)) {
return state.system->GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole_TrackedControllerRole_RightHand);
} else if (path.p[0] == P_TRACKER && path.p[1] >= P_1 && path.p[1] <= P_8 && path.p[2] == P_NONE) {
TrackedDeviceIndex_t indices[8];
uint32_t trackerCount = state.system->GetSortedTrackedDeviceIndicesOfClass(ETrackedDeviceClass_TrackedDeviceClass_GenericTracker, indices, 8, 0);
uint32_t index = path.p[1] - P_1;
return index < trackerCount ? indices[index] : k_unTrackedDeviceIndexInvalid;
} else {
return k_unTrackedDeviceIndexInvalid;
}