The tablet's evdev device has all possible axes set for all tools on this
device. We can't know which axes are available for each tool. Fix this.

For now, the database was fixed to provide tilt, pressure and distance for all
devices. Except Puck devices, they only get tilt.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 data/libwacom.stylus         | 53 ++++++++++++++++++++++++++++++++++++++++++++
 libwacom/libwacom-database.c | 32 ++++++++++++++++++++++++++
 libwacom/libwacom.c          | 19 ++++++++++++++++
 libwacom/libwacom.h          | 23 +++++++++++++++++++
 libwacom/libwacomint.h       |  1 +
 test/tablet-validity.c       | 13 +++++++++++
 6 files changed, 141 insertions(+)

diff --git a/data/libwacom.stylus b/data/libwacom.stylus
index ceed599..49c3bde 100644
--- a/data/libwacom.stylus
+++ b/data/libwacom.stylus
@@ -3,11 +3,13 @@
 Name=General Pen
 Buttons=2
 HasEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0xffffe]
 Name=General Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 # Inking pen have no eraser
@@ -16,6 +18,7 @@ Type=General
 Name=Inking Pen
 Buttons=0
 HasEraser=false
+Axes=Tilt;Pressure;Distance;
 Type=Inking
 
 [0x801]
@@ -23,6 +26,7 @@ Type=Inking
 Name=Inking Pen
 Buttons=0
 HasEraser=false
+Axes=Tilt;Pressure;Distance;
 Type=Inking
 
 [0x20802]
@@ -30,6 +34,7 @@ Type=Inking
 Name=Inking Pen
 Buttons=0
 HasEraser=false
+Axes=Tilt;Pressure;Distance;
 Type=Inking
 
 [0x120802]
@@ -37,12 +42,14 @@ Type=Inking
 Name=Inking Pen
 Buttons=0
 HasEraser=false
+Axes=Tilt;Pressure;Distance;
 Type=Inking
 
 [0x012]
 Name=Inking Pen
 Buttons=0
 HasEraser=false
+Axes=Tilt;Pressure;Distance;
 Type=Inking
 
 # Regular pen has eraser
@@ -51,6 +58,7 @@ Type=Inking
 Name=Classic Pen
 HasEraser=true
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=Classic
 
 [0x842]
@@ -58,6 +66,7 @@ Type=Classic
 Name=Designer Pen
 HasEraser=false
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0x852]
@@ -65,6 +74,7 @@ Type=General
 Name=Grip Pen
 HasEraser=true
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0x823]
@@ -72,6 +82,7 @@ Type=General
 Name=Grip Pen
 HasEraser=true
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0x813]
@@ -79,6 +90,7 @@ Type=General
 Name=Classic Pen
 HasEraser=true
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=Classic
 
 [0x885]
@@ -86,6 +98,7 @@ Type=Classic
 Name=6D Art Pen
 HasEraser=false
 Buttons=0
+Axes=Tilt;Pressure;Distance;
 Type=Marker
 
 [0x802]
@@ -93,6 +106,7 @@ Type=Marker
 Name=Grip Pen
 HasEraser=true
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0x804]
@@ -100,6 +114,7 @@ Type=General
 Name=Art Pen
 HasEraser=true
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=Marker
 
 [0x100804]
@@ -107,12 +122,14 @@ Type=Marker
 Name=Art Pen
 HasEraser=true
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=Marker
 
 [0x100802]
 # Intuos4, 5 and Cintiq 21UX2, 24HD
 Name=Grip Pen
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0x40802]
@@ -120,6 +137,7 @@ Type=General
 Name=Classic Pen
 HasEraser=true
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=Classic
 
 [0x140802]
@@ -127,6 +145,7 @@ Type=Classic
 Name=Classic Pen
 HasEraser=true
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=Classic
 
 [0x160802]
@@ -134,6 +153,7 @@ Type=Classic
 Name=Pro Pen
 HasEraser=true
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=Classic
 
 [0x180802]
@@ -141,6 +161,7 @@ Type=Classic
 Name=Pen
 HasEraser=true
 Buttons=2
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0x022]
@@ -153,11 +174,13 @@ HasEraser=true
 Name=Stroke Pen
 HasEraser=false
 Buttons=0
+Axes=Tilt;Pressure;Distance;
 Type=Stroke
 
 [0x032]
 Name=Stroke Pen
 HasEraser=false
+Axes=Tilt;Pressure;Distance;
 Type=Stroke
 
 # Erasers
@@ -165,24 +188,28 @@ Type=Stroke
 # Intuos and Intuos2
 Name=Classic Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Classic
 
 [0x85a]
 # Intuos2
 Name=Grip Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0x91a]
 # Intuos2
 Name=Airbrush Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Airbrush
 
 [0xd1a]
 # Intuos
 Name=Airbrush Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Airbrush
 
 [0x0fa]
@@ -193,78 +220,91 @@ IsEraser=true
 # Intuos3 and Cintiq 21UX
 Name=Grip Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0x81b]
 # Intuos3 and Cintiq 21UX
 Name=Classic Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Classic
 
 [0x91b]
 # Intuos3 and Cintiq 21UX
 Name=Airbrush Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Airbrush
 
 [0x80c]
 # Intuos4, 5 and Cintiq 21UX2, 24HD
 Name=Art Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Marker
 
 [0x80a]
 # Intuos4, 5 and Cintiq 21UX2, 24HD
 Name=Grip Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0x4080a]
 # Intuos4, 5 and Cintiq 21UX2, 24HD
 Name=Classic Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Classic
 
 [0x14080a]
 # Intuos4, 5 and Cintiq 21UX2, 24HD
 Name=Classic Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Classic
 
 [0x10080c]
 # Intuos4, 5 and 13HD, 24HD Art Pen
 Name=Art Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Marker
 
 [0x10080a]
 # Intuos4, 5 and Cintiq 21UX2, 24HD
 Name=Grip Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0x16080a]
 # Cintiq 13HD
 Name=Pro Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Classic
 
 [0x18080a]
 # DTH2242 Eraser
 Name=Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=General
 
 [0x10090a]
 # Intuos4, 5 and Cintiq 13HD, 22HD, 24HD Airbrush Eraser
 Name=Airbrush Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Airbrush
 
 [0x90a]
 # Intuos4, 5 and Cintiq 21UX2, 24HD
 Name=Airbrush Pen Eraser
 IsEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Airbrush
 
 # Airbrush pen has eraser
@@ -273,6 +313,7 @@ Type=Airbrush
 Name=Airbrush Pen
 HasEraser=true
 Buttons=1
+Axes=Tilt;Pressure;Distance;
 Type=Airbrush
 
 [0x912]
@@ -280,11 +321,13 @@ Type=Airbrush
 Name=Airbrush Pen
 HasEraser=true
 Buttons=1
+Axes=Tilt;Pressure;Distance;
 Type=Airbrush
 
 [0x112]
 Name=Airbrush Pen
 HasEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Airbrush
 
 [0x913]
@@ -292,6 +335,7 @@ Type=Airbrush
 Name=Airbrush Pen
 Buttons=1
 HasEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Airbrush
 
 [0x902]
@@ -299,6 +343,7 @@ Type=Airbrush
 Name=Airbrush Pen
 Buttons=1
 HasEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Airbrush
 
 [0x100902]
@@ -306,12 +351,14 @@ Type=Airbrush
 Name=Airbrush Pen
 Buttons=1
 HasEraser=true
+Axes=Tilt;Pressure;Distance;
 Type=Airbrush
 
 # Puck devices
 [0x096]
 # Intuos and Intuos2
 Name=Lens Cursor
+Axes=Tilt;
 Type=Puck
 HasLens=true
 HasWheel=false
@@ -320,6 +367,7 @@ Buttons=5
 [0x097]
 # Intuos3
 Name=Lens Cursor
+Axes=Tilt;
 Type=Puck
 HasLens=true
 HasWheel=false
@@ -328,6 +376,7 @@ Buttons=5
 [0x006]
 # Intuos4 and Intuos5
 Name=Lens Cursor
+Axes=Tilt;
 Type=Puck
 HasLens=true
 HasWheel=false
@@ -336,6 +385,7 @@ Buttons=5
 [0x094]
 # Intuos and Intuos2
 Name=4D Mouse
+Axes=Tilt;
 Type=Puck
 HasLens=false
 HasWheel=false
@@ -344,6 +394,7 @@ Buttons=5
 [0x007]
 # Intuos3
 Name=2D Mouse
+Axes=Tilt;
 Type=Puck
 HasLens=false
 HasWheel=true
@@ -352,6 +403,7 @@ Buttons=3
 [0x017]
 # Intuos3
 Name=Mouse
+Axes=Tilt;
 Type=Puck
 HasLens=false
 HasWheel=true
@@ -360,6 +412,7 @@ Buttons=5
 [0x806]
 # Intuos4 and Intuos5
 Name=Five Button Mouse
+Axes=Tilt;
 Type=Puck
 HasLens=false
 HasWheel=true
diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c
index bd0c422..a8b0396 100644
--- a/libwacom/libwacom-database.c
+++ b/libwacom/libwacom-database.c
@@ -190,6 +190,7 @@ libwacom_parse_stylus_keyfile(WacomDeviceDatabase *db, 
const char *path)
                GError *error = NULL;
                char *type;
                int id;
+               char **string_list;
 
                id = strtol (groups[i], NULL, 16);
                if (id == 0) {
@@ -231,6 +232,37 @@ libwacom_parse_stylus_keyfile(WacomDeviceDatabase *db, 
const char *path)
                        stylus->has_wheel = FALSE;
                }
 
+               string_list = g_key_file_get_string_list (keyfile, groups[i], 
"Axes", NULL, NULL);
+               if (string_list) {
+                       WacomAxisTypeFlags axes = WACOM_AXIS_TYPE_NONE;
+                       guint i;
+
+                       for (i = 0; string_list[i]; i++) {
+                               WacomAxisTypeFlags flag = WACOM_AXIS_TYPE_NONE;
+                               if (strcmp (string_list[i], "Tilt") == 0) {
+                                       flag = WACOM_AXIS_TYPE_TILT;
+                               } else if (strcmp (string_list[i], "RotationZ") 
== 0) {
+                                       flag = WACOM_AXIS_TYPE_ROTATION_Z;
+                               } else if (strcmp (string_list[i], "Distance") 
== 0) {
+                                       flag = WACOM_AXIS_TYPE_DISTANCE;
+                               } else if (strcmp (string_list[i], "Pressure") 
== 0) {
+                                       flag = WACOM_AXIS_TYPE_PRESSURE;
+                               } else if (strcmp (string_list[i], "Slider") == 
0) {
+                                       flag = WACOM_AXIS_TYPE_SLIDER;
+                               } else {
+                                       g_warning ("Invalid axis %s for stylus 
ID %s\n",
+                                                  string_list[i], groups[i]);
+                               }
+                               if (axes & flag)
+                                       g_warning ("Duplicate axis %s for 
stylus ID %s\n",
+                                                  string_list[i], groups[i]);
+                               axes |= flag;
+                       }
+
+                       stylus->axes = axes;
+                       g_strfreev (string_list);
+               }
+
                type = g_key_file_get_string(keyfile, groups[i], "Type", NULL);
                stylus->type = type_from_str (type);
                g_free (type);
diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
index c0c6ed3..d100793 100644
--- a/libwacom/libwacom.c
+++ b/libwacom/libwacom.c
@@ -1037,6 +1037,11 @@ int libwacom_stylus_has_wheel (const WacomStylus *stylus)
        return stylus->has_wheel;
 }
 
+WacomAxisTypeFlags libwacom_stylus_get_axes (const WacomStylus *stylus)
+{
+       return stylus->axes;
+}
+
 WacomStylusType libwacom_stylus_get_type (const WacomStylus *stylus)
 {
        if (stylus->type == WSTYLUS_UNKNOWN) {
@@ -1050,6 +1055,7 @@ void
 libwacom_print_stylus_description (int fd, const WacomStylus *stylus)
 {
        const char *type;
+       WacomAxisTypeFlags axes;
 
        dprintf(fd, "[%#x]\n",  libwacom_stylus_get_id(stylus));
        dprintf(fd, "Name=%s\n",        libwacom_stylus_get_name(stylus));
@@ -1058,6 +1064,19 @@ libwacom_print_stylus_description (int fd, const 
WacomStylus *stylus)
        dprintf(fd, "IsEraser=%s\n",    libwacom_stylus_is_eraser(stylus) ? 
"true" : "false");
        dprintf(fd, "HasLens=%s\n",     libwacom_stylus_has_lens(stylus) ? 
"true" : "false");
        dprintf(fd, "HasWheel=%s\n",    libwacom_stylus_has_wheel(stylus) ? 
"true" : "false");
+       axes = libwacom_stylus_get_axes(stylus);
+       dprintf(fd, "Axes=");
+       if (axes & WACOM_AXIS_TYPE_TILT)
+               dprintf(fd, "Tilt;");
+       if (axes & WACOM_AXIS_TYPE_ROTATION_Z)
+               dprintf(fd, "RotationZ;");
+       if (axes & WACOM_AXIS_TYPE_DISTANCE)
+               dprintf(fd, "Distance;");
+       if (axes & WACOM_AXIS_TYPE_PRESSURE)
+               dprintf(fd, "Pressure;");
+       if (axes & WACOM_AXIS_TYPE_SLIDER)
+               dprintf(fd, "Slider;");
+       dprintf(fd, "\n");
 
        switch(libwacom_stylus_get_type(stylus)) {
                case WSTYLUS_UNKNOWN:   type = "Unknown";        break;
diff --git a/libwacom/libwacom.h b/libwacom/libwacom.h
index b1c0ff8..60c873f 100644
--- a/libwacom/libwacom.h
+++ b/libwacom/libwacom.h
@@ -177,6 +177,23 @@ typedef enum {
        WACOM_BUTTON_TOUCHSTRIPS_MODESWITCH = 
(WACOM_BUTTON_TOUCHSTRIP_MODESWITCH | WACOM_BUTTON_TOUCHSTRIP2_MODESWITCH),
 } WacomButtonFlags;
 
+/**
+ * Axis type for a stylus. Note that x/y is implied.
+ */
+typedef enum {
+       WACOM_AXIS_TYPE_NONE                = 0,
+       /** Tilt in x and y direction */
+       WACOM_AXIS_TYPE_TILT                = (1 << 1),
+       /** Rotation in the z-axis */
+       WACOM_AXIS_TYPE_ROTATION_Z          = (1 << 2),
+       /** Distance to surface */
+       WACOM_AXIS_TYPE_DISTANCE            = (1 << 3),
+       /** Tip pressure */
+       WACOM_AXIS_TYPE_PRESSURE            = (1 << 4),
+       /** A absolute-position slider like the wheel on the airbrush */
+       WACOM_AXIS_TYPE_SLIDER              = (1 << 5),
+} WacomAxisTypeFlags;
+
 typedef enum {
        WFALLBACK_NONE = 0,
        WFALLBACK_GENERIC = 1
@@ -567,6 +584,12 @@ int         libwacom_stylus_has_wheel (const WacomStylus 
*stylus);
 
 /**
  * @param stylus The stylus to query
+ * @return The flags specifying the list of absolute axes
+ */
+WacomAxisTypeFlags libwacom_stylus_get_axes (const WacomStylus *stylus);
+
+/**
+ * @param stylus The stylus to query
  * @return The type of stylus
  */
 WacomStylusType libwacom_stylus_get_type (const WacomStylus *stylus);
diff --git a/libwacom/libwacomint.h b/libwacom/libwacomint.h
index 004b0aa..3ba54cc 100644
--- a/libwacom/libwacomint.h
+++ b/libwacom/libwacomint.h
@@ -103,6 +103,7 @@ struct _WacomStylus {
        gboolean has_lens;
        gboolean has_wheel;
        WacomStylusType type;
+       WacomAxisTypeFlags axes;
 };
 
 struct _WacomDeviceDatabase {
diff --git a/test/tablet-validity.c b/test/tablet-validity.c
index c7cfbc3..1cb83a4 100644
--- a/test/tablet-validity.c
+++ b/test/tablet-validity.c
@@ -168,6 +168,8 @@ static void verify_tablet(WacomDeviceDatabase *db, 
WacomDevice *device)
        for (i = 0; i < nstyli; i++) {
                const WacomStylus *stylus;
                const char *stylus_name;
+               WacomAxisTypeFlags axes;
+
                stylus = libwacom_stylus_get_for_id (db, styli[i]);
                assert(stylus);
                stylus_name = libwacom_stylus_get_name (stylus);
@@ -190,6 +192,17 @@ static void verify_tablet(WacomDeviceDatabase *db, 
WacomDevice *device)
                                assert (has_wheel != has_lens);
                        }
                }
+
+               axes = libwacom_stylus_get_axes (stylus);
+               if (libwacom_stylus_get_type (stylus) == WSTYLUS_PUCK) {
+                       assert(axes & WACOM_AXIS_TYPE_TILT);
+                       assert((axes & WACOM_AXIS_TYPE_PRESSURE) == 0);
+                       assert((axes & WACOM_AXIS_TYPE_DISTANCE) == 0);
+               } else {
+                       assert(axes & WACOM_AXIS_TYPE_TILT);
+                       assert(axes & WACOM_AXIS_TYPE_PRESSURE);
+                       assert(axes & WACOM_AXIS_TYPE_DISTANCE);
+               }
        }
        assert(libwacom_get_ring_num_modes(device) >= 0);
        assert(libwacom_get_ring2_num_modes(device) >= 0);
-- 
2.1.0


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to