Currently only PressCurve but I guess we'll have more of those soon.

Signed-off-by: Peter Hutterer <[email protected]>
---
 tools/xsetwacom.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 59602b4..e1f2753 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -945,6 +945,28 @@ static XDevice* find_device(Display *display, char *name)
        return dev;
 }
 
+/* Return True if the given device has the property, or False otherwise */
+static Bool test_property(Display *dpy, XDevice* dev, Atom prop)
+{
+       int nprops_return;
+       Atom *properties;
+       int found = False;
+
+       properties = XListDeviceProperties(dpy, dev, &nprops_return);
+
+       while(nprops_return--)
+       {
+               if (properties[nprops_return] == prop)
+               {
+                       found = True;
+                       break;
+               }
+       }
+
+       XFree(properties);
+       return found;
+}
+
 static void list_one_device(Display *dpy, XDeviceInfo *info)
 {
        static int      wacom_prop = 0;
@@ -1871,6 +1893,13 @@ static void get_presscurve(Display *dpy, XDevice *dev, 
param_t *param, int argc,
 
        TRACE("Getting pressure curve for device %ld.\n", dev->device_id);
 
+       if (!test_property(dpy, dev, prop))
+       {
+               fprintf(stderr, "Property '%s' does not exist on device.\n",
+                               param->prop_name);
+                               return;
+       }
+
        XGetDeviceProperty(dpy, dev, prop, 0, 1000, False, AnyPropertyType,
                                &type, &format, &nitems, &bytes_after, &data);
 
-- 
1.7.0.1


------------------------------------------------------------------------------

_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to