On Fri, Jan 20, 2012 at 10:55:59AM -0800, Jason Gerecke wrote: > On Thu, Jan 19, 2012 at 8:12 PM, Peter Hutterer > <peter.hutte...@who-t.net> wrote: > > CC-ing Eduard, since he's been working on this as well > > > > On Wed, Jan 18, 2012 at 08:15:47PM -0600, Chris Bagwell wrote: > >> Well, this showed up just in time for me to be conflicted. I've > >> completed support for monitoring the battery on wireless bamboo's and > >> thinking about adding support to control powersavings timeout period > >> like Windows driver has. Its kinda a waste unless there is a GUI to > >> go with it though. > >> > >> Since sysfs is only read/write by root, we need to overcome that. I > >> was going to make a python daemon that advertises wacom sysfs changes > >> on DBUS and supports modifying timeout via DBUS requests. Then add > >> some sort of applet GUI for end users that talks over DBUS. > >> > >> Well, you've provided an interesting alternative to DBUS. It solves > >> the root issue and if we could somehow do a select() on the sysfs then > >> I could monitor for battery changes as well and advertise changes as > >> property updates. > >> > >> For me, its probably the same amount of total code either way. I need > >> to decide on if its appropriate to put these type of features into > >> xf86-input-wacom. > >> > >> I'm more comfortable working with DBUS then X properties (says the guy > >> working on X drivers :-) ) so probably why I chose it. > >> > >> I probably only have 1 code comment beyond a general concern if this > >> is a feature we should be support (I'd like to hear others opinions). > >> See below. > > > > the reason why I'd like to see this as a property is simple: graphical > > applications already communicate with the X server for events and thus have > > device-specific knowledge (XI/XI2 applications anyway). I consider the LED > > just as an additional feature on the device, so controlling it through a > > device property seems to make sense. > > > > Otherwise a client would have to figure out which device it is that needs > > the LED changed, hook up to sysfs (or some custom daemon). Said daemon would > > need to provide notification systems (if more than one client access the > > LED), etc. All this infrastructure is already there in X, even if it may not > > necessarily be the sanest infrastructure.. > > > > Comments regarding the patch itself are in a separate email. > > > > Cheers, > > Peter > > > This is actually kind of what I thought you were getting at the first > time you mentioned the idea of libwacom to me. An intermediary library > that takes the ugly out of working directly with the X properties that > we expose. Combined with a deep knowledge of the actual tablet, > clients could do some really neat things without having to duplicate > code. For example, it'd be awesome if clients could find out (or > libwacom somehow handled) the Intuos4's quirk where the first button > in the X properties is *not* the top-left button.
refresh my memory: is this a bug or a feature? if it's a bug, I'd argue for not worrying about it too much, otherwise we'll just end up in ifdef hell. > Of course, the devil's in figuring out how to represent those quirks > (both to libwacom in its config files, and to clients via the API)... some of it is true. yes, I want libwacom to be a convenience library so that clients don't have to poke at properties around. Nonetheless, the above is still true - the client that has to do all the work would just be libwacom (plus any client not using it). > Or the quirk that > the 24HD can actually turn off all the LEDs in a bank since it only > has 3 of the expected 4 LEDs. other tablets can't turn off all LEDs? Cheers, Peter > >> On Wed, Jan 18, 2012 at 6:25 PM, Ping Cheng <pingli...@gmail.com> wrote: > >> > Signed-off-by: Ping Cheng <pi...@wacom.com> > >> > --- > >> > Changes to v1: > >> > Updated test_parameter_number; > >> > Added DBG to report sysfs node. > >> > --- > >> > include/wacom-properties.h | 3 ++ > >> > man/xsetwacom.man | 7 ++++ > >> > src/wcmCommon.c | 4 ++- > >> > src/wcmConfig.c | 67 > >> > +++++++++++++++++++++++++++++++++++++++++++- > >> > src/wcmXCommand.c | 39 +++++++++++++++++++++++++- > >> > src/xf86Wacom.c | 14 ++++++++- > >> > src/xf86WacomDefs.h | 6 +++- > >> > tools/xsetwacom.c | 18 +++++++++++- > >> > 8 files changed, 152 insertions(+), 6 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. <lep...@xfree86.org> > >> > - * Copyright 2002-2010 by Ping Cheng, Wacom. <pi...@wacom.com> > >> > + * Copyright 2002-2012 by Ping Cheng, Wacom. <pi...@wacom.com> > >> > * > >> > * 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..aff8b0f 100644 > >> > --- a/src/wcmConfig.c > >> > +++ b/src/wcmConfig.c > >> > @@ -1,6 +1,6 @@ > >> > /* > >> > * Copyright 1995-2002 by Frederic Lepied, France. <lep...@xfree86.org> > >> > - * Copyright 2002-2010 by Ping Cheng, Wacom. <pi...@wacom.com> > >> > + * Copyright 2002-2012 by Ping Cheng, Wacom. <pi...@wacom.com> > >> > * > >> > * 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,65 @@ 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'; > >> > + } > >> > + else > >> > + DBG(2, common, "No LED0 sysfs on %s for %s\n", > >> > + fs_path, pInfo->name); > >> > + > >> > + 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'; > >> > + } > >> > + else > >> > + DBG(2, common, "No LED1 sysfs on %s for %s\n", > >> > + fs_path, pInfo->name); > >> > >> This is complicated enough that I'd factor it out into a function for > >> common behavior or at list make it a for() loop somehow. > >> > >> Chris > >> > >> > +} > >> > + > >> > /* wcmPreInit - called for each input devices with the driver set to > >> > * "wacom" */ > >> > #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12 > >> > @@ -524,9 +584,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. <pi...@wacom.com> > >> > + * Copyright 2007-2012 by Ping Cheng, Wacom. <pi...@wacom.com> > >> > * > >> > * 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. <lep...@xfree86.org> > >> > - * Copyright 2002-2010 by Ping Cheng, Wacom. <pi...@wacom.com> > >> > + * Copyright 2002-2012 by Ping Cheng, Wacom. <pi...@wacom.com> > >> > * > >> > * 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. <lep...@xfree86.org> > >> > - * Copyright 2002-2010 by Ping Cheng, Wacom. <pi...@wacom.com> > >> > + * Copyright 2002-2012 by Ping Cheng, Wacom. <pi...@wacom.com> > >> > * > >> > * 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..fa22352 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). ", > >> > @@ -2689,7 +2705,7 @@ static void test_parameter_number(void) > >> > * deprecated them. > >> > * Numbers include trailing NULL entry. > >> > */ > >> > - assert(ARRAY_SIZE(parameters) == 36); > >> > + assert(ARRAY_SIZE(parameters) == 38); > >> > assert(ARRAY_SIZE(deprecated_parameters) == 17); > >> > } > >> > > >> > -- > >> > 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 > >> > Linuxwacom-devel@lists.sourceforge.net > >> > https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel > >> > >> ------------------------------------------------------------------------------ > >> 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 > >> Linuxwacom-devel@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel > >> > > Cheers, > > Peter > > > > ------------------------------------------------------------------------------ > > 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 > > Linuxwacom-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel > ------------------------------------------------------------------------------ Try before you buy = See our experts in action! 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-dev2 _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel