# Can the xf86-input-usbtablet driver be ported to FreeBSD?



## Amooti (Jun 1, 2022)

After moving over from Ubuntu to FreeBSD around the beginning of this year, one of my few disappointments has been that my HUION Inspiroy H950P was not supported and FreeBSD support seemed to indicate that only Wacom tablets were supported.  Yet, as a teacher, the use of the tablet has been so helpful whether teaching "face-to-face" or online.

More recently, I embarked on trying to revitalize an old laptop (Dell Latitude D620).  After deciding that Ubuntu was a bit sluggish and finding that wifi was problematic on both MX linux and FreeBSD, today I installed OpenBSD 7.1.  Much to my surprise, when I connected the tablet and restarted OpenBSD, the tablet worked.  I did not do much, but the fact that it was detected by xournal and I could draw was great!

The OpenBSD man page for the driver can be found here

With a little searching, I found this driver for NetBSD on Github that had been imported from OpenBSD Xenocara which is also on Github.  My hope is that, since this driver is apparently working on two other BSDs, it may be possible for it be adapted for FreeBSD.  I don't believe I have the necessary knowledge or skills to do it myself, however!


----------



## Phishfry (Jun 1, 2022)

Have you tried it with xf86-input-evdev? I really don't think you are going to need a special driver.
Does the device show up in dmesg as wmt0?
Show us how it shows up on bootup or hotplug..
Libinput handles everything and you might need some custom entries into an xorg.conf for events.


----------



## sidetone (Jun 1, 2022)

hmt(4) is the newer FreeBSD driver that replaces wmt(4). Newer replacement drivers come with the base system of FreeBSD 13.1, but some or some features only work with the desktop. The newer mouse and keyboard drivers work on the console too. The xf86 drivers in the links you showed come with Xorg. Freshports shows a few ports of drivers prefixed with xf86-input in the x11-drivers directory: Fresh ports: x11-drivers/xf86-input-. While some of those drivers are or were described as obsolete to the drivers in FreeBSD's base system, the hmt's and wmt's man pages say they work with x11-drivers/xf86-input-evdev.

I don't know if those will work. The only way to know is if someone tests them or similar ones, then taking a risk and trying them yourself.

FreeBSD 13.1 has the newer usbhid(3) interface that hmt works on top of, as well as the older driver interface. I believe that the newer one is the same driver interface from NetBSD. However, the XF86 driver itself seems to be a different one. The one from NetBSD and OpenBSD were xf86-input-usbtablet.

Thread howto-enabling-multimedia-keys-for-desktop-usbhid.84464 is a how-to thread I started on enabling multimedia keys, and also on enabling using newer device drivers, including hmt. With the old driver, not everyone's keyboard would work with the multimedia key feature. The newer usbhid driver is expected to work with more other types of hardware.


----------



## Amooti (Jun 1, 2022)

Just for your information, my FreeBSD 13.1 is installed on a Lenovo c440 AIO. The xf86-input-evdev package is installed.

Here are the last six lines of dmesg after hot plugging:


> ugen0.3: <HUION Huion TabletH950P> at usbus0
> ums1 on uhub2
> ums1: <HUION Huion TabletH950P, class 0/0, rev 2.00/1.11, addr 3> on usbus0
> ukbd1 on uhub2
> ...


However, let me also reboot and see what happens!

The tablet is still not working after a reboot.

Here are about 30 lines from dmesg that include references at the beginning and end to the tablet:


> uhub3: 6 ports with 6 removable, self powered
> ugen0.3: <HUION Huion TabletH950P> at usbus0
> ukbd0 on uhub2
> ukbd0: <HUION Huion TabletH950P, class 0/0, rev 2.00/1.11, addr 3> on usbus0
> ...


----------



## sidetone (Jun 1, 2022)

Try loading wmt, by typing `kldload wmt`. Alternatively, you can also try `kldload hmt`, but will take enabling `usbhid` from /boot/loader.conf and rebooting. More instructions for trying the new driver are in the howto.

The output showed the older drivers, they're usually prefixed with u or w. The newer ones are prefixed with an h. Like hkbd instead of ukbd, or hms in place of ums. Newer and older drivers have worked side by side, so all you may need is hmt, if wmt doesn't work.


----------



## Amooti (Jun 1, 2022)

Thanks sidetone!  I tried my best to follow the howto, however, a couple of  errors slowed me down!  I accidentally put "htm" instead of hmt and also fell into the "kld_list trap" by adding a second kld_list entry which interfered with loading my nvidia drivers!

Unfortunately, even after clearing up those issues, the tablet still did not work.  I tried the devd_enable="NO", but, although it enabled usbhid to activate without the older drivers, it also interfered with dhclient and blocked connection to the internet!

So, the struggle continues, but I have learned a few things in the process.  I will try these things tomorrow on my laptop which has GhostBSD.  The laptop is pretty new as opposed to this desktop which is close to ten years old.

Your help is much appreciated.


----------



## sidetone (Jun 1, 2022)

You may not need to disable the older drivers. They've worked side by side. Depending on hardware, perhaps.

Likely, the older drivers can be left on, and maybe devd.

You can try `kldunload wmt` and `kldload hmt`, or something like that. Also, try the xev(1) program from the desktop, to see if any inputs register from your device.



Amooti said:


> I tried the devd_enable="NO", but, although it enabled usbhid to activate without the older drivers, it also interfered with dhclient and blocked connection to the internet!


That may explain why my Internet stopped working reliably. devd, may have been compensating for an obsolete Internet connection. It happened after I set this, but didn't think that was it. I also set the Internet manually, even if I don't fully understand what happened, or every detail. Adding a netmask is what worked. IDK if this is related to devd: Thread ipv4-stopped-working-on-freebsd-13-1-release-manually-set-it-to-access-internet.85370.

If you don't need to disable devd for it to work, it doesn't have to be disabled. It depends on the particular hardware. Until it's working, that may have been needed to be tried.


----------



## Amooti (Jun 2, 2022)

Thanks once more, sidetone!  I tried the "kld" commands. The results indicated that wmt was not loaded and hmt was already loaded.

I also tried the xev program, though it took this amateur a while to figure that I needed to first use xwininfo to get the id of the xournal window I wanted to track.  In any case, the HUION tablet remains unresponsive.

As for network issues, I need more time to work on that.  I definitely have issues because the boot process itself does not result in a connection and I have resulted to a hack by putting some commands in /etc/rc.local which result in a connection by the time the slim login window appears.  This also means that booting takes time since dhclient spends some time "trying"!

Here is my /etc/rc.local


> /sbin/ifconfig re0 down
> /sbin/ifconfig re0 up
> /sbin/ifconfig wlan0 down
> /sbin/ifconfig wlan0 up
> kldload coretemp


For now, I will give this desktop a rest and see what happens with the laptop!

I wouldn't necessarily look forward to the work of switching to OpenBSD which may also have its own problems.  I have invested quite many hours to get where I am with FreeBSD!


----------



## sidetone (Jun 2, 2022)

There's also x11/xinput for tablets, which is hosted at x.org. It isn't in the x11-driver directory, which is kind of odd. This port uses Xorg's option to xi.

The xinput driver would be tested on top of either wmt or hmt.

Also, there's x11/dsbxinput which is meant for testing with xinput. From the description, it's like xev. If that doesn't work, x11/inputplug can be tried.


You can see the call to Xorg in the xinput's Makefile:

```
USES=           xorg xorg-cat:app
USE_XORG=       xorgproto x11 xi xext xrandr xinerama
```

/usr/ports/Mk/Uses/xorg.mk:

```
xorg.mk:                xi \
...
xorg.mk:xi_LIB_PC_DEPENDS=              ${LOCALBASE}/libdata/pkgconfig/xi.pc:x11/libXi
```


----------



## sidetone (Jun 4, 2022)

Somehow, pen tablet drivers hpen(4) and hconf(4) for usbhid have gone under the radar. It's available for FreeBSD 13.0 and 13.1. There may be better chances of success trying it on FreeBSD 13.1.

Is the hpen module automatically loaded when the device is plugged in? If it's not, `kldload hpen`. This module requires the usbhid architecture, which needs to be enabled from /boot/loader.conf. The output you showed above shows a lot of older drivers from uhid: they're prefixed with u instead of h. usbhid and uhid drivers can run side by side. There can be some issues depending on hardware, but there's workarounds.

It's important to increase the permissions of /dev/input/* for the wheel group. This must happen before additional steps can work. This is done through /etc/devfs.rules, with a reference from rc.conf.

Also, you may have tried xev. If that doesn't work, see if x11/antimicro shows anything for it: it's for gamepads, but it also can automatically detect a device and register multimedia keys and keyboard events.

It will likely need to a custom /usr/local/etc/X11/xorg.conf.d/ file as mentioned above so the device will behave like a mouse across the window screen.

There's more details in Thread howto-enabling-multimedia-keys-gamepads-joysticks-for-desktop-usbhid.84464. This is the same howto linked above, more was added to it, and the title was changed to be for gamepads too. It's about drivers that use usbhid. These usbhid drivers use plenty of the same instructions. A few workarounds to potential problems are there.


There's an older wsp, which was meant for the older uhid system.

Some got a touchpad to work before by using iichid instead of usbhid on an older system of FreeBSD: Thread asus-zenbook-13-ux433fn-touchpad-unrecognized.73750. They made a custom install without the ports system on a CURRENT system. Using CURRENT isn't recommended for most purposes and compiling a driver without a Makefile would be challenging. That thread is good for looking at. Now, there's a version of iichid(4) in the kernel and in ports. There are actually few iichid drivers available.

usbhid is now standard on FreeBSD 13.1.


----------



## sidetone (Jun 7, 2022)

Hi Amooti,

The How-to was updated. Try it with usbhid, and post the `dmesg` from hot-plugging it. I'm curious if `hpen` shows up there.

Then, translate the gamestick/joypad instructions for the tablet. After setting up the /dev/ permissions, can you see if joytran detects any device and if it registers any events from it?


Anyone who can try that on a tablet can also respond. These instructions aren't expected to work for Bluetooth devices.


----------



## Amooti (Jun 27, 2022)

Thanks once more sidetone!  I kind of dropped out of this conversation to experiment with OpenBSD, which has its advantages and disadvantages, I guess, though the tablet input just works.  I will now try your most recent suggestions and post my results when I am through.


----------

