DIGImend / digimend-kernel-drivers

DIGImend graphics tablet drivers for the Linux kernel
GNU General Public License v2.0
1.17k stars 173 forks source link

XP-Pen Artist 24 Pro #535

Open Deevad opened 3 years ago

Deevad commented 3 years ago

2021-05-11_article-xppen24pro_1_general-overviewsmall A photo of my model on my desk, CC-By Deevad

Hi, here is my thread for requesting the support of the XP-Pen Artist 24 Pro.

Full Diagnostics

And everything as a zip: XPPEN_24-pro-artist_Digimend-full-diagnostics.zip

(Note: uclogic-probe command line really made the tablet totally disapear as a device. I had to remove all the cables, wait a minute and then reboot the system to get it back to life.)

Workaround and review on Linux:

Many parts of the tablet already works with the Digimend driver (mapping/coordinate/tilt/stylus button 1) and I documented workarounds (with udev) for the remaining part not supported yet on my blog post about XP-Pen Artist 24 Pro and on my video-review of the XP-Pen Artist 24 Pro on Linux but the workarounds have limitation.

References

From my non technical point-of-view, it sounds this tablet share a lot in common with all its siblings at lower size resolution. It was possible to already find many thread here, and I'll link them under as they were all useful and valuable to produce my workarounds (thank you to all participant).

Issues with full descriptors for reference:

Pull Request that might help for reference:

kurikaesu commented 3 years ago

Hi Deevad, I'm looking to add support for your Artist 24 Pro to my pull request here: https://github.com/DIGImend/digimend-kernel-drivers/pull/557

I need you to push the special handshake key to interface 2 then resubmit the data for:

The special handshake key can be sent to the tablet using the python script provided by @Korvox in one of the issues/PRs:

#! /usr/bin/env python3

import usb.core
import usb.util

dev = usb.core.find(idVendor=0x28bd, idProduct=0x092d)

if dev.is_kernel_driver_active(2):
    dev.detach_kernel_driver(2)

cfg = dev.get_active_configuration()
intf = cfg[(2,0)]
ei = intf[0]
eo = intf[1]

eo.write(bytes.fromhex('02b00400000000000000'))

while(True):
    print(''.join(format(x, '02x') for x in ei.read(12)))

pyusb needs to be installed for the root user since writing on the USB device requires root permissions. Can be installed with sudo pip3 install pyusb

You can ignore the USBTimeoutError that it spits out at the end.

Once the key has been sent to the tablet, when you start capturing the data like Pen Coordinates, the prefix byte should switch to 02 like: 02 f0 00 00 04 00 00 00 00 13. It is fine if the length of the data differs as it is important to know that it is different.

PS. Love your artwork!

Deevad commented 3 years ago

Hey, thank you very much for your kind words on my arts and for proposing help on the tablet :+1:

I installed sudo pip3 install pyusb, saved the Python script into a handshake.py file, I rand a chmod +x on it and executed as root, the result:

$ sudo ./handshake.py 
02b10400000000000000
Traceback (most recent call last):
  File "./handshake.py", line 19, in <module>
    print(''.join(format(x, '02x') for x in ei.read(12)))
  File "/usr/local/lib/python3.8/dist-packages/usb/core.py", line 423, in read
    return self.device.read(self, size_or_buffer, timeout)
  File "/usr/local/lib/python3.8/dist-packages/usb/core.py", line 1029, in read
    ret = fn(
  File "/usr/local/lib/python3.8/dist-packages/usb/backend/libusb1.py", line 864, in intr_read
    return self.__read(self.lib.libusb_interrupt_transfer,
  File "/usr/local/lib/python3.8/dist-packages/usb/backend/libusb1.py", line 954, in __read
    _check(retval)
  File "/usr/local/lib/python3.8/dist-packages/usb/backend/libusb1.py", line 602, in _check
    raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out

It doesn't look like a good output. Also, the cursor of the tablet totally disapear after the handshake, and only a power-of (removing the power plug of the device) makes the cursor coming back.

I then redid the diadnostic, even without cursor visible and it changed the output of the diagnostic and it starts now by 02, so I guess the script had the expected effect on my device to influencate the output. Here are the files:

Or all in one zip: XPPEN_24-pro-artist_Digimend-full-diagnostics_V2.zip

Let me know if I need to provide additional info, or modifiy my system (Kubuntu 20.04LTS) to install new library for the script to run better.

nic3-14159 commented 3 years ago

Hello! As kurikaesu said, you can ignore the USBTimeoutError, which is what the output you posted indicates. The new diagnostics look fine to me, and should be enough for adding support for this tablet.

Deevad commented 3 years ago

Thanks @nic3-14159 for the quick reply. I'm glad it did work.

kurikaesu commented 3 years ago

Thanks for providing them! Interesting. The 24 Pro uses 12 bytes like the 13.3 Pro but lays out the data like the 22R Pro.

Anyway I've pushed in code to this branch on my fork: https://github.com/kurikaesu/digimend-kernel-drivers/tree/xppen-artist-24-pro

I believe it should work but I don't have a 24 Pro to test with locally to confirm. Let me know if it works for you and I'll merge it into my existing PR :smile:

Deevad commented 3 years ago

Thanks! Unfortunately, testing a branch will be tricky for me; mainly because I never compiled Digimend (I'll read the documentation to learn about it) and also I can't test it on my production machine (where the tablet runs right now) without un-installing the current Digimend, the Udev rule, the xsetwacom script, the custom xorg.conf.d rule. I'll try to setup another system (using another hardware, my laptop for traveling) to compile it, and then connect the tablet to it to report how it works.

What should I expect once it is compiled and installed? Directly see all the buttons of the stylus and frame listed via xsetwacom ?

kurikaesu commented 3 years ago

The wacom driver is limited in what it can represent on the Artist 24 Pro (and Artist 22R Pro).

Both buttons on the stylus and all of the left hand side express keys except the dial can be mapped using xsetwacom

The right hand express keys need to be mapped using other means. First of I change the right hand side button-codes to named buttons by creating a hwdb file and entry in /etc/udev/hwdb.d/70-xppen.hwdb with:

evdev:input:b0003v28BDp091Be0100*
 KEYBOARD_KEY_9000b=0x120
 KEYBOARD_KEY_9000c=0x121
 KEYBOARD_KEY_9000d=0x122
 KEYBOARD_KEY_9000e=0x123
 KEYBOARD_KEY_9000f=0x124
 KEYBOARD_KEY_90010=0x125

Without the above, the first 5 buttons on the right hand side will have no name and show up as "null" events.

You will need to find out what the proper address of your 24 Pro is. This can be done by doing something like sudo libinput record and noting down the XX number in the /dev/input/eventXX written next to the PenTablet Pad entry. With the number in hand, you can then do: cat /sys/class/input/eventXX/device/modalias replacing XX with the above number. It should come out with a long line like: input:b0003v28BDp0909e0100-e0,1,2,4,k100,101,102,103,104,105,106,107,r6,8,B,C,am4,lsfw From here you take the up to the first - and that will be the entry used in hwdb, making sure to put a * at the end so that it captures the rest of the modalias without having to be too specific: evdev:input:b0003v28BDp091Be0100*

If you are able to reply to this comment with the actual modalias file output then we may be a good reference for others with the same device.

With that complete, doing a sudo udevadm hwdb --update followed by a sudo udevadm trigger /sys/class/input should apply the button remaps. With the remaps in hand, the remaining step is to use something to actually map the buttons and left/right dials to shortcuts. There are probably countless utilities and methods available in Linux to do this but I personally just use Key-Mapper: https://github.com/sezanzeb/key-mapper

It isn't the best user experience setting it all up but I leave the stylus and stylus buttons in the hands of xsetwacom and all of the express keys (both left and right) and dials to Key-Mapper.

Deevad commented 3 years ago

Thanks for the detailed reply.

Both buttons on the stylus and all of the left hand side express keys except the dial can be mapped using xsetwacom

That's a great news!

If you are able to reply to this comment with the actual modalias file output then we may be a good reference for others with the same device.

The modalias of the 24 Pro is :

evdev:input:b0003v28BDp092De0100-e0*

The buttons:

Left side:
01. b             70005 / code 48 (KEY_B)
02. e             70008 / code 18 (KEY_E)
03. alt           700e2 / code 56 (KEY_LEFTALT)
04. space         7002c / code 57 (KEY_SPACE)
05. ctrl+S        700e0 / code 29 (KEY_LEFTCTRL) + 70016 / code 31 (KEY_S)

LDL: ctrl+-       700e0 / code 29 (KEY_LEFTCTRL) + 70056 / code 74 (KEY_KPMINUS)
LDR: ctrl++       700e0 / code 29 (KEY_LEFTCTRL) + 70057 / code 78 (KEY_KPPLUS)

06. ctrl+z        700e0 / code 29 (KEY_LEFTCTRL) + 7001d / code 44 (KEY_Z)
07. ctrl+alt+z    700e0 / code 29 (KEY_LEFTCTRL) + 700e2 / code 56 (KEY_LEFTALT) + 7001d / code 44 (KEY_Z)
08. ctrl+shift+z  700e0 / code 29 (KEY_LEFTCTRL) + 700e1 / code 42 (KEY_LEFTSHIFT) + 7001d / code 44 (KEY_Z)
09. v             70019 / code 47 (KEY_V)
10. l             7000f / code 38 (KEY_L)

Right side:
11. ctrl+o        700e0 / code 29 (KEY_LEFTCTRL) + 70012 / code 24 (KEY_O)
12. ctrl+n        700e0 / code 29 (KEY_LEFTCTRL) + 70011 / code 49 (KEY_N)
13. ctrl+shift+n  700e0 / code 29 (KEY_LEFTCTRL) + 700e1 / code 42 (KEY_LEFTSHIFT) + 70011 (KEY_N)
14. ctrl+e        700e0 / code 29 (KEY_LEFTCTRL) + 70008 / code 18 (KEY_E)
15. f             70009 / code 33 (KEY_F)

RDL: [            7002f / code 26 (KEY_LEFTBRACE)
RDR: ]            70030 / code 27 (KEY_RIGHTBRACE)

16. d             70007 / code 32 (KEY_D)
17. x             7001b / code 45 (KEY_X)
18. ctrl+delete   700e0 / code 29 (KEY_LEFTCTRL) + 7004c / code 111 (KEY_DELETE)
19. ctrl+c        700e0 / code 29 (KEY_LEFTCTRL) + 70006 / code 46 (KEY_C)
20. ctrl+v        700e0 / code 29 (KEY_LEFTCTRL) + 70019 / code 47 (KEY_V)

Here so far, I customised the default layout to get this:

Thanks for the tip about Key-Mapper: https://github.com/sezanzeb/key-mapper , I didn't know it; it looks like this utility will ease a lot customising other keys :+1:

Deevad commented 3 years ago

Hey, so I tested your fork: https://github.com/kurikaesu/digimend-kernel-drivers/tree/xppen-artist-24-pro after install, the tablet works, but I'm not able to setup it (map area, changes buttons). Here is more infos:

After install, the tablet wasn't listed by xsetwacom --list at all.

I added a new file 60-xppen.conf into /usr/share/X11/xorg.conf.d/ containing:

Section "InputClass"
  Identifier "tablet"
  Driver "wacom"
  MatchUSBID "28bd:092d"
  MatchDevicePath "/dev/input/event*"
EndSection

Once this rule set (and after a reboot), xsetwacom recognize better the device and list the pad (with digimend-v10, I have a single entry here only for the stylus).

$ xsetwacom --list
UGTABLET 24 inch PenDisplay Pen stylus  id: 16  type: STYLUS    
UGTABLET 24 inch PenDisplay Pad pad     id: 17  type: PAD  

The output of available parameters are:

 ~ »»» xsetwacom --get "UGTABLET 24 inch PenDisplay Pen stylus" all -s
Option "Area" "0 0 39834 59270"
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
Option "DebugLevel" "0"
Option "CommonDBG" "0"
Option "Suppress" "2"
Option "RawSample" "4"
Option "PressCurve" "0 0 100 100"
Option "Mode" "Absolute"
Option "TPCButton" "off"
Option "Touch" "off"
Property 'Wacom Hardware Touch Switch' does not exist on device.
Option "Gesture" "off"
Option "ZoomDistance" "0"
Option "ScrollDistance" "0"
Option "TapTime" "250"
Option "CursorProx" "30"
Incorrect number of arguments supplied.
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Strip Buttons' does not exist on device.
Property 'Wacom Strip Buttons' does not exist on device.
Property 'Wacom Strip Buttons' does not exist on device.
Property 'Wacom Strip Buttons' does not exist on device.
Option "Threshold" "26"
Option "Serial" "0"
Option "PressureRecalibration" "on"
Option "PanScrollThreshold" "2600"
 ~ »»» xsetwacom --get "UGTABLET 24 inch PenDisplay Pen stylus" all
Option "Area" "0 0 39834 59270"
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
Option "DebugLevel" "0"
Option "CommonDBG" "0"
Option "Suppress" "2"
Option "RawSample" "4"
Option "PressCurve" "0 0 100 100"
Option "Mode" "Absolute"
Option "TPCButton" "off"
Option "Touch" "off"
Property 'Wacom Hardware Touch Switch' does not exist on device.
Option "Gesture" "off"
Option "ZoomDistance" "0"
Option "ScrollDistance" "0"
Option "TapTime" "250"
Option "CursorProx" "30"
Option "Rotate" "none"
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Wheel Buttons' does not exist on device.
Property 'Wacom Strip Buttons' does not exist on device.
Property 'Wacom Strip Buttons' does not exist on device.
Property 'Wacom Strip Buttons' does not exist on device.
Property 'Wacom Strip Buttons' does not exist on device.
Option "Threshold" "26"
Option "Serial" "0"
Option "PressureRecalibration" "on"
Option "PanScrollThreshold" "2600"

But I can't, for example, just remap the device to use its own display, something like that under doesn't apply the transform. (while it is possible with Digimend-V10 deb).

tabletstylus="UGTABLET 24 inch PenDisplay Pen stylus"
xsetwacom --set "$tabletstylus" MapToOutput "HDMI-A-0"

I hope it will help doing progress. Thanks for the researches and efforts! :+1:

kurikaesu commented 3 years ago

Thanks for testing it out! I'm glad that the stylus is still working and the pad shows up correctly to xsetwacom list at least.

As for the mapping not working, that is pretty odd. I also use the same directive and it works:

# XP Pen Artist 22R Pro
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pen stylus" MapToOutput "HDMI-A-0"
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pen stylus" button 2 0
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pen stylus" button 3 0
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pen stylus" Area 120 95 47718 26807

Since you are testing on your laptop, could it be that the name of the HDMI output is different? Does it consider the laptop screen as HDMI-A-0 for example?

Deevad commented 3 years ago

Thanks @kurikaesu for the feedback and guidance. I finally decided to test on my main workstation (laptop had a too weak graphic card for the quadHD of the 24Pro anyway); I also saw I had compilation/install issues...

I tried again today, and I tried to get a cleaner method. I used sudo apt purge digimend-dkms instead of sudo apt remove digimend-dkms to clean the system, and then I generated the package with 'dpkg-buildpackage -b -uc' and after generation (without errors), I install (after a cd ..) with sudo apt install ./digimend-dkms_11_all.deb, then I perform a sudo reboot now before testing. It sounds like a cleaner method to test.

I also added 28bd:092d tablet ID to the xorg.conf file of your branch to ease testing.

So, after a first run, good news: now I can control the stylus mapping and buttons of the stylus with xsetwacom. I have MapToOutput that works, Tilt that works, pressure that works. (Note: it was already the case with digimend v.10). But now I can also assign keys to the three buttons of the stylus via xsetwacom.

But

  1. The Pad buttons still reports 3 active buttons only (like a stylus?)
  2. The mapping of the stylus on the monitor has a bug: it's like if my display is split into two block horyzontally, as if I had two active areas on the tablet (A from 0 to around 3/4 of the tablet, and a B from 3/4 to the end). However, the vertical is fine. For the horyzontal, If I move stylus from extreme left to extreme right, the cursor first travel the monitor fully from left to right while having my stylus over block A, then reset at left position when reaching block B and redo a full display travel from left to right for this block). I tried to ResetArea with xsetwacom, or to MapToOutput, I still obtain the same effect (just on another monitor). This is not something that happens with digimend v.10 driver where the mapping takes full tablet area by default.

Thanks if you have an idea how to fix the size of the tablet and how the Pad/Frame can target the buttons.

kurikaesu commented 3 years ago

Which 3 buttons are the only ones active?

The monitor mapping definitely sounds like a bug but I don't know if it is a bug with the descriptor or not. It could be that the resolution of the digitizer is much higher than the 22R for example and is "overflowing" the number container that I'm using.

One way to check this is to do pen_coords test but with just 2 points, the top left of the digitizer and the bottom right of the digitizer.

Lastly, thank you for your patience with this. Hopefully we are only a few steps away from proper support.

kurikaesu commented 3 years ago

It has been a while since I last commented but I have something that may interest you. I've been working on userland (not kernel) drivers for my 22R Pro here: https://github.com/kurikaesu/xp-pen-userland

This tool runs as an application in the background (I have it running on login) and creates a working driver for my pen display that leverages the wacom driver for all of the stylus related things like stylus buttons and actual drawing. My driver also currently supports all of the buttons and can map all of the buttons on the fly. I don't have a nice user interface to do it yet as you need to hand-update a JSON config file to change the mappings and I haven't set up mapping of the dials yet.

I will keep you posted with progress but knowing that your 24 Pro is similar enough I thought you may want to try testing my driver out while I work on getting a proper interface written.

Deevad commented 3 years ago

Hey @kurikaesu ! Oh wow, thank you for sharing it. That sounds great! :+1:

Sorry for no recent test/news here; I have a deadline for delivering many illustrations and a storyboard by the mid of September, and I'm full time working on it. I'll probably recover testing time budget after that.

kurikaesu commented 3 years ago

I've added support for the 24 Pro to my userland drivers. Since I don't have a 24 Pro myself to to test that it is working I will have to rely on you to try it out. I have actually tried contacting XP-Pen to see if they would lend me a 24 Pro so that I can test and develop on it but no reply yet. I doubt they will oblige but I wanted to try anyway.

Instructions on how to build the driver and run it are in the readme of the git repository. I've also made progress with the configuration GUI here: https://github.com/kurikaesu/xp-pen-userland-config-util

Deevad commented 2 years ago

Thanks for merging it in your MR; it will be easier to test.

About the model; I can ask my contact at XP-Pen. I can also ask around community/social media if someone around your location can lend you a 24 Pro. Where are you located? (roughly, at city scale)

kurikaesu commented 2 years ago

I am in Seattle city, Washington State (Not D.C) in the USA.

I'm still doing a few bits of refining on the driver and I have a new GUI in planning as well to hopefully make things more simpler and less clunky.

Deevad commented 2 years ago

Thanks for the info. I asked by email (but unfortunately, my contact are mostly marketing/youtube one, not sure they can take this type of decisions) and on social media here:

kurikaesu commented 2 years ago

Good news! I believe I have identified and resolved the issue you were having on my userspace drivers where the stylus was looping around as you moved the stylus to the right.

I was only really able to see the issue and figure it out because I had a tablet that was large enough to cause the problem.

Please test my driver out again (the name has changed because I am now also starting to support Huion) here: https://github.com/kurikaesu/userspace-tablet-driver-daemon

Any issues you find can be posted to the repository as I've started adding my own issues and todo there.

Deevad commented 2 years ago

@kurikaesu Woohoo! Thanks. I'll test this week-end. :+1: