Signed-off-by: Ping Cheng <[email protected]>
---
 include/wacom-properties.h |    3 ++
 man/xsetwacom.man          |    7 +++++
 src/wcmCommon.c            |    4 ++-
 src/wcmConfig.c            |   61 +++++++++++++++++++++++++++++++++++++++++++-
 src/wcmXCommand.c          |   39 +++++++++++++++++++++++++++-
 src/xf86Wacom.c            |   14 +++++++++-
 src/xf86WacomDefs.h        |    6 +++-
 tools/xsetwacom.c          |   16 +++++++++++
 8 files changed, 145 insertions(+), 5 deletions(-)

diff --git a/include/wacom-properties.h b/include/wacom-properties.h
index 0bb84b1..b2a3523 100644
--- a/include/wacom-properties.h
+++ b/include/wacom-properties.h
@@ -46,6 +46,9 @@
   */
 #define WACOM_PROP_STRIPBUTTONS "Wacom Strip Buttons"
 
+/* 8 bit, 2 values, LED0 (right side) and LED1 (left side) */
+#define WACOM_PROP_LED "Wacom LEDs"
+
 /* 8 bit, 6 values, rel wheel up, rel wheel down, abs wheel up, abs wheel 
down, abs wheel 2 up, abs wheel 2 down
    OR
    Atom, 6 values , rel wheel up, rel wheel down, abs wheel up, abs wheel 
down, abs wheel 2 up, abs wheel 2 down
diff --git a/man/xsetwacom.man b/man/xsetwacom.man
index dc0995f..97da416 100644
--- a/man/xsetwacom.man
+++ b/man/xsetwacom.man
@@ -201,6 +201,13 @@ sets the max distance from tablet to stop reporting 
movement for cursor in
 relative mode. Default for Intuos series is 10, for Graphire series (including
 Volitos) is 42. Only available for the cursor/puck device.
 .TP
+\fBLED0\fR status
+Set the right LED status of an Intuos4/Cintiq 21UX/Cintiq 24HD. Default:  0,
+range of 0 to 3.
+.TP
+\fBLED1\fR status
+Set the left LED status of a Cintiq 21UX/24HD. Default:  0, range of 0 to 3.
+.TP
 \fBThreshold\fR level
 Set the minimum pressure necessary to generate a Button event for the stylus
 tip, eraser, or touch.  The pressure levels of all tablets are normalized to
diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 0f041e3..e4a8630 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -1,6 +1,6 @@
 /*
  * Copyright 1995-2002 by Frederic Lepied, France. <[email protected]>
- * Copyright 2002-2010 by Ping Cheng, Wacom. <[email protected]>
+ * Copyright 2002-2012 by Ping Cheng, Wacom. <[email protected]>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -1472,6 +1472,8 @@ WacomCommonPtr wcmNewCommon(void)
        common->wcmMaxStripY = 4096;       /* Max fingerstrip Y */
        common->wcmMaxtiltX = 128;         /* Max tilt in X directory */
        common->wcmMaxtiltY = 128;         /* Max tilt in Y directory */
+       common->fd_sysfs0 = -1;            /* file descriptor to sysfs led0 */
+       common->fd_sysfs1 = -1;            /* file descriptor to sysfs led1 */
        common->wcmCursorProxoutDistDefault = PROXOUT_INTUOS_DISTANCE;
                        /* default to Intuos */
        common->wcmSuppress = DEFAULT_SUPPRESS;
diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 5920e11..72aaa68 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -1,6 +1,6 @@
 /*
  * Copyright 1995-2002 by Frederic Lepied, France. <[email protected]>
- * Copyright 2002-2010 by Ping Cheng, Wacom. <[email protected]>
+ * Copyright 2002-2012 by Ping Cheng, Wacom. <[email protected]>
  *                                                                            
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -21,6 +21,7 @@
 #include <config.h>
 #endif
 
+#include <libudev.h>
 #include "xf86Wacom.h"
 #include "wcmFilter.h"
 #include <sys/stat.h>
@@ -441,6 +442,59 @@ static int wcmIsHotpluggedDevice(InputInfoPtr pInfo)
        return !strcmp(source, "_driver/wacom");
 }
 
+static void wcmStoreLEDsysfsInfo(InputInfoPtr pInfo)
+{
+       WacomDevicePtr  priv = (WacomDevicePtr)pInfo->private;
+       WacomCommonPtr  common = priv->common;
+       struct stat st;
+       struct udev *udev = udev_new();
+       struct udev_device *parent;
+       struct udev_device *device;
+       char fs_path[128], buf[10];
+       int err = -1;
+
+       stat(common->device_path, &st);
+       device = udev_device_new_from_devnum(udev, 'c', st.st_rdev);
+       if (!device)
+               return;
+
+       parent = udev_device_get_parent_with_subsystem_devtype(device,
+                "usb", NULL);
+
+       if (!parent)
+               return;
+
+       sprintf(fs_path, "%s/wacom_led/status_led0_select",
+               udev_device_get_syspath(parent));
+       common->fd_sysfs0 = open(fs_path, O_RDWR);
+       if (common->fd_sysfs0 >= 0)
+       {
+               SYSCALL(err = read(common->fd_sysfs0, buf, 1));
+               if (err < -1)
+               {
+                       xf86Msg(X_WARNING, "%s: failed to get led0 status in "
+                               "wcmStoreLEDsysfsInfo.\n", pInfo->name);
+               }
+               else
+                       common->led0_status = buf[0] - '0';
+       }
+
+       sprintf(fs_path, "%s/wacom_led/status_led1_select",
+               udev_device_get_syspath(parent));
+       common->fd_sysfs1 = open(fs_path, O_RDWR);
+       if (common->fd_sysfs1 >= 0)
+       {
+               SYSCALL(err = read(common->fd_sysfs1, buf, 1));
+               if (err < -1)
+               {
+                       xf86Msg(X_WARNING, "%s: failed to get led1 status in "
+                               "wcmStoreLEDsysfsInfo.\n", pInfo->name);
+               }
+               else
+                       common->led1_status = buf[0] - '0';
+       }
+}
+
 /* wcmPreInit - called for each input devices with the driver set to
  * "wacom" */
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
@@ -524,9 +578,14 @@ static int wcmPreInit(InputDriverPtr drv, InputInfoPtr 
pInfo, int flags)
 
        /* check if this is the first tool on the port */
        if (!wcmMatchDevice(pInfo, &common))
+       {
                /* initialize supported keys with the first tool on the port */
                wcmDeviceTypeKeys(pInfo);
 
+               /* store lED sysfs file descriptor and initial status */
+               wcmStoreLEDsysfsInfo(pInfo);
+       }
+
        common->debugLevel = xf86SetIntOption(pInfo->options,
                                              "CommonDBG", common->debugLevel);
        oldname = pInfo->name;
diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
index 40393dc..aec3fee 100644
--- a/src/wcmXCommand.c
+++ b/src/wcmXCommand.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007-2010 by Ping Cheng, Wacom. <[email protected]>
+ * Copyright 2007-2012 by Ping Cheng, Wacom. <[email protected]>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -91,6 +91,7 @@ Atom prop_tv_resolutions;
 Atom prop_cursorprox;
 Atom prop_threshold;
 Atom prop_suppress;
+Atom prop_led;
 Atom prop_touch;
 Atom prop_gesture;
 Atom prop_gesture_param;
@@ -206,6 +207,10 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
        values[1] = common->wcmRawSample;
        prop_suppress = InitWcmAtom(pInfo->dev, WACOM_PROP_SAMPLE, XA_INTEGER, 
32, 2, values);
 
+       values[0] = common->led0_status;
+       values[1] = common->led1_status;
+       prop_led = InitWcmAtom(pInfo->dev, WACOM_PROP_LED, XA_INTEGER, 8, 2, 
values);
+
        values[0] = common->wcmTouch;
        prop_touch = InitWcmAtom(pInfo->dev, WACOM_PROP_TOUCH, XA_INTEGER, 8, 
1, values);
 
@@ -695,6 +700,38 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property, 
XIPropertyValuePtr prop,
                        common->wcmSuppress = values[0];
                        common->wcmRawSample = values[1];
                }
+       } else if (property == prop_led)
+       {
+               CARD8 *values;
+
+               if (prop->size != 2 || prop->format != 8)
+                       return BadValue;
+
+               values = (CARD8*)prop->data;
+
+               if ((values[0] < 0) || (values[0] > 3))
+                       return BadValue;
+               else if ((common->fd_sysfs0 >= 0) && !checkonly)
+               {
+                       char buf[10];
+                       int err = -1;
+                       sprintf(buf, "%d", values[0]);
+                       err = xf86WriteSerial(common->fd_sysfs0, buf, 
strlen(buf));
+                       if (err == strlen(buf))
+                               common->led0_status = values[0];
+               }
+
+               if ((values[1] < 0) || (values[1] > 3))
+                       return BadValue;
+               else if ((common->fd_sysfs1 >= 0) && !checkonly)
+               {
+                       char buf[10];
+                       int err = -1;
+                       sprintf(buf, "%d", values[1]);
+                       err = xf86WriteSerial(common->fd_sysfs1, buf, 
strlen(buf));
+                       if (err == strlen(buf))
+                               common->led1_status = values[1];
+               }
        } else if (property == prop_rotation)
        {
                CARD8 value;
diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index d1c149f..de7135c 100644
--- a/src/xf86Wacom.c
+++ b/src/xf86Wacom.c
@@ -1,6 +1,6 @@
 /*
  * Copyright 1995-2002 by Frederic Lepied, France. <[email protected]> 
- * Copyright 2002-2010 by Ping Cheng, Wacom. <[email protected]>
+ * Copyright 2002-2012 by Ping Cheng, Wacom. <[email protected]>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -770,6 +770,18 @@ static void wcmDevClose(InputInfoPtr pInfo)
                        xf86CloseSerial (common->fd);
                }
        }
+
+       if (common->fd_sysfs0 >= 0)
+       {
+               xf86CloseSerial(common->fd_sysfs0);
+               common->fd_sysfs0 = -1;
+       }
+
+       if (common->fd_sysfs1 >= 0)
+       {
+               xf86CloseSerial(common->fd_sysfs1);
+               common->fd_sysfs1 = -1;
+       }
 }
 
 static void wcmEnableDisableTool(DeviceIntPtr dev, Bool enable)
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index 2f3f7b4..22dea41 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -1,6 +1,6 @@
 /*
  * Copyright 1995-2002 by Frederic Lepied, France. <[email protected]>
- * Copyright 2002-2010 by Ping Cheng, Wacom. <[email protected]>
+ * Copyright 2002-2012 by Ping Cheng, Wacom. <[email protected]>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -420,6 +420,10 @@ struct _WacomCommonRec
        int tablet_type;             /* bitmask of tablet features (WCM_LCD, 
WCM_PEN, etc) */
        int fd;                      /* file descriptor to tablet */
        int fd_refs;                 /* number of references to fd; if =0, fd 
is invalid */
+       int fd_sysfs0;               /* file descriptor to sysfs led0 */
+       int fd_sysfs1;               /* file descriptor to sysfs led1 */
+       unsigned char led0_status;   /* Right LED status */
+       unsigned char led1_status;   /* Left LED status */
        unsigned long wcmKeys[NBITS(KEY_MAX)]; /* supported tool types for the 
device */
        WacomDevicePtr wcmTouchDevice; /* The pointer for pen to access the
                                          touch tool of the same device id */
diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 9ab285b..1f984ad 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -361,6 +361,22 @@ static param_t parameters[] =
                .get_func = get_map,
        },
        {
+               .name = "LED0",
+               .desc = "Sets right LED status ",
+               .prop_name = WACOM_PROP_LED,
+               .prop_format = 8,
+               .prop_offset = 0,
+               .arg_count = 1,
+       },
+       {
+               .name = "LED1",
+               .desc = "Sets left LED status ",
+               .prop_name = WACOM_PROP_LED,
+               .prop_format = 8,
+               .prop_offset = 1,
+               .arg_count = 1,
+       },
+       {
                .name = "Threshold",
                .desc = "Sets tip/eraser pressure threshold "
                "(default is 27). ",
-- 
1.7.6.4


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to