libinput needs to tell whether a wheel is present to set up the tool axes
correctly.

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

diff --git a/data/libwacom.stylus b/data/libwacom.stylus
index 318936d..ceed599 100644
--- a/data/libwacom.stylus
+++ b/data/libwacom.stylus
@@ -314,6 +314,7 @@ Type=Airbrush
 Name=Lens Cursor
 Type=Puck
 HasLens=true
+HasWheel=false
 Buttons=5
 
 [0x097]
@@ -321,6 +322,7 @@ Buttons=5
 Name=Lens Cursor
 Type=Puck
 HasLens=true
+HasWheel=false
 Buttons=5
 
 [0x006]
@@ -328,6 +330,7 @@ Buttons=5
 Name=Lens Cursor
 Type=Puck
 HasLens=true
+HasWheel=false
 Buttons=5
 
 [0x094]
@@ -335,6 +338,7 @@ Buttons=5
 Name=4D Mouse
 Type=Puck
 HasLens=false
+HasWheel=false
 Buttons=5
 
 [0x007]
@@ -342,6 +346,7 @@ Buttons=5
 Name=2D Mouse
 Type=Puck
 HasLens=false
+HasWheel=true
 Buttons=3
 
 [0x017]
@@ -349,6 +354,7 @@ Buttons=3
 Name=Mouse
 Type=Puck
 HasLens=false
+HasWheel=true
 Buttons=5
 
 [0x806]
@@ -356,4 +362,5 @@ Buttons=5
 Name=Five Button Mouse
 Type=Puck
 HasLens=false
+HasWheel=true
 Buttons=5
diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c
index 33b8bdc..bd0c422 100644
--- a/libwacom/libwacom-database.c
+++ b/libwacom/libwacom-database.c
@@ -220,10 +220,15 @@ libwacom_parse_stylus_keyfile(WacomDeviceDatabase *db, 
const char *path)
                        if (error && error->code == 
G_KEY_FILE_ERROR_INVALID_VALUE)
                                g_warning ("Stylus %s (%s) %s\n", stylus->name, 
groups[i], error->message);
                        g_clear_error (&error);
+                       stylus->has_wheel = g_key_file_get_boolean(keyfile, 
groups[i], "HasWheel", &error);
+                       if (error && error->code == 
G_KEY_FILE_ERROR_INVALID_VALUE)
+                               g_warning ("Stylus %s (%s) %s\n", stylus->name, 
groups[i], error->message);
+                       g_clear_error (&error);
                } else {
                        stylus->num_buttons = 0;
                        stylus->has_eraser = FALSE;
                        stylus->has_lens = FALSE;
+                       stylus->has_wheel = FALSE;
                }
 
                type = g_key_file_get_string(keyfile, groups[i], "Type", NULL);
diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
index e32ce4a..c0c6ed3 100644
--- a/libwacom/libwacom.c
+++ b/libwacom/libwacom.c
@@ -1032,6 +1032,11 @@ int libwacom_stylus_has_lens (const WacomStylus *stylus)
        return stylus->has_lens;
 }
 
+int libwacom_stylus_has_wheel (const WacomStylus *stylus)
+{
+       return stylus->has_wheel;
+}
+
 WacomStylusType libwacom_stylus_get_type (const WacomStylus *stylus)
 {
        if (stylus->type == WSTYLUS_UNKNOWN) {
@@ -1052,6 +1057,7 @@ libwacom_print_stylus_description (int fd, const 
WacomStylus *stylus)
        dprintf(fd, "HasEraser=%s\n", libwacom_stylus_has_eraser(stylus) ? 
"true" : "false");
        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");
 
        switch(libwacom_stylus_get_type(stylus)) {
                case WSTYLUS_UNKNOWN:   type = "Unknown";        break;
diff --git a/libwacom/libwacom.h b/libwacom/libwacom.h
index 476bcf7..b1c0ff8 100644
--- a/libwacom/libwacom.h
+++ b/libwacom/libwacom.h
@@ -561,6 +561,12 @@ int         libwacom_stylus_has_lens (const WacomStylus 
*stylus);
 
 /**
  * @param stylus The stylus to query
+ * @return Whether the stylus has a relative mouse wheel
+ */
+int         libwacom_stylus_has_wheel (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 f6adb7c..004b0aa 100644
--- a/libwacom/libwacomint.h
+++ b/libwacom/libwacomint.h
@@ -101,6 +101,7 @@ struct _WacomStylus {
        gboolean has_eraser;
        gboolean is_eraser;
        gboolean has_lens;
+       gboolean has_wheel;
        WacomStylusType type;
 };
 
diff --git a/test/tablet-validity.c b/test/tablet-validity.c
index 19a4b98..c7cfbc3 100644
--- a/test/tablet-validity.c
+++ b/test/tablet-validity.c
@@ -177,6 +177,19 @@ static void verify_tablet(WacomDeviceDatabase *db, 
WacomDevice *device)
                        type = libwacom_stylus_get_type (stylus);
                        assert(eraser_is_present (db, styli, nstyli, type));
                }
+
+               if (libwacom_stylus_get_type (stylus) == WSTYLUS_PUCK) {
+                       int has_wheel = libwacom_stylus_has_wheel (stylus);
+                       int has_lens = libwacom_stylus_has_lens (stylus);
+                       /* 4D mouse is the only one with neither, everything
+                        * else has either wheel or lens */
+                       if (styli[i] == 0x94) {
+                               assert (!has_wheel);
+                               assert (!has_lens);
+                       } else {
+                               assert (has_wheel != has_lens);
+                       }
+               }
        }
        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