⛏️ index : haiku.git

author Samuel Rodríguez Pérez <samuelgaliza@gmail.com> 2025-11-14 10:45:41.0 +00:00:00
committer waddlesplash <waddlesplash@gmail.com> 2025-11-24 18:21:26.0 +00:00:00
commit
7ae2e6756b1e685220556b715f7595e53a5b9444 [patch]
tree
560233ac770611d979aa8d2c67efae3e62ec5308
parent
9c5da6de539a9ee8489b7cda5f52d1d85080b6f0
download
7ae2e6756b1e685220556b715f7595e53a5b9444.tar.gz

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 <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: nephele nephele <nep-git@packageloss.eu>

Diff

 src/add-ons/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 41f4dcb..276a594 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 @@
			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) {