Hi,
As an owner of multiple tools and a intuos and and a gimp developer
being able to hotplug my tablet with all the trimmings is important,
so Ive hacked up this patch. It's fully functional, but with one
caveat. xsetwacom-s ability to report ToolSerials seems to be broken.
All I get from it is 0. Fortunately I had an old configuration file
from the watahod tool around, so I go the serials from there. I think
the alternative way of getting it is turning on full debug log and
getting them from there.
The patch provides a configuration option ToolSerials for
50-wacom.conf that takes currently a list of ";" separated serials. I
want to extend this so that the user can provide tools to be added,
so either stylus, eraser or both and optionally a nickname for the pen
to be used instead of the generated name.
I'm posting this for some early review and a lost of things that must
be fixed to be considered for inclusion.
Best,
--Alexia
From ba79692c80f0c9ebd68068b92486a6bed58ffd92 Mon Sep 17 00:00:00 2001
From: Alexia Death <[email protected]>
Date: Fri, 26 Nov 2010 21:04:12 +0200
Subject: [PATCH] Add basic tool serial hotplug support
---
src/wcmValidateDevice.c | 70 ++++++++++++++++++++++++++++++++++++++++++-----
src/xf86WacomDefs.h | 4 +++
2 files changed, 67 insertions(+), 7 deletions(-)
diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c
index b2ec79e..f7231dc 100644
--- a/src/wcmValidateDevice.c
+++ b/src/wcmValidateDevice.c
@@ -289,7 +289,7 @@ int wcmDeviceTypeKeys(InputInfoPtr pInfo)
/**
* Duplicate xf86 options, replace the "type" option with the given type
* (and the name with "$name $type" and convert them to InputOption */
-static InputOption *wcmOptionDupConvert(InputInfoPtr pInfo, const char* basename, const char *type)
+static InputOption *wcmOptionDupConvert(InputInfoPtr pInfo, const char* basename, const char *type, int serial)
{
pointer original = pInfo->options;
InputOption *iopts = NULL, *new;
@@ -307,11 +307,17 @@ static InputOption *wcmOptionDupConvert(InputInfoPtr pInfo, const char* basename
options = dummy.options;
}
#endif
-
- name = Xprintf("%s %s", basename, type);
+ if (serial > 0)
+ name = Xprintf("%s %s %d", basename, type, serial);
+ else
+ name = Xprintf("%s %s", basename, type);
options = xf86ReplaceStrOption(options, "Type", type);
options = xf86ReplaceStrOption(options, "Name", name);
+
+ if (serial > 0)
+ options = xf86ReplaceIntOption(options, "Serial", serial);
+
free(name);
while(options)
@@ -362,7 +368,7 @@ static InputAttributes* wcmDuplicateAttributes(InputInfoPtr pInfo,
* erasor, stylus, pad, touch, cursor, etc.
* Name of the new device is set automatically to "<device name> <type>".
*/
-static void wcmHotplug(InputInfoPtr pInfo, const char* basename, const char *type)
+static void wcmHotplug(InputInfoPtr pInfo, const char* basename, const char *type, int serial)
{
DeviceIntPtr dev; /* dummy */
InputOption *input_options;
@@ -370,7 +376,7 @@ static void wcmHotplug(InputInfoPtr pInfo, const char* basename, const char *typ
InputAttributes *attrs = NULL;
#endif
- input_options = wcmOptionDupConvert(pInfo, basename, type);
+ input_options = wcmOptionDupConvert(pInfo, basename, type, serial);
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 11
attrs = wcmDuplicateAttributes(pInfo, type);
@@ -390,7 +396,9 @@ static void wcmHotplug(InputInfoPtr pInfo, const char* basename, const char *typ
void wcmHotplugOthers(InputInfoPtr pInfo, const char *basename)
{
- int i, skip = 1;
+ WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
+ WacomCommonPtr common = priv->common;
+ int i, j, skip = 1;
char* device;
xf86Msg(X_INFO, "%s: hotplugging dependent devices.\n", pInfo->name);
@@ -404,9 +412,28 @@ void wcmHotplugOthers(InputInfoPtr pInfo, const char *basename)
if (skip)
skip = 0;
else
- wcmHotplug(pInfo, basename, wcmType[i].type);
+ wcmHotplug(pInfo, basename, wcmType[i].type, 0);
}
}
+
+ if (common->nserials > 0)
+ {
+ for (j = 0; j < common->nserials; j++)
+ {
+ xf86Msg(X_INFO, "%s: hotplugging serial %d.\n", pInfo->name, common->serials[j]);
+
+ if (wcmIsAValidType(pInfo, "stylus"))
+ {
+ wcmHotplug(pInfo, basename, "stylus", common->serials[j]);
+ }
+
+ if (wcmIsAValidType(pInfo, "eraser"))
+ {
+ wcmHotplug(pInfo, basename, "eraser", common->serials[j]);
+ }
+ }
+ }
+
xf86Msg(X_INFO, "%s: hotplugging completed.\n", pInfo->name);
}
@@ -550,6 +577,35 @@ int wcmParseOptions(InputInfoPtr pInfo, int hotplugged)
wcmSetPressureCurve(priv,a,b,c,d);
}
+ /*Serials of tools we want hotpluged*/
+ s = xf86SetStrOption(pInfo->options, "ToolSerials", NULL);
+ if (s)
+ {
+ int i = 0;
+ char* tok = strtok(s, ";");
+ while ((tok != NULL) && (i < WCM_MAX_SERIALS))
+ {
+ int serial;
+
+ sscanf(tok,"%d",&serial);
+
+ xf86Msg(X_CONFIG, "%s: Tool serial %d found.\n",
+ pInfo->name, serial);
+
+ common->serials[i] = serial;
+
+ tok = strtok(NULL,",");
+ i++;
+ }
+ common->nserials = i;
+
+ if ((i == WCM_MAX_SERIALS) && (tok != NULL))
+ xf86Msg(X_CONFIG, "%s: Only %d tool serials supported, you had more listed.\n",
+ pInfo->name, WCM_MAX_SERIALS);
+
+ }
+
+
if (IsCursor(priv))
{
common->wcmCursorProxoutDist = xf86SetIntOption(pInfo->options, "CursorProx", 0);
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index 8cdc9e2..5135a4d 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -152,6 +152,8 @@ struct _WacomModel
* For backword compability support,
* tablet buttons besides the strips are
* treated as buttons */
+#define WCM_MAX_SERIALS 32 /* maximum number of tablet buttons */
+
/* get/set/property */
typedef struct _PROPINFO PROPINFO;
@@ -443,6 +445,8 @@ struct _WacomCommonRec
void *private; /* backend-specific information */
WacomToolPtr wcmTool; /* List of unique tools */
+ int serials[WCM_MAX_SERIALS];/* Serial numbers provided at startup*/
+ int nserials; /*Number of serials configured*/
/* DO NOT TOUCH THIS. use wcmRefCommon() instead */
int refcnt; /* number of devices sharing this struct */
--
1.7.1
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel