From dbdc1d81ec172b8ccaf8b24fdfc8d0a23822557e Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 14 Oct 2024 22:31:18 -0400 Subject: [PATCH 1/8] Point people to the better fleshed out wiki page for adding new devices These instructions are old, and then I followed them because I didn't know there was a wiki page. Let's link that in the README so other people don't make my mistake. --- README.md | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/README.md b/README.md index 45b072f0d..ad543a06d 100644 --- a/README.md +++ b/README.md @@ -29,18 +29,7 @@ device in the kernel (see `/proc/bus/input/devices`) and in the X session (see Use the `libwacom-list-devices` tool to list all known devices and verify the tablet is not in that list. -## To add support for a new tablet to libwacom git: - -1. Create a new tablet definition file. See `data/wacom.example` in the source - for a guideline on how to add a new tablet. For an installed version of - libwacom, see the existing data files (e.g. - `/usr/share/libwacom/cintiq-13hd.tablet`) -2. A new tablet description is enabled by adding and installing a new file with - a `.tablet` suffix. Once installed the tablet is part of libwacom's - database, no rebuild is necessary -3. The tablet is then available through `libwacom-list-local-devices` - -You must update udev after installing the file, see below. +See the [wiki page on adding a new device](https://github.com/linuxwacom/libwacom/wiki/Adding-a-new-device). ## To add support for a tablet to an installed libwacom From b9c4a40375fc5ed75d5821d1ffd05a2656c68727 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Oct 2024 10:53:05 +1000 Subject: [PATCH 2/8] tools/clean_svg: drop superfluous nargs If nargs=1 the result is a tuple but that's not really necessary here. --- tools/clean_svg.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/clean_svg.py b/tools/clean_svg.py index 92a6a6bfd..da9e80c2b 100755 --- a/tools/clean_svg.py +++ b/tools/clean_svg.py @@ -302,11 +302,10 @@ def clean_svg(root, tabletname): if __name__ == "__main__": parser = ArgumentParser(description="Clean SVG files for libwacom") parser.add_argument( - "filename", nargs=1, type=str, help="SVG file to clean", metavar="FILE" + "filename", type=str, help="SVG file to clean", metavar="FILE" ) parser.add_argument( "tabletname", - nargs=1, type=str, help="The name of the tablet", metavar="TABLET_NAME", @@ -315,10 +314,10 @@ def clean_svg(root, tabletname): ET.register_namespace("", NAMESPACE) try: - tree = ET.parse(args.filename[0]) + tree = ET.parse(args.filename) except Exception as e: sys.stderr.write(str(e) + "\n") sys.exit(1) root = tree.getroot() - clean_svg(root, args.tabletname[0]) + clean_svg(root, args.tabletname) print(to_string(root)) From 7a6c7e141a60e79e1fbf210d34d7a00ebf4e31e0 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Oct 2024 10:54:10 +1000 Subject: [PATCH 3/8] tools/clean_svg: fix leftover call to getchildren() Fixes: 275227634963 ("tools/clean_svg.py: fix to work with Python3") --- tools/clean_svg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/clean_svg.py b/tools/clean_svg.py index da9e80c2b..a55580589 100755 --- a/tools/clean_svg.py +++ b/tools/clean_svg.py @@ -261,7 +261,7 @@ def apply_id_and_class_from_group(group_node): _id = group_node.attrib.get("id") if _id is None: return - for child in group_node.getchildren(): + for child in group_node: if child.tag == "rect" or child.tag == "circle": if button_assigned: continue From 1e85c03b82a6d4a835594a756ef5e70cf1fa9b8d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Oct 2024 10:59:31 +1000 Subject: [PATCH 4/8] tools/clean_svg: allow passing in a .tablet file If the svg file passed in is a .tablet file, extract the layout and tablet name from there. This allows us to run the tool on the existing tablet files to check for any differences. Add this into the CI so we ensure that script doesn't crash on our SVG files. --- .github/workflows/main.yml | 16 ++++++++++++++++ tools/clean_svg.py | 23 +++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7c3ee5037..b54bbcd8e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -194,6 +194,22 @@ jobs: test $(libwacom-list-devices --format=yaml | yq -r '.devices[] | select(.bus == "usb") | select(.vid == "0x056a") | select(.pid == "0x0358") | .name' | wc -l) -eq 1 test $(libwacom-list-devices --format=yaml | yq -r '.devices[] | select(.bus == "usb") | select(.vid == "0x056a") | select(.pid == "0x032a") | .name' | wc -l) -eq 1 + #### + # make sure clean_svg.py works on our layout files + clean-svg-check: + needs: build-and-dist + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: run clean-svg on all .tablet files + run: | + for tabletfile in data/*.tablet; do + ./tools/clean_svg.py --ignore-missing "$tabletfile" "" + done + ### # # tarball verification diff --git a/tools/clean_svg.py b/tools/clean_svg.py index a55580589..b84a48ec7 100755 --- a/tools/clean_svg.py +++ b/tools/clean_svg.py @@ -19,6 +19,7 @@ # import sys +from pathlib import Path from argparse import ArgumentParser from xml.etree import ElementTree as ET @@ -301,6 +302,9 @@ def clean_svg(root, tabletname): if __name__ == "__main__": parser = ArgumentParser(description="Clean SVG files for libwacom") + parser.add_argument( + "--ignore-missing", action="store_true", default=False, help="Ignore .tablet files without a Layout" + ) parser.add_argument( "filename", type=str, help="SVG file to clean", metavar="FILE" ) @@ -312,12 +316,27 @@ def clean_svg(root, tabletname): ) args = parser.parse_args() + svgfile = args.filename + tabletname = args.tabletname + if args.filename.endswith(".tablet"): + import configparser + config = configparser.ConfigParser() + config.read(args.filename) + try: + svgname = config["Device"]["Layout"] + except KeyError: + print(f"{args.filename} does not specify a layout, skipping", file=sys.stderr) + sys.exit(0 if args.ignore_missing else 77) + svgfile = Path(args.filename).parent / "layouts" / svgname + tabletname = config["Device"]["Name"] + + ET.register_namespace("", NAMESPACE) try: - tree = ET.parse(args.filename) + tree = ET.parse(svgfile) except Exception as e: sys.stderr.write(str(e) + "\n") sys.exit(1) root = tree.getroot() - clean_svg(root, args.tabletname) + clean_svg(root, tabletname) print(to_string(root)) From 64886a4ee60376f752d99a8bb18f1c4cc7ccaeb5 Mon Sep 17 00:00:00 2001 From: leskunberg Date: Fri, 11 Oct 2024 19:55:35 -0600 Subject: [PATCH 5/8] add support for the lenovo x1 fold 16 gen 1 --- data/isdv4-52ba.tablet | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 data/isdv4-52ba.tablet diff --git a/data/isdv4-52ba.tablet b/data/isdv4-52ba.tablet new file mode 100644 index 000000000..7a72a4471 --- /dev/null +++ b/data/isdv4-52ba.tablet @@ -0,0 +1,22 @@ +# Lenovo ThinkPad X1 Fold 16 Gen 1 +# Sensor Type: AES +# Features: Touch (Integrated), Tilt +# HW Resolution: 25715 x 32525 (2540 x 2540 lpi) +# +# Autogenerated from sysinfo.yXmeuvXvKq.tar.gz +# https://github.com/linuxwacom/wacom-hid-descriptors/issues/410 + +[Device] +Name=ISDv4 52ba +ModelName=Lenovo ThinkPad X1 Fold 16 Gen 1 +DeviceMatch=i2c|056a|52ba +Class=ISDV4 +Width=10 +Height=13 +IntegratedIn=Display;System +Styli=@isdv4-aes; + +[Features] +Stylus=true +Touch=true +Buttons=0 From 7747256b6ef05f03198c608dd9784d5fcef74f4a Mon Sep 17 00:00:00 2001 From: leskunberg Date: Fri, 11 Oct 2024 20:08:02 -0600 Subject: [PATCH 6/8] fix name --- data/isdv4-52ba.tablet | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/data/isdv4-52ba.tablet b/data/isdv4-52ba.tablet index 7a72a4471..825f0408e 100644 --- a/data/isdv4-52ba.tablet +++ b/data/isdv4-52ba.tablet @@ -7,8 +7,7 @@ # https://github.com/linuxwacom/wacom-hid-descriptors/issues/410 [Device] -Name=ISDv4 52ba -ModelName=Lenovo ThinkPad X1 Fold 16 Gen 1 +Name=Lenovo ThinkPad X1 Fold 16 Gen 1 DeviceMatch=i2c|056a|52ba Class=ISDV4 Width=10 From 7609cb8be24f98adc83a0c26114b2523ccbcfb56 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Tue, 15 Oct 2024 15:39:13 -0400 Subject: [PATCH 7/8] Remove testing instructions from the README These are now maintained alongside the rest of the building instructions on the wiki. The text for the current version of libwacom is kept. --- README.md | 54 +----------------------------------------------------- 1 file changed, 1 insertion(+), 53 deletions(-) diff --git a/README.md b/README.md index ad543a06d..83376e3ea 100644 --- a/README.md +++ b/README.md @@ -29,59 +29,7 @@ device in the kernel (see `/proc/bus/input/devices`) and in the X session (see Use the `libwacom-list-devices` tool to list all known devices and verify the tablet is not in that list. -See the [wiki page on adding a new device](https://github.com/linuxwacom/libwacom/wiki/Adding-a-new-device). - -## To add support for a tablet to an installed libwacom - -If the system-provided libwacom does not include a `.tablet` file, it is -possible to "backport" that `.tablet` file to the system-provided libwacom. - -### libwacom 1.10 and newer - -Copy the `.tablet` file into `/etc/libwacom` and run the -`libwacom-update-db` tool. Copy the tablet's `.svg` layout file -to `/etc/libwacom/layouts`. - -``` -$ cp my-tablet-file-from-upstream.tablet /etc/libwacom/ -$ cp my-tablet-file-layout.svg /etc/libwacom/layouts/ -$ libwacom-update-db /etc/libwacom -``` - -The tool will take care of updating udev, the hwdb, etc. - -### libwacom 1.9 and earlier - -For versions of libwacom <= 1.9, the file must be copied to -`/usr/share/libwacom`. It may be overwritten on updates. - -You must update udev after installing the file. The simplest (and broadest) -way to do this is outlined below: - -``` -# create the hwdb file -$ cat /etc/udev/hwdb.d/66-libwacom.hwdb -# WARNING: change "Your Device Name" to the actual name of your device -libwacom:name:Your Device Name*:input:* - ID_INPUT=1 - ID_INPUT_TABLET=1 - ID_INPUT_JOYSTICK=0 - -libwacom:name:Your Device Name Pad:input:* - ID_INPUT_TABLET_PAD=1 - -# Use this if the device is an external tablet -libwacom:name:Your Device Name Finger:input:* - ID_INPUT_TOUCHPAD=1 - -# Use this if the device is a screen tablet -libwacom:name:Your Device Name Finger:input:* - ID_INPUT_TOUCHSCREEN=1 - -EOF -$ systemd-hwdb --update -``` -Now disconnect and reconnect the device and it should be detected by libwacom. +See [this wiki page on adding a new device and how to test it](https://github.com/linuxwacom/libwacom/wiki/Adding-a-new-device). # API Documentation From 34bd864a2858b512f2ba55431a98b48b4dc5b39d Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 14 Oct 2024 21:56:34 -0400 Subject: [PATCH 8/8] data: Add support for the XP-Pen Artist 22R Pro --- data/layouts/xp-pen-artist22r-pro.svg | 465 ++++++++++++++++++++++++++ data/xp-pen-artist-22r-pro.tablet | 31 ++ 2 files changed, 496 insertions(+) create mode 100644 data/layouts/xp-pen-artist22r-pro.svg create mode 100644 data/xp-pen-artist-22r-pro.tablet diff --git a/data/layouts/xp-pen-artist22r-pro.svg b/data/layouts/xp-pen-artist22r-pro.svg new file mode 100644 index 000000000..99e673ffd --- /dev/null +++ b/data/layouts/xp-pen-artist22r-pro.svg @@ -0,0 +1,465 @@ + + + + XP-Pen Artist 22R Pro + + + + A + + + + + B + + + + + C + + + + + D + + + + + E + + + + + + + + CCW + CW + + + + + F + + + + + G + + + + + H + + + + + I + + + + + J + + + + + K + + + + + L + + + + + M + + + + + N + + + + + O + + + + + + + + CCW + CW + + + + + P + + + + + Q + + + + + R + + + + + S + + + + + T + + diff --git a/data/xp-pen-artist-22r-pro.tablet b/data/xp-pen-artist-22r-pro.tablet new file mode 100644 index 000000000..ff6c41cd9 --- /dev/null +++ b/data/xp-pen-artist-22r-pro.tablet @@ -0,0 +1,31 @@ +# XP-Pen +# Artist 22R Pro +# +# sysinfo.1WObL2yt9b.tar.gz +# https://github.com/linuxwacom/wacom-hid-descriptors/issues/412 + +[Device] +Name=XP-Pen Artist 22R Pro +ModelName= +DeviceMatch=usb|28bd|091b +PairedIDs= +Class=Cintiq +Width=22 +Height=13 +IntegratedIn=Display +Layout=xp-pen-artist22r-pro.svg +Styli=@generic-no-eraser; + +[Features] +Stylus=true +Reversible=false +Touch=false +TouchSwitch=false +NumRings=0 +NumStrips=0 +NumDials=2 + +[Buttons] +Left=A;B;C;D;E;F;G;H;I;J +Right=K;L;M;N;O;P;Q;R;S;T +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7;BTN_8;BTN_RIGHT;BTN_MIDDLE;BTN_SIDE;BTN_EXTRA;BTN_FORWARD;BTN_BACK;BTN_B;BTN_A;BTN_BASE;BTN_BASE2;BTN_X