From 7ae2e6756b1e685220556b715f7595e53a5b9444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Rodr=C3=ADguez=20P=C3=A9rez?= Date: Fri, 14 Nov 2025 10:45:41 +0000 Subject: [PATCH] input mouse: Handle B_BAD_DATA status code The intended behaviour for this is when a kerned driver responds with B_BAD_DATA status code is any data comming out should not be taken into account and not trigger a device restart. By providing this, device drivers have a way to communicate to the user space something is not completely right comming out from the hardware such as checksum issues, debounce packets that need to be ignored, palm detention filters, partial processed information requiring extra packets, detected incorrect data, partlially or completelly uninitilised data, etc. A potential workaround for device drivers is the usage of B_TIMED_OUT which currently has part of the same code path but as the intention for the naming it's not the same, there is no warranty that in the near future the code path here will not diverge. This fixes many misbehavious as per description above when drivers only deal with B_OK or B_ERROR return codes. The first telling userspace to process wrong data and the latter by issuing a device restart. Change-Id: Ic57df649ba0972a60004db3d2b3aeebdeb65e133 Reviewed-on: https://review.haiku-os.org/c/haiku/+/9905 Reviewed-by: waddlesplash Tested-by: Commit checker robot Reviewed-by: nephele nephele --- .../input_server/devices/mouse/MouseInputDevice.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp index 41f4dcb098..276a594a8a 100644 --- a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp +++ b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp @@ -439,14 +439,14 @@ MouseDevice::_ControlThread() status_t status = ioctl(fDevice, MS_READ_TOUCHPAD, &read, sizeof(read)); if (status < 0) status = errno; - if (status != B_OK && status != B_INTERRUPTED && status != B_TIMED_OUT) { + if (status == B_TIMED_OUT || status == B_BAD_DATA) { + read.event = MS_READ_TOUCHPAD; + read.u.touchpad = lastTouchpadMovement; + } else if (status != B_OK && status != B_INTERRUPTED) { LOG_ERR("Mouse (touchpad) device exiting, %s\n", strerror(errno)); _ControlThreadCleanup(); // TOAST! return; - } else if (status == B_TIMED_OUT) { - read.event = MS_READ_TOUCHPAD; - read.u.touchpad = lastTouchpadMovement; } if (read.event == MS_READ_TOUCHPAD) {