-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to udev-hid-bpf? #11
Comments
@whot I've never worked with BPF programs before so you'll have to bear with me if what I am doing is wrong, but after compiling with meson by following the instructions in the readme, I do not see an option for the H610 BPF. I noticed it's in the "userhack" folder which I'm guessing is supposed to be ignored just by how the readme talks about it. So I tried using
as mentioned in the readme and got "Error: Expected a bpf.o file as argument, not "0010-Huion__H610-Pro.bpf.c"" So I'm guessing that I am installing it wrong. I also tried compiling it via
then tried installing it and got "Error: Failed to read BPF from 0010-Huion__H610-Pro.bpf.o": bpf call "libbpf_rs::btf::Btf::from_path::inner::{{closure}}" returned NULL" Not sure if any of that helps since I'm 90% sure I'm installing it wrong and just missed something or I just don't know enough about bpf files. Let me know if there's a way to fix this. I'll try to help as much as I can. |
There's a bit to unpack in this sentence :) First: udev-hid-bpf is an approach to fix the kernel, the BPFs are similar to a kernel module. GNOME has nothing to do with that. Second: Traditionally the kernel driver for Huion devices was hid-uclogic but that one doesn't support all devices and specifically it doesn't seem to support the KD100 because otherwise this project here wouldn't need to exist :) The current plan is to add support for new devices to udev-hid-bpf while leaving devices previously supported by hid-uclogic as-is so we don't break anything. That's the reason why the H610 is in userhacks - that particular device is supported by hid-uclogic and we're doubling up on support here.
I think you're referring to what libwacom thinks this device is? The cause for this is that huion re-uses PIDs and the 0x6d PID is used by a multitude of devices so until quite recently libwacom wasn't able to differ between the devices. It still isn't because the firmware ID somewhat requires the hid-uclogic driver though we're working on that. The real kernel driver for your device will be listed in
Obviously adjust Testing the existing BPFI just realised the H610 BPF needs kernel 6.11 so if ubuntu doesn't use that one yet it won't work anyway, so you can skip the rest below... First, I recommend copying the H610 sources and editing the copy because otherwise this will get a mess quickly. To actually try the H610 you'll need to add this line to
with or without a nice Then you need to run (and install) huion-switcher to check what the firmware ID is because the BPF checks for that, grep for
The
( Oh, and finally: there's a tutorial which explains the bits and pieces so you don't have to guess what everything means. So in summary:
|
Sorry, for some reason I assumed that the project was related to gnome. I switched over to an Arch VM and I was able to get everything to build without errors but I am guessing that I would need another program to configure the device correct? Either way, after install the driver and using
The driver still shows that it is using uclogic. Which I assume is still ok. I followed a bit of the tutorial to create a new bpf file to mess with and it does show that the file working in "/sys/fs/bpf/hid". I'll be working on this in my free time but I'm still very new to bpf files so it may take me a week or two. |
@whot I might need a bit more help working on this. I've got a bpf program that is being assigned to the device but I haven't gotten much further than that. I used hid-recorder and got more information on the 2 interfaces that the device uses. And that's about as far as I got. I cannot get huion-switcher to do anything with the device as it prints the error: "thread 'main' panicked at src/main.rs:53:10: I'm not sure if you want to see the backtrace or how important it is for the program but that's not entirely what I'm stuck on. The tutorial was quite helpful on how to make a bpf program but I believe it's for a mouse correct? I'm not exactly sure what to do beyond that point. This is probably because I don't work with kernal drivers and maybe my program is a bit misleading as it's not a kernal driver but runs as an application. Is there some sort of standard or protocol that I need to try and make the device follow to get it to act as a configurable keypad? The way my program works is it reads the raw USB data and then handles it depending on the users configuration. I'm assuming that your driver doesn't actually handle the input but instead corrects the input so that something like gnome-control-center or libwacom can read it correct? |
Sorry about the silence, I was swamped with something else. So there are a few comments here, the most important one is though: if anything isn't clear about udev-hid-bpf please file an issue there and we can fix the documentation. The goal is long-term to have this replace many HID drivers so ideally users can just come in, fix their device and done. If that's not the case, documentation is missing but we'll need help identifying where this is. fwiw, I've filed this mr for better docs on the high-level approach. If Having said that, there's the possiblity that uc-logic interferes, can you do an Basically: the KD100 is a hid device and it (probably) has multiple report descriptors. Those describe how to interpret the data - in the form "bit 3 is button left, bytes 3 and 4 are x/y" and so on. But one of the rdescs is a pure "vendor" report, i.e. without any details, just vendor-specific data. The kernel ignores that since we don't know what the data means. If you run hid-recorder you should see at least 2, more likely 3 reports. If the tablet is in firmware mode it will send key events, hid-recorder should show those. The idea behind the BPFs is that we convert those events into proper button events and that we also convert the vendor report into a proper tablet report instead (that can be handled by the kernel). So the BPF I linked to actually does two different things, depending on which report the device sends (which will depend on whether huion-switcher changes it into raw mode). Maybe have a look at the Inspiroy BPF which I wrote and has lots of comments (because I was learning myself at the time). In other words: If you load the (correct) BPF without huion-switcher, the BPF should convert the incoming reports to tablet events instead (and maybe change the report descriptor if need be). That part is identical to what you appear do do in this utility here (https://github.com/mckset/KD100/blob/main/KD100.c#L326 is basically https://gitlab.freedesktop.org/libevdev/udev-hid-bpf/-/blob/main/src/bpf/stable/0010-Huion__Inspiroy-2-S.bpf.c#L433) If you load the (correct) BPF with huion-switcher, the BPF changes the report descriptor from lots of "vendor specific, haha" to a proper tablet report ("button X is bit Y", etc). The inspiroy bpf does this here - and that's a matter of a memcpy. Once that's done any event coming over that HID report will be interpreted correctly by the kernel and no further action is necessary. It changes this (approximately)
to this:
|
I don't mind the wait. This project doesn't seem like it's too urgent. A couple of things I want to note.
What you sent did help me get a bit further but it's still the same issue where I'm not exactly sure how to change the data for the device to be read properly. If you want, I can open an issue on the project and ask for more documentation. Right now I have all the data from hid-recorder and the data that is sent from each button and the wheel. So I think I have everything I need from the device but it's just a matter of figuring out how fix it in a way that can be interpreted by the operating system. |
yeah, the software fetches the magic usb field (see the huion-switcher code, it's very simple) so that may explain why it works. Once it's switched to raw mode you need to unplug to get the firmware mode again.
I'm basing this off my Inspiroy 2S and the other tablets we've seen in udev-hid-bpf: I suspect that is what you are seeing? the keyboard shortcuts? I think we're at the point where it's best to open an issue in udev-hid-bpf though, with all the hid-recorder output for the various report ids attached. That way we should be able to proceed faster. |
Hi, I just found this while looking for the vid/pid of the KD100 while I'm working on linuxwacom/libwacom#779 and gnome-control-center#3216
You may not be aware of it but we're currently aiming to replace the hid-uclogic kernel driver for currently unsupported devices with BPF programs via udev-hid-bpf. The idea is that we'll then be able to just load the BPF and the device works out of the box - just like a true kernel driver.
I don't have access to a KD100 but if you're have the time we'd very much appreciate it if you can have a look at udev-hid-bpf, in particular the H610 BPF which might actually get you 90% of the way anyway (huion tends to share a lot of firmware bits so there's a good chance you can copy that one and re-use it).
Note you'll probably need huion-switcher too since this devices seems to have a shared PID.
Happy to answer any questions.
The text was updated successfully, but these errors were encountered: