[Bug 274620] USB HID mouse not working

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 21 Oct 2023 06:07:32 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274620

            Bug ID: 274620
           Summary: USB HID mouse not working
           Product: Base System
           Version: 14.0-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: usb
          Assignee: usb@FreeBSD.org
          Reporter: tamaru@psc.t.u-tokyo.ac.jp

I have ATEN IP-KVM products, and FreeBSD console K/B and mouse are provided as
(emulated) USB devices by KVM modules such as KA7188.

The keyboard part is detected as ukbd0 and is functional both on console and X.
However, uhid0 attaches to the mouse part and does not work on console nor X.

This is on FreeBSD 14.0-RC1 amd64.

From boot message:
ugen0.2: <Manufacturer KVM Adapter> at usbus0
ukbd0 on uhub0
ukbd0: <Manufacturer KVM Adapter, class 0/0, rev 1.10/1.00, addr 1> on usbus0
kbd2 at ukbd0
 :
uhid0 on uhub0
uhid0: <Manufacturer KVM Adapter, class 0/0, rev 1.10/1.00, addr 1> on usbus0

# usbconfig -d 0.2 show_ifdrv
ugen0.2: <Manufacturer KVM Adapter> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps)
pwr=ON (100mA)
ugen0.2.0: ukbd0: <Manufacturer KVM Adapter, class 0/0, rev 1.10/1.00, addr 1>
ugen0.2.1: uhid0: <Manufacturer KVM Adapter, class 0/0, rev 1.10/1.00, addr 1>

I have ums.ko and hms.ko loaded.
from kldstat:
Id Refs Address                Size Name
 3    1 0xffffffff81f3d000     7ec8 ums.ko
 5    1 0xffffffff8251c000     3c78 hms.ko
 6    2 0xffffffff82520000     4e80 hidmap.ko
 7    4 0xffffffff82525000     77c0 hidbus.ko
13    1 0xffffffff8308a000     3360 uhid.ko
14    1 0xffffffff8308e000     33c0 usbhid.ko
15    1 0xffffffff83092000     3360 wmt.ko

Just to be sure, I ran:
# hd < /dev/sysmouse
and moved my mouse around, but with no output.




Then, I tried uhidd from sysutils/uhidd
# uhidd -dmu /dev/ugen0.2
ugen0.2[1]-> Kernel driver is active
ugen0.2[1]-> kernel driver detached!

and ran hd and moved my mouse again:
# hd < /dev/sysmouse
00000000  87 7f 80 80 81 87 7f 80  80 81 87 7f 80 80 81 87  |................|
00000010  7f 80 80 81 87 7f 80 80  81 87 7f 80 80 81 87 7f  |................|
00000020  80 80 81 87 7f 80 80 81  87 7f 80 80 81 87 7f 80  |................|
00000030  80 81 87 7f 80 80 81 87  7f 80 80 81 87 7f 80 80  |................|
00000040  81 87 7f 80 80 81 87 7f  80 80 81 87 7f 80 80 81  |................|
00000050  87 7f 80 80 81 87 7f 80  80 81 87 7f 80 80 81 87  |................|
00000060  7f 80 80 81 87 7f 80 80  81 87 7f 80 80 81 87 7f  |................|
00000070  80 80 81 87 7f 80 80 81  87 7f 80 80 81 87 7f 80  |................|
^C

My mouse motion seemed to be recognized by uhidd,
but there is no mouse activity on the actual console,
with or without hd running.
I have enabled console mouse (I'm on ttyv0) by
# vidcontrol -m on < /dev/ttyv0
and the mouse pointer shows up, but no motion, and dissappears in a while (due
to lack of recognized mouse activity).

With uhidd enabled, I then enabled /dev/sysmouse to evdev.

# sysctl kern.evdev
kern.evdev.input.5.uniq:
kern.evdev.input.5.phys: ukbd0
kern.evdev.input.5.id: { bustype = 0x0003, vendor = 0x0557, product = 0x2310,
version = 0x0000 }
kern.evdev.input.5.name: Manufacturer KVM Adapter, class 0/0, rev 1.10/1.00,
addr 1
kern.evdev.input.4.uniq:
kern.evdev.input.4.phys: atkbd0
kern.evdev.input.4.id: { bustype = 0x0011, vendor = 0x0001, product = 0x0001,
version = 0x0000 }
kern.evdev.input.4.name: AT keyboard
kern.evdev.input.3.uniq:
kern.evdev.input.3.phys: acpi_button1
kern.evdev.input.3.id: { bustype = 0x0019, vendor = 0x0000, product = 0x0000,
version = 0x0001 }
kern.evdev.input.3.name: Power Button
kern.evdev.input.2.uniq:
kern.evdev.input.2.phys: acpi_button0
kern.evdev.input.2.id: { bustype = 0x0019, vendor = 0x0000, product = 0x0000,
version = 0x0001 }
kern.evdev.input.2.name: Sleep Button
kern.evdev.input.1.uniq:
kern.evdev.input.1.phys: sysmouse
kern.evdev.input.1.id: { bustype = 0x0006, vendor = 0x0000, product = 0x0000,
version = 0x0000 }
kern.evdev.input.1.name: System mouse
kern.evdev.input.0.uniq:
kern.evdev.input.0.phys: kbdmux0
kern.evdev.input.0.id: { bustype = 0x0006, vendor = 0x0000, product = 0x0000,
version = 0x0000 }
kern.evdev.input.0.name: System keyboard multiplexer
kern.evdev.sysmouse_t_axis: 0
kern.evdev.rcpt_mask: 12

# hd < /dev/input/event1
(no output despite mouse motion, as expected)
^C

# grep EVDEV_RCPT /sys/dev/evdev/evdev.h
#define EVDEV_RCPT_SYSMOUSE     (1<<0)
#define EVDEV_RCPT_KBDMUX       (1<<1)
#define EVDEV_RCPT_HW_MOUSE     (1<<2)
#define EVDEV_RCPT_HW_KBD       (1<<3)

# sysctl kern.evdev.rcpt_mask=9
kern.evdev.rcpt_mask: 12 -> 9

# hd < /dev/input/event1
00000000  27 db 32 65 00 00 00 00  5f b9 05 00 00 00 00 00  |'.2e...._.......|
00000010  02 00 00 00 df 07 00 00  27 db 32 65 00 00 00 00  |........'.2e....|
00000020  5f b9 05 00 00 00 00 00  02 00 01 00 b7 05 00 00  |_...............|
00000030  27 db 32 65 00 00 00 00  5f b9 05 00 00 00 00 00  |'.2e...._.......|
00000040  00 00 00 00 01 00 00 00  27 db 32 65 00 00 00 00  |........'.2e....|
00000050  61 07 06 00 00 00 00 00  02 00 00 00 af 07 00 00  |a...............|
00000060  27 db 32 65 00 00 00 00  61 07 06 00 00 00 00 00  |'.2e....a.......|
00000070  02 00 01 00 b7 05 00 00  27 db 32 65 00 00 00 00  |........'.2e....|
^C

and started X.
Now the mouse motion is recognized, but as soon as
I touched my mouse, the mouse cursor flew to right bottom corner
of the screen and got stuck there.

It seems as if the protocol format sending events to sysmouse
by uhidd mismatches with what is expected, both for console and X.




After a fresh reboot (to eliminate the effects by uhidd), I tried
# usbhidctl -f /dev/uhid0 -al
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_1=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_2=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_3=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_3.Generic_Desktop:Wheel=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Generic_Desktop:X=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Generic_Desktop:Y=0

Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_1=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_2=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_3=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_3.Generic_Desktop:Wheel=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Generic_Desktop:X=2048
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Generic_Desktop:Y=1055

Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_1=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_2=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_3=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Button:Button_3.Generic_Desktop:Wheel=0
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Generic_Desktop:X=2035
Generic_Desktop:Mouse.Generic_Desktop:Pointer.Generic_Desktop:Y=1055
^C

so uhid0 itself seemed to be working well.

After surfing the net for a very good while, I found,
https://github.com/jiixyj/evdevfbsd
https://lists.freebsd.org/pipermail/freebsd-x11/2017-March/018978.html
and gave it a try.

# kldload cuse
# ./evdevfbsd -c /dev/uhid0
input/event6: inp mou
input/event6

The console mouse still does not work
(but since the pointer does not disappear in a while and stays at the screen
center, I guess SOMETHING different from uhidd is passed to the console),
but X started to recognize this mouse correctly!
Many htanks to Jan Kokemueller!



So this is where I am.

The hardware is functional,
uhid can decode them correctly, and
evdevfbsd seems to recognize its protocols (at least for X),
but ums, hms (and uhidd) are not handling them correctly.

I assume it is best to have ums recognize this device correctly in the first
place. so this is a bug report for the system part of the FreeBSD, to ask for
an
update of the ums module.

And surely, if evdevfbsd can be made into a port and pkg,
it would help a lot to workaround the issue in the mean time.

Thank you.

-- 
You are receiving this mail because:
You are the assignee for the bug.