u/vive: Pass in logging level to parse function

This commit is contained in:
Jakob Bornecrantz 2021-08-20 13:02:49 +01:00
parent 00aca14832
commit a89c8309c7
5 changed files with 19 additions and 17 deletions

View file

@ -208,8 +208,9 @@ vive_init_defaults(struct vive_config *d)
}
bool
vive_config_parse(struct vive_config *d, char *json_string)
vive_config_parse(struct vive_config *d, char *json_string, enum u_logging_level ll)
{
d->ll = ll;
vive_init_defaults(d);
VIVE_DEBUG(d, "JSON config:\n%s", json_string);
@ -355,8 +356,9 @@ vive_config_teardown(struct vive_config *config)
}
bool
vive_config_parse_controller(struct vive_controller_config *d, char *json_string)
vive_config_parse_controller(struct vive_controller_config *d, char *json_string, enum u_logging_level ll)
{
d->ll = ll;
VIVE_DEBUG(d, "JSON config:\n%s", json_string);
cJSON *json = cJSON_Parse(json_string);

View file

@ -149,7 +149,7 @@ struct vive_controller_config
};
bool
vive_config_parse(struct vive_config *d, char *json_string);
vive_config_parse(struct vive_config *d, char *json_string, enum u_logging_level ll);
/*!
* Free any allocated resources on this config.
@ -160,4 +160,4 @@ vive_config_teardown(struct vive_config *d);
struct vive_controller_device;
bool
vive_config_parse_controller(struct vive_controller_config *d, char *json_string);
vive_config_parse_controller(struct vive_controller_config *d, char *json_string, enum u_logging_level ll);

View file

@ -796,14 +796,20 @@ compute_distortion(struct xrt_device *xdev, int view, float u, float v, struct x
}
static bool
_create_hmd_device(struct survive_system *sys, const struct SurviveSimpleObject *sso, struct vive_config *config)
_create_hmd_device(struct survive_system *sys, const struct SurviveSimpleObject *sso, char *conf_str)
{
enum u_device_alloc_flags flags = (enum u_device_alloc_flags)U_DEVICE_ALLOC_HMD;
int inputs = 1;
int outputs = 0;
struct survive_device *survive = U_DEVICE_ALLOCATE(struct survive_device, flags, inputs, outputs);
if (!vive_config_parse(&survive->hmd.config, conf_str, sys->ll)) {
free(survive);
return false;
}
sys->hmd = survive;
survive->sys = sys;
survive->survive_obj = sso;
@ -822,8 +828,6 @@ _create_hmd_device(struct survive_system *sys, const struct SurviveSimpleObject
survive->base.hmd->blend_modes[idx++] = XRT_BLEND_MODE_OPAQUE;
survive->base.hmd->num_blend_modes = idx;
survive->hmd.config = *config;
switch (survive->hmd.config.variant) {
case VIVE_VARIANT_VIVE: snprintf(survive->base.str, XRT_DEVICE_NAME_LEN, "HTC Vive (libsurvive)"); break;
case VIVE_VARIANT_PRO: snprintf(survive->base.str, XRT_DEVICE_NAME_LEN, "HTC Vive Pro (libsurvive)"); break;
@ -1150,13 +1154,11 @@ add_device(struct survive_system *ss, const struct SurviveSimpleConfigEvent *e)
if (type == SurviveSimpleObject_HMD) {
struct vive_config config = {.ll = ss->ll};
vive_config_parse(&config, conf_str);
_create_hmd_device(ss, sso, &config);
_create_hmd_device(ss, sso, conf_str);
} else if (type == SurviveSimpleObject_OBJECT) {
struct vive_controller_config config = {.ll = ss->ll};
vive_config_parse_controller(&config, conf_str);
struct vive_controller_config config = {0};
vive_config_parse_controller(&config, conf_str, ss->ll);
switch (config.variant) {
case CONTROLLER_VIVE_WAND:

View file

@ -1,5 +1,5 @@
// Copyright 2020, Collabora, Ltd.
// Copyright 2016 Philipp Zabel
// Copyright 2020-2021, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
@ -1086,10 +1086,8 @@ vive_controller_create(struct os_hid_device *controller_hid, enum watchman_gen w
// successful config parsing determines d->config.variant
char *config = vive_read_config(d->controller_hid);
d->config.ll = d->ll;
if (config != NULL) {
vive_config_parse_controller(&d->config, config);
vive_config_parse_controller(&d->config, config, d->ll);
free(config);
} else {
VIVE_ERROR(d, "Could not get Vive controller config\n");

View file

@ -777,7 +777,7 @@ vive_device_create(struct os_hid_device *mainboard_dev,
d->config.ll = d->ll;
// usb connected HMD variant is known because of USB id, config parsing relies on it.
if (config != NULL) {
vive_config_parse(&d->config, config);
vive_config_parse(&d->config, config, d->ll);
free(config);
}