mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
xrt: Add enum xrt_device_name so that state trackers can reason about device
This commit is contained in:
parent
a0f2793457
commit
29b1713be9
|
@ -272,10 +272,13 @@ hdk_device_create(struct os_hid_device *dev,
|
|||
hd->base.get_view_pose = hdk_device_get_view_pose;
|
||||
hd->base.destroy = hdk_device_destroy;
|
||||
hd->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_RELATION;
|
||||
hd->base.name = XRT_DEVICE_GENERIC_HMD;
|
||||
hd->dev = dev;
|
||||
hd->print_spew = print_spew;
|
||||
hd->print_debug = print_debug;
|
||||
|
||||
snprintf(hd->base.str, XRT_DEVICE_NAME_LEN, "OSVR HDK-family Device");
|
||||
|
||||
if (variant == HDK_UNKNOWN) {
|
||||
HDK_ERROR(hd, "Don't know which HDK variant this is.");
|
||||
hdk_device_destroy(&hd->base);
|
||||
|
@ -442,8 +445,7 @@ hdk_device_create(struct os_hid_device *dev,
|
|||
|
||||
|
||||
if (hd->print_debug) {
|
||||
u_device_dump_config(&hd->base, __func__,
|
||||
"OSVR HDK-family Device");
|
||||
u_device_dump_config(&hd->base, __func__, hd->base.str);
|
||||
}
|
||||
|
||||
return hd;
|
||||
|
|
|
@ -685,7 +685,8 @@ hydra_found(struct xrt_prober *xp,
|
|||
hd->base.update_inputs = hydra_device_update_inputs;
|
||||
hd->base.get_tracked_pose = hydra_device_get_tracked_pose;
|
||||
// hs->base.set_output = hydra_device_set_output;
|
||||
snprintf(hd->base.name, XRT_DEVICE_NAME_LEN, "%s %i",
|
||||
hd->base.name = XRT_DEVICE_HYDRA;
|
||||
snprintf(hd->base.str, XRT_DEVICE_NAME_LEN, "%s %i",
|
||||
"Razer Hydra Controller", (int)(i + 1));
|
||||
SET_INPUT(1_CLICK);
|
||||
SET_INPUT(2_CLICK);
|
||||
|
|
|
@ -353,13 +353,14 @@ oh_device_create(ohmd_context *ctx,
|
|||
ohd->base.get_view_pose = oh_device_get_view_pose;
|
||||
ohd->base.destroy = oh_device_destroy;
|
||||
ohd->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_RELATION;
|
||||
ohd->base.name = XRT_DEVICE_GENERIC_HMD;
|
||||
ohd->ctx = ctx;
|
||||
ohd->dev = dev;
|
||||
ohd->print_spew = print_spew;
|
||||
ohd->print_debug = print_debug;
|
||||
ohd->enable_finite_difference = debug_get_bool_option_oh_finite_diff();
|
||||
|
||||
snprintf(ohd->base.name, XRT_DEVICE_NAME_LEN, "%s", prod);
|
||||
snprintf(ohd->base.str, XRT_DEVICE_NAME_LEN, "%s", prod);
|
||||
|
||||
const struct device_info info = get_info(ohd, prod);
|
||||
|
||||
|
|
|
@ -477,7 +477,8 @@ psmv_found(struct xrt_prober *xp,
|
|||
psmv->base.update_inputs = psmv_device_update_inputs;
|
||||
psmv->base.get_tracked_pose = psmv_device_get_tracked_pose;
|
||||
psmv->base.set_output = psmv_device_set_output;
|
||||
snprintf(psmv->base.name, XRT_DEVICE_NAME_LEN, "%s",
|
||||
psmv->base.name = XRT_DEVICE_PSMV;
|
||||
snprintf(psmv->base.str, XRT_DEVICE_NAME_LEN, "%s",
|
||||
"PS Move Controller");
|
||||
psmv->hid = hid;
|
||||
SET_INPUT(PS_CLICK);
|
||||
|
|
|
@ -686,8 +686,9 @@ psvr_device_create(struct hid_device_info *hmd_handle_info,
|
|||
psvr->base.get_view_pose = psvr_device_get_view_pose;
|
||||
psvr->base.destroy = psvr_device_destroy;
|
||||
psvr->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_RELATION;
|
||||
psvr->base.name = XRT_DEVICE_GENERIC_HMD;
|
||||
|
||||
snprintf(psvr->base.name, XRT_DEVICE_NAME_LEN, "PS VR Headset");
|
||||
snprintf(psvr->base.str, XRT_DEVICE_NAME_LEN, "PS VR Headset");
|
||||
|
||||
ret = open_hid(psvr, hmd_handle_info, &psvr->hmd_handle);
|
||||
if (ret != 0) {
|
||||
|
|
|
@ -302,6 +302,18 @@ struct xrt_space_relation
|
|||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
* A enum that is used to name devices so that the
|
||||
* state trackers can reason about the devices easier.
|
||||
*/
|
||||
enum xrt_device_name
|
||||
{
|
||||
XRT_DEVICE_GENERIC_HMD = 1,
|
||||
|
||||
XRT_DEVICE_PSMV = 2,
|
||||
XRT_DEVICE_HYDRA = 3,
|
||||
};
|
||||
|
||||
/*!
|
||||
* Base type of this inputs.
|
||||
*
|
||||
|
|
|
@ -179,10 +179,11 @@ struct xrt_output
|
|||
*/
|
||||
struct xrt_device
|
||||
{
|
||||
/*!
|
||||
* A string describing the device.
|
||||
*/
|
||||
char name[XRT_DEVICE_NAME_LEN];
|
||||
//! Enum identifier of the device.
|
||||
enum xrt_device_name name;
|
||||
|
||||
//! A string describing the device.
|
||||
char str[XRT_DEVICE_NAME_LEN];
|
||||
|
||||
//! Null if this device does not interface with the users head.
|
||||
struct xrt_hmd_parts *hmd;
|
||||
|
|
|
@ -180,7 +180,7 @@ oxr_system_get_properties(struct oxr_logger *log,
|
|||
properties->systemId = sys->systemId;
|
||||
|
||||
// Needed to silence the warnings.
|
||||
const char *name = sys->head->name;
|
||||
const char *name = sys->head->str;
|
||||
|
||||
snprintf(properties->systemName, XR_MAX_SYSTEM_NAME_SIZE, "Monado: %s",
|
||||
name);
|
||||
|
|
|
@ -414,7 +414,7 @@ handle_found_device(struct prober* p,
|
|||
size_t num_xdevs,
|
||||
struct xrt_device* xdev)
|
||||
{
|
||||
P_DEBUG(p, "Found '%s' %p", xdev->name, (void*)xdev);
|
||||
P_DEBUG(p, "Found '%s' %p", xdev->str, (void*)xdev);
|
||||
|
||||
// For controllers we put them after the first found HMD.
|
||||
if (xdev->hmd == NULL) {
|
||||
|
@ -426,7 +426,7 @@ handle_found_device(struct prober* p,
|
|||
}
|
||||
|
||||
P_ERROR(p, "Too many controller devices closing '%s'",
|
||||
xdev->name);
|
||||
xdev->str);
|
||||
xdev->destroy(xdev);
|
||||
return;
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ handle_found_device(struct prober* p,
|
|||
return;
|
||||
}
|
||||
|
||||
P_ERROR(p, "Found more then one, HMD closing '%s'", xdev->name);
|
||||
P_ERROR(p, "Found more then one, HMD closing '%s'", xdev->str);
|
||||
xdev->destroy(xdev);
|
||||
}
|
||||
|
||||
|
@ -507,7 +507,7 @@ select_device(struct xrt_prober* xp,
|
|||
|
||||
|
||||
if (xdevs[0] != NULL) {
|
||||
P_DEBUG(p, "Found HMD! '%s'", xdevs[0]->name);
|
||||
P_DEBUG(p, "Found HMD! '%s'", xdevs[0]->str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -519,7 +519,7 @@ select_device(struct xrt_prober* xp,
|
|||
continue;
|
||||
}
|
||||
|
||||
P_DEBUG(p, "Destroying '%s'", xdevs[i]->name);
|
||||
P_DEBUG(p, "Destroying '%s'", xdevs[i]->str);
|
||||
xdevs[i]->destroy(xdevs[i]);
|
||||
xdevs[i] = NULL;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ cli_cmd_test(int argc, const char **argv)
|
|||
continue;
|
||||
}
|
||||
|
||||
printf("\tFound '%s'\n", xdevs[i]->name);
|
||||
printf("\tFound '%s'\n", xdevs[i]->str);
|
||||
}
|
||||
|
||||
// End of program
|
||||
|
@ -84,7 +84,7 @@ cli_cmd_test(int argc, const char **argv)
|
|||
continue;
|
||||
}
|
||||
|
||||
printf("\tDestroying '%s'\n", xdevs[i]->name);
|
||||
printf("\tDestroying '%s'\n", xdevs[i]->str);
|
||||
|
||||
xdevs[i]->destroy(xdevs[i]);
|
||||
xdevs[i] = NULL;
|
||||
|
|
Loading…
Reference in a new issue