mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
d/wmr: WMR Controller (BT): Don't waste CPU cycles when reading
This commit is contained in:
parent
2d48a9bca2
commit
b3e0f5bc6a
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue