xrt: Make sure that auto probers can add non-HMD devices after a HMD has been found

This commit is contained in:
Jakob Bornecrantz 2020-01-23 15:51:30 +00:00
parent c2560ae6d2
commit b3e84f9041
4 changed files with 22 additions and 8 deletions

View file

@ -51,10 +51,17 @@ oh_prober_destroy(struct xrt_auto_prober *p)
} }
static struct xrt_device * static struct xrt_device *
oh_prober_autoprobe(struct xrt_auto_prober *xap, struct xrt_prober *xp) oh_prober_autoprobe(struct xrt_auto_prober *xap,
bool no_hmds,
struct xrt_prober *xp)
{ {
struct oh_prober *ohp = oh_prober(xap); struct oh_prober *ohp = oh_prober(xap);
// Do not use OpenHMD if we are not looking for HMDs.
if (no_hmds) {
return NULL;
}
int device_idx = -1; int device_idx = -1;
/* Probe for devices */ /* Probe for devices */

View file

@ -69,7 +69,9 @@ psvr_prober_destroy(struct xrt_auto_prober *p)
} }
static struct xrt_device * static struct xrt_device *
psvr_prober_autoprobe(struct xrt_auto_prober *xap, struct xrt_prober *xp) psvr_prober_autoprobe(struct xrt_auto_prober *xap,
bool no_hmds,
struct xrt_prober *xp)
{ {
struct psvr_prober *ppsvr = psvr_prober(xap); struct psvr_prober *ppsvr = psvr_prober(xap);
struct hid_device_info *info_control = NULL; struct hid_device_info *info_control = NULL;
@ -78,6 +80,11 @@ psvr_prober_autoprobe(struct xrt_auto_prober *xap, struct xrt_prober *xp)
struct hid_device_info *devs = NULL; struct hid_device_info *devs = NULL;
struct xrt_device *dev = NULL; struct xrt_device *dev = NULL;
// Do not look for the PSVR if we are not looking for HMDs.
if (no_hmds) {
return NULL;
}
devs = hid_enumerate(PSVR_VID, PSVR_PID); devs = hid_enumerate(PSVR_VID, PSVR_PID);
cur_dev = devs; cur_dev = devs;

View file

@ -333,6 +333,7 @@ xrt_prober_match_string(struct xrt_prober *xp,
struct xrt_auto_prober struct xrt_auto_prober
{ {
struct xrt_device *(*lelo_dallas_autoprobe)(struct xrt_auto_prober *xap, struct xrt_device *(*lelo_dallas_autoprobe)(struct xrt_auto_prober *xap,
bool no_hmds,
struct xrt_prober *xp); struct xrt_prober *xp);
void (*destroy)(struct xrt_auto_prober *xdev); void (*destroy)(struct xrt_auto_prober *xdev);
}; };

View file

@ -592,16 +592,15 @@ select_device(struct xrt_prober *xp,
for (int i = 0; i < MAX_AUTO_PROBERS && p->auto_probers[i]; i++) { for (int i = 0; i < MAX_AUTO_PROBERS && p->auto_probers[i]; i++) {
/* /*
* If we have found a HMD stop checking the auto probers. This * If we have found a HMD, tell the auto probers not to open
* is mostly to stop OpenHMD and Monado fighting over devices. * any more HMDs. This is mostly to stop OpenHMD and Monado
* fighting over devices.
*/ */
if (xdevs[0] != NULL) { bool no_hmds = xdevs[0] != NULL;
break;
}
struct xrt_device *xdev = struct xrt_device *xdev =
p->auto_probers[i]->lelo_dallas_autoprobe( p->auto_probers[i]->lelo_dallas_autoprobe(
p->auto_probers[i], xp); p->auto_probers[i], no_hmds, xp);
if (xdev == NULL) { if (xdev == NULL) {
continue; continue;
} }