joseluis / huion-linux-drivers

Linux user-space drivers for Huion Graphic Tablets
MIT License
168 stars 95 forks source link

Multi-monitor xinput error using GT-116 #86

Open joymachs opened 4 years ago

joymachs commented 4 years ago

Hello everyone. I'm trying to configure the multi-monitor settings for 2 monitors (notebook:1366x768 and tablet:1920x1080), but I'm having a hard time. I suspect it has something about the screen size calculations and I looked inside the .py code to try to understand what I could be doing wrong, but I didn't get it.

Here is my debug log:

Finding USB device. . . Done! Reading configuration. . . Done! Setting up driver. . . Done! Tablet model name GT-116 Buttons ENABLED (4) Scrollbar ENABLED (1) Notifications: ENABLED for buttons ENABLED for scrollbar disabled Screen Enabled (1920x1080) Current Monitor Setup [monitor_2] Multi Monitor Setup ENABLED Calling xrandr disabled Calibrate Mapping ENABLED

          < DEBUG MODE ENABLED >
Enabled by default. You can disable it by setting debug_mode = false

SYSTEM: Linux 5.4.0-37-generic (x86_64 x86_64)

41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020

DEVICE: /dev/input/event15 (py-evdev-uinput) bus: 0003, vendor 0001, product 0001, version 0003

  ENDPOINT 0x81: Interrupt IN ==========================
   bLength          :    0x7 (7 bytes)
   bDescriptorType  :    0x5 Endpoint
   bEndpointAddress :   0x81 IN
   bmAttributes     :    0x3 Interrupt
   wMaxPacketSize   :   0x40 (64 bytes)
   bInterval        :    0x2

TABLET CAPABILITIES: [('SYN_REPORT', 0), ('SYN_CONFIG', 1), ('SYN_DROPPED', 3), ('?', 21)] [(['BTN_DIGI', 'BTN_TOOL_PEN'], 320), ('BTN_TOUCH', 330), ('BTN_STYLUS', 331), ('BTN_STYLUS2', 332)] [(('ABS_X', 0), AbsInfo(value=0, min=0, max=53580, fuzz=0, flat=0, resolution=5080)), (('ABS_Y', 1), AbsInfo(value=0, min=0, max=33640, fuzz=0, flat=0, resolution=5080)), (('ABS_PRESSURE', 24), AbsInfo(value=0, min=0, max=8191, fuzz=0, flat=0, resolution=0)), (('ABS_TILT_X', 26), AbsInfo(value=0, min=0, max=255, fuzz=0, flat=0, resolution=0)), (('ABS_TILT_Y', 27), AbsInfo(value=0, min=0, max=255, fuzz=0, flat=0, resolution=0))]

VPEN: name "Tablet Monitor Pen 213417", bus "BUS_USB", vendor "0001", product "0001", version "0003", phys "py-evdev-uinput" event types: EV_SYN EV_KEY EV_ABS

XINPUT: ⎜ ↳ Tablet Monitor Pen 213233 Pen (0) id=16 [slave pointer (2)] ↳ Tablet Monitor Pen 213233 id=15 [slave keyboard (3)] ↳ Tablet Monitor Pen 213417 id=17 [slave keyboard (3)]

Setting up multiple monitors. . . Running xinput. . . » xinput set-prop "Tablet Monitor Pen 213417" --type=float "Coordinate Transformation Matrix" 0.5842970176506391 0 0.4157029823493609 0 1.40625 0.0 0 0 1 X Error of failed request: BadMatch (invalid parameter attributes) Major opcode of failed request: 131 (XInputExtension) Minor opcode of failed request: 57 () Serial number of failed request: 20 Current serial number in output stream: 21 ERROR running the following comand: xinput set-prop "Tablet Monitor Pen 213417" --type=float "Coordinate Transformation Matrix" 0.5842970176506391 0 0.4157029823493609 0 1.40625 0.0 0 0 1 RETURN CODE: 1

And here is my config.ini:

# Configuration settings for:
# Linux Drivers for Huion Kamvas Tablets
# at github.com/joseluis/huion-linux-drivers
#
#  1 Main Configuration
#  2 Buttons Menus
#  3 Monitor Setups
#  4 Supported Tablets

#
# 1 MAIN CONFIGURATION:
# -----------------------------------------------------------------------------

[config]

# Your tablet. Find the supported models at the end of this file.
# Or use [tablet_debug] for just printing input info for sharing.
# gt116 is Huion Kamvas Pro 12
current_tablet = [tablet_gt116]  

# Configure buttons
enable_buttons          = true
pen_buttons_reverse     = false

# Configure scrollbar
enable_scrollbar        = true
scrollbar_reverse       = false

# Multi Monitor Configuration
enable_multi_monitor    = true
enable_xrandr           = false
current_monitor_setup   = [monitor_2]

# Calibrate via Mapping
enable_calibrate_mapping = true

# Calibration via Data
enable_calibration      = false
calibrate_min_x         = 250
calibrate_max_x         = 95250
calibrate_min_y         = 300
calibrate_max_y         = 53400

# Notifications
enable_notifications    = true
buttons_notifications   = true
scrollbar_notifications = false

# Miscellaneus
uclogic_bins            = /usr/local/bin
refresh_rate_fps        = 300

debug_mode              = true

# Here you can select a menu with the appropriate number of buttons for your tablet. E.g.:
#start_menu              = [menu_simple_4b]
#start_menu              = [menu_main_10b]
start_menu              = [menu_krita_5b]

#
# 2 BUTTONS MENUS:
# -----------------------------------------------------------------------------

[menu_simple_4b]
b0 = key Tab           # hide interface
b1 = key r             # rect select (gimp) & pick layer (krita)
b2 = key ctrl+z        # undo
b3 = key ctrl+y        # redo (gimp)
#
# scrollbar (up/down)
su = key ctrl+minus    # zoom out (krita)
sd = key ctrl+plus     # zoom in (krita)

[menu_simple_10b]
# upper buttons
b0 = key Tab           # hide interface
b1 = key r             # rect select (gimp) & pick layer (krita)
b2 = key ctrl+x        # cut
b3 = key ctrl+c        # copy
b4 = key ctrl+v        # paste
#
# scrollbar (up/down)
su = key ctrl+minus    # zoom out (krita)
sd = key ctrl+plus     # zoom in (krita)
#
# lower buttons
b5 = key ctrl+z        # undo
b6 = key ctrl+y        # redo (gimp)
b7 = key ctrl+shift+z  # redo (krita)
b8 = key 4             # turn left (krita)
b9 = key 6             # turn right (krita)

[menu_simple_14b]
# upper buttons
b0 = key Tab           # hide interface
b1 = key r             # rect select (gimp) & pick layer (krita)
b2 = key ctrl+x        # cut
b3 = key ctrl+c        # copy
b4 = key ctrl+v        # paste
b5 = key ctrl+z        # undo
b6 = key ctrl+y        # redo (gimp)
b7 = key ctrl+shift+z  # redo (krita)
#
# scrollbar (up/down)
su = key ctrl+minus    # zoom out (krita)
sd = key ctrl+plus     # zoom in (krita)
#
# lower buttons
b8  = key 4            # turn left (krita)
b9  = key 6            # turn right (krita)
b10 =
b11 =
b12 =
b13 =
b14 =

# Main menu that links to other sub-menus (DEFAULT MENU) (10 buttons)
[menu_main_10b]
title = % Main Menu %
b0 = [menu_krita]
b1 = [menu_gimp]
b2 = [menu_darktable]
b3 =
b4 =
#
su = click 4           # mouse wheel up
sd = click 5           # mouse wheel down
#
b5 = [menu_vlc]
b6 =
b7 = key Escape
b8 = key Return
b9 = [menu_main]

[menu_krita]
# https://defkey.com/krita-shortcuts
title = % Krita %
b0 = [menu_krita_draw]
b1 = [menu_krita_edit]
b2 =
b3 = key Insert        # new paint layer
b4 = key F5            # export
#
su = key ctrl+minus    # zoom out
sd = key ctrl+plus     # zoom in
#
b5 = key ctrl+alt+s    # save incremental
b6 = key ctrl+s        # save
b7 = key ctrl+w        # close
b8 = key ctrl+o        # open
b9 = [menu_main]

[menu_krita_draw]
title = % Krita - DRAW %
b0 = key Tab           # hide interface
b1 = key b             # draw tool
b2 = key p             # select color
b3 = key ctrl+g        # new group
b4 = key e             # erase mode
#
su = key ctrl+minus    # zoom out
sd = key ctrl+plus     # zoom in
#
b5 = key ctrl+z        # undo
b6 = key ctrl+shift+z  # redo
b7 = key 4             # rotate left
b8 = key 6             # rotate right
b9 = [menu_krita]

[menu_krita_edit]
title = % Krita - EDIT %
b0 = key Tab           # hide interface
b1 =
b2 = key ctrl+r        # select square
b3 =
b4 =
#
su = key ctrl+minus    # zoom out
sd = key ctrl+plus     # zoom in
#
b5 = key ctrl+x        # cut
b6 = key ctrl+c        # copy
b7 = key ctrl+alt+c    # copy merged
b8 = key ctrl+v        # paste
b9 = [menu_krita]

[menu_krita_5b]
b0 = key Tab            # hide interface
b1 = key ctrl           # color selection tool (krita)
b2 = key ctrl+z         # undo
b3 = key ctrl+shift+z   # redo (krita)
b4 = key e              # eraser toggle (krita)
su = key ctrl+minus     # zoom out (krita)
sd = key ctrl+plus      # zoom in (krita)

[menu_gimp]
# http://www.gimpusers.com/gimp/hotkeys
title = % Gimp %
b0 = key Tab           # hide interface
b1 = key p             # paintbrush
b2 = key r             # rect select
b3 = key c             # clone
b4 = key shift+e       # eraser
#
su = key minus         # zoom out
sd = key plus          # zoom in
#
b5 = key ctrl+z        # undo
b6 = key ctrl+y        # redo
b7 = key x             # swap colors
b8 = key shift+r       # rotate
b9 = [menu_main]

[menu_darktable]
# https://www.darktable.org/usermanual/en/shortcuts.html
title = % DarkTable %
b0 = key Tab           # toggle side borders
b1 = key ctrl+h        # toggle header
b2 =
b3 = key ctrl+e        # export
b4 = key period        # switch view
#
su = key alt+3         # zoom out
sd = key alt+2         # zoom in
#
b5 = key ctrl+z        # undo
b6 = key ctrl+y        # redo
b7 = key Return        # image operations/clipping/commit
b8 = key Escape
b9 = [menu_main]

[menu_vlc]
# http://www.vlcshortcuts.com/
title = % VLC  %
b0 = key f            # fullscreen
b1 = key space        # play / pause
b2 = key ctrl+Left    # 60s rewind (1m)
b3 = key alt+Left     # 10s rewind
b4 = key shift+Left   # 3s rewind
#
su = key ctrl+Up      # volume up
sd = key ctrl+Down    # volume down
#
b5 = key shift+Right  # 3s forward
b6 = key alt+Right    # 10s forward
b7 = key ctrl+Right   # 60s forward (1m)
b8 = key ctrl+s       # save screenshot
b9 = [menu_main]

#
# 3 MONITOR SETUPS
# -----------------------------------------------------------------------------

[monitor_1]
# The tablet is the only monitor
screen_1W = 1920
screen_1H = 1080

# global geometry
total_screen_width   = ${screen_1W}
total_screen_height  = ${screen_1H}
tablet_offset_x      = 0
tablet_offset_y      = 0

xrandr_output1 = --output HDMI-1 --mode ${screen_1W}x${screen_1H} --pos 0x0 --rotate normal
xrandr_args    = ${xrandr_output1}

[monitor_1+1]
# 2 full HD monitors sharing the same view
screen_1W = 2560
screen_1H = 1440
screen_2W = 1920
screen_2H = 1080

# global geometry
total_screen_width   = ${screen_1W}
total_screen_height  = ${screen_1H}
tablet_offset_x      = 0
tablet_offset_y      = 0

xrandr_output1 = --output DVI-D-1 --mode ${screen_1W}x${screen_1H} --pos 0x0 --rotate normal
xrandr_output2 = --output VGA-1 --mode ${screen_2W}x${screen_2H} --pos 0x0 --rotate normal
xrandr_args    = ${xrandr_output1} ${xrandr_output2}

[monitor_2]
# 2 monitors arranged horizontally

# screens widths and heights
screen_1W = 1366
screen_1H = 768
screen_2W = 1920
screen_2H = 1080

# global geometry
total_screen_width   = ${screen_1W} + ${screen_2W}
total_screen_height  = ${screen_1H}
tablet_offset_x      = ${screen_1W}
tablet_offset_y      = 0

xrandr_output1 = --output HDMI-1 --mode ${screen_1W}x${screen_1H} --pos 0x0 --rotate normal
xrandr_output2 = --output DVI-D-1 --mode ${screen_2W}x${screen_2H} --pos ${screen_1W}x0 --rotate normal
xrandr_args    = ${xrandr_output1} ${xrandr_output2}

[monitor_3]
# 3 monitors arranged horizontally

# screens widths and heights
screen_1W = 2560
screen_1H = 1440
screen_2W = 1920
screen_2H = 1080
screen_3W = 1920
screen_3H = 1080

# global geometry
total_screen_width   = ${screen_1W} + ${screen_2W} + ${screen_3W}
total_screen_height  = ${screen_1H}
tablet_offset_x      = ${screen_1W} + ${screen_2W}
tablet_offset_y      = 0

xrandr_output1 = --output HDMI-1 --mode ${screen_1W}x${screen_1H} --pos 0x0 --rotate normal
xrandr_output2 = --output DVI-D-1 --mode ${screen_2W}x${screen_2H} --pos ${screen_1W}x0 --rotate normal
xrandr_output3 = --output VGA-1 --mode ${screen_3W}x${screen_3H} --pos 4480x0 --rotate normal
xrandr_args    = ${xrandr_output1} ${xrandr_output2} ${xrandr_output3}

[monitor_2+1]
# 3 monitors. But 2 and 3 share the same view

screen_1W = 2560
screen_1H = 1440
screen_2W = 1920
screen_2H = 1080
screen_3W = 1920
screen_3H = 1080

total_screen_width   = ${screen_1W} + ${screen_2W}
total_screen_height  = ${screen_1H}
tablet_offset_x      = ${screen_1W}
tablet_offset_y      = 0

xrandr_output1 = --output HDMI-1 --mode ${screen_1W}x${screen_1H} --pos 0x0 --rotate normal
xrandr_output2 = --output DVI-D-1 --mode ${screen_2W}x${screen_2H} --pos ${screen_1W}x0 --rotate normal
xrandr_output3 = --output VGA-1 --mode ${screen_3W}x${screen_3H} --pos ${screen_1W}x0 --rotate normal
xrandr_args    = ${xrandr_output1} ${xrandr_output2} ${xrandr_output3}

#
# 4 SUPPORTED TABLETS:
# -----------------------------------------------------------------------------

[tablet_1060plus]
model_name = 1060 PLUS
pen_max_x = 50800
pen_max_y = 31750
pen_max_z = 8191
resolution = 5080
buttons = 12

[tablet_1060pro]
model_name    = 1060 PRO
pen_max_x     = 40000
pen_max_y     = 25000
pen_max_z     = 2047
resolution    = 4000
buttons       = 12

[tablet_dwh69]
model_name    = DWH69
pen_max_x     = 36000
pen_max_y     = 22500
pen_max_z     = 2047
resolution    = 5080
buttons       = 8

[tablet_gt116]
model_name    = GT-116
screen        = true
screen_width  = 1920
screen_height = 1080
pen_max_x     = 53580
pen_max_y     = 33640
pen_max_z     = 8191
resolution    = 5080
buttons       = 4
scrollbar     = 1

[tablet_gt133]
model_name    = GT-133
screen        = true
screen_width  = 1920
screen_height = 1080
pen_max_x     = 58752
pen_max_y     = 33048
pen_max_z     = 8191
resolution    = 5080
buttons       = 5
scrollbar     = 1

# Huion Kamvas Pro 16
[tablet_gt156]
model_name    = GT-156
screen        = true
screen_width  = 1920
screen_height = 1080
pen_max_x     = 68840
pen_max_y     = 38720
pen_max_z     = 8191
resolution    = 5080
buttons       = 8
scrollbar     = 1

[tablet_gt156v2]
model_name    = GT-156 v2
screen        = true
screen_width  = 1920
screen_height = 1080
pen_max_x     = 68834
pen_max_y     = 38710
pen_max_z     = 8191
resolution    = 5080
buttons       = 14
scrollbar     = 1

[tablet_gt185]
model_name    = GT-185
screen        = true
screen_width  = 1366
screen_height = 768
pen_max_x     = 64400
pen_max_y     = 36240
pen_max_z     = 2047
resolution    = 4000
buttons       = 8

[tablet_gt191]
model_name    = GT-191
screen        = true
screen_width  = 1920
screen_height = 1080
pen_max_x     = 86970
pen_max_y     = 47752
pen_max_z     = 8191
resolution    = 5080

[tablet_gt220v2]
model_name    = GT-220 v2
screen        = true
screen_width  = 1920
screen_height = 1080
pen_max_x     = 95352
pen_max_y     = 53645
pen_max_z     = 8191
resolution    = 5080

[tablet_gt221pro]
model_name    = GT-221 PRO
screen        = true
screen_width  = 1920
screen_height = 1080
pen_max_x     = 95352
pen_max_y     = 53645
pen_max_z     = 8191
resolution    = 5080
buttons       = 10
scrollbar     = 1

[tablet_h950p]
model_name    = H950P
pen_max_x     = 44200
pen_max_y     = 27600
pen_max_z     = 8191
resolution    = 5080
buttons       = 8

[tablet_h430p]
model_name    = H430P
pen_max_x     = 24384
pen_max_y     = 15240
pen_max_z     = 8191
resolution    = 5080
buttons       = 4

[tablet_hs64]
model_name    = HS64
pen_max_x     = 32000
pen_max_y     = 20400
pen_max_z     = 8191
resolution    = 5080
buttons       = 4

# You can use this tablet to show the technical input information
[tablet_debug]
model_name    = DEBUG TABLET
debug_only    = true

# PLEASE SEND THE INFORMATION FROM YOUR TABLET
# ------------------------------------------------------------------------------
; If you have access to a Huion model that is not present in the latest
; [config.ini][1] file, or that doesn't work correctly, please
; [open an issue][2] and send the console output.
;
; [1]: https://github.com/joseluis/huion-linux-drivers/blob/master/config.ini
; [2]: https://github.com/joseluis/huion-linux-drivers/issues/new
;
; Make sure you have:
;   1. configured the option: current_table = [tablet_debug]
;   2. touched each corner of the screen as the script instructs
;
; So that the output is similar to the following example:
;
; ```
; Finding USB device. . . Done!
; Reading configuration. . . Done!
; Preparing driver. . . Done!
; --------------------------------------------------------------------------------
;     |                Product: Tablet Monitor
;  64 |        Params block #1: ??????
;     |                          Max X: 37540
;     |                          Max Y: 21120
;     |                   Max pressure: 8191
;     |                     Resolution: 2000
;     |
;  79 |         Internal model:
;  7b |         Buttons status: HK On
;  c8 |        Params block #2: ????????
;     |                          Max X: 95352
;     |                          Max Y: 53645
;     |                   Max pressure: 8191
;     |                     Resolution: 5080
;     |
;  c9 |       Firmware version: HUION_M167_170623
;  ca |  Internal manufacturer: HUION Animation Technology Co.,ltd
; --------------------------------------------------------------------------------
; Setting up driver. . . Done!
;     Tablet model name         DEBUG TABLET
;     Buttons                   disabled (0)
;     Scrollbar                 disabled (0)
;     Notifications:            ENABLED
;           for buttons         ENABLED
;           for scrollbar       disabled
;   Screen                      disabled
;
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;             < DEBUG MODE ENABLED >
;     [Debug mode only]. Input from tablet wont be used, except
;     for printing out the information to the console.
;
;     INSTRUCTIONS: briefly touch the four corners of the screen:
;         1) Left up 2) Right up 3) Left Down 4) Right Down
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
; Huion Kamvas driver should now be running
;
; Input from the tablet will be printed out
nxn commented 3 years ago

I know this is somewhat old, but I found this post while searching around for solutions to getting a GT-116 and a notebook display with the same 1366x768 resolution to work together. After a bit of tinkering I got a multi-monitor setup to work, so I figured I'd offer some guidance in case anyone else stumbles upon this.

So, first, I'd recommend making sure that xrandr is installed and also enabled in the config:

# Multi Monitor Configuration
enable_multi_monitor    = true
enable_xrandr           = true
current_monitor_setup   = [monitor_2]

Moving on, my [monitor_2] setup is as follows:

[monitor_2]
# 2 monitors arranged horizontally

# screens widths and heights
screen_1W = 1920
screen_1H = 1080
screen_2W = 1366
screen_2H = 768

# global geometry
total_screen_width   = ${screen_1W} + ${screen_2W}
total_screen_height  = ${screen_1H}
tablet_offset_x      = 0
tablet_offset_y      = 0

xrandr_output1 = --output HDMI-2 --mode ${screen_1W}x${screen_1H} --pos 0x0 --rotate normal
xrandr_output2 = --output LVDS-1 --mode ${screen_2W}x${screen_2H} --pos ${screen_1W}x0 --rotate normal
xrandr_args    = ${xrandr_output1} ${xrandr_output2}

So, to break this down, first you will need to verify that the xrandr --output arguments are using the correct video interfaces. In my case that's HDMI-2 for the GT-116 and LVDS-1 for my laptop's primary display. To figure these out for your system you can run xrandr without any arguments or, alternatively, narrow the output down to only connected displays:

xrandr | grep -P '(?<!dis)connected'

The second thing to note is that I have the tablet's display associated with the screen_1 settings and my primary display as screen_2. I'm pretty sure you can do the opposite if you want, but the important thing is to make sure the rest of the settings are consistent with whichever option you go with. So if you instead choose to associate the tablet with screen_2 then make sure that the xrandr_output# associated with the tablet's video interface now gets the screen_2W and screen_2H mode values, and so on. From my limited experiments both options seem to work fine so long as you update all the other settings to reflect whichever way you defined them.

Moving on, the total_screen_width should be the sum of both displays, so it doesn't matter which is which, but you need to make sure the total_screen_height is using the height of whichever config setting is storing the tablet's vertical resolution. Otherwise you will get problems with the pointer cumulatively drifting farther and farther away from where it should be as you move it in a direction away from the origin.

Finally, the configuration I provided assumes that the tablet will be physically left of the laptop's screen, but you can switch it if it makes more sense to have it be on the other side, just update these lines as follows:

tablet_offset_x      = ${screen_2W}
...
xrandr_output1 = --output HDMI-2 --mode ${screen_1W}x${screen_1H} --pos ${screen_2W}x0 --rotate normal
xrandr_output2 = --output LVDS-1 --mode ${screen_2W}x${screen_2H} --pos 0x0 --rotate normal

Note: the above still assumes screen_2 is the laptop and screen_1 is the tablet. Essentially it just makes xrandr position the tablet's display to the right of the laptop's display, and sets the tablet_offset_x over by the same amount so that the pointer is still relative to where the screen is.

Also, in my case, since I specifically want the tablet to be left of the primary display I also have the following command run when I start X:

xrandr --output HDMI-2 --left-of LVDS-1

Probably not strictly necessary, but in my case it helps prevent some of the other things on my desktop from getting swapped around when I start the driver script, so I figured I'd mention it.