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(-)
@@ -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();
return;
} else if (status == B_TIMED_OUT) {
read.event = MS_READ_TOUCHPAD;
read.u.touchpad = lastTouchpadMovement;
}
if (read.event == MS_READ_TOUCHPAD) {