mckset / KD100

A Linux driver for the Huion KD100 Mini Keydial written in C
GNU General Public License v3.0
15 stars 4 forks source link

Attempt to work with duplicated idVendor:idProduct pairs #1

Closed kepi closed 1 year ago

kepi commented 1 year ago

Hello,

first of all, huge thanks for this project. I was afraid I'll be without keypad, but you stepped in into Huion incompetency and fixed their mess :)

Anyway, I'm probably lucky and my system is always special. No easy ways for me. Looks like I'm not able to have it working, because I don't have single 256c:006d USB device, but two. One for tablet, one for KD100 (at least that is my understanding). And KD100 is unfortunately second, not first.

~/dev/os/KD100 main*
❯ sudo lsusb | grep -i 256c:006d
Bus 005 Device 025: ID 256c:006d  Huion Tablet_GT2401
Bus 001 Device 003: ID 256c:006d

I wrote you many paragraphs of excuses about why I'm not able to submit PR because I didn't write any C in about 10 years etc... But when trying to research correct approach and give you some references, I ended up trying it and... voilá, "PR" is here.

Please take it more like proof of concept or working example. I didn't even try to get grasp of your coding style, sort definitions or something like that, I just get examples from documentation, sone SO and glued it together. Feel free to just take an idea and fix it in whatever way you find best, no harmed feelings.

As for the fix itself: From what little I understand, libusb_open_device_with_vid_pid opens first vendorId:productId pair, no matter if it is one you need. Looks like we have to use more chatty way:

  1. get device list
  2. go trough it and take whatever you need
  3. free reference
  4. use device you found

Btw. this fix takes totally naive approach, which just assumes that KD100 is device without product description. Which is true in my case, but I'm really not sure if it is universal truth.

Anyway, just finished first drawing with this approach and it is working :)

mckset commented 1 year ago

Thanks for pointing that out. You are correct that the method I was using opened the first usb device it found. I thought this won't be a problem because I assumed that Huion devices wouldn't share product IDs. I couldn't test that assumption because I use an XP-Pen tablet but by the looks of it, your patch should fix it. I'll test it and I will try to push the update tomorrow