From dfc0f4c0c362d032965fcd8a07460bec7447862c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 27 Sep 2023 13:24:51 +1000 Subject: [PATCH] Add support for evdev code parsing Use libevdev to parse the evdev code names which makes the tablet files a bit easier to understand. Every current user of libwacom has a libevdev dependency already anyway so adding it doesn't hurt us. --- .github/workflows/main.yml | 2 +- data/bamboo-0fg-m-p-alt.tablet | 2 +- data/bamboo-0fg-s-p-alt.tablet | 2 +- data/bamboo-0fg-s-p.tablet | 2 +- data/bamboo-16fg-m-pt.tablet | 2 +- data/bamboo-16fg-s-p.tablet | 2 +- data/bamboo-16fg-s-pt.tablet | 2 +- data/bamboo-16fg-s-t.tablet | 2 +- data/bamboo-2fg-fun-m-pt.tablet | 2 +- data/bamboo-2fg-fun-s-pt.tablet | 2 +- data/bamboo-2fg-s-pt.tablet | 2 +- data/bamboo-2fg-s-t.tablet | 2 +- data/bamboo-4fg-fun-m.tablet | 2 +- data/bamboo-4fg-fun-s.tablet | 2 +- data/bamboo-4fg-s-pt.tablet | 2 +- data/bamboo-4fg-s-t.tablet | 2 +- data/bamboo-4fg-se-m-pt.tablet | 2 +- data/bamboo-4fg-se-s-pt.tablet | 2 +- data/bamboo-pad-wireless.tablet | 2 +- data/bamboo-pad.tablet | 2 +- data/ek-remote.tablet | 2 +- data/gaomon-s620.tablet | 2 +- data/graphire4-6x8.tablet | 2 +- data/huion-h1060p.tablet | 2 +- data/huion-h420.tablet | 2 +- data/huion-h610-pro.tablet | 2 +- data/huion-h640p.tablet | 2 +- data/huion-h950p.tablet | 2 +- data/huion-hs611.tablet | 2 +- data/huion-kamvas-13.tablet | 2 +- data/huion-new-1060-plus.tablet | 2 +- data/intuos-m-p3-wl.tablet | 2 +- data/intuos-m-p3.tablet | 2 +- data/intuos-s-p3-android.tablet | 2 +- data/intuos-s-p3-wl.tablet | 2 +- data/intuos-s-p3.tablet | 2 +- data/kamvas-pro-13.tablet | 4 ++-- data/wacom.example | 2 +- data/xp-pen-artist12.tablet | 2 +- data/xp-pen-deco-l.tablet | 2 +- data/xp-pen-deco-mini7.tablet | 2 +- data/xp-pen-deco-mw.tablet | 2 +- data/xp-pen-deco-pro-mw.tablet | 2 +- data/xp-pen-deco-pro-sw.tablet | 2 +- data/xp-pen-deco01-v2.tablet | 2 +- data/xp-pen-star03.tablet | 2 +- libwacom/libwacom-database.c | 15 +++++++++++---- libwacom/libwacom.c | 12 ++++++++---- meson.build | 10 ++++++---- 49 files changed, 72 insertions(+), 59 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 70be41b6b..caf26aca6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,7 @@ on: [ push, pull_request ] env: CFLAGS: "-Werror -Wno-error=missing-field-initializers" - UBUNTU_PACKAGES: libgudev-1.0-dev libxml++2.6-dev valgrind tree python3-pip python3-setuptools libevdev2 + UBUNTU_PACKAGES: libgudev-1.0-dev libxml++2.6-dev valgrind tree python3-pip python3-setuptools libevdev-dev PIP_PACKAGES: meson ninja libevdev pyudev pytest yq jobs: diff --git a/data/bamboo-0fg-m-p-alt.tablet b/data/bamboo-0fg-m-p-alt.tablet index 23c83060b..b5736b4d4 100644 --- a/data/bamboo-0fg-m-p-alt.tablet +++ b/data/bamboo-0fg-m-p-alt.tablet @@ -57,4 +57,4 @@ Ring=true [Buttons] Top=A;B;C;D -EvdevCodes=0x116;0x115;0x110;0x111 +EvdevCodes=BTN_BACK;BTN_FORWARD;BTN_LEFT;BTN_RIGHT diff --git a/data/bamboo-0fg-s-p-alt.tablet b/data/bamboo-0fg-s-p-alt.tablet index 6e4d32a32..0760378c7 100644 --- a/data/bamboo-0fg-s-p-alt.tablet +++ b/data/bamboo-0fg-s-p-alt.tablet @@ -58,4 +58,4 @@ Ring=true [Buttons] Top=A;B;C;D -EvdevCodes=0x116;0x115;0x110;0x111 +EvdevCodes=BTN_BACK;BTN_FORWARD;BTN_LEFT;BTN_RIGHT diff --git a/data/bamboo-0fg-s-p.tablet b/data/bamboo-0fg-s-p.tablet index 8b5fb5807..6d607c5ce 100644 --- a/data/bamboo-0fg-s-p.tablet +++ b/data/bamboo-0fg-s-p.tablet @@ -58,4 +58,4 @@ Ring=true [Buttons] Top=A;B;C;D -EvdevCodes=0x116;0x115;0x110;0x111 +EvdevCodes=BTN_BACK;BTN_FORWARD;BTN_LEFT;BTN_RIGHT diff --git a/data/bamboo-16fg-m-pt.tablet b/data/bamboo-16fg-m-pt.tablet index 04cc63637..ebc8ebba2 100644 --- a/data/bamboo-16fg-m-pt.tablet +++ b/data/bamboo-16fg-m-pt.tablet @@ -26,4 +26,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x110;0x115;0x116;0x111 +EvdevCodes=BTN_LEFT;BTN_FORWARD;BTN_BACK;BTN_RIGHT diff --git a/data/bamboo-16fg-s-p.tablet b/data/bamboo-16fg-s-p.tablet index 824194f2d..9ac0a7939 100644 --- a/data/bamboo-16fg-s-p.tablet +++ b/data/bamboo-16fg-s-p.tablet @@ -22,4 +22,4 @@ Stylus=true Reversible=true Touch=false Buttons=0 -EvdevCodes=0x110;0x115;0x116;0x111 +EvdevCodes=BTN_LEFT;BTN_FORWARD;BTN_BACK;BTN_RIGHT diff --git a/data/bamboo-16fg-s-pt.tablet b/data/bamboo-16fg-s-pt.tablet index 7dc9e2d43..47bfb67e5 100644 --- a/data/bamboo-16fg-s-pt.tablet +++ b/data/bamboo-16fg-s-pt.tablet @@ -26,4 +26,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x110;0x115;0x116;0x111 +EvdevCodes=BTN_LEFT;BTN_FORWARD;BTN_BACK;BTN_RIGHT diff --git a/data/bamboo-16fg-s-t.tablet b/data/bamboo-16fg-s-t.tablet index baa4ca68b..83eb1fc47 100644 --- a/data/bamboo-16fg-s-t.tablet +++ b/data/bamboo-16fg-s-t.tablet @@ -25,4 +25,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x110;0x115;0x116;0x111 +EvdevCodes=BTN_LEFT;BTN_FORWARD;BTN_BACK;BTN_RIGHT diff --git a/data/bamboo-2fg-fun-m-pt.tablet b/data/bamboo-2fg-fun-m-pt.tablet index aa8e211e9..d0c3bf749 100644 --- a/data/bamboo-2fg-fun-m-pt.tablet +++ b/data/bamboo-2fg-fun-m-pt.tablet @@ -38,4 +38,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x111;0x116;0x115;0x110 +EvdevCodes=BTN_RIGHT;BTN_BACK;BTN_FORWARD;BTN_LEFT diff --git a/data/bamboo-2fg-fun-s-pt.tablet b/data/bamboo-2fg-fun-s-pt.tablet index cac05497f..2265443d0 100644 --- a/data/bamboo-2fg-fun-s-pt.tablet +++ b/data/bamboo-2fg-fun-s-pt.tablet @@ -38,4 +38,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x111;0x116;0x115;0x110 +EvdevCodes=BTN_RIGHT;BTN_BACK;BTN_FORWARD;BTN_LEFT diff --git a/data/bamboo-2fg-s-pt.tablet b/data/bamboo-2fg-s-pt.tablet index 300aa38d6..4882e2259 100644 --- a/data/bamboo-2fg-s-pt.tablet +++ b/data/bamboo-2fg-s-pt.tablet @@ -38,4 +38,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x111;0x116;0x115;0x110 +EvdevCodes=BTN_RIGHT;BTN_BACK;BTN_FORWARD;BTN_LEFT diff --git a/data/bamboo-2fg-s-t.tablet b/data/bamboo-2fg-s-t.tablet index a8a044881..2f0fb3a97 100644 --- a/data/bamboo-2fg-s-t.tablet +++ b/data/bamboo-2fg-s-t.tablet @@ -37,4 +37,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x111;0x116;0x115;0x110 +EvdevCodes=BTN_RIGHT;BTN_BACK;BTN_FORWARD;BTN_LEFT diff --git a/data/bamboo-4fg-fun-m.tablet b/data/bamboo-4fg-fun-m.tablet index cfcacae9e..c53715e8a 100644 --- a/data/bamboo-4fg-fun-m.tablet +++ b/data/bamboo-4fg-fun-m.tablet @@ -26,4 +26,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x111;0x116;0x115;0x110 +EvdevCodes=BTN_RIGHT;BTN_BACK;BTN_FORWARD;BTN_LEFT diff --git a/data/bamboo-4fg-fun-s.tablet b/data/bamboo-4fg-fun-s.tablet index 3e8fbe489..428f8d016 100644 --- a/data/bamboo-4fg-fun-s.tablet +++ b/data/bamboo-4fg-fun-s.tablet @@ -26,4 +26,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x111;0x116;0x115;0x110 +EvdevCodes=BTN_RIGHT;BTN_BACK;BTN_FORWARD;BTN_LEFT diff --git a/data/bamboo-4fg-s-pt.tablet b/data/bamboo-4fg-s-pt.tablet index c4117177f..307a5d2a0 100644 --- a/data/bamboo-4fg-s-pt.tablet +++ b/data/bamboo-4fg-s-pt.tablet @@ -26,4 +26,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x111;0x116;0x115;0x110 +EvdevCodes=BTN_RIGHT;BTN_BACK;BTN_FORWARD;BTN_LEFT diff --git a/data/bamboo-4fg-s-t.tablet b/data/bamboo-4fg-s-t.tablet index e31edcb45..fef1a3faa 100644 --- a/data/bamboo-4fg-s-t.tablet +++ b/data/bamboo-4fg-s-t.tablet @@ -25,4 +25,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x111;0x116;0x115;0x110 +EvdevCodes=BTN_RIGHT;BTN_BACK;BTN_FORWARD;BTN_LEFT diff --git a/data/bamboo-4fg-se-m-pt.tablet b/data/bamboo-4fg-se-m-pt.tablet index e6bf82d6e..23175754d 100644 --- a/data/bamboo-4fg-se-m-pt.tablet +++ b/data/bamboo-4fg-se-m-pt.tablet @@ -26,4 +26,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x111;0x116;0x115;0x110 +EvdevCodes=BTN_RIGHT;BTN_BACK;BTN_FORWARD;BTN_LEFT diff --git a/data/bamboo-4fg-se-s-pt.tablet b/data/bamboo-4fg-se-s-pt.tablet index fd871b79f..58a8d90b6 100644 --- a/data/bamboo-4fg-se-s-pt.tablet +++ b/data/bamboo-4fg-se-s-pt.tablet @@ -26,4 +26,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x111;0x116;0x115;0x110 +EvdevCodes=BTN_RIGHT;BTN_BACK;BTN_FORWARD;BTN_LEFT diff --git a/data/bamboo-pad-wireless.tablet b/data/bamboo-pad-wireless.tablet index 189b6d0c0..a902e971e 100644 --- a/data/bamboo-pad-wireless.tablet +++ b/data/bamboo-pad-wireless.tablet @@ -21,4 +21,4 @@ Buttons=2 [Buttons] Bottom=A;B -EvdevCodes=0x110;0x111 +EvdevCodes=BTN_LEFT;BTN_RIGHT diff --git a/data/bamboo-pad.tablet b/data/bamboo-pad.tablet index 27af7285d..918a8befe 100644 --- a/data/bamboo-pad.tablet +++ b/data/bamboo-pad.tablet @@ -21,4 +21,4 @@ Buttons=2 [Buttons] Bottom=A;B -EvdevCodes=0x110;0x111 +EvdevCodes=BTN_LEFT;BTN_RIGHT diff --git a/data/ek-remote.tablet b/data/ek-remote.tablet index 03909f750..45415a736 100644 --- a/data/ek-remote.tablet +++ b/data/ek-remote.tablet @@ -27,7 +27,7 @@ StatusLEDs=Ring [Buttons] Left=A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107;0x108;0x109;0x130;0x131;0x132;0x133;0x134;0x135;0x126;0x127 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7;BTN_8;BTN_9;0x130;0x131;0x132;0x133;0x134;0x135;0x126;0x127 #Note that though this device has 3 ring modes #this mode selection does not function the same diff --git a/data/gaomon-s620.tablet b/data/gaomon-s620.tablet index abcb37468..a1b843b1c 100644 --- a/data/gaomon-s620.tablet +++ b/data/gaomon-s620.tablet @@ -26,4 +26,4 @@ Buttons=4 [Buttons] Left=A;B;C;D -EvdevCodes=0x100;0x101;0x102;0x103 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3 diff --git a/data/graphire4-6x8.tablet b/data/graphire4-6x8.tablet index f4674f1a8..fab446b8a 100644 --- a/data/graphire4-6x8.tablet +++ b/data/graphire4-6x8.tablet @@ -31,4 +31,4 @@ Buttons=2 [Buttons] Top=A;B -EvdevCodes=0x116;0x115 +EvdevCodes=BTN_BACK;BTN_FORWARD diff --git a/data/huion-h1060p.tablet b/data/huion-h1060p.tablet index 7dbf61d93..9ed05cf27 100644 --- a/data/huion-h1060p.tablet +++ b/data/huion-h1060p.tablet @@ -23,4 +23,4 @@ Buttons=12 [Buttons] Left=A;B;C;D;E;F;G;H;I;J;K;L -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107;0x108;0x109;0x130;0x131 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7;BTN_8;BTN_9;0x130;0x131 diff --git a/data/huion-h420.tablet b/data/huion-h420.tablet index 7e34b7b57..6a3ad9417 100644 --- a/data/huion-h420.tablet +++ b/data/huion-h420.tablet @@ -31,4 +31,4 @@ Buttons=3 [Buttons] Left=A;B;C -EvdevCodes=0x100;0x101;0x102; +EvdevCodes=BTN_0;BTN_1;BTN_2; diff --git a/data/huion-h610-pro.tablet b/data/huion-h610-pro.tablet index 91398e4b1..4878a99ad 100644 --- a/data/huion-h610-pro.tablet +++ b/data/huion-h610-pro.tablet @@ -21,4 +21,4 @@ Buttons=8 [Buttons] Left=A;B;C;D;E;F;G;H -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7 diff --git a/data/huion-h640p.tablet b/data/huion-h640p.tablet index d40cd1b2f..e81cd07a9 100644 --- a/data/huion-h640p.tablet +++ b/data/huion-h640p.tablet @@ -32,4 +32,4 @@ Buttons=6 [Buttons] Left=A;B;C;D;E;F -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5 diff --git a/data/huion-h950p.tablet b/data/huion-h950p.tablet index 8c3f21e43..c7fbfe36f 100644 --- a/data/huion-h950p.tablet +++ b/data/huion-h950p.tablet @@ -22,4 +22,4 @@ Buttons=8 [Buttons] Left=A;B;C;D;E;F;G;H -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7 diff --git a/data/huion-hs611.tablet b/data/huion-hs611.tablet index 866089563..5239b0a9a 100644 --- a/data/huion-hs611.tablet +++ b/data/huion-hs611.tablet @@ -53,4 +53,4 @@ Buttons=10 [Buttons] Left=A;B;C;D;E;F;G;H;I;J -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107;0x108;0x109 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7;BTN_8;BTN_9 diff --git a/data/huion-kamvas-13.tablet b/data/huion-kamvas-13.tablet index 1ce49c8b4..f8a21f089 100644 --- a/data/huion-kamvas-13.tablet +++ b/data/huion-kamvas-13.tablet @@ -43,4 +43,4 @@ Buttons=8 [Buttons] Left=A;B;C;D;E;F;G;H -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7 diff --git a/data/huion-new-1060-plus.tablet b/data/huion-new-1060-plus.tablet index 7eef56811..4f3f504bf 100644 --- a/data/huion-new-1060-plus.tablet +++ b/data/huion-new-1060-plus.tablet @@ -21,4 +21,4 @@ Buttons=12 [Buttons] Left=A;B;C;D;E;F;G;H;I;J;K;L -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107;0x108;0x109;0x130;0x131 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7;BTN_8;BTN_9;0x130;0x131 diff --git a/data/intuos-m-p3-wl.tablet b/data/intuos-m-p3-wl.tablet index 23599cb70..89c52b442 100644 --- a/data/intuos-m-p3-wl.tablet +++ b/data/intuos-m-p3-wl.tablet @@ -35,4 +35,4 @@ Buttons=4 [Buttons] Top=A;B;C;D -EvdevCodes=0x100;0x101;0x102;0x103 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3 diff --git a/data/intuos-m-p3.tablet b/data/intuos-m-p3.tablet index d7a61a493..d53067ba9 100644 --- a/data/intuos-m-p3.tablet +++ b/data/intuos-m-p3.tablet @@ -35,4 +35,4 @@ Buttons=4 [Buttons] Top=A;B;C;D -EvdevCodes=0x100;0x101;0x102;0x103 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3 diff --git a/data/intuos-s-p3-android.tablet b/data/intuos-s-p3-android.tablet index 1d8d849e2..d872c1cd6 100644 --- a/data/intuos-s-p3-android.tablet +++ b/data/intuos-s-p3-android.tablet @@ -40,4 +40,4 @@ Buttons=4 [Buttons] Top=A;B;C;D -EvdevCodes=0x100;0x101;0x102;0x103 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3 diff --git a/data/intuos-s-p3-wl.tablet b/data/intuos-s-p3-wl.tablet index 5af97ba75..a513da522 100644 --- a/data/intuos-s-p3-wl.tablet +++ b/data/intuos-s-p3-wl.tablet @@ -35,4 +35,4 @@ Buttons=4 [Buttons] Top=A;B;C;D -EvdevCodes=0x100;0x101;0x102;0x103 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3 diff --git a/data/intuos-s-p3.tablet b/data/intuos-s-p3.tablet index 606924fa0..8e940a7b8 100644 --- a/data/intuos-s-p3.tablet +++ b/data/intuos-s-p3.tablet @@ -35,4 +35,4 @@ Buttons=4 [Buttons] Top=A;B;C;D -EvdevCodes=0x100;0x101;0x102;0x103 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3 diff --git a/data/kamvas-pro-13.tablet b/data/kamvas-pro-13.tablet index 4bdc36b0d..1bee3698d 100644 --- a/data/kamvas-pro-13.tablet +++ b/data/kamvas-pro-13.tablet @@ -21,7 +21,7 @@ # # Touch Strip Map: # NOTE: not enabled because i couldnt get it to work -# evtest reports 0x108 (BTN_8), 0x109 (BTN_9), 0x130 (BTN_SOUTH) +# evtest reports BTN_8, BTN_9, BTN_SOUTH # # *-----------------------* # | | @@ -54,4 +54,4 @@ Buttons=5 [Buttons] Left=A;B;C;D;E -EvdevCodes=0x100;0x101;0x102;0x103;0x104 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4 diff --git a/data/wacom.example b/data/wacom.example index 2ff0830ec..c6e6f4654 100644 --- a/data/wacom.example +++ b/data/wacom.example @@ -178,7 +178,7 @@ Top= Bottom= # The evdev codes for the buttons in order A, B, C, ... # The code must be defined for all buttons or this line is ignored -EvdevCodes=0x110;0x112;0x111;0x113 +EvdevCodes=BTN_LEFT;BTN_MIDDLE;BTN_RIGHT;BTN_SIDE ##################### # ADVANCED FEATURES # diff --git a/data/xp-pen-artist12.tablet b/data/xp-pen-artist12.tablet index 17c74570e..0484a7321 100644 --- a/data/xp-pen-artist12.tablet +++ b/data/xp-pen-artist12.tablet @@ -28,4 +28,4 @@ Buttons=6 [Buttons] Left=A;B;C;D;E;F -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5 diff --git a/data/xp-pen-deco-l.tablet b/data/xp-pen-deco-l.tablet index 7db9d1e03..8e48a2b8d 100644 --- a/data/xp-pen-deco-l.tablet +++ b/data/xp-pen-deco-l.tablet @@ -28,4 +28,4 @@ Buttons=8 [Buttons] Left=A;B;C;D;E;F;G;H -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7 diff --git a/data/xp-pen-deco-mini7.tablet b/data/xp-pen-deco-mini7.tablet index 06f3d8721..eaaeb585f 100644 --- a/data/xp-pen-deco-mini7.tablet +++ b/data/xp-pen-deco-mini7.tablet @@ -22,4 +22,4 @@ Buttons=8 [Buttons] Left=A;B;C;D;E;F;G;H -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7 diff --git a/data/xp-pen-deco-mw.tablet b/data/xp-pen-deco-mw.tablet index 98f9ad11e..fdbe7fd2d 100644 --- a/data/xp-pen-deco-mw.tablet +++ b/data/xp-pen-deco-mw.tablet @@ -26,5 +26,5 @@ Buttons=8 [Buttons] Left=A;B;C;D;E;F;G;H -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7 diff --git a/data/xp-pen-deco-pro-mw.tablet b/data/xp-pen-deco-pro-mw.tablet index 6d1885c23..6f564cfbc 100644 --- a/data/xp-pen-deco-pro-mw.tablet +++ b/data/xp-pen-deco-pro-mw.tablet @@ -40,4 +40,4 @@ Buttons=8 [Buttons] Left=A;B;C;D;E;F;G;H -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7 diff --git a/data/xp-pen-deco-pro-sw.tablet b/data/xp-pen-deco-pro-sw.tablet index 85e988159..a836dd4d5 100644 --- a/data/xp-pen-deco-pro-sw.tablet +++ b/data/xp-pen-deco-pro-sw.tablet @@ -27,4 +27,4 @@ Buttons=8 [Buttons] Left=A;B;C;D;E;F;G;H -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7 diff --git a/data/xp-pen-deco01-v2.tablet b/data/xp-pen-deco01-v2.tablet index 582eea810..609188e90 100644 --- a/data/xp-pen-deco01-v2.tablet +++ b/data/xp-pen-deco01-v2.tablet @@ -28,4 +28,4 @@ Buttons=8 [Buttons] Left=A;B;C;D;E;F;G;H -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7 diff --git a/data/xp-pen-star03.tablet b/data/xp-pen-star03.tablet index 2e03a3ad2..edfdf97ef 100644 --- a/data/xp-pen-star03.tablet +++ b/data/xp-pen-star03.tablet @@ -21,4 +21,4 @@ Buttons=8 [Buttons] Left=A;B;C;D;E;F;G;H -EvdevCodes=0x100;0x101;0x102;0x103;0x104;0x105;0x106;0x107 +EvdevCodes=BTN_0;BTN_1;BTN_2;BTN_3;BTN_4;BTN_5;BTN_6;BTN_7 diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c index 804ac3d09..e55cbb445 100644 --- a/libwacom/libwacom-database.c +++ b/libwacom/libwacom-database.c @@ -30,6 +30,7 @@ #include "libwacomint.h" #include "util-strings.h" #include +#include #include #include @@ -455,8 +456,9 @@ set_button_codes_from_string(WacomDevice *device, char **strvals) for (guint i = 0; i < g_hash_table_size(device->buttons); i++) { char key = 'A' + i; - int code; + int code = -1; WacomButton *button = g_hash_table_lookup(device->buttons, GINT_TO_POINTER(key)); + const char *str = strvals[i]; if (!button) { g_error("%s: Button %c is not defined, ignoring all codes\n", @@ -464,17 +466,22 @@ set_button_codes_from_string(WacomDevice *device, char **strvals) goto out; } - if (!strvals[i]) { + if (!str) { g_error ("%s: Missing EvdevCode for button %d, ignoring all codes\n", device->name, i); goto out; + } else if (g_str_has_prefix(str, "BTN")) { + code = libevdev_event_code_from_code_name(str); + } else if (!safe_atoi_base(str, &code, 16)) { + code = -1; } - if (!safe_atoi_base (strvals[i], &code, 16) || code < BTN_MISC || code >= BTN_DIGI) { + if (code < BTN_MISC || code >= BTN_DIGI) { g_warning ("%s: Invalid EvdevCode %s for button %c, ignoring all codes\n", - device->name, strvals[i], key); + device->name, str, key); goto out; } + button->code = code; } success = true; diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c index ccfe43acc..84cfd099b 100644 --- a/libwacom/libwacom.c +++ b/libwacom/libwacom.c @@ -33,8 +33,7 @@ #include #include #include - -#include +#include #if !HAVE_G_MEMDUP2 #define g_memdup2 g_memdup @@ -754,9 +753,14 @@ static void print_button_evdev_codes(int fd, const WacomDevice *device) unsigned idx = 0; for (b = 'A'; b < 'A' + nbuttons; b++) { + unsigned int code = libwacom_get_button_evdev_code(device, b); + const char *str = libevdev_event_code_get_name(EV_KEY, code); + assert(idx < sizeof(buf) - 30); - idx += snprintf(buf + idx, 30, "0x%x;", - libwacom_get_button_evdev_code(device, b)); + if (str) + idx += snprintf(buf + idx, 30, "%s;", str); + else + idx += snprintf(buf + idx, 30, "0x%x;", code); } dprintf(fd, "EvdevCodes=%s\n", buf); } diff --git a/meson.build b/meson.build index f34f752cb..581254969 100644 --- a/meson.build +++ b/meson.build @@ -50,9 +50,10 @@ cflags = cc.get_supported_arguments( add_project_arguments(cflags, language: 'c') # Dependencies -pkgconfig = import('pkgconfig') -dep_gudev = dependency('gudev-1.0') -dep_glib = dependency('glib-2.0') +pkgconfig = import('pkgconfig') +dep_gudev = dependency('gudev-1.0') +dep_glib = dependency('glib-2.0') +dep_libevdev = dependency('libevdev') includes_include = include_directories('include') includes_src = include_directories('libwacom') @@ -75,7 +76,8 @@ src_libwacom = [ deps_libwacom = [ dep_gudev, - dep_glib + dep_glib, + dep_libevdev, ] inc_libwacom = [