Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 libwacom/libwacom.c |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++
 libwacom/libwacom.h |   16 +++++++++++++++
 2 files changed, 72 insertions(+)

diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
index eaf5e2c..c16c104 100644
--- a/libwacom/libwacom.c
+++ b/libwacom/libwacom.c
@@ -222,6 +222,62 @@ libwacom_copy(const WacomDevice *device)
        return d;
 }
 
+
+static int
+compare_matches(const WacomDevice *a, const WacomDevice *b)
+{
+       /* FIXME: fill this in */
+       return 0;
+}
+
+int
+libwacom_compare(const WacomDevice *a, const WacomDevice *b, WacomCompareFlags 
flags)
+{
+       if ((a && !b) || (b && !a))
+               return 1;
+
+       if (strcmp(a->name, b->name) != 0)
+               return 1;
+
+       if (a->width != b->width || a->height != b->height)
+               return 1;
+
+       if (a->cls != b->cls)
+               return 1;
+
+       if (a->num_strips != b->num_strips)
+               return 1;
+
+       if (a->features != b->features)
+               return 1;
+
+       if (a->strips_num_modes != b->strips_num_modes)
+               return 1;
+
+       if (a->ring_num_modes != b->ring_num_modes)
+               return 1;
+
+       if (a->ring2_num_modes != b->ring2_num_modes)
+               return 1;
+
+       if (a->num_buttons != b->num_buttons)
+               return 1;
+
+       if (a->num_styli != b->num_styli)
+               return 1;
+
+       if (memcmp(a->supported_styli, b->supported_styli, sizeof(int) * 
a->num_styli) != 0)
+               return 1;
+
+       if (memcmp(a->buttons, b->buttons, sizeof(WacomButtonFlags) * 
a->num_buttons) != 0)
+               return 1;
+
+       if ((flags & WCOMPARE_MATCHES) && compare_matches(a, b) != 0)
+               return 1;
+
+       return 0;
+}
+
 static const WacomDevice *
 libwacom_new (WacomDeviceDatabase *db, int vendor_id, int product_id, 
WacomBusType bus, WacomError *error)
 {
diff --git a/libwacom/libwacom.h b/libwacom/libwacom.h
index 11192a4..b3a30ef 100644
--- a/libwacom/libwacom.h
+++ b/libwacom/libwacom.h
@@ -167,6 +167,11 @@ typedef enum {
        WFALLBACK_GENERIC = 1
 } WacomFallbackFlags;
 
+typedef enum {
+       WCOMPARE_NORMAL         = 0,            /**< compare the device only */
+       WCOMPARE_MATCHES        = (1 << 1),     /**< compare all possible 
matches too */
+} WacomCompareFlags;
+
 /**
  * Allocate a new structure for error reporting.
  *
@@ -290,6 +295,17 @@ void libwacom_print_device_description (FILE *file, 
WacomDevice *device);
 void libwacom_destroy(WacomDevice *device);
 
 /**
+ * Compare the two devices for equal-ness.
+ *
+ * @param a The first device
+ * @param b The second device
+ * @param flags Flags to dictate what constitutes a match
+ *
+ * @return 0 if the devices are identical, nonzero otherwise
+ */
+int libwacom_compare(const WacomDevice *a, const WacomDevice *b, 
WacomCompareFlags flags);
+
+/**
  * @param device The tablet to query
  * @return The class of the device
  */
-- 
1.7.10


------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to