mirror of https://github.com/bjornbytes/lovr.git
Merge pull request #335 from bjornbytes/trackers
Support Vive Trackers;
This commit is contained in:
commit
1513191660
|
@ -32,6 +32,18 @@ StringEntry lovrDevice[] = {
|
|||
[DEVICE_HAND_RIGHT] = ENTRY("hand/right"),
|
||||
[DEVICE_HAND_LEFT_POINT] = ENTRY("hand/left/point"),
|
||||
[DEVICE_HAND_RIGHT_POINT] = ENTRY("hand/right/point"),
|
||||
[DEVICE_ELBOW_LEFT] = ENTRY("elbow/left"),
|
||||
[DEVICE_ELBOW_RIGHT] = ENTRY("elbow/right"),
|
||||
[DEVICE_SHOULDER_LEFT] = ENTRY("shoulder/left"),
|
||||
[DEVICE_SHOULDER_RIGHT] = ENTRY("shoulder/right"),
|
||||
[DEVICE_CHEST] = ENTRY("chest"),
|
||||
[DEVICE_WAIST] = ENTRY("waist"),
|
||||
[DEVICE_KNEE_LEFT] = ENTRY("knee/left"),
|
||||
[DEVICE_KNEE_RIGHT] = ENTRY("knee/right"),
|
||||
[DEVICE_FOOT_LEFT] = ENTRY("foot/left"),
|
||||
[DEVICE_FOOT_RIGHT] = ENTRY("foot/right"),
|
||||
[DEVICE_CAMERA] = ENTRY("camera"),
|
||||
[DEVICE_KEYBOARD] = ENTRY("keyboard"),
|
||||
[DEVICE_EYE_LEFT] = ENTRY("eye/left"),
|
||||
[DEVICE_EYE_RIGHT] = ENTRY("eye/right"),
|
||||
[DEVICE_BEACON_1] = ENTRY("beacon/1"),
|
||||
|
|
|
@ -31,6 +31,18 @@ typedef enum {
|
|||
DEVICE_HAND_RIGHT,
|
||||
DEVICE_HAND_LEFT_POINT,
|
||||
DEVICE_HAND_RIGHT_POINT,
|
||||
DEVICE_ELBOW_LEFT,
|
||||
DEVICE_ELBOW_RIGHT,
|
||||
DEVICE_SHOULDER_LEFT,
|
||||
DEVICE_SHOULDER_RIGHT,
|
||||
DEVICE_CHEST,
|
||||
DEVICE_WAIST,
|
||||
DEVICE_KNEE_LEFT,
|
||||
DEVICE_KNEE_RIGHT,
|
||||
DEVICE_FOOT_LEFT,
|
||||
DEVICE_FOOT_RIGHT,
|
||||
DEVICE_CAMERA,
|
||||
DEVICE_KEYBOARD,
|
||||
DEVICE_EYE_LEFT,
|
||||
DEVICE_EYE_RIGHT,
|
||||
DEVICE_BEACON_1,
|
||||
|
|
|
@ -3,6 +3,18 @@
|
|||
#include "resources/bindings_vive.json.h"
|
||||
#include "resources/bindings_knuckles.json.h"
|
||||
#include "resources/bindings_touch.json.h"
|
||||
#include "resources/bindings_vive_tracker_left_elbow.json.h"
|
||||
#include "resources/bindings_vive_tracker_right_elbow.json.h"
|
||||
#include "resources/bindings_vive_tracker_left_shoulder.json.h"
|
||||
#include "resources/bindings_vive_tracker_right_shoulder.json.h"
|
||||
#include "resources/bindings_vive_tracker_chest.json.h"
|
||||
#include "resources/bindings_vive_tracker_waist.json.h"
|
||||
#include "resources/bindings_vive_tracker_left_knee.json.h"
|
||||
#include "resources/bindings_vive_tracker_right_knee.json.h"
|
||||
#include "resources/bindings_vive_tracker_left_foot.json.h"
|
||||
#include "resources/bindings_vive_tracker_right_foot.json.h"
|
||||
#include "resources/bindings_vive_tracker_camera.json.h"
|
||||
#include "resources/bindings_vive_tracker_keyboard.json.h"
|
||||
#include "event/event.h"
|
||||
#include "filesystem/filesystem.h"
|
||||
#include "graphics/graphics.h"
|
||||
|
@ -73,7 +85,7 @@ static struct {
|
|||
struct VR_IVRRenderModels_FnTable* renderModels;
|
||||
struct VR_IVRInput_FnTable* input;
|
||||
VRActionSetHandle_t actionSet;
|
||||
VRActionHandle_t poseActions[5];
|
||||
VRActionHandle_t poseActions[MAX_DEVICES];
|
||||
VRActionHandle_t buttonActions[2][MAX_BUTTONS];
|
||||
VRActionHandle_t touchActions[2][MAX_BUTTONS];
|
||||
VRActionHandle_t axisActions[2][MAX_AXES];
|
||||
|
@ -131,7 +143,19 @@ static bool openvr_init(float supersample, float offset, uint32_t msaa) {
|
|||
lovrFilesystemWrite("actions.json", (const char*) src_resources_actions_json, src_resources_actions_json_len, false) != src_resources_actions_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive.json", (const char*) src_resources_bindings_vive_json, src_resources_bindings_vive_json_len, false) != src_resources_bindings_vive_json_len ||
|
||||
lovrFilesystemWrite("bindings_knuckles.json", (const char*) src_resources_bindings_knuckles_json, src_resources_bindings_knuckles_json_len, false) != src_resources_bindings_knuckles_json_len ||
|
||||
lovrFilesystemWrite("bindings_touch.json", (const char*) src_resources_bindings_touch_json, src_resources_bindings_touch_json_len, false) != src_resources_bindings_touch_json_len
|
||||
lovrFilesystemWrite("bindings_touch.json", (const char*) src_resources_bindings_touch_json, src_resources_bindings_touch_json_len, false) != src_resources_bindings_touch_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_left_elbow.json", (const char*) src_resources_bindings_vive_tracker_left_elbow_json, src_resources_bindings_vive_tracker_left_elbow_json_len, false) != src_resources_bindings_vive_tracker_left_elbow_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_right_elbow.json", (const char*) src_resources_bindings_vive_tracker_right_elbow_json, src_resources_bindings_vive_tracker_right_elbow_json_len, false) != src_resources_bindings_vive_tracker_right_elbow_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_left_shoulder.json", (const char*) src_resources_bindings_vive_tracker_left_shoulder_json, src_resources_bindings_vive_tracker_left_shoulder_json_len, false) != src_resources_bindings_vive_tracker_left_shoulder_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_right_shoulder.json", (const char*) src_resources_bindings_vive_tracker_right_shoulder_json, src_resources_bindings_vive_tracker_right_shoulder_json_len, false) != src_resources_bindings_vive_tracker_right_shoulder_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_chest.json", (const char*) src_resources_bindings_vive_tracker_chest_json, src_resources_bindings_vive_tracker_chest_json_len, false) != src_resources_bindings_vive_tracker_chest_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_waist.json", (const char*) src_resources_bindings_vive_tracker_waist_json, src_resources_bindings_vive_tracker_waist_json_len, false) != src_resources_bindings_vive_tracker_waist_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_left_knee.json", (const char*) src_resources_bindings_vive_tracker_left_knee_json, src_resources_bindings_vive_tracker_left_knee_json_len, false) != src_resources_bindings_vive_tracker_left_knee_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_right_knee.json", (const char*) src_resources_bindings_vive_tracker_right_knee_json, src_resources_bindings_vive_tracker_right_knee_json_len, false) != src_resources_bindings_vive_tracker_right_knee_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_left_foot.json", (const char*) src_resources_bindings_vive_tracker_left_foot_json, src_resources_bindings_vive_tracker_left_foot_json_len, false) != src_resources_bindings_vive_tracker_left_foot_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_right_foot.json", (const char*) src_resources_bindings_vive_tracker_right_foot_json, src_resources_bindings_vive_tracker_right_foot_json_len, false) != src_resources_bindings_vive_tracker_right_foot_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_camera.json", (const char*) src_resources_bindings_vive_tracker_camera_json, src_resources_bindings_vive_tracker_camera_json_len, false) != src_resources_bindings_vive_tracker_camera_json_len ||
|
||||
lovrFilesystemWrite("bindings_vive_tracker_keyboard.json", (const char*) src_resources_bindings_vive_tracker_keyboard_json, src_resources_bindings_vive_tracker_keyboard_json_len, false) != src_resources_bindings_vive_tracker_keyboard_json_len
|
||||
) {
|
||||
VR_ShutdownInternal();
|
||||
return false;
|
||||
|
@ -148,6 +172,18 @@ static bool openvr_init(float supersample, float offset, uint32_t msaa) {
|
|||
state.input->GetActionHandle("/actions/lovr/in/rightHandPose", &state.poseActions[DEVICE_HAND_RIGHT]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/leftHandPoint", &state.poseActions[DEVICE_HAND_LEFT_POINT]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/rightHandPoint", &state.poseActions[DEVICE_HAND_RIGHT_POINT]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/leftElbowPose", &state.poseActions[DEVICE_ELBOW_LEFT]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/rightElbowPose", &state.poseActions[DEVICE_ELBOW_RIGHT]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/leftShoulderPose", &state.poseActions[DEVICE_SHOULDER_LEFT]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/rightShoulderPose", &state.poseActions[DEVICE_SHOULDER_RIGHT]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/chestPose", &state.poseActions[DEVICE_CHEST]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/waistPose", &state.poseActions[DEVICE_WAIST]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/leftKneePose", &state.poseActions[DEVICE_KNEE_LEFT]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/rightKneePose", &state.poseActions[DEVICE_KNEE_RIGHT]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/leftFootPose", &state.poseActions[DEVICE_FOOT_LEFT]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/rightFootPose", &state.poseActions[DEVICE_FOOT_RIGHT]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/cameraPose", &state.poseActions[DEVICE_CAMERA]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/keyboardPose", &state.poseActions[DEVICE_KEYBOARD]);
|
||||
|
||||
state.input->GetActionHandle("/actions/lovr/in/leftTriggerDown", &state.buttonActions[0][BUTTON_TRIGGER]);
|
||||
state.input->GetActionHandle("/actions/lovr/in/leftThumbstickDown", &state.buttonActions[0][BUTTON_THUMBSTICK]);
|
||||
|
@ -347,6 +383,7 @@ static bool openvr_getPose(Device device, vec3 position, quat orientation) {
|
|||
return state.renderPoses[k_unTrackedDeviceIndex_Hmd].bPoseIsValid;
|
||||
}
|
||||
|
||||
// Lighthouse devices use the old tracked device index API
|
||||
if (device >= DEVICE_BEACON_1 && device <= DEVICE_BEACON_4) {
|
||||
TrackedDeviceIndex_t devices[4];
|
||||
ETrackedDeviceClass class = ETrackedDeviceClass_TrackedDeviceClass_TrackingReference;
|
||||
|
@ -361,7 +398,8 @@ static bool openvr_getPose(Device device, vec3 position, quat orientation) {
|
|||
return pose->bPoseIsValid;
|
||||
}
|
||||
|
||||
if (device == DEVICE_HAND_LEFT || device == DEVICE_HAND_RIGHT) {
|
||||
// Generic device
|
||||
if (state.poseActions[device]) {
|
||||
InputPoseActionData_t action;
|
||||
state.input->GetPoseActionDataForNextFrame(state.poseActions[device], state.compositor->GetTrackingSpace(), &action, sizeof(action), 0);
|
||||
mat4_fromMat34(transform, action.pose.mDeviceToAbsoluteTracking.m);
|
||||
|
@ -380,7 +418,7 @@ static bool openvr_getVelocity(Device device, vec3 velocity, vec3 angularVelocit
|
|||
|
||||
if (device == DEVICE_HEAD) {
|
||||
pose = &state.renderPoses[k_unTrackedDeviceIndex_Hmd];
|
||||
} else if (device == DEVICE_HAND_LEFT || device == DEVICE_HAND_RIGHT) {
|
||||
} else if (state.poseActions[device]) {
|
||||
state.input->GetPoseActionDataForNextFrame(state.poseActions[device], state.compositor->GetTrackingSpace(), &action, sizeof(action), 0);
|
||||
pose = &action.pose;
|
||||
} else {
|
||||
|
|
|
@ -5,6 +5,18 @@
|
|||
"actions" : [
|
||||
{ "name" : "/actions/lovr/in/leftHandPose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/rightHandPose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/leftElbowPose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/rightElbowPose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/leftShoulderPose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/rightShoulderPose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/chestPose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/waistPose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/leftKneePose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/rightKneePose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/leftFootPose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/rightFootPose", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/camera", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/keyboard", "type" : "pose" },
|
||||
{ "name" : "/actions/lovr/in/leftTriggerDown", "type" : "boolean" },
|
||||
{ "name" : "/actions/lovr/in/leftTriggerTouch", "type" : "boolean" },
|
||||
{ "name" : "/actions/lovr/in/leftTriggerAxis", "type" : "vector1" },
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/cameraPose", "path": "/user/camera/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_camera",
|
||||
"description" : "",
|
||||
"name" : "Camera Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/chestPose", "path": "/user/chest/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_chest",
|
||||
"description" : "",
|
||||
"name" : "Chest Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/keyboardPose", "path": "/user/keyboard/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_keyboard",
|
||||
"description" : "",
|
||||
"name" : "Keyboard Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/leftElbowPose", "path": "/user/elbow/left/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_left_elbow",
|
||||
"description" : "",
|
||||
"name" : "Left Elbow Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/leftFootPose", "path": "/user/foot/left/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_left_foot",
|
||||
"description" : "",
|
||||
"name" : "Left Foot Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/leftKneePose", "path": "/user/knee/left/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_left_knee",
|
||||
"description" : "",
|
||||
"name" : "Left Knee Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/leftShoulderPose", "path": "/user/shoulder/left/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_left_shoulder",
|
||||
"description" : "",
|
||||
"name" : "Left Shoulder Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/rightElbowPose", "path": "/user/elbow/right/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_right_elbow",
|
||||
"description" : "",
|
||||
"name" : "Right Elbow Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/rightFootPose", "path": "/user/foot/right/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_right_foot",
|
||||
"description" : "",
|
||||
"name" : "Right Foot Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/rightKneePose", "path": "/user/knee/right/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_right_knee",
|
||||
"description" : "",
|
||||
"name" : "Right Knee Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/rightShoulderPose", "path": "/user/shoulder/right/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_right_shoulder",
|
||||
"description" : "",
|
||||
"name" : "Right Shoulder Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"action_manifest_version" : 0,
|
||||
"alias_info" : {},
|
||||
"bindings" : {
|
||||
"/actions/lovr" : {
|
||||
"poses" : [
|
||||
{ "output": "/actions/lovr/in/waistPose", "path": "/user/waist/pose/raw" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_tracker_waist",
|
||||
"description" : "",
|
||||
"name" : "Waist Vive Tracker Bindings",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
Loading…
Reference in New Issue