From b3e0f5bc6aa36683b3cca6e7e3a6b883c98ecb2e Mon Sep 17 00:00:00 2001 From: Nima01 Date: Sun, 12 Dec 2021 21:37:50 +0100 Subject: [PATCH] d/wmr: WMR Controller (BT): Don't waste CPU cycles when reading --- src/xrt/drivers/wmr/wmr_bt_controller.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xrt/drivers/wmr/wmr_bt_controller.c b/src/xrt/drivers/wmr/wmr_bt_controller.c index 5f5d05e1b..ae066c1a4 100644 --- a/src/xrt/drivers/wmr/wmr_bt_controller.c +++ b/src/xrt/drivers/wmr/wmr_bt_controller.c @@ -53,11 +53,11 @@ read_packets(struct wmr_bt_controller *d) { unsigned char buffer[WMR_MOTION_CONTROLLER_MSG_BUFFER_SIZE]; - // Get the timing as close to packet reception as possible. - uint64_t now_ns = os_monotonic_get_ns(); + // Better cpu efficiency with blocking reads instead of multiple reads. + int size = os_hid_read(d->controller_hid, buffer, sizeof(buffer), 500); - // Read must be non-blocking for reliable timing. - int size = os_hid_read(d->controller_hid, buffer, sizeof(buffer), 0); + // Get the timing as close to reading packet as possible. + uint64_t now_ns = os_monotonic_get_ns(); if (size < 0) { WMR_ERROR(d, "WMR Controller (Bluetooth): Error reading from device");