git: b21881d8c421 - stable/14 - ums(4): fix incorrect mouse button reporting via evdev

From: Vladimir Kondratyev <wulf_at_FreeBSD.org>
Date: Thu, 19 Sep 2024 21:43:29 UTC
The branch stable/14 has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=b21881d8c42132fca37f361c0baa2fd08b51f9e2

commit b21881d8c42132fca37f361c0baa2fd08b51f9e2
Author:     Niko Sonack <nsonack@outlook.com>
AuthorDate: 2024-07-02 19:27:25 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2024-09-19 21:41:43 +0000

    ums(4): fix incorrect mouse button reporting via evdev
    
    when ums driver receives non-mouse HID report. This results in
    unexpected button release event. Reuse existing sysmouse logic to
    keep button pressed.
    
    Reviewed by:    imp, wulf
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D45838
    
    (cherry picked from commit d6888e211b07be79dd8de3145ac41b365f482ae8)
---
 sys/dev/usb/input/ums.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c
index 8416be656f81..067feed13e92 100644
--- a/sys/dev/usb/input/ums.c
+++ b/sys/dev/usb/input/ums.c
@@ -320,11 +320,12 @@ ums_intr_callback(struct usb_xfer *xfer, usb_error_t error)
 		if (++info != &sc->sc_info[UMS_INFO_MAX])
 			goto repeat;
 
+		/* keep old button value(s) for non-detected buttons */
+		buttons |= sc->sc_status.button & ~buttons_found;
+
 #ifdef EVDEV_SUPPORT
 		buttons_reported = buttons;
 #endif
-		/* keep old button value(s) for non-detected buttons */
-		buttons |= sc->sc_status.button & ~buttons_found;
 
 		if (dx || dy || dz || dt || dw ||
 		    (buttons != sc->sc_status.button)) {