[gnome-settings-daemon] wacom: Add method to get the default calibration values



commit 0886a389b5872b4b5528fe591d651c06bc0300fe
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Oct 8 17:49:49 2013 +0200

    wacom: Add method to get the default calibration values
    
    From the device's valuators.

 plugins/wacom/gsd-wacom-device.c |   71 ++++++++++++++++++++++++++++++++++++++
 plugins/wacom/gsd-wacom-device.h |    1 +
 2 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c
index 918363f..cd75960 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -1903,6 +1903,77 @@ gsd_wacom_device_get_area (GsdWacomDevice *device)
        return device_area;
 }
 
+static gboolean
+fill_old_axis (int     device_id,
+              gint  **items)
+{
+       int ndevices, i;
+       XDeviceInfoPtr list, slist;
+       gboolean retval = FALSE;
+
+       slist = list = (XDeviceInfoPtr) XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), 
&ndevices);
+
+       for (i = 0; i < ndevices; i++, list++) {
+               XAnyClassPtr any = (XAnyClassPtr) (list->inputclassinfo);
+               int j;
+
+               /* Core pointer and keyboard */
+               if (list->use == IsXKeyboard || list->use == IsXPointer)
+                       continue;
+
+               if (list->id != device_id)
+                       continue;
+
+               for (j = 0; j < list->num_classes; j++) {
+                       if (any->class == ValuatorClass) {
+                               XValuatorInfoPtr V = (XValuatorInfoPtr) any;
+                               XAxisInfoPtr ax = (XAxisInfoPtr) V->axes;
+
+                               if (V->mode == Absolute && V->num_axes >= 2) {
+                                       *items[0] = ax[0].min_value;
+                                       *items[1] = ax[0].max_value;
+                                       *items[2] = ax[1].min_value;
+                                       *items[3] = ax[1].max_value;
+                                       g_debug ("Found factory values for device calibration");
+                                       retval = TRUE;
+                                       break;
+                               }
+                       }
+
+                       /*
+                        * Increment 'any' to point to the next item in the linked
+                        * list.  The length is in bytes, so 'any' must be cast to
+                        * a character pointer before being incremented.
+                        */
+                       any = (XAnyClassPtr) ((char *) any + any->length);
+               }
+       }
+       XFreeDeviceList(slist);
+
+       return retval;
+}
+
+gint *
+gsd_wacom_device_get_default_area (GsdWacomDevice *device)
+{
+       int id;
+       gint *device_area;
+       gboolean ret;
+
+       g_return_val_if_fail (GSD_IS_WACOM_DEVICE (device), NULL);
+
+       g_object_get (device->priv->gdk_device, "device-id", &id, NULL);
+
+       device_area = g_new0 (int, 4);
+       ret = fill_old_axis (id, &device_area);
+       if (!ret) {
+               g_free (device_area);
+               return NULL;
+       }
+
+       return device_area;
+}
+
 const char *
 gsd_wacom_device_type_to_string (GsdWacomDeviceType type)
 {
diff --git a/plugins/wacom/gsd-wacom-device.h b/plugins/wacom/gsd-wacom-device.h
index 3657e88..3753218 100644
--- a/plugins/wacom/gsd-wacom-device.h
+++ b/plugins/wacom/gsd-wacom-device.h
@@ -173,6 +173,7 @@ GsdWacomStylus * gsd_wacom_device_get_stylus_for_type (GsdWacomDevice     *devic
 
 GsdWacomDeviceType gsd_wacom_device_get_device_type (GsdWacomDevice *device);
 gint           * gsd_wacom_device_get_area          (GsdWacomDevice *device);
+gint           * gsd_wacom_device_get_default_area  (GsdWacomDevice *device);
 const char     * gsd_wacom_device_type_to_string    (GsdWacomDeviceType type);
 GList          * gsd_wacom_device_get_buttons       (GsdWacomDevice *device);
 GsdWacomTabletButton *gsd_wacom_device_get_button   (GsdWacomDevice   *device,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]