From b3e84f90419591a272100136010b5dcfabbfe605 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 23 Jan 2020 15:51:30 +0000 Subject: [PATCH] xrt: Make sure that auto probers can add non-HMD devices after a HMD has been found --- src/xrt/drivers/ohmd/oh_prober.c | 9 ++++++++- src/xrt/drivers/psvr/psvr_prober.c | 9 ++++++++- src/xrt/include/xrt/xrt_prober.h | 1 + src/xrt/state_trackers/prober/p_prober.c | 11 +++++------ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/xrt/drivers/ohmd/oh_prober.c b/src/xrt/drivers/ohmd/oh_prober.c index c0cdc5073..ba3a56c0b 100644 --- a/src/xrt/drivers/ohmd/oh_prober.c +++ b/src/xrt/drivers/ohmd/oh_prober.c @@ -51,10 +51,17 @@ oh_prober_destroy(struct xrt_auto_prober *p) } 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); + // Do not use OpenHMD if we are not looking for HMDs. + if (no_hmds) { + return NULL; + } + int device_idx = -1; /* Probe for devices */ diff --git a/src/xrt/drivers/psvr/psvr_prober.c b/src/xrt/drivers/psvr/psvr_prober.c index 65e4f0766..06078016b 100644 --- a/src/xrt/drivers/psvr/psvr_prober.c +++ b/src/xrt/drivers/psvr/psvr_prober.c @@ -69,7 +69,9 @@ psvr_prober_destroy(struct xrt_auto_prober *p) } 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 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 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); cur_dev = devs; diff --git a/src/xrt/include/xrt/xrt_prober.h b/src/xrt/include/xrt/xrt_prober.h index 1eec73942..20fa3bc71 100644 --- a/src/xrt/include/xrt/xrt_prober.h +++ b/src/xrt/include/xrt/xrt_prober.h @@ -333,6 +333,7 @@ xrt_prober_match_string(struct xrt_prober *xp, struct xrt_auto_prober { struct xrt_device *(*lelo_dallas_autoprobe)(struct xrt_auto_prober *xap, + bool no_hmds, struct xrt_prober *xp); void (*destroy)(struct xrt_auto_prober *xdev); }; diff --git a/src/xrt/state_trackers/prober/p_prober.c b/src/xrt/state_trackers/prober/p_prober.c index ed3087c5c..34200b5a2 100644 --- a/src/xrt/state_trackers/prober/p_prober.c +++ b/src/xrt/state_trackers/prober/p_prober.c @@ -592,16 +592,15 @@ select_device(struct xrt_prober *xp, 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 - * is mostly to stop OpenHMD and Monado fighting over devices. + * If we have found a HMD, tell the auto probers not to open + * any more HMDs. This is mostly to stop OpenHMD and Monado + * fighting over devices. */ - if (xdevs[0] != NULL) { - break; - } + bool no_hmds = xdevs[0] != NULL; struct xrt_device *xdev = p->auto_probers[i]->lelo_dallas_autoprobe( - p->auto_probers[i], xp); + p->auto_probers[i], no_hmds, xp); if (xdev == NULL) { continue; }