libwacom icon indicating copy to clipboard operation
libwacom copied to clipboard

Stylus not working as expected

Open hantangantan opened this issue 1 year ago • 0 comments

  • Lenovo Yoga X1 Gen5

  • libwacom version: 2.11.0-1.fc40

  • Fedora 40 (Wayland)

  • [x] I understand that libwacom does affect whether the device works (see Troubleshooting)

Bug description

Dear all,

Unfortunately I am not an expert, but I hope you might help me with my issue:

I have three different styli for my convertible:

  • one stylus that comes with the tablet. It is correctly detected and working fine without any problems
  • two other ones (Lenovo Precision Pen 2 and Lenovo Active Pen 2). They are not working as expected.

The probelm is, that inputs from those two pens are always detected in eraser mode and not pen mode. I tried to analyse the issue by checking libinput record while touching the surface with one of the not correctly mapped pens without pressing any buttons:

$ sudo libinput record
Available devices:
/dev/input/event0:      Sleep Button
/dev/input/event1:      Lid Switch
/dev/input/event2:      Power Button
/dev/input/event3:      AT Translated Set 2 keyboard
/dev/input/event4:      TPPS/2 ALPS TrackPoint
/dev/input/event5:      Wacom Pen and multitouch sensor Pen
/dev/input/event6:      Wacom Pen and multitouch sensor Finger
/dev/input/event7:      Video Bus
/dev/input/event8:      HP Inc. HP Thunderbolt Dock G4 System Control
/dev/input/event9:      Intel HID events
/dev/input/event10:     SYNA8006:00 06CB:CD8B Mouse
/dev/input/event11:     SYNA8006:00 06CB:CD8B Touchpad
/dev/input/event12:     ThinkPad Extra Buttons
/dev/input/event13:     Logitech MK700
/dev/input/event14:     PC Speaker
/dev/input/event15:     Logitech M705
/dev/input/event16:     C-Media Electronics Inc. USB Audio Device
/dev/input/event17:     sof-hda-dsp Mic
/dev/input/event18:     sof-hda-dsp Headphone
/dev/input/event19:     sof-hda-dsp HDMI/DP,pcm=3
/dev/input/event20:     sof-hda-dsp HDMI/DP,pcm=4
/dev/input/event21:     sof-hda-dsp HDMI/DP,pcm=5
Select the device event number: 5
Recording to 'stdout'.
# libinput record
version: 1
ndevices: 1
libinput:
  version: "1.26.2"
  git: "unknown"
system:
  os: "fedora:40"
  kernel: "6.11.3-200.fc40.x86_64"
  dmi: "dmi:bvnLENOVO:bvrN2WET45W(1.35):bd03/18/2024:br1.35:efr1.16:svnLENOVO:pn20UCS17W1D:pvrThinkPadX1YogaGen5:rvnLENOVO:rn20UCS17W1D:rvrSDK0J40697WIN:cvnLENOVO:ct31:cvrNone:skuLENOVO_MT_20UC_BU_Think_FM_ThinkPadX1YogaGen5:"
devices:
- node: /dev/input/event5
  evdev:
    # Name: Wacom Pen and multitouch sensor Pen
    # ID: bus 0x0003 (usb) vendor 0x056a product 0x522b version 0x0111
    # Size in mm: 309x174
    # Supported Events:
    # Event type 0 (EV_SYN)
    # Event type 1 (EV_KEY)
    #   Event code 320 (BTN_TOOL_PEN)
    #   Event code 321 (BTN_TOOL_RUBBER)
    #   Event code 330 (BTN_TOUCH)
    #   Event code 331 (BTN_STYLUS)
    #   Event code 332 (BTN_STYLUS2)

.......

  udev:
    properties:
    - ID_INPUT=1
    - ID_INPUT_HEIGHT_MM=174
    - ID_INPUT_TABLET=1
    - ID_INPUT_WIDTH_MM=309
    - LIBINPUT_DEVICE_GROUP=3/56a/522b:usb-0000:00:14.0-6
    - DRIVER=wacom
  quirks:
  events:
  # Current time is 20:34:58
  - evdev:
    - [  0,      0,   3,   0,   14574] # EV_ABS / ABS_X                 14574 (+86)
    - [  0,      0,   3,   1,   10605] # EV_ABS / ABS_Y                 10605 (+1412)
    - [  0,      0,   3,  26,       0] # EV_ABS / ABS_TILT_X                0 (-17)
    - [  0,      0,   3,  27,       0] # EV_ABS / ABS_TILT_Y                0 (+2)
    - [  0,      0,   1, 321,       1] # EV_KEY / BTN_TOOL_RUBBER           1
    - [  0,      0,   4,   0, -2132770304] # EV_MSC / MSC_SERIAL           -2132770304
    - [  0,      0,   3,  40,   33899] # EV_ABS / ABS_MISC              33899 (+33899)
    - [  0,      0,   0,   0,       0] # ------------ SYN_REPORT (0) ---------- +0ms
  - evdev:
    - [  0,      7,   3,  24,    1311] # EV_ABS / ABS_PRESSURE           1311 (+1311)
    - [  0,      7,   1, 330,       1] # EV_KEY / BTN_TOUCH                 1
    - [  0,      7,   4,   0, -2132770304] # EV_MSC / MSC_SERIAL           -2132770304
    - [  0,      7,   0,   0,       0] # ------------ SYN_REPORT (0) ---------- +0ms

....

    - [  0, 237660,   3,   0,   14360] # EV_ABS / ABS_X                 14360 (-34)
    - [  0, 237660,   3,   1,   10629] # EV_ABS / ABS_Y                 10629 (+9)
    - [  0, 237660,   4,   0, -2132770304] # EV_MSC / MSC_SERIAL           -2132770304
    - [  0, 237660,   0,   0,       0] # ------------ SYN_REPORT (0) ---------- +1ms
  - evdev:
    - [  0, 512616,   1, 321,       0] # EV_KEY / BTN_TOOL_RUBBER           0
    - [  0, 512616,   3,  40,       0] # EV_ABS / ABS_MISC                  0 (-33899)
    - [  0, 512616,   0,   0,       0] # ------------ SYN_REPORT (0) ---------- +275ms
  # Current time is 20:35:00

As you can see a BTN_TOOL_RUBBER event with event code 321 is detected while touching the screen.

As my tablet is not listed within your database, i created /usr/share/libwacom/lenovo-yoga-x1-gen5.tablet with content:

[Device]
Name=Lenovo Yoga X1 Gen5
DeviceMatch=usb:056a:522b
Class=ISDV4
IntegratedIn=Display;System;
Styli=@generic-with-eraser

[Features]
Stylus=true
Touch=true

The config file seems to work as I get

❯ libwacom-list-local-devices
devices:
- name: 'Lenovo Yoga X1 Gen5'
  bus: 'usb'
  vid: '0x056a'
  pid: '0x522b'
  nodes: 
  - /dev/input/event5: 'Wacom Pen and multitouch sensor Pen'
  styli:
   - id: 0xffffe
     name: 'General Pen Eraser'
     type: 'general'
     axes: ['x', 'y' , 'tilt', 'distance', 'pressure']
     buttons: 2
     is_eraser: 'true'
     eraser_type: 'invert'
   - id: 0xfffff
     name: 'General Pen'
     type: 'general'
     axes: ['x', 'y' , 'tilt', 'distance', 'pressure']
     buttons: 2
     erasers: [0xffffe]

I have already tried switching the Styli parameters to the predefined Lenovo numbers without any success. Is this an issue related to this project or related to KDE? I would be really thankful if you can help me here as I dont know what to do next....

PS: Someone on Reddit has the same problem like me - maybe it is related?!

Thanks for your answers!

Best, Fabi

hantangantan avatar Oct 23 '24 19:10 hantangantan