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

Add support for GAOMON PD1560 #110

Open
loentar opened this issue Jan 17, 2018 · 35 comments
Open

Add support for GAOMON PD1560 #110

loentar opened this issue Jan 17, 2018 · 35 comments

Comments

@loentar
Copy link

loentar commented Jan 17, 2018

pd1560 is an high-precision pen display produced by Gaomon company.

This pen display is recognized by this driver as HUION tablet and partially works in compatibility mode. Pressure sensor is not fully working (cropped at 2047 but max is 8191) as well as the last button is cannot be bound with xsetwacom because it is recognized as X axis.

With the pull request #114 which enables high-precision mode for HUION tablets issues with pressure and buttons are fixed. But it introduces another issue. This tablet has maximum X = 68834 which cause 16-bit overflow and it's not usable on the very right side (cursor jumps back to the left side after x> 65535).

As temporary fix I applied this code in uclogic_raw_event:

if (data[0] == 0x08 && (data[1] & 0xFE) == 0x80 && drvdata->is_hires && size >= 12) {
    // fix tablet
    u16 *data16 = (u16*)data;
    data16[1] = ((data16[1] >> 1) & 0x7FFF) | (data16[4] << 15);
    data16[2] = ((data16[2] >> 1) & 0x7FFF) | (data16[5] << 15);
    data16[4] = 0;
    data16[5] = 0;
}

As @anpaza mentioned in that pull request, 32-bit mode is the correct way to work with this tablet. But it needs to detect this model and re-mix the bytes to make the event HID-compliant.

The string 0x79 is not actually string and contains value 0x03. Also there is another string number 0xC9 which looks like some OEM id:

 c9 |      Unknown string #1: OEM02_M177_170831
@loentar loentar changed the title GAOMON PD1560 button mapping Add support for GAOMON PD1560 Feb 11, 2018
@loentar
Copy link
Author

loentar commented Feb 11, 2018

Output generated by uclogin-tools:

uclogic-decode-gaomon-pd1560.txt
uclogic-probe-gaomon-pd1560.txt

@Eqlipse
Copy link

Eqlipse commented Mar 3, 2018

Out of curiosity, how did you get your system to even see it as a HUION product? Mine doesn't even show up using "xsetwacom list."

Here's what shows up under some simple investigations:
Using xinput...

eqlipse@eqlipse-Secondary-Linux:$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Tablet Monitor Pad id=8 [slave pointer (2)]
⎜ ↳ Logitech M570 id=10 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=11 [slave pointer (2)]
⎜ ↳ ckb1: Corsair STRAFE Gaming Keyboard id=12 [slave pointer (2)]
⎜ ↳ ckb1: Corsair STRAFE Gaming Keyboard id=13 [slave pointer (2)]
⎜ ↳ Tablet Monitor Pen Pen (0) id=16 [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)]
↳ Tablet Monitor Pen id=9 [slave keyboard (3)]
↳ ckb1: Corsair STRAFE Gaming Keyboard id=14 [slave keyboard (3)]
↳ ckb1: Corsair STRAFE Gaming Keyboard id=15 [slave keyboard (3)]
eqlipse@eqlipse-Secondary-Linux:$ xinput query-state 8
2 classes :
ButtonClass
button[1]=up
button[2]=up
button[3]=up
button[4]=up
button[5]=up
button[6]=up
button[7]=up
button[8]=up
button[9]=up
button[10]=up
button[11]=up
button[12]=up
button[13]=up
ValuatorClass Mode=Absolute Proximity=In
valuator[0]=0
valuator[1]=0
valuator[2]=0
valuator[3]=0
valuator[4]=0
valuator[5]=0
valuator[6]=0
eqlipse@eqlipse-Secondary-Linux:~$ xinput list-props 8
Device 'Tablet Monitor Pad':
Device Enabled (141): 1
Coordinate Transformation Matrix (143): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Send Events Modes Available (261): 1, 0
libinput Send Events Mode Enabled (262): 0, 0
libinput Send Events Mode Enabled Default (263): 0, 0
Device Node (264): "/dev/input/event7"
Device Product ID (265): 9580, 110

Using evtest...

eqlipse@eqlipse-Secondary-Linux:~$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: Power Button
/dev/input/event1: Power Button
/dev/input/event2: Logitech M570
/dev/input/event3: ckb1: Corsair STRAFE Gaming Keyboard
/dev/input/event4: ckb1: Corsair STRAFE Gaming Keyboard
/dev/input/event5: Logitech USB-PS/2 Optical Mouse
/dev/input/event6: Tablet Monitor Pen
/dev/input/event7: Tablet Monitor Pad
/dev/input/event8: HDA ATI HDMI HDMI/DP,pcm=3
/dev/input/event9: HDA ATI HDMI HDMI/DP,pcm=7
/dev/input/event10: HDA ATI HDMI HDMI/DP,pcm=8
/dev/input/event11: HDA ATI HDMI HDMI/DP,pcm=9
/dev/input/event12: HDA ATI HDMI HDMI/DP,pcm=10
/dev/input/event13: HDA ATI HDMI HDMI/DP,pcm=11
/dev/input/event14: HDA ATI SB Rear Mic
/dev/input/event15: HDA ATI SB Front Mic
/dev/input/event16: HDA ATI SB Line
/dev/input/event17: HDA ATI SB Line Out Front
/dev/input/event18: HDA ATI SB Line Out Surround
/dev/input/event19: HDA ATI SB Line Out CLFE
/dev/input/event20: HDA ATI SB Line Out Side
/dev/input/event21: HDA ATI SB Front Headphone
Select the device event number [0-21]: 7
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x256c product 0x6e version 0x111
Input device name: "Tablet Monitor Pad"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 256 (BTN_0)
Event code 257 (BTN_1)
Event code 258 (BTN_2)
Event code 259 (BTN_3)
Event code 260 (BTN_4)
Event code 261 (BTN_5)
Event code 262 (BTN_6)
Event code 263 (BTN_7)
Event code 264 (BTN_8)
Event code 331 (BTN_STYLUS)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 0
Min 0
Max 1
Event code 1 (ABS_Y)
Value 0
Min 0
Max 1
Event code 40 (ABS_MISC)
Value 0
Min 0
Max 1
Event type 4 (EV_MSC)
Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)

Edit: and pressing the buttons while testing with evdev shows..

Event: time 1520051395.431211, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1520051395.431211, type 1 (EV_KEY), code 256 (BTN_0), value 1
Event: time 1520051395.431211, -------------- SYN_REPORT ------------
Event: time 1520051395.599210, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1520051395.599210, type 1 (EV_KEY), code 256 (BTN_0), value 0
Event: time 1520051395.599210, -------------- SYN_REPORT ------------
Event: time 1520051402.543255, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1520051402.543255, type 1 (EV_KEY), code 257 (BTN_1), value 1
Event: time 1520051402.543255, -------------- SYN_REPORT ------------
5k earlier.Event: time 1520051402.733251, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1520051402.733251, type 1 (EV_KEY), code 257 (BTN_1), value 0
Event: time 1520051402.733251, -------------- SYN_REPORT ------------
Event: time 1520051405.961273, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1520051405.961273, type 1 (EV_KEY), code 258 (BTN_2), value 1
Event: time 1520051405.961273, -------------- SYN_REPORT ------------
Event: time 1520051406.151273, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1520051406.151273, type 1 (EV_KEY), code 258 (BTN_2), value 0
Event: time 1520051406.151273, -------------- SYN_REPORT ------------
Event: time 1520051406.727276, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90004
Event: time 1520051406.727276, type 1 (EV_KEY), code 259 (BTN_3), value 1
Event: time 1520051406.727276, -------------- SYN_REPORT ------------
Event: time 1520051406.887276, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90004
Event: time 1520051406.887276, type 1 (EV_KEY), code 259 (BTN_3), value 0
Event: time 1520051406.887276, -------------- SYN_REPORT ------------
Event: time 1520051407.529280, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90005
Event: time 1520051407.529280, type 1 (EV_KEY), code 260 (BTN_4), value 1
Event: time 1520051407.529280, -------------- SYN_REPORT ------------
Event: time 1520051407.933282, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90005
Event: time 1520051407.933282, type 1 (EV_KEY), code 260 (BTN_4), value 0
Event: time 1520051407.933282, -------------- SYN_REPORT ------------
Event: time 1520051409.527292, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90007
Event: time 1520051409.527292, type 1 (EV_KEY), code 262 (BTN_6), value 1
Event: time 1520051409.527292, -------------- SYN_REPORT ------------
Event: time 1520051409.741292, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90007
Event: time 1520051409.741292, type 1 (EV_KEY), code 262 (BTN_6), value 0
Event: time 1520051409.741292, -------------- SYN_REPORT ------------
Event: time 1520051410.087296, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90008
Event: time 1520051410.087296, type 1 (EV_KEY), code 263 (BTN_7), value 1
Event: time 1520051410.087296, -------------- SYN_REPORT ------------
Event: time 1520051410.301295, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90008
Event: time 1520051410.301295, type 1 (EV_KEY), code 263 (BTN_7), value 0
Event: time 1520051410.301295, -------------- SYN_REPORT ------------
Event: time 1520051410.663298, type 4 (EV_MSC), code 4 (MSC_SCAN), value d0020
Event: time 1520051410.663298, type 1 (EV_KEY), code 264 (BTN_8), value 1
Event: time 1520051410.663298, -------------- SYN_REPORT ------------
Event: time 1520051410.845298, type 4 (EV_MSC), code 4 (MSC_SCAN), value d0020
Event: time 1520051410.845298, type 1 (EV_KEY), code 264 (BTN_8), value 0
Event: time 1520051410.845298, -------------- SYN_REPORT ------------
Event: time 1520051411.331302, type 3 (EV_ABS), code 0 (ABS_X), value 1
Event: time 1520051411.331302, -------------- SYN_REPORT ------------
Event: time 1520051411.525302, type 3 (EV_ABS), code 0 (ABS_X), value 0
Event: time 1520051411.525302, -------------- SYN_REPORT ------------

@loentar
Copy link
Author

loentar commented Mar 3, 2018

Probably it was captured by evdev driver.

Try to edit your /usr/share/X11/xorg.conf.d/10-evdev.conf commenting out the tablet section like this:

#Section "InputClass"
#        Identifier "evdev tablet catchall"
#        MatchIsTablet "on"
#        MatchDevicePath "/dev/input/event*"
#        Driver "evdev"
#EndSection

Also I've added a new conf like this:
/usr/share/X11/xorg.conf.d/52-tablet.conf:

Section "InputClass"
  Identifier "GAOMON"
  MatchUSBID "256c:006e"
  MatchDevicePath "/dev/input/event*"
  Driver "wacom"
EndSection

Also more correct (but still hacky) modification of the driver:

if (data[0] == 0x08 && (data[1] & 0xF0) == 0x80 && drvdata->is_hires && size >= 12) {
    u16 *data16 = (u16*)data;
    data16[1] = (u16)(((((u32) data16[1] & 0xffff) | ((u32) data16[4] << 16)) * 100 / 106));
    data16[4] = 0;
}

@Eqlipse
Copy link

Eqlipse commented Mar 3, 2018

I do not have a /usr/share/X11/xorg.conf.d/52-tablet.conf

However, I do seem to have an equivalent /usr/share/X11/xorg.conf.d/70-wacom.confand placing the suggested 52-tablet.conf change in there, as well as disabling the evdev capture seemed to work.

xsetwacom can now see and interact with the tablet ^_^ Thanks!

However, directly tinkering with the drivers on LInux is something I've never done before. Where exactly would I be inserting that if-then line of coding?

@loentar
Copy link
Author

loentar commented Mar 4, 2018

Well.. I applied it over anpaza's repository. Here is short instruction (didn't checked it):

mkdir -p ~/install
cd ~/install
git clone https://github.com/anpaza/digimend-kernel-drivers.git digimend-kernel-drivers-gaomon
cd digimend-kernel-drivers-gaomon
mcedit +736 hid-uclogic-core.c

Copy and paste lines in my previous comment before this line:

if (drvdata->has_virtual_pad_interface && (data[1] & 0x20))

save and exit.

Then compile and install driver like this:

sudo rmmod hid-uclogic
make clean
make
sudo make install
sudo modprobe hid-uclogic

Also I have this script to initialize device parameters. The pen display is configured to be second display to the right of main display:

#!/bin/bash

keyboard="Huion  Tablet Pad pad"
tablet="Huion  Tablet Pen stylus"

bindings=(
"+shift"
"+ctrl"
"+z" # undo
"+x" # redo

"/"  # last brush
";"  # last layer

"+e"
"+a"
"+home"
"+m"
)

buttons=(1 2 3 8 9 10 11 12 13 14)

i=0
for binding in "${bindings[@]}"
do
  xsetwacom --set "$keyboard" Button ${buttons[$((i++))]} key $binding
done

xinput set-prop "$tablet" --type=float "Coordinate Transformation Matrix" 0.5 0 0.5 0 1 0 0 0 1
xsetwacom --set "$tablet" Area 200 0 65100 38500
xsetwacom --set "$tablet" Button 2 button +2
xsetwacom --set "$tablet" Button 3 button +3

@Eqlipse
Copy link

Eqlipse commented Mar 18, 2018

Sorry for the late reply. Thanks, that did the trick! Now it's seeing the full sensitivity range, too, or at least much better than it had before (something I previously forced myself to "get used to" instead). Of course I switched up the keybindings to suite my preferences.

Some of those variables I'll have to look into, such as the "Coordinate Transformation Matrix." I like to know what's actually being done inside the code, after all. :)

@spbnick
Copy link
Member

spbnick commented May 4, 2018

@danghai, do you think you could add this tablet to the tablets repo?

@spbnick
Copy link
Member

spbnick commented May 4, 2018

Everyone concerned with this issue, you're welcome to join the new #DIGImend channel on irc.freenode.net, discuss this and other issues, and help each other! Come and say "Hi!"

@veryprofessionaldodo
Copy link

I just recently bought this device, and it works great! Though there are two things that are really bugging me, and one of them is really strange... If I go to Windows, and then switch back to Linux, the Tablet will not recognize anything the stylus does.
Evtest shows absolutely nothing. I need to power down the pc, wait for it to drain all power, and then if I restart back into Linux, everything is working fine again...

The other thing is that Windows show significantly less lag on input. I already tweaked the Sample and Supress values of the xinput, and that fixed a great deal (why was it so smoothed out in the first place, I find it really strange).

Does anyone know how to improve latency of this device? Sorry for necro-ing this old thread, but I'm really at a loss, I much rather work on Linux over Windows.

@veryprofessionaldodo
Copy link

Okay, so quick answer to my previous comment in regards to that strange Windows thing. To solve it you need to have the Windows Gaomon driver UNINSTALLED. Uninstalled it now, powered down pc, restarted, switched OSes without a hitch. I have a feeling though that the lag just might be something out of my reach... Will report later!

@maxim-sheronov
Copy link

Hi. Maybe it can help. I have similar problem, that tablet does not recognize the pen. To fix it, I have to do:
sudo rmmod hid-uclogic
sudo modprobe hid-uclogic

And then it works.

@veryprofessionaldodo
Copy link

Thanks! Do you know of a way of reducing pen latency though? That is my biggest concern right now... If I can't get this at least imperceptibly on par with Windows, then I'm going to have to work there, which I really didn't want...

@danghai
Copy link
Member

danghai commented May 5, 2018

@spbnick Yeah sure.
@loentar Hello, could you help me provide information about descriptor, frame_buttons, pen_buttons, pen_coords, pen_pressure, pen_tilt, hid_report_descriptors? Thanks a lot

@veryprofessionaldodo
Copy link

@danghai I can't right now, but I'll do that tomorrow in the afternoon. Thanks for the help!

@veryprofessionaldodo
Copy link

veryprofessionaldodo commented May 5, 2018

But just to make sure, you would like the output of xinput, and maybe lsusb? I can also present xsetwacom --list devices, a little bit of evtest, and the list-props of both the pen and the display.

@loentar
Copy link
Author

loentar commented May 5, 2018

@danghai sorry, I do not own this device anymore.

@veryprofessionaldodo
Copy link

What a brainfart, I didn't read the tags and thought you were talking to me, @danghai... Sorry guys!

@danghai
Copy link
Member

danghai commented May 6, 2018

@veryprofessionaldodo
Copy link

Okay, so this was what I can give to you, I followed the guide you recommended thoroughly, and these were the files that have all the info. Thanks for the help :)

test_results.txt
pen_buttons.txt
pen_coords.txt
pen_pressure.txt
frame_wheel_srolling.txt

@danghai
Copy link
Member

danghai commented May 8, 2018

@veryprofessionaldodo Thanks, would you mind to provide your probe.txt? You can review the command from there: https://github.com/DIGImend/uclogic-tools to get information your probe. Thanks

@veryprofessionaldodo
Copy link

They present an error, described here.

probe.txt

@spbnick
Copy link
Member

spbnick commented May 8, 2018

@veryprofessionaldodo, could you please use the latest development version of uclogic-tools from here: https://github.com/DIGImend/uclogic-tools/archive/master.zip (I need to make a release of that).

@veryprofessionaldodo
Copy link

I had installed it from the AUR, but it looks like it isn't that up to date. I uninstalled my previous version, installed directly from the repository, and now I get these results.

probe.txt

@veryprofessionaldodo
Copy link

veryprofessionaldodo commented May 16, 2018

And I think I got it. The difference in latency in Windows is barely perceptible, and something I'll easily get used to. I have made this script in case anyone wants to use it, with button bindings made for Krita.

This is my particular setup in terms of display, if you want to know more about the coordinate transformation matrix go here https://github.com/linuxwacom/xf86-input-wacom/wiki/Dual-and-Multi-Monitor-Set-Up

gaomon.zip

@teleportingtortoise
Copy link

teleportingtortoise commented Jul 14, 2018

Tried @loentar 's driver fix but got issue #160 instead when trying to compile.

@spbnick
Copy link
Member

spbnick commented Jul 14, 2018

@teleportingtortoise
Copy link

@spbnick Thank you, the new release seems to work with this pen display without any noticeable issues.

@jonnor
Copy link

jonnor commented Apr 2, 2020

So it seems the PD1560 works OK for a while. Does anyone know if the smaller version, PD1161 can work also?

@dexter30
Copy link

@jonnor I just tried it out with my PD1161 on manjaro. Seems to work all fine. Just getting the transformation set up now.

@BloodyMess
Copy link

What about the PD2200? Thinking of getting it, or one of the XP-Pen Artist 22 Pro models, but I want to be sure it will work on linux first.

@loentar
Copy link
Author

loentar commented Jan 24, 2021

@BloodyMess As I remember PD1650 had noticable lags and pen offset with digimend drivers when comparing to windows version.

XP-PEN 22E HD Pro still works well for me, see #168 for details. I use it almost every day. There is a newer version of this display on market, can't say anything about it.

@BloodyMess
Copy link

@BloodyMess As I remember PD1650 had noticable lags and pen offset with digimend drivers when comparing to windows version.

XP-PEN 22E HD Pro still works well for me, see #168 for details. I use it almost every day. There is a newer version of this display on market, can't say anything about it.

@loentar Have you tried the methods that @veryprofessionaldodo and @teleportingtortoise say they've had success with?

I went ahead and ordered the PD2200. I would have gone with the XP-Pen 22E, but it doesn't have support for detecting/reporting stylus tilt. It also isn't fully laminated, and I don't want to deal with parallax.

@loentar
Copy link
Author

loentar commented Jan 25, 2021

@BloodyMess Unfortunately no, I sold it before theirs solution. I wanted a larger pen display with better characteristics at that moment.

Well, if you haven't had a pen display before, the parallax effect is unavoidable. The difference between PD1650 and 22E was very noticable. PD1650 had a parallax gap about 2.5mm in worst case on the right bottom edge.

I'm not sure if the "laminate" technology can solve the parallax effect, because it's more connected to the display itself not the pen sensor. But I hope they greatly improved their sensor, 3 years is a pretty long period to make it work better.

Once you have a chance to try PD2200, please say how it works for you.

@NamesNetworkNic
Copy link

This issue hasn't been updated in a long time. Has their been any developments?

@veryprofessionaldodo
Copy link

@NamesNetworkNic I haven't had any problems with my Gaomon PD1560 on Linux, using standard drivers and digimend-drivers-git-dkms from AUR.

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

No branches or pull requests