d/vive/controller: Add Vive tracker gen 2 support.

This commit is contained in:
Lubosz Sarnecki 2020-07-02 18:18:41 +02:00
parent 6662e0caef
commit d047ce8af4
4 changed files with 14 additions and 2 deletions

View file

@ -365,7 +365,10 @@ vive_config_parse_controller(struct vive_controller_device *d,
} else if (strcmp(d->firmware.model_number, "Vive Tracker PVT") == 0) {
d->variant = CONTROLLER_TRACKER_GEN1;
VIVE_CONTROLLER_DEBUG(d, "Found Gen 1 tracker.");
} else if (strcmp(d->firmware.model_number, "VIVE Tracker Pro MV") ==
0) {
d->variant = CONTROLLER_TRACKER_GEN2;
VIVE_CONTROLLER_DEBUG(d, "Found Gen 2 tracker.");
} else {
VIVE_CONTROLLER_ERROR(d, "Failed to parse controller variant");
}
@ -381,13 +384,17 @@ vive_config_parse_controller(struct vive_controller_device *d,
d->firmware.mb_serial_number);
} break;
case CONTROLLER_INDEX_LEFT:
case CONTROLLER_INDEX_RIGHT: {
case CONTROLLER_INDEX_RIGHT:
case CONTROLLER_TRACKER_GEN2: {
const cJSON *imu = u_json_get(json, "imu");
_get_pose_from_pos_x_z(imu, &d->imu.trackref);
JSON_VEC3(imu, "acc_bias", &d->imu.acc_bias);
JSON_VEC3(imu, "acc_scale", &d->imu.acc_scale);
JSON_VEC3(imu, "gyro_bias", &d->imu.gyro_bias);
if (d->variant == CONTROLLER_TRACKER_GEN2)
JSON_VEC3(imu, "gyro_scale", &d->imu.gyro_scale);
} break;
default:
VIVE_CONTROLLER_ERROR(d, "Unknown Vive watchman variant.\n");

View file

@ -1145,6 +1145,9 @@ vive_controller_create(struct os_hid_device *controller_hid,
} else if (d->variant == CONTROLLER_TRACKER_GEN1) {
d->base.name = XRT_DEVICE_VIVE_TRACKER_GEN1;
d->base.update_inputs = _update_tracker_inputs;
} else if (d->variant == CONTROLLER_TRACKER_GEN2) {
d->base.name = XRT_DEVICE_VIVE_TRACKER_GEN2;
d->base.update_inputs = _update_tracker_inputs;
} else {
d->base.name = XRT_DEVICE_GENERIC_HMD;
VIVE_CONTROLLER_ERROR(d,

View file

@ -39,6 +39,7 @@ enum controller_variant
CONTROLLER_INDEX_LEFT,
CONTROLLER_INDEX_RIGHT,
CONTROLLER_TRACKER_GEN1,
CONTROLLER_TRACKER_GEN2,
CONTROLLER_UNKNOWN
};

View file

@ -387,6 +387,7 @@ enum xrt_device_name
XRT_DEVICE_INDEX_CONTROLLER = 5,
XRT_DEVICE_VIVE_WAND = 6,
XRT_DEVICE_VIVE_TRACKER_GEN1 = 7,
XRT_DEVICE_VIVE_TRACKER_GEN2 = 8,
};
/*!