Hi, Second iteration of my patches. These just concentrate on the driver side config snipplet support. I belive prop system hooks and solutions should be a separate issue in a separate patch after this is done. I tried to fix the points Peter commented on and also incorporate support for cursors.
--Alexia
From 8b35476dd0bae02f3ae35d033813046e7482ce1d Mon Sep 17 00:00:00 2001 From: Alexia Death <[email protected]> Date: Fri, 26 Nov 2010 21:04:12 +0200 Subject: [PATCH 1/2] Add tool serial hotplug support through ToolSerials parameter Adds a parameter named "ToolSerials" that takes a list of tool serials, with name and tool type (pen, airbrush cursor), to be turned into devices when a matching tablet appears. --- src/wcmCommon.c | 5 ++ src/wcmConfig.c | 2 + src/wcmValidateDevice.c | 120 +++++++++++++++++++++++++++++++++++++++++++++-- src/xf86WacomDefs.h | 21 ++++++++ 4 files changed, 143 insertions(+), 5 deletions(-) diff --git a/src/wcmCommon.c b/src/wcmCommon.c index ff4e423..f002502 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -1553,6 +1553,11 @@ void wcmFreeCommon(WacomCommonPtr *ptr) if (--common->refcnt == 0) { free(common->private); + while (--common->nserials >= 0) + { + free(common->serials[common->nserials]); + DBG(10, common, "Free common serial %d\n", common->nserials); + } free(common); } *ptr = NULL; diff --git a/src/wcmConfig.c b/src/wcmConfig.c index 2694306..7aa5051 100644 --- a/src/wcmConfig.c +++ b/src/wcmConfig.c @@ -142,6 +142,8 @@ static int wcmAllocate(InputInfoPtr pInfo) area->next = NULL; /* next area in list */ area->device = pInfo; /* associated WacomDevice */ + common->nserials = 0; + return 1; error: diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c index fd424dc..7f77461 100644 --- a/src/wcmValidateDevice.c +++ b/src/wcmValidateDevice.c @@ -297,9 +297,12 @@ 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 iserial) { + WacomDevicePtr priv = pInfo->private; + WacomCommonPtr common = priv->common; pointer original = pInfo->options; + WacomToolSerialPtr ser = common->serials[iserial]; InputOption *iopts = NULL, *new; char *name; pointer options; @@ -315,11 +318,23 @@ static InputOption *wcmOptionDupConvert(InputInfoPtr pInfo, const char* basename options = dummy.options; } #endif + if (iserial > -1) + { - name = Xprintf("%s %s", basename, type); + if (strlen(ser->name) > 0) + name = Xprintf("%s %s %s", basename, ser->name, type); + else + name = Xprintf("%s %d %s", basename, ser->serial, type); + } + else + name = Xprintf("%s %s", basename, type); options = xf86ReplaceStrOption(options, "Type", type); options = xf86ReplaceStrOption(options, "Name", name); + + if (iserial > -1) + options = xf86ReplaceIntOption(options, "Serial", ser->serial); + free(name); while(options) @@ -370,7 +385,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_id) { DeviceIntPtr dev; /* dummy */ InputOption *input_options; @@ -378,7 +393,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_id); #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 11 attrs = wcmDuplicateAttributes(pInfo, type); @@ -398,6 +413,8 @@ static void wcmHotplug(InputInfoPtr pInfo, const char* basename, const char *typ void wcmHotplugOthers(InputInfoPtr pInfo, const char *basename) { + WacomDevicePtr priv = (WacomDevicePtr)pInfo->private; + WacomCommonPtr common = priv->common; int i, skip = 1; char* device; @@ -412,9 +429,31 @@ void wcmHotplugOthers(InputInfoPtr pInfo, const char *basename) if (skip) skip = 0; else - wcmHotplug(pInfo, basename, wcmType[i].type); + wcmHotplug(pInfo, basename, wcmType[i].type, -1); + } + } + + if (common->nserials > 0) + { + for (i = 0; i < common->nserials; i++) + { + WacomToolSerialPtr ser = common->serials[i]; + xf86Msg(X_INFO, "%s: hotplugging serial %d.\n", pInfo->name, ser->serial); + + if (wcmIsAValidType(pInfo, "stylus") && + (ser->types & SERIAL_HAS_STYLUS)) + wcmHotplug(pInfo, basename, "stylus", i); + + if (wcmIsAValidType(pInfo, "eraser") && + (ser->types & SERIAL_HAS_ERASER)) + wcmHotplug(pInfo, basename, "eraser", i); + + if (wcmIsAValidType(pInfo, "cursor") && + (ser->types & SERIAL_HAS_CURSOR)) + wcmHotplug(pInfo, basename, "cursor", i); } } + xf86Msg(X_INFO, "%s: hotplugging completed.\n", pInfo->name); } @@ -558,6 +597,77 @@ 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 && (common->nserials == 0)) /*Dont parse again, if the commons have values already*/ + { + int nserials = 0; + char* tok = strtok(s, ";"); + while ((tok != NULL) && (nserials < WCM_MAX_SERIALS)) + { + int serial, nmatch; + char type[strlen(tok) + 1]; + char name[strlen(tok) + 1]; + WacomToolSerialPtr ser = malloc(sizeof(WacomToolSerial)); + + if (ser == NULL) + goto error; + + nmatch = sscanf(tok,"%d,%[a-z],%[A-Za-z ]",&serial, type, name); + + if (nmatch < 1) + { + xf86Msg(X_ERROR, "%s: %s is invalid serial string.\n", + pInfo->name, tok); + goto error; + } + + if (nmatch >= 1) + { + xf86Msg(X_CONFIG, "%s: Tool serial %d found.\n", + pInfo->name, serial); + + ser->serial = serial; + + ser->types = SERIAL_HAS_STYLUS | SERIAL_HAS_ERASER; /*Default to both tools*/ + } + + if (nmatch >= 2) + { + xf86Msg(X_CONFIG, "%s: Tool %d has type %s.\n", + pInfo->name, serial, type); + if ((strcmp(type, "pen") == 0) || (strcmp(type, "airbrush") == 0)) + ser->types = SERIAL_HAS_STYLUS | SERIAL_HAS_ERASER; + else if (strcmp(type, "artpen") == 0) + ser->types = SERIAL_HAS_STYLUS; + else if (strcmp(type, "cursor") == 0) + ser->types = SERIAL_HAS_CURSOR; + else xf86Msg(X_CONFIG, "%s: Invalid type %s, defaulting to pen.\n", + pInfo->name, type); + } + + if (nmatch == 3) + { + xf86Msg(X_CONFIG, "%s: Tool %d is named %s.\n", + pInfo->name, serial, name); + ser->name = strdup(name); + } + else ser->name = ""; /*no name yet*/ + + common->serials[nserials] = ser; + + tok = strtok(NULL,";"); + nserials++; + } + common->nserials = nserials; + + if ((nserials == WCM_MAX_SERIALS) && (tok != NULL)) + xf86Msg(X_CONFIG, "%s: Only %d tool serials supported, ignored the rest.\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 87d75d5..bd136eb 100644 --- a/src/xf86WacomDefs.h +++ b/src/xf86WacomDefs.h @@ -82,6 +82,8 @@ typedef struct _WacomFilterState WacomFilterState, *WacomFilterStatePtr; typedef struct _WacomDeviceClass WacomDeviceClass, *WacomDeviceClassPtr; typedef struct _WacomTool WacomTool, *WacomToolPtr; typedef struct _WacomToolArea WacomToolArea, *WacomToolAreaPtr; +typedef struct _WacomToolSerial WacomToolSerial, *WacomToolSerialPtr; + /****************************************************************************** * WacomModel - model-specific device capabilities @@ -162,6 +164,8 @@ struct _WacomModel * For backword compability support, * tablet buttons besides the strips are * treated as buttons */ +#define WCM_MAX_SERIALS 32 /* maximum number of tool serials to be hotplugged */ + /* get/set/property */ typedef struct _PROPINFO PROPINFO; @@ -382,6 +386,10 @@ enum WacomProtocol { WCM_PROTOCOL_5 }; +#define SERIAL_HAS_ERASER 1 +#define SERIAL_HAS_STYLUS 2 +#define SERIAL_HAS_CURSOR 4 + struct _WacomCommonRec { /* Do not move device_path, same offset as priv->name. Used by DBG macro */ @@ -453,6 +461,8 @@ struct _WacomCommonRec void *private; /* backend-specific information */ WacomToolPtr wcmTool; /* List of unique tools */ + WacomToolSerialPtr 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 */ @@ -490,6 +500,17 @@ struct _WacomToolArea InputInfoPtr device; /* The InputDevice connected to this area */ }; +/****************************************************************************** + * WacomToolSerial + *****************************************************************************/ +struct _WacomToolSerial +{ + + int serial; /* Serial id */ + int types; /* Tool types this serial has */ + char *name; /* Label for the tool*/ +}; + #endif /*__XF86_XF86WACOMDEFS_H */ /* vim: set noexpandtab tabstop=8 shiftwidth=8: */ -- 1.7.1
From 5ef662d6d7590b79afd3f49755b2c76d6f5d90ff Mon Sep 17 00:00:00 2001 From: Alexia Death <[email protected]> Date: Sat, 11 Dec 2010 19:45:54 +0200 Subject: [PATCH 2/2] Describe ToolSerials option in manpage --- man/wacom.man | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/man/wacom.man b/man/wacom.man index 61c69fb..9363b7f 100644 --- a/man/wacom.man +++ b/man/wacom.man @@ -195,6 +195,12 @@ option is only available on wacom V devices (Intuos series and Cintiq 21U). To see which serial number belongs to a device, you need to run the utility program, xsetwacom, which comes with linuxwacom package. .TP 4 +.B Option \fI"ToolSerial"\fP \fI"number[,pen|airbrush|cursor,label];..."\fP +sets the list of serial numbered devices that need to be hotplugged for a physical +device. This option is only available on wacom V devices (Intuos series and Cintiq 21U). +To see which serial number belongs to a device, you need to run the utility program, +xsetwacom, which comes with linuxwacom package. +.TP 4 .B Option \fI"Threshold"\fP \fI"number"\fP sets the pressure threshold used to generate a button 1 events of stylus. The default is MaxPressure*3/50. -- 1.7.1
------------------------------------------------------------------------------ Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL, new data types, scalar functions, improved concurrency, built-in packages, OCI, SQL*Plus, data movement tools, best practices and more. http://p.sf.net/sfu/oracle-sfdev2dev
_______________________________________________ Linuxwacom-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
