Skip to content
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

XP-Pen Deco Pro SM, Artist 12, 13.3, 15.6 and 22R Pro Support #557

Closed
wants to merge 3 commits into from
Closed

XP-Pen Deco Pro SM, Artist 12, 13.3, 15.6 and 22R Pro Support #557

wants to merge 3 commits into from

Conversation

kurikaesu
Copy link

@kurikaesu kurikaesu commented Aug 19, 2021

Adds some support for the XP-Pen Artist 22R Pro.

I used a bunch of code from PR #291 to get the digitizer/stylus working however the frame buttons are not configured correctly.
Some of the buttons will respond to touches but they do not have unique codes being emitted.

Left button 8 and right button 6 for example emit the key 123 which on my system increases sound volume.

There is still a bunch of test rdescs that I wrote for interfaces 0 and 1 but those interfaces will result in the buttons emitting their default hard coded keyboard keycodes. They will be removed in future.

@kurikaesu
Copy link
Author

I tested these changes on my XP-Pen 13.3 Pro to see if at least the pen would work and it doesn't.

Moving the pen around results in input irq status -75 received so for the 13.3 Pro the report descriptor for the stylus is wrong.
The frame buttons also do not report any keypresses when using "xinput test"

@kurikaesu
Copy link
Author

@kurikaesu
Copy link
Author

Trying to create a manual report descriptor for the frame keys referring to the usb packet dumps I made but not having much luck. So far there are no IRQ errors in dmesg and the 6th button on the right reports motion a[3]=-60 when pressed but every other key or dial turn produces nothing.

@kurikaesu
Copy link
Author

Using the bit of research I posted above I found what was different on the 13.3 pro. The stylus now works on the 13.3 pro with pressure sensitivity and I would guess tilt support.

@kurikaesu kurikaesu changed the title XP-Pen Artist 22R Pro Support XP-Pen Artist 22R Pro and Artist 13.3 Pro Support (WIP) Aug 21, 2021
@kurikaesu
Copy link
Author

kurikaesu commented Aug 21, 2021

With that last commit it appears that the 13.3 pro's frame / express keys are now working correctly.

> xinput list
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ LingYao ShangHai Thumb Keyboard         	id=10	[slave  pointer  (2)]
⎜   ↳ UGTABLET 13.3 inch PenDisplay Pad pad   	id=11	[slave  pointer  (2)]
⎜   ↳ UGTABLET 13.3 inch PenDisplay Pen stylus	id=12	[slave  pointer  (2)]
⎜   ↳ Convertible 2 TKL Consumer Control      	id=14	[slave  pointer  (2)]
⎜   ↳ SteelSeries SteelSeries Rival 3 Wireless Consumer Control	id=20	[slave  pointer  (2)]
⎜   ↳ SteelSeries SteelSeries Rival 3 Wireless	id=22	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Power Button                            	id=6	[slave  keyboard (3)]
    ↳ Power Button                            	id=7	[slave  keyboard (3)]
    ↳ Microsoft® LifeCam HD-3000: Mi         	id=17	[slave  keyboard (3)]
    ↳ UVC Camera (046d:0825)                  	id=18	[slave  keyboard (3)]
    ↳ Samson Technologies Samson Go Mic       	id=8	[slave  keyboard (3)]
    ↳ LingYao ShangHai Thumb Keyboard         	id=9	[slave  keyboard (3)]
    ↳ Convertible 2 TKL System Control        	id=13	[slave  keyboard (3)]
    ↳ Convertible 2 TKL Consumer Control      	id=15	[slave  keyboard (3)]
    ↳ Convertible 2 TKL                       	id=16	[slave  keyboard (3)]
    ↳ SteelSeries SteelSeries Rival 3 Wireless Keyboard	id=19	[slave  keyboard (3)]
    ↳ SteelSeries SteelSeries Rival 3 Wireless Consumer Control	id=21	[slave  keyboard (3)]
> xsetwacom list
UGTABLET 13.3 inch PenDisplay Pad pad	id: 11	type: PAD       
UGTABLET 13.3 inch PenDisplay Pen stylus	id: 12	type: STYLUS   
> xsetwacom set "UGTABLET 13.3 inch PenDisplay Pad pad" Button 1 "key 5"

* press top-most express key button *

5

> xsetwacom set "UGTABLET 13.3 inch PenDisplay Pad pad" Button 13 "key ."
> xsetwacom set "UGTABLET 13.3 inch PenDisplay Pad pad" Button 14 "key ,"

* rotate dial left and right *
,,,,,,...........,,,,,.........,,,,,,,

@kurikaesu
Copy link
Author

Just checked out my Art Deco Pro and it looks like it may be almost identical in implementation as the 13.3 pro. It might be more close to the implementation in #291 actually.

@kurikaesu
Copy link
Author

kurikaesu commented Aug 21, 2021

The last commit enabled the stylus on the Deco Pro SM.
For the Artist 22R Pro using the code changes in the PR:

Creating hwdb rule in /etc/udev/hwdb.d/70-xppen.hwdb with the contents:

id-input:*:input:b0003v28BDp091Be0100*
 ID_INPUT_MOUSE=0
 ID_INPUT_TABLET=1
 ID_INPUT_TABLET_PAD=1

Then executing a sudo udevadm hwdb --update followed by a sudo udevadm trigger /sys/class/input/eventX where eventX should be replaced with whatever sudo libinput record says the Pad event id is appears to make the left side buttons (but not the dial) work:

> xsetwacom list
UGTABLET 21.5 inch PenDisplay Pen stylus	id: 19	type: STYLUS    
UGTABLET 21.5 inch PenDisplay Pad pad	id: 20	type: PAD 
> xsetwacom -s get "UGTABLET 21.5 inch PenDisplay Pad pad" all
Property 'Wacom Tablet Area' does not exist on device.
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Button" "1" "button +1 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Button" "2" "button +2 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Button" "3" "button +3 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Button" "8" "button +8 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Button" "9" "button +9 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Button" "10" "button +10 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Button" "11" "button +11 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Button" "12" "button +12 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Button" "13" "button +13 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Button" "14" "button +14 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "ToolDebugLevel" "0"
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "TabletDebugLevel" "0"
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Suppress" "2"
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "RawSample" "4"
Property 'Wacom Pressurecurve' does not exist on device.
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Mode" "Absolute"
Property 'Wacom Hover Click' does not exist on device.
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Touch" "off"
Property 'Wacom Hardware Touch Switch' does not exist on device.
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Gesture" "off"
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "ZoomDistance" "0"
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "ScrollDistance" "0"
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "TapTime" "250"
Property 'Wacom Proximity Threshold' does not exist on device.
Property 'Wacom Rotation' does not exist on device.
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "RelWheelUp" "1" "button +5 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "RelWheelDown" "2" "button +4 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "AbsWheelUp" "3" "button +4 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "AbsWheelDown" "4" "button +5 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "AbsWheel2Up" "5" "button +4 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "AbsWheel2Down" "6" "button +5 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "StripLeftUp" "1" "button +4 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "StripLeftDown" "2" "button +5 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "StripRightUp" "3" "button +4 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "StripRightDown" "4" "button +5 "
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "Threshold" "0"
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "BindToSerial" "0"
Property 'Wacom Pressure Recalibration' does not exist on device.
xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" "PanScrollThreshold" "13"
> xsetwacom set "UGTABLET 21.5 inch PenDisplay Pad pad" Button 1 "key m"

* press top left-most button / express key *
m

I suspect the the Deco Pro SM express keys will also start working if the appropriate hwdb entry is created.

Another problem that I don't know how to deal with right now is that there may be only 10 buttons actually defined:
https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h#L342

For the Artist 22R Pro which has 20 buttons and 2 dials with 4 "buttons" (left & right turns emit buttons) I don't know if these can actually be properly mapped.

The Deco Pro SM also has the touch-pad in the dial that also functions as a second dial which brings the total buttons on it to 12. Maybe these dials can be somehow mapped to the StripLeftUp/Down and StripRightUp/Down?

@kurikaesu
Copy link
Author

kurikaesu commented Aug 21, 2021

After messing around with things more on my Artist 22R Pro, I've been able to do the following:

Assigned named buttons to the right side express keys and both dials:
/etc/udev/hwdb.d/70-xppen.hwdb

id-input:*:input:b0003v28BDp091Be0100*
 ID_INPUT_MOUSE=0
 ID_INPUT_TABLET=1
 ID_INPUT_TABLET_PAD=1

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
 KEYBOARD_KEY_90011=0x126
 KEYBOARD_KEY_90012=0x127
 KEYBOARD_KEY_90013=0x128
 KEYBOARD_KEY_90014=0x129
 KEYBOARD_KEY_90015=0x111
 KEYBOARD_KEY_90016=0x110
 KEYBOARD_KEY_90017=0x115
 KEYBOARD_KEY_90018=0x116

Then using Key Mapper: https://github.com/sezanzeb/key-mapper
Map these keys to shortcuts or even macros.

Still a work-around but its better than nothing. If there was a way to map the express keys to the wacom driver button 4, 5, 6, etc. which don't seem to correspond to anything then I would definitely like to know.

@nic3-14159
Copy link

nic3-14159 commented Aug 21, 2021

@kurikaesu Wacom buttons 4-7 are reserved and cannot be mapped to the express keys. From the digimend readme:
"Note that buttons are numbered 1, 2, 3, 8, 9, 10, and so on, i.e. buttons 4, 5, 6, and 7 are not used. They're reserved for vertical and horizontal scrolling events by the X server."

@kurikaesu
Copy link
Author

Oh I see! Thanks for the clarification 😃
Guess there is naught to do but use tools to remap the keys. At least now they aren't hard-coded keyboard scan-codes.

The 22R Pro's dials don't send a "key-up/stop rotate" state unlike the 13.3 pro so evtest or libinput record discard the pressed state past the first message. Need to press something else or turn the dial the other way in order to be able to reset the state. Maybe the dials should not be set as buttons on the 22R Pro?

@kurikaesu
Copy link
Author

kurikaesu commented Aug 22, 2021

Added this to my /etc/udev/hwdb.d/70-xppen.hwdb:

id-input:*:input:b0003v28BDp0909e0100*
 ID_INPUT_MOUSE=0
 ID_INPUT_KEY=0
 ID_INPUT_TABLET=1
 ID_INPUT_TABLET_PAD=1

This enables the Deco Pro SM:

> xsetwacom list
9 inch PenTablet Pen stylus     	id: 19	type: STYLUS    
9 inch PenTablet Pad pad        	id: 22	type: PAD  

The Deco Pro SM dials have the same behavior as the Artist 22R Pro so its probably not a good idea to bind a shortcut to them right now.

@Korvox
Copy link

Korvox commented Aug 22, 2021

If you ever want to get these patches properly merged into mainline along with mine, hit me up some time, I think we have to bypass Digimend.

And tilt support works? I assume the chip is accounting for the tilt in the reported coordinates? Lucky, I guess they learned from the 15.6 that tilt reporting angle but not just hardware-side including that in the position reporting just sucked.

We also might be able to get the Artist 12 Pro included if @alfazaz's work in #351 is applicable.

@nic3-14159
Copy link

nic3-14159 commented Aug 22, 2021

@Korvox I also have some code on my machine for the Star 06 (There is currently pen support but no frame button support, that tablet also needs a "key packet" sent to it) based on your patches, but I was sort of waiting until your patch got merged into DIGImend before posting.

The init packet uses a different value than your parch and this patch, (0x02b002 and then 0s instead of 0x02b004), so I wonder if we should make that init function more general to handle more tablets. Otherwise, we'll probably have a lot of long functions with similar code. I think I saw another uclogic (non XP-Pen) tablet that I suspect also needs an init packet (it reported keyboard events on the frame butttons) but I think it had a different number of interfaces and thus such an init packet would need to be sent to a different endpoint

@kurikaesu
Copy link
Author

@Korvox I haven't tested tilt yet since I don't have a tool test it with nor do I know how to set up tilt in Krita.
I do think that I'll need to merge your tilt fixes in your PR for most if not all of the cases.

Definitely keen on getting these changes all through to mainline once I can deal with the frame dials.
I'll take a look through #351 to see what I can use or adapt. I've also reached out to @Deevad in #535 to see if I'm able to get the 24 Pro done too.

@nic3-14159 if you fork this repository and push your changes to a branch, link it here and I can also take a look at it and see how we can merge it all together.

@nic3-14159
Copy link

nic3-14159 commented Aug 22, 2021

@Korvox @kurikaesu I'm assuming mainline is referring to the kernel tree? If so, I feel like we should communicate our intentions to @spbnick before trying to bypass DIGImend. Just to avoid any confusion if he is pushing changes in the future.

@kurikaesu
Copy link
Author

Last commit changes the Deco Pro's dial to emulate a Wheel (0x38) which overcomes the not resetting state back to 0 issue. Unfortunately we can only have 1 wheel in the report ID so the inner touch dial is now a Dial (0x37).

Both of the dials emit -1 (or -2 for some reason) and 1 indicating positive and negative however I don't think Dial can be bound by Key Mapper for example since it has no idea what a Dial is. Not too sure if dials can also be udev/hwdb rebound to something else either.

@kurikaesu
Copy link
Author

@nic3-14159 Agreed, for now I'm just happy enough to have my hardware work in Linux.

hid-uclogic-core.c Outdated Show resolved Hide resolved
@kurikaesu
Copy link
Author

Looked through #351. The 12 Pro and the 13.3 Pro are identical.

Committed the hardware ID to my fork & branch to enable it.

@alfazaz
Copy link

alfazaz commented Aug 22, 2021

@kurikaesu Your commit for the 12 Pro works for me... I think it solves #351.

Thanks !

@Korvox
Copy link

Korvox commented Aug 22, 2021

I don't have a tool test it with nor do I know how to set up tilt in Krita.

Krita natively uses tilt, you can verify its present at least with libinput via libinput record (assuming that is the userspace input driver you are using with the device, of course).

Besides the packet function taking different magic values, is there anything else to be made generic? I rebased and amended my branch with what should be something to just base all other devices off of. Of course timing is funny, I won't have my a156p back to make sure there are no regressions for a week.

@alfazaz
Copy link

alfazaz commented Aug 22, 2021

@kurikaesu @Korvox I saw that tilt also works on my 12 Pro with your work. :-)

@nic3-14159
Copy link

nic3-14159 commented Aug 22, 2021

@Korvox I think the interface that should be used to send the init packet and receive reports might need to be general. As I've said before, I think there are other tablets that I suspect need an init packet which seem to have a different number of interfaces (not 100% sure though). I'll see if I can dig up relevant issues. I don't believe they were XP-Pen though, so it is possible that they require many other changes. But so far, all XP-Pen tablets I've seen use interface 2. I'll also have to check my Star 06 code does anything majorly different in the params init function. (I currently don't have access to my main system, so I'll post my code and check some other things later)

@nic3-14159
Copy link

@Korvox Found it, the Star G960 (#446) reports keyboard events for the frame and has an OUT endpoint on interface 1 (only 2 interfaces). The HID descriptor on interface 1 also appears to be very similar to the interface 2 descriptors on tablets known to need the init packet. All of these are characteristic of tablets needing the init packet, so it does appear that the code needs to support different interfaces in order to support that tablet.

@kurikaesu
Copy link
Author

Last commit makes at least the left dial on the 22R Pro usable.

@nic3-14159 I should be able to handle the G960, just need to update the python script to inject the key on interface 1 and dump the packets that way. I'll make a comment in #446 with the updated script.

As far as different activation keys are concerned, I originally thought my 22R would have a different key so I wrote the function calls with passing of a custom key in mind. I can certainly re-do this, just need to know the second activation key to handle.

@kurikaesu
Copy link
Author

Just tested Key-Mapper which I mentioned above: https://github.com/sezanzeb/key-mapper
Confirming that I can definitely map the inner and right scroll wheel of both the 22R Pro and the Deco Pro SM!

This means for both the Artist 22R Pro and Deco Pro SM all controls are now mappable in Linux!

@kurikaesu kurikaesu changed the title XP-Pen Deco Pro SM, Artist 12, 13.3, 15.6 and 22R Pro Support (WIP) XP-Pen Deco Pro SM, Artist 12, 13.3, 15.6 and 22R Pro Support Aug 25, 2021
@kurikaesu
Copy link
Author

@Korvox @nic3-14159 I'm about ready to squash all of my commits.
How do we want to coordinate this?

Secondly, is Digimend actually dormant again? I saw a post back in 2016 or 17 saying Digimend was being abandoned but then another post in 2018 that said it is being brought back alive. However there hasn't been any merges from PRs in a while now. @spbnick ?

@nic3-14159
Copy link

@kurikaesu I'm personally don't have a problem with you squashing your commits, as they don't really interfere with anything I have. You did pull in support for the 15.6, so you may want to coordinate with Korvox. There was also another commit in #291 to add the interface endpoint address as an argument to the new params init function, so you may want to pull that in as well.

@Korvox
Copy link

Korvox commented Aug 26, 2021

@Korvox @nic3-14159 I'm about ready to squash all of my commits.

Each persons work can just be a separate commit. My work is the oldest so just base your commits off mine.

@kurikaesu
Copy link
Author

Squashed my commits.
I'll rebase once yours are squashed.

@Korvox
Copy link

Korvox commented Aug 26, 2021

It be squashed

@kurikaesu
Copy link
Author

Rebased on top of your commits onto a new branch here: https://github.com/kurikaesu/digimend-kernel-drivers/tree/xppen-artist22r-pro-rebased

Once your PR is merged then I'll do another rebase and pull it into this PR.

@kurikaesu
Copy link
Author

After testing my changes the past few days there is something different with the Art Deco Pro. While the report descriptors appear to be correct and all functions work, the tablet itself does not immediately start working when plugged in. I have to use the dumper tool to sort of activate the tablet after which it will work fine until I disconnect and plug it in again.

I'm guessing there is a piece of the handshake puzzle missing in the digimend driver that the dumper does

@kanashimia
Copy link

kanashimia commented Aug 29, 2021

Deco pro M has different product id: 0904
See #366 for more info dumps.

EDIT: i've tested driver with substituted id, and everything works.
EDIT2: Well it works, but when you use libinput pad buttons are unmapped by default, and when you use wacom drivers it is two wheels that are unmapped.
EDIT3: After aggressively pressing pads physical dial becomes active, wth?

@kanashimia
Copy link

After testing my changes the past few days there is something different with the Art Deco Pro. While the report descriptors appear to be correct and all functions work, the tablet itself does not immediately start working when plugged in. I have to use the dumper tool to sort of activate the tablet after which it will work fine until I disconnect and plug it in again.

I'm guessing there is a piece of the handshake puzzle missing in the digimend driver that the dumper does

I have same problem, and just doing sudo modprobe -r hid-uclogic && sudo modprobe hid-uclogic helps.
What is the dumper tool you are talking about?

@kurikaesu
Copy link
Author

Thanks for reporting the ID. I've added it into my PR as one of the supported devices.

When using libinput it is normal for it to be unbound since the pads buttons are just "button_0", "button_1" etc.
It allows you to fully bind the pad to do whatever. This is in contrast to using the default bindings that are available but restrict you on what you can change the bindings to. For example, if a button produces a keypress of "B" then it can only be substituted by another single keypress. Can't be changed into something like "shift+space" as an example.

The "button_0", "button_1"... unbound libinput gives you full flexibility at the cost of having no default bindings as I haven't provided any.

Dumper tool I am talking about is usbhid-dump: https://github.com/DIGImend/usbhid-dump
Used like sudo usbhid-dump --entity=stream --model=28bd

Ideally the driver should not have to be unloaded in order for the tablet to work when plugged in (this is what modprobe -r does)

@kurikaesu
Copy link
Author

kurikaesu commented Sep 2, 2021

Latest commit fixes the deco pro small (and probably medium) on-connect issues. The tablet for whatever reason sends through a blank message on Report ID 1 and report ID 6 before switching over to using the unified interface. This causes the driver to block receiving new messages until the interface is reset by either using a tool to forcefully detach and claim the device and release it or other methods.

Implementing the report descriptors for interface 0 which receives the report id 1 and 6 fixes the connection issues. This means that the tablet should start working on plug in without having to do any fiddling around (other than of course making sure to bind all of the buttons and wheel).

There is also something that has changed recently and I don't know why but the touch-dial on the Deco Pro is now reporting as a mouse input on interface 0 (even if we use the key to get all the stylus movements, buttons and dial reporting on interface 2). Very odd! I tested this behavior before my most recent commit so the changes I added didn't introduce this weird behavior.

@kurikaesu
Copy link
Author

For those who come here and have an Artist 22R Pro, consider testing out my userland drivers here: https://github.com/kurikaesu/xp-pen-userland

It comes with a configuration gui here: https://github.com/kurikaesu/xp-pen-userland-config-util

I'll add support for all of the devices listed in this PR in my userland drivers as time goes on.

@alfazaz
Copy link

alfazaz commented Sep 8, 2021

Thanks in advance for your work for the artist 12 pro which I will be able to test when it will be released.

@kurikaesu
Copy link
Author

I have just added support for the Artist 12 Pro and the 24 Pro but I can't test them since I don't own either product.
If you do test them and find issues, create an issue in my corresponding repository. Don't post issues here.

@kanashimia
Copy link

So what i have found out:

When you hover with pen then both wheels don't work, it is like if touch arbitration is in place, really annoying.
There is no such problem when using wacom driver.

Wheels don't work while using wacom driver, but when you press pads many times very fast - physical dial starts working, while touch dial doesn't. Not sure what is going.

By default udev assigns ID_INPUT_KEY=1 to pads, but if you modify hwdb like this:

id-input:modalias:input:b0003v28BDp0904e0100-e0,1,2,4*r6*
  ID_INPUT_TABLET=1
  ID_INPUT_TABLET_PAD=1
  ID_INPUT_KEY=0

(supposed to match only *Pad) then pads start emitting events, and wheels stop working.
Changing ID_INPUT* stuff doesn't seem to do anything while using wacom driver.

@kurikaesu
Copy link
Author

kurikaesu commented Sep 11, 2021

The Deco Pro is pretty special in how it functions behind the scenes. It appears there is an on-device bit that can be set by the official driver. I haven't captured the bit yet, just tested the effects of switching it around.

The process I went through was:
Plug Deco Pro into Windows computer => Change touch to <X> and hit OK => Unplug from Windows computer and plug into Linux computer => Execute sudo usbhid-dump --entity=stream --model=28bd and note the stream output.

Just for reference, interface 1 is 0x00.

When <X> is set to "mouse", outputs come out of interface 2 (0x01) and produce X, Y coordinates:

001:015:000:STREAM             1631326995.444260
 01 00 FB FF FF FF 00 00

When <X> is set to "roller", then it still outputs from interface 2 (0x01) but emulates the scroll wheel:

001:016:000:STREAM             1631327086.714873
 01 00 00 00 00 00 01 00

001:016:000:STREAM             1631327086.898879
 01 00 00 00 00 00 FF 00

When <X> is set to "customized" then it will output from interface 3 (0x02) and share the same bitmap field as the dial:

001:017:002:STREAM             1631327213.877488
 02 F0 00 00 00 00 00 04 00 00

001:017:002:STREAM             1631327214.047540
 02 F0 00 00 00 00 00 08 00 00

If you haven't used the tablet with the official drivers yet and changed the default behavior then the tablet will probably be in mouse mode. Since mouse mode and roller mode share the same interface, we would have to have bytes 3 to 7 all mapped in the resource descriptor.

If you are using the code before beb79ff then whenever you use the touch pad it will likely be sending a message through interface 2 which the driver up until the above commit doesn't read. Since it doesn't parse it the whole device "hangs" while it waits for something to parse the message.

The above commit will interpret the message as mouse movements but that isn't mapped to anything and its unlikely the wacom driver will know what to do with it either.

I'm not providing a fix for this in this DIGImend PR, just writing out research notes and explanations.

@kurikaesu
Copy link
Author

Just finished adding support for the Deco Pro SM and MD (MD is unconfirmed, someone please test).
I don't send in the necessary message to change the touch-pad to "Customized" which means it will support the tablet in whatever configuration it is set at, be it "mouse", "roller" or "customized".

Configuration GUI also supports setting up the bindings but again, if the touch-pad is not set to customized then the touch pad binding will not be in effect.

@kanashimia
Copy link

[..] but if you modify hwdb like this:
[..] then pads start emitting events, and wheels stop working.

I figured it out, it is a problem with libinput, it doesn't handle EV_REL events for tablet pad, you can see it when you run libinput debug-events

@kurikaesu kurikaesu closed this Mar 1, 2022
@kurikaesu kurikaesu deleted the xppen-artist22r-pro branch March 1, 2022 08:40
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this pull request Dec 26, 2022
Adds support for the  XP-PEN Artist 22R Pro in uclogic, including the stylus,
frame and pen pressure support.

I did not do the research for this hardware, or the original patch - that work
has been done by Aren Villanueva. For some reason they decided not to merge
it. My changes include remapping the stupid amount of tablet frame buttons,
cleaning up the code to match kernel style, and other small stuff.

The tablet is (almost) fully functional even when uclogic doesn't handle it.
Without initialization, the tablet has some sort of "basic driverless mode"
that allows the tablet frame buttons to have some default keys associated with
them (CTRL-S, CTRL-Z, that kind of stuff), but unfortunately the stylus pen
semi-works. While pressure sensitivity works, only one stylus button functions
correctly. Since the initialization process differs for Pro series tablets, the
new function uclogic_params_init_ugee_xppen_pro had to be introduced. I also
added USB HID IDs for this tablet too, but it's classified under the UGEE
vendor ID.

One of the more strange things I had to do is figure out a way to remap the
buttons since there are 20 of them in total, and of course there are more
buttons than there are BTN constants defined for us. When running without
uclogic, it starts at BTN_0, ends at BTN_8 and the tablet starts reporting
nonsensical keycodes so just leaving it alone isn't an option. I'm testing
this under a libinput system, which has a list of buttons it considers "tablet
pad buttons" which are notably BTN_0, BTN_1, so on and some
gamepad/joystick buttons. So I created a new array called
uclogic_extra_input_mapping for 20 working inputs.

Another weird feature of this tablet is the second dial, which the original
patchset introduced a new uclogic_frame param to handle since it seems it
throws both dials values into one byte. The left wheel is considered EV_WHEEL
and the other, EV_HWHEEL which seems fine to me. I also added the new param to
the debug messages too.

Link: DIGImend/digimend-kernel-drivers#557
Signed-off-by: Joshua Goins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants