diff options
-rw-r--r-- | ChangeLog | 101 | ||||
-rw-r--r-- | configure.in | 53 | ||||
-rw-r--r-- | src/include/xdrv-config.h.in | 16 | ||||
-rwxr-xr-x | src/util/wacomcfg.c | 25 | ||||
-rwxr-xr-x | src/util/xsetwacom.c | 17 | ||||
-rwxr-xr-x | src/wacomxi/wacomcpl-exec | 42 | ||||
-rwxr-xr-x | src/xdrv/wcmCommon.c | 2 | ||||
-rwxr-xr-x | src/xdrv/wcmConfig.c | 325 | ||||
-rwxr-xr-x | src/xdrv/wcmFilter.c | 11 | ||||
-rwxr-xr-x | src/xdrv/wcmUSB.c | 58 | ||||
-rwxr-xr-x | src/xdrv/xf86Wacom.c | 72 | ||||
-rwxr-xr-x | src/xdrv/xf86WacomDefs.h | 1 |
12 files changed, 449 insertions, 274 deletions
@@ -1,14 +1,30 @@ +2009-10-31 Ping Cheng <pingc@wacom.com> + * Avoid duplicated devices + * Validate tool type before adding it + * Use struct input_id and struct input_absinfo in wcmUSB.c + - for kernel cross version compatibility support + * Support device names with white spaces in xsetwacom and wacomcpl + - for hot-plugged devices + * Fine tuned configure.in (tested by Camille Moncelier) + * Label 0.8.5-1 + 2009-10-19 Ping Cheng <pingc@wacom.com> * Added Cap+ (9F) touch support (Camille Moncelier) * Added TabletPC (E2 and E3) support * Merged Thomas Jaeger's xidump patch * Merged Peter Hutterer's remove kernel 2.4 support patch * Updated 10-linuxwacom.fdi for touch - * Don't allow HAL add tools defined in xorg.conf again + * Don't allow HAL add tools that were defined in xorg.conf again * Added calibration-only feature to wacomcpl (Oleg Gaier) * Fixed a package configuration issue for Xorgs 6.7 - 7.2 * Label 0.8.5 +2009-10-07 Ping Cheng <pingc@wacom.com> + * Fixed a minor TwinView bug in xsetwacom command + * Fixed a serial number = 0 case in wcmUSB.c + * Fixed a crash issue on Xserver 1.6 or later + * Label 0.8.4-3 + 2009-09-16 Ping Cheng <pingc@wacom.com> * Fixed a mapping issue introduced by non-TwinView support * Label 0.8.4-2 @@ -156,86 +172,3 @@ * Update ~/.xsession from wacomcpl for KDE system * Added IsXExtensionKeyboard check for Xserver 1.4 or later in wacomcfg.c * Label 0.8.0 - -2008-04-11 Ping Cheng <pingc@wacom.com> - * Excluded dixScreenOrigins call for Xorg 6.8.x - * Synchronized databases - * Updated webpages - * Label 0.7.9-11 - -2008-04-03 Ping Cheng <pingc@wacom.com> - * Minor fixes in kernel and wacomcpl - * Removed debug statement in wcmSerial.c - * Label 0.7.9-10 - -2008-03-30 Ping Cheng <pingc@wacom.com> - * Updated configure.in for keystrokes (Magnus Vigerlöf) - * Added touch support for serial TabletPC (ISDv4) - * Added autoprobe patch (Matthias Hopf @ Suse) - * Label 0.7.9-9 - -2008-03-07 Ping Cheng <pingc@wacom.com> - * Updated wacomcpl for keystrokes - * Excluded keystroke support for XFree86 - * Introduced wacom defined keymap (Magnus Vigerlöf) - * Support building outside the source-directory (Magnus Vigerlöf) - -2008-02-28 Ping Cheng <pingc@wacom.com> - * Added support for Cintiq 20WSX - * Fixed Bug 1875050 (Kovid Goyal) - * Incorporated patch 1901778 (Steven Seed) - -2008-02-23 Magnus Vigerlöf <Magnus.Vigerlof@ipbo.se> - * The rescaling patch is now in X.org master database - * Updated configure.in - * Added 2.6.24 support - * Updated kernel 2.4 make file - -2008-01-22 Ping Cheng <pingc@wacom.com> - * Updarted xsetwacom for Cintiq 12WX, Bamboo1, and BambooFun - * Regrouped the routines for coming Xorg 7.3 hot-plug support (Magnus Vigerlöf) - * refer to http://git.debian.org/?p=collab-maint/linux-wacom.git;a=summary for detailed changes - * Label 0.7.9-7 - -2008-01-10 Ping Cheng <pingc@wacom.com> - * Label 0.7.9-6 - -2008-01-02 Ping Cheng <pingc@wacom.com> - * Updated build and configure scripts (Magnus Vigerlöf) - * Support Xorg 7.3 with multimonitors - * Unified screen, tablet, and cordinate initialization - -2007-12-19 Ping Cheng <pingc@wacom.com> - * Support multimonitor setup on 4 directions - -2007-12-13 Ping Cheng <pingc@wacom.com> - * Updated wacomcpl - * Incorporated Xorg 7.3 workaround from Magnus Vigerlöf - * Label 0.7.9-4 - -2007-11-28 Ping Cheng <pingc@wacom.com> - * Clean support of outbound tracking for Bamboo, etc - * Updated kernel 2.4.x code - * Label 0.7.9-3 - -2007-11-28 Ping Cheng <pingc@wacom.com> - * Updated TwinView support to eliminate the unnecessary tvoffset (bug 1812593) - * Incorporated Bartosz Fabianowski's patch (bug 1831998) - * Patch 1818295 from Alexander V. Inyukhin - * Patch 1834712 from Magnus Vigerlöf - * Fixed bug 1791005 (protocol 4 tablets don't support serial numbers) - * Patch 1839008 from Magnus Vigerlöf - -2007-11-12 Ping Cheng <pingc@wacom.com> - * Support legacy kernels - * Label 0.7.9-2 - -2007-11-08 Ping Cheng <pingc@wacom.com> - * Added support for BambooFun, Bamboo1 and Hummingbird - * Support multimonitors horizontally and vertically in the same configuration - -2007-10-24 Ping Cheng <pingc@wacom.com> - * Added support for 2.6.22 - * Temporary workaround for Xorg 7.3 (Magnus and Ron) - * Support up to 8 screens in xsetwacom - * Label 0.7.9 diff --git a/configure.in b/configure.in index edd7da4..6ee6f6a 100644 --- a/configure.in +++ b/configure.in @@ -426,33 +426,37 @@ if test "$WCM_ENV_XFREE86" != yes; then AC_DEFINE(WCM_XORG_TABLET_SCALING,1, [Some X.org versions require that the events are scaled to screen size]) fi - WCM_UNINIT_CALLED= - AC_ARG_ENABLE(quirk-Uninit-called, - AC_HELP_STRING([--enable-quirk-Uninit-called], - [Enable Uninit called [[default=when_needed]]]), - WCM_UNINIT_CALLED=$enableval) - if test -z "$WCM_UNINIT_CALLED"; then - AC_MSG_CHECKING([if Uninit is called]) + AC_MSG_CHECKING([if Xorg server is version 1.4 or later]) + save_CFLAGS="$CFLAGS" + CFLAGS="-I$WCM_XORGSDK_DIR $CFLAGS" + AC_TRY_COMPILE([ +#include <xorg-server.h> +#include <xorgVersion.h> +#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 4, 0, 0, 0) +# error "X.org < 1.4" +#endif +], , [WCM_XORG_XSERVER_1_4=yes], [WCM_XORG_XSERVER_1_4=no]) + CFLAGS="$save_CFLAGS" + AC_MSG_RESULT($WCM_XORG_XSERVER_1_4) + if test "$WCM_XORG_XSERVER_1_4" = "yes"; then + AC_DEFINE(WCM_XORG_XSERVER_1_4, 1, + [Using version 1.4 or later of X.org]) + fi + AC_MSG_CHECKING([if Xorg is 7.3 or earlier]) save_CFLAGS="$CFLAGS" CFLAGS="-I$WCM_XORGSDK_DIR $CFLAGS" AC_TRY_COMPILE([ #include <xorg-server.h> #include <xorgVersion.h> -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 4, 0, 0, 0) -# error "Xserver < 1.4 doesn't call Uninit" -#elif XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(6, 0, 0, 0, 0) -# error "X.org < 7.3 doesn't call Uninit" +#if XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(6, 0, 0, 0, 0) +# error "X.org < 6 don't need PKG_CHECK_MODULES" +#elif XORG_VERSION_CURRENT > XORG_VERSION_NUMERIC(7, 3, 0, 0, 0) +# error "X.org > 7.3 " #endif -], , [WCM_UNINIT_CALLED=yes], [WCM_UNINIT_CALLED=no]) - CFLAGS="$save_CFLAGS" - AC_MSG_RESULT($WCM_UNINIT_CALLED) - fi - if test "$WCM_UNINIT_CALLED" = "yes"; then - WCM_XDRIVER_QUIRKS="$WCM_XDRIVER_QUIRKS Uninit-called" - AC_DEFINE(WCM_XORG_XSERVER_1_4,1, - [Xserver versions 1.4 and later call Uninit before closing a device]) - fi - AC_MSG_CHECKING([if Xorg is version 1.6 or later]) +], , [WCM_XORG_XORG=yes], [WCM_XORG_XORG=no]) + CFLAGS="$save_CFLAGS" + AC_MSG_RESULT($WCM_XORG_XORG) + AC_MSG_CHECKING([if Xorg server is version 1.6 or later]) save_CFLAGS="$CFLAGS" CFLAGS="-I$WCM_XORGSDK_DIR $CFLAGS" AC_TRY_COMPILE([ @@ -468,6 +472,7 @@ if test "$WCM_ENV_XFREE86" != yes; then AC_DEFINE(WCM_XORG_XSERVER_1_6, 1, [Using version 1.6 or later of X.org]) fi + AC_MSG_CHECKING([if Xorg SDK defined IsXExtensionPointer]) save_CFLAGS="$CFLAGS" CFLAGS="-I$WCM_XORGSDK_DIR $CFLAGS" AC_TRY_COMPILE([ @@ -579,7 +584,11 @@ if test "$WCM_XORG_XSERVER_1_6" == yes; then fi fi -if test "$WCM_ENV_XFREE86" != yes -a "$WCM_XORG_XSERVER_1_4" == yes; then +if test "$WCM_XORG_XSERVER_1_4" == yes -a "$WCM_XORG_XSERVER_1_6" != yes; then + WCM_XDRIVER_QUIRKS="$WCM_XDRIVER_QUIRKS Uninit-called" +fi + +if test "$WCM_ENV_XFREE86" != yes -a "$WCM_XORG_XORG" == yes -a "$WCM_XORG_XSERVER_1_4" != yes; then PKG_CHECK_MODULES(XORG, [xorg-server]) AC_SUBST([XORG_CFLAGS]) fi diff --git a/src/include/xdrv-config.h.in b/src/include/xdrv-config.h.in index afe7748..fade638 100644 --- a/src/include/xdrv-config.h.in +++ b/src/include/xdrv-config.h.in @@ -4,10 +4,18 @@ #define _XDRV_CONFIG_H_ /* Misc defines moved from the command line */ -#undef IN_MODULE -#undef XFree86LOADER -#undef XINPUT -#undef XKB +#ifndef IN_MODULE + #undef IN_MODULE +#endif +#ifndef XFree86LOADER + #undef XFree86LOADER +#endif +#ifndef XINPUT + #undef XINPUT +#endif +#ifndef XKB + #undef XKB +#endif /* Compiling for X.org */ #undef WCM_XORG diff --git a/src/util/wacomcfg.c b/src/util/wacomcfg.c index 9a53c85..f9eb7cd 100755 --- a/src/util/wacomcfg.c +++ b/src/util/wacomcfg.c @@ -2,7 +2,7 @@ ** wacomcfg.c ** ** Copyright (C) 2003-2004 - John E. Joganic -** Copyright (C) 2004-2008 - Ping Cheng +** Copyright (C) 2004-2009 - Ping Cheng ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU Lesser General Public License @@ -28,6 +28,7 @@ ** 2007-01-10 0.0.7 - PC - don't display uninitialized tools ** 2008-03-24 0.0.8 - PC - Added touch for serial TabletPC (ISDv4) ** 2008-07-31 0.0.9 - PC - Added patches from Danny Kukawka +** 2009-10-29 0.1.0 - PC - Support hot-plugged names ** ****************************************************************************/ @@ -203,7 +204,6 @@ int WacomConfigListDevices(WACOMCONFIG *hConfig, WACOMDEVICEINFO** ppInfo, for (j=0; j<strlen(pInfo->pszName); j++) devName[j] = tolower(pInfo->pszName[j]); devName[j] = '\0'; - pInfo->type = mapStringToType (devName); #if WCM_XF86CONFIG @@ -267,8 +267,9 @@ WACOMDEVICETYPE mapStringToType (const char* name) if (!name) return WACOMDEVICETYPE_UNKNOWN; - /* No spaces are allowed in Wacom device identifiers */ - if (strstr(name," ") != NULL) + /* If there is a white space in the name, + the "wacom" string has to be in it too */ + if (strstr(name," ") != NULL && strstr(name,"wacom") == NULL) return WACOMDEVICETYPE_UNKNOWN; if (strstr(name,"cursor") != NULL) return WACOMDEVICETYPE_CURSOR; @@ -288,10 +289,11 @@ WACOMDEVICETYPE mapStringToType (const char* name) WACOMDEVICE * WacomConfigOpenDevice(WACOMCONFIG * hConfig, const char* pszDeviceName) { - int i; + int i, j; WACOMDEVICE* pInt; XDevice* pDev; XDeviceInfo *pDevInfo = NULL, *info; + char nameOut[60]; /* sanity check input */ if (!hConfig || !pszDeviceName) { errno=EINVAL; return NULL; } @@ -304,7 +306,18 @@ WACOMDEVICE * WacomConfigOpenDevice(WACOMCONFIG * hConfig, for (i=0; i<hConfig->nDevCnt; ++i) { info = hConfig->pDevs + i; - if (!strcmp(info->name, pszDeviceName) && info->num_classes) + + /* convert the underscores back to spaces for name */ + for(j=0; j<strlen(pszDeviceName); j++) + { + if(pszDeviceName[j] == '_') + nameOut[j] = ' '; + else + nameOut[j] = pszDeviceName[j]; + } + nameOut[strlen(pszDeviceName)] = '\0'; + + if (!strcmp(info->name, nameOut) && info->num_classes) pDevInfo = info; } diff --git a/src/util/xsetwacom.c b/src/util/xsetwacom.c index e7abcbf..cbb06cc 100755 --- a/src/util/xsetwacom.c +++ b/src/util/xsetwacom.c @@ -39,10 +39,11 @@ ** 2009-07-14 0.2.0 - PC - Support Nvidia Xinerama setting ** 2009-08-24 0.2.1 - PC - Add SCREENTOGGLE command ** 2009-09-31 0.2.2 - PC - Add Dual Touch +** 2009-10-31 0.2.3 - PC - Support spaced names from hot-plugged devices ** ****************************************************************************/ -#define XSETWACOM_VERSION "0.1.9" +#define XSETWACOM_VERSION "0.2.3" #include "../include/util-config.h" @@ -691,6 +692,7 @@ static int ListDev(WACOMCONFIG *hConfig, char** argv) const char* pszType; WACOMDEVICEINFO* pInfo; unsigned int i, j, uCount; + char nameOut[60]; static TYPEXLAT xTypes[] = { @@ -714,7 +716,18 @@ static int ListDev(WACOMCONFIG *hConfig, char** argv) if (xTypes[j].type == pInfo[i].type) pszType = xTypes[j].pszText; - fprintf(stdout,"%-16s %-10s\n",pInfo[i].pszName,pszType); + /* tcl/tk (wacomcpl) has problem to process spaced names + * so we make the name into one string */ + for(j=0; j<strlen(pInfo[i].pszName); j++) + { + if(pInfo[i].pszName[j] == ' ') + nameOut[j] = '_'; + else + nameOut[j] = pInfo[i].pszName[j]; + } + nameOut[strlen(pInfo[i].pszName)] = '\0'; + + fprintf(stdout,"%s %s\n", nameOut, pszType); } WacomConfigFree(pInfo); diff --git a/src/wacomxi/wacomcpl-exec b/src/wacomxi/wacomcpl-exec index f86c351..e58dd70 100755 --- a/src/wacomxi/wacomcpl-exec +++ b/src/wacomxi/wacomcpl-exec @@ -50,7 +50,7 @@ set line_size 30 set origin_x [ expr ($desktopWidth/2) - ($desktopWidth/4) ] set origin_y [ expr ($desktopHeight/2) - ($desktopHeight/4) ] -set windowSize "540x300" +set windowSize "600x300" set device "" set deviceIndex 0 @@ -191,7 +191,7 @@ proc calibrationSequence {which xDev yDev} { global getDeviceModel screenXBottom screenYBottom global calibX_org calibY_org calibX_botm calibY_botm global xDevMin xDevMax yDevMin yDevMax - global calibration_sequence_only + global calibration_sequence_only orig_device set scaling [exec xsetwacom get $device xscaling] if { $scaling == 1 } { @@ -206,13 +206,13 @@ proc calibrationSequence {which xDev yDev} { if { $which == 0 } { .topleft.m configure -background "#505075" - wacomxi::bindevent .topleft.m $device <ButtonRelease> "" + wacomxi::bindevent .topleft.m $orig_device <ButtonRelease> "" .bottomright.m configure -background "#df94df" - wacomxi::bindevent .bottomright.m $device <ButtonRelease> \ + wacomxi::bindevent .bottomright.m $orig_device <ButtonRelease> \ {calibrationSequence 1 %0 %1} } elseif { $which == 1 } { .bottomright.m configure -background "#505075" - wacomxi::bindevent .bottomright.m $device <ButtonRelease> "" + wacomxi::bindevent .bottomright.m $orig_device <ButtonRelease> "" set borderOffset [expr ($size / 2 )] # A direction verification of the click @@ -321,7 +321,7 @@ proc Calibration {} { } proc startCalibration {} { - global device size numScreens tvID + global device size numScreens tvID orig_device global calibResults calibX_org calibY_org calibX_botm calibY_botm global screenX_org screenY_org screenXBottom screenYBottom global screenWidth screenHeight @@ -330,7 +330,10 @@ proc startCalibration {} { bindtags .screen.list.list . } - if { $tvID == 1 } { # Nvidia Xinerama setup starts at (0,0) even when it is different in xorg.conf + # convert underscores back to spaces for wacomxi.c + regsub -all {_} $device " " orig_device + + if { $tvID == 1 } { # Nvidia Xinerama setup starts at (0,0) even when it is not in xorg.conf set calibX_org 0 set calibY_org 0 set calibX_botm $screenWidth @@ -351,7 +354,7 @@ proc startCalibration {} { catch {unset calibResults} exec xsetwacom set $device xydefault .topleft.m configure -background "#df94df" - wacomxi::bindevent .topleft.m $device <ButtonRelease> \ + wacomxi::bindevent .topleft.m $orig_device <ButtonRelease> \ {calibrationSequence 0 %0 %1} helpWindow "Help Window " \ "\n\nPlease click on the center of \n\ @@ -518,7 +521,6 @@ proc getDeviceOptionProc { dev i } { proc CreateDevicePanel { type model } { global hasPad isLCD hasTouch hasGesture - if { ![ string compare $type "pad" ] } { if { $hasPad($model) } { createPanel 0 1 0 0 @@ -545,7 +547,7 @@ proc CreateDevicePanel { type model } { } proc updateDevice {} { - global device deviceIndex hasPad isLCD + global device deviceIndex hasPad isLCD orig_device global numScreens getDeviceModel hasTouch set olddev $device @@ -555,8 +557,11 @@ proc updateDevice {} { # # Clear old state related to preceding device # - wacomxi::bindevent . $device <ButtonPress> "" - wacomxi::bindevent . $device <ButtonRelease> "" + + # convert underscores back to spaces for wacomxi.c + regsub -all {_} $olddev " " orig_device + wacomxi::bindevent . $orig_device <ButtonPress> "" + wacomxi::bindevent . $orig_device <ButtonRelease> "" } if { $device != ""} { @@ -583,6 +588,7 @@ proc createDeviceList {} { set index 0 set devices "" set dev [ lindex $infoString $index ] + while { $dev != "" } { set index [ expr $index+1 ] set type [ lindex $infoString $index ] @@ -599,13 +605,13 @@ proc createDeviceList {} { frame .workingDev label .workingDev.title -text "Select the Device:" label .workingDev.label -background gray - listbox .workingDev.list -width 16 -height 12 \ + listbox .workingDev.list -width 28 -height 12 \ -yscrollcommand ".workingDev.sb set" scrollbar .workingDev.sb -width 10 \ -command ".workingDev.list yview" - grid .workingDev.title -row 0 -column 0 -columnspan 3 -sticky we - grid .workingDev.label -row 1 -column 0 -columnspan 3 -sticky we - grid .workingDev.list -row 2 -column 0 + grid .workingDev.title -row 0 -column 0 -columnspan 5 -sticky we + grid .workingDev.label -row 1 -column 0 -columnspan 5 -sticky we + grid .workingDev.list -row 2 -column 0 grid .workingDev.sb -row 2 -sticky nse set flag 0 foreach dev $devices { @@ -1884,7 +1890,7 @@ proc updateModelInfo { } { set isLCD($i) 1 } #TabletPC - for { set i 151 } { $i <= 166 } { incr i 1 } { + for { set i 144 } { $i <= 159 } { incr i 1 } { set isLCD($i) 1 } #TabletPC with 2FG touch @@ -1949,7 +1955,7 @@ proc updateModelInfo { } { } # one finger - for { set i 154 } { $i <= 166 } { incr i 1 } { + for { set i 147 } { $i <= 159 } { incr i 1 } { set hasTouch($i) 1 } diff --git a/src/xdrv/wcmCommon.c b/src/xdrv/wcmCommon.c index 134e092..7f6fb86 100755 --- a/src/xdrv/wcmCommon.c +++ b/src/xdrv/wcmCommon.c @@ -1261,7 +1261,7 @@ void xf86WcmEvent(WacomCommonPtr common, unsigned int channel, * will need to change the values (ie. for error correction) */ ds = *pState; - /* timestamp the state for velocity and acceleration analysis */ + /* timestamp to track the last event sent */ ds.sample = (int)GetTimeInMillis(); DBG(10, common->debugLevel, ErrorF("xf86WcmEvent: " diff --git a/src/xdrv/wcmConfig.c b/src/xdrv/wcmConfig.c index 0e6ba94..4447f24 100755 --- a/src/xdrv/wcmConfig.c +++ b/src/xdrv/wcmConfig.c @@ -19,6 +19,13 @@ #include "xf86Wacom.h" #include "wcmFilter.h" +#ifdef WCM_XORG_XSERVER_1_4 + #include <fcntl.h> + #ifndef _XF86_ANSIC_H + #include <sys/stat.h> + #endif + extern Bool xf86WcmIsWacomDevice (char* fname, struct input_id* id); +#endif /***************************************************************************** * xf86WcmAllocate -- @@ -175,6 +182,9 @@ LocalDevicePtr xf86WcmAllocate(char* name, int flag) priv->throttleLimit = -1; common->wcmDevice = ""; /* device file name */ +#ifdef WCM_XORG_XSERVER_1_6 + common->min_maj = 0; /* device major and minor */ +#endif common->wcmFlags = RAW_FILTERING_FLAG; /* various flags */ common->wcmDevices = priv; common->npadkeys = 0; /* Default number of pad keys */ @@ -424,86 +434,235 @@ static Bool xf86WcmMatchDevice(LocalDevicePtr pMatch, LocalDevicePtr pLocal) return 0; } -static Bool supportStylus(char * identifier) -{ - if (strstr(identifier, "Wacom Intuos") || strstr(identifier, "Wacom Cintiq") || - strstr(identifier, "Wacom Graphire") || strstr(identifier, "Wacom Bamboo") || - strstr(identifier, "Wacom Volito") || strstr(identifier, "Wacom PenPartner") || - strstr(identifier, "Wacom PL") || strstr(identifier, "Wacom DTU") || - (strstr(identifier, "Wacom ISDv4") && !strstr(identifier, "Wacom ISDv4 E2")) || - strstr(identifier, "Wacom DTF" )) - return 1; +#ifdef WCM_XORG_XSERVER_1_4 - return 0; -} +/* xf86WcmCheckTypeAndSource - Check if both devices have the same type OR + * the device has been used in xorg.conf: don't add the tool by hal/udev + * if user has defined at least one tool for the device in xorg.conf */ -static Bool supportEraser(char * identifier) +static Bool xf86WcmCheckTypeAndSource(LocalDevicePtr fakeLocal, LocalDevicePtr pLocal) { - if (strstr(identifier, "Wacom Intuos") || strstr(identifier, "Wacom Cintiq") || - strstr(identifier, "Wacom Graphire") || strstr(identifier, "Wacom Bamboo") || - strstr(identifier, "Wacom PenPartner") || - strstr(identifier, "Wacom PL") || strstr(identifier, "Wacom DTU") || - (strstr(identifier, "Wacom ISDv4") && !strstr(identifier, "Wacom ISDv4 E2")) || - strstr(identifier, "Wacom DTF" )) - return 1; - - return 0; + int match = 1; + char* fsource = xf86CheckStrOption(fakeLocal->options, "_source", ""); + char* psource = xf86CheckStrOption(pLocal->options, "_source", ""); + char* type = xf86FindOptionValue(fakeLocal->options, "Type"); + WacomDevicePtr priv = (WacomDevicePtr) pLocal->private; + + /* only add the new tool if the matching major/minor + * was from the same source */ + if (!strcmp(fsource, psource)) + { + /* and the tools have different types */ + if (strcmp(type, xf86FindOptionValue(pLocal->options, "Type"))) + match = 0; + } + DBG(2, priv->debugLevel, xf86Msg(X_INFO, "xf86WcmCheckTypeAndSource " + "device %s from %s %s \n", fakeLocal->name, fsource, + match ? "will be added" : "will be ignored")); + return match; } -static Bool supportCursor(char * identifier) +/* check if the device has been added */ +static int wcmIsDuplicate(char* device, LocalDevicePtr local) { - if (strstr(identifier, "Wacom Intuos") || - strstr(identifier, "Wacom Graphire") || strstr(identifier, "Wacom Bamboo") || - strstr(identifier, "Wacom PenPartner")) - return 1; +#ifdef _XF86_ANSIC_H + struct xf86stat st; +#else + struct stat st; +#endif + int isInUse = 0; + LocalDevicePtr localDevices = NULL; + WacomCommonPtr common = NULL; - return 0; -} + /* open the port */ + do { + local->fd = open(device, O_RDONLY, 0); + } while (local->fd < 0 && errno == EINTR); -static Bool supportPad(char * identifier) -{ - if (strstr(identifier, "Wacom Intuos3") || strstr(identifier, "Wacom Intuos4") || - strstr(identifier, "Wacom Graphire4") || strstr(identifier, "Wacom Bamboo") || - (strstr(identifier, "Wacom Cintiq") && strstr(identifier, "X"))) - return 1; + if (local->fd < 0) + { + /* can not open the device */ + xf86Msg(X_ERROR, "Unable to open Wacom device \"%s\".\n", device); + isInUse = 2; + goto ret; + } - return 0; -} +#ifdef _XF86_ANSIC_H + if (xf86fstat(local->fd, &st) == -1) +#else + if (fstat(local->fd, &st) == -1) +#endif + { + /* can not access major/minor to check device duplication */ + xf86Msg(X_ERROR, "%s: stat failed (%s). cannot check for duplicates.\n", + local->name, strerror(errno)); -static Bool supportTouch(char * identifier) -{ - if (strstr(identifier, "Wacom ISDv4") && !strstr(identifier, "90")) - return 1; + /* older systems don't support the required ioctl. let it pass */ + goto ret; + } - return 0; -} + if ((int)st.st_rdev) + { + localDevices = xf86FirstLocalDevice(); -/* xf86WcmCheckModelnType - Choose supported type for a hotplugged model */ -static Bool xf86WcmCheckModelnType(IDevPtr dev, LocalDevicePtr pLocal) -{ - char * type = xf86FindOptionValue(pLocal->options, "Type"); - char castType[32] = ""; - int i = 0; + for (; localDevices != NULL; localDevices = localDevices->next) + { + device = xf86CheckStrOption(localDevices->options, "Device", NULL); - for (i=0; i<strlen(type); i++) - castType[i] = (char)tolower(type[i]); + /* device can be NULL on some distros */ + if (!device || !strstr(localDevices->drv->driverName, "wacom")) + continue; - /* Check the device model to see if the type is supported or not. - * Yes, let it go. No, don't initialize it. - */ - if (supportStylus(dev->identifier) && strstr(type, "stylus")) return 1; + common = ((WacomDevicePtr)localDevices->private)->common; + if (local != localDevices && + common->min_maj && + common->min_maj == st.st_rdev) + { + /* device matches with another added port */ + if (xf86WcmCheckTypeAndSource(local, localDevices)) + { + xf86Msg(X_WARNING, "%s: device file already in use by %s. " + "Ignoring.\n", local->name, localDevices->name); + isInUse = 4; + goto ret; + } + } + } + } + else + { + /* major/minor can never be 0, right? */ + xf86Msg(X_ERROR, "%s: device opened with a major/minor of 0. " + "Something was wrong.\n", local->name); + isInUse = 5; + } +ret: + if (local->fd >= 0) + { + close(local->fd); + local->fd = -1; + } + return isInUse; +} - if (supportEraser(dev->identifier) && strstr(type, "eraser")) return 1; +static struct +{ + __u16 productID; + __u16 flags; +} validType [] = +{ + { 0x00, STYLUS_ID }, /* PenPartner */ + { 0x10, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Graphire */ + { 0x11, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Graphire2 4x5 */ + { 0x12, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Graphire2 5x7 */ + + { 0x13, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Graphire3 4x5 */ + { 0x14, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Graphire3 6x8 */ + + { 0x15, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* Graphire4 4x5 */ + { 0x16, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* Graphire4 6x8 */ + { 0x17, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* BambooFun 4x5 */ + { 0x18, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* BambooFun 6x8 */ + { 0x19, STYLUS_ID | ERASER_ID }, /* Bamboo1 Medium*/ + { 0x81, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* Graphire4 6x8 BlueTooth */ + + { 0x20, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos 4x5 */ + { 0x21, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos 6x8 */ + { 0x22, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos 9x12 */ + { 0x23, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos 12x12 */ + { 0x24, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos 12x18 */ + + { 0x03, STYLUS_ID | ERASER_ID }, /* PTU600 */ + { 0x30, STYLUS_ID | ERASER_ID }, /* PL400 */ + { 0x31, STYLUS_ID | ERASER_ID }, /* PL500 */ + { 0x32, STYLUS_ID | ERASER_ID }, /* PL600 */ + { 0x33, STYLUS_ID | ERASER_ID }, /* PL600SX */ + { 0x34, STYLUS_ID | ERASER_ID }, /* PL550 */ + { 0x35, STYLUS_ID | ERASER_ID }, /* PL800 */ + { 0x37, STYLUS_ID | ERASER_ID }, /* PL700 */ + { 0x38, STYLUS_ID | ERASER_ID }, /* PL510 */ + { 0x39, STYLUS_ID | ERASER_ID }, /* PL710 */ + { 0xC0, STYLUS_ID | ERASER_ID }, /* DTF720 */ + { 0xC2, STYLUS_ID | ERASER_ID }, /* DTF720a */ + { 0xC4, STYLUS_ID | ERASER_ID }, /* DTF521 */ + { 0xC7, STYLUS_ID | ERASER_ID }, /* DTU1931 */ + + { 0x41, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos2 4x5 */ + { 0x42, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos2 6x8 */ + { 0x43, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos2 9x12 */ + { 0x44, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos2 12x12 */ + { 0x45, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos2 12x18 */ + { 0x47, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos2 6x8 */ + + { 0x60, STYLUS_ID }, /* Volito */ + { 0x61, STYLUS_ID }, /* PenStation */ + { 0x62, STYLUS_ID }, /* Volito2 4x5 */ + { 0x63, STYLUS_ID }, /* Volito2 2x3 */ + { 0x64, STYLUS_ID }, /* PenPartner2 */ + + { 0x65, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* Bamboo */ + { 0x69, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Bamboo1 */ + + { 0xB0, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos3 4x5 */ + { 0xB1, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos3 6x8 */ + { 0xB2, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos3 9x12 */ + { 0xB3, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos3 12x12 */ + { 0xB4, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos3 12x19 */ + { 0xB5, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos3 6x11 */ + { 0xB7, STYLUS_ID | ERASER_ID | CURSOR_ID }, /* Intuos3 4x6 */ + + { 0xB8, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* Intuos4 4x6 */ + { 0xB9, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* Intuos4 6x9 */ + { 0xBA, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* Intuos4 8x13 */ + { 0xBB, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* Intuos4 12x19*/ + + { 0x3F, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* Cintiq 21UX */ + { 0xC5, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* Cintiq 20WSX */ + { 0xC6, STYLUS_ID | ERASER_ID | CURSOR_ID | PAD_ID }, /* Cintiq 12WX */ + + { 0x90, STYLUS_ID | ERASER_ID }, /* TabletPC 0x90 */ + { 0x93, STYLUS_ID | ERASER_ID | TOUCH_ID }, /* TabletPC 0x93 */ + { 0x9A, STYLUS_ID | ERASER_ID | TOUCH_ID }, /* TabletPC 0x9A */ + { 0x9F, TOUCH_ID }, /* CapPlus 0x9F */ + { 0xE2, TOUCH_ID }, /* TabletPC 0xE2 */ + { 0xE3, STYLUS_ID | ERASER_ID | TOUCH_ID } /* TabletPC 0xE3 */ +}; - if (supportCursor(dev->identifier) && strstr(type, "cursor")) return 1; +static struct +{ + const char* type; + __u16 id; +} wcmTypeAndID [] = +{ + { "stylus", STYLUS_ID }, + { "eraser", ERASER_ID }, + { "cursor", CURSOR_ID }, + { "touch", TOUCH_ID }, + { "pad", PAD_ID } +}; - if (supportPad(dev->identifier) && strstr(type, "pad")) return 1; +/* validate tool type for device/product */ +static int wcmIsAValidType(char* device, LocalDevicePtr local, unsigned short id) +{ + int i, j, ret = 0; + char* type = xf86FindOptionValue(local->options, "Type"); - if (supportTouch(dev->identifier) && strstr(type, "touch")) return 1; + /* walkthrough all supported models */ + for (i = 0; i < sizeof (validType) / sizeof (validType [0]); i++) + { + if (validType[i].productID == id) + { - return 0; + /* walkthrough all types */ + for (j = 0; j < sizeof (wcmTypeAndID) / sizeof (wcmTypeAndID [0]); j++) + if (!strcmp(wcmTypeAndID[j].type, type)) + if (wcmTypeAndID[j].id & validType[i].flags) + ret = 1; + } + } + return ret; } - +#endif /* WCM_XORG_XSERVER_1_4 */ /* xf86WcmInit - called when the module subsection is found in XF86Config */ static LocalDevicePtr xf86WcmInit(InputDriverPtr drv, IDevPtr dev, int flags) @@ -515,8 +674,10 @@ static LocalDevicePtr xf86WcmInit(InputDriverPtr drv, IDevPtr dev, int flags) char *s, b[12]; int i, oldButton; LocalDevicePtr localDevices; - static int calledByConf = 0; - +#ifdef WCM_XORG_XSERVER_1_4 + char* device; + struct input_id id; +#endif WacomToolPtr tool = NULL; WacomToolAreaPtr area = NULL; @@ -533,27 +694,25 @@ static LocalDevicePtr xf86WcmInit(InputDriverPtr drv, IDevPtr dev, int flags) */ xf86CollectInputOptions(fakeLocal, default_options, NULL); - /* who called us? */ - if (!strcmp(xf86CheckStrOption(fakeLocal->options, "_source", ""), "server/hal")) - { - if (calledByConf) - { - xf86Msg(X_INFO, "WACOM: Don't add duplicated device %s \n", dev->identifier); - xfree(fakeLocal); - return NULL; - } else if (!xf86WcmCheckModelnType(dev, fakeLocal)) { - xf86Msg(X_INFO, "WACOM: Device %s does not support type: %s\n", - dev->identifier, xf86FindOptionValue(fakeLocal->options, "Type")); - xfree(fakeLocal); - return NULL; - } - } else { - /* we were called from xorg.conf. We assume users want their own settings - * So, don't create a LocalDevice for the same tool if hal/udev calls again. - */ - calledByConf = 1; - } - +#ifdef WCM_XORG_XSERVER_1_4 + device = xf86CheckStrOption(fakeLocal->options, "Device", NULL); + fakeLocal->name = dev->identifier; + + /* leave the undefined for auto-dev (if enabled) to deal with */ + if(device) + { + if (!xf86WcmIsWacomDevice(device, &id)) + goto SetupProc_fail; + + /* check if the type is valid for the device */ + if(!wcmIsAValidType(device, fakeLocal, id.product)) + goto SetupProc_fail; + + /* check if the device has been added */ + if (wcmIsDuplicate(device, fakeLocal)) + goto SetupProc_fail; + } +#endif /* WCM_XORG_XSERVER_1_4 */ /* Type is mandatory */ s = xf86FindOptionValue(fakeLocal->options, "Type"); diff --git a/src/xdrv/wcmFilter.c b/src/xdrv/wcmFilter.c index 9bd77da..825ecd9 100755 --- a/src/xdrv/wcmFilter.c +++ b/src/xdrv/wcmFilter.c @@ -1,6 +1,6 @@ /* * Copyright 1995-2002 by Frederic Lepied, France. <Lepied@XFree86.org> - * Copyright 2002-2008 by Ping Cheng, Wacom. <pingc@wacom.com> + * Copyright 2002-2009 by Ping Cheng, Wacom. <pingc@wacom.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -29,7 +29,8 @@ static void filterCurveToLine(int* pCurve, int nMax, double x0, double y0, static int filterOnLine(double x0, double y0, double x1, double y1, double a, double b); static void filterLine(int* pCurve, int nMax, int x0, int y0, int x1, int y1); -static void filterIntuosStylus(WacomCommonPtr common, WacomFilterStatePtr state, WacomDeviceStatePtr ds); +static void filterIntuosStylus(WacomCommonPtr common, + WacomFilterStatePtr state, WacomDeviceStatePtr ds); /***************************************************************************** * xf86WcmSetPressureCurve -- apply user-defined curve to pressure values @@ -204,7 +205,8 @@ static void filterLine(int* pCurve, int nMax, int x0, int y0, int x1, int y1) * but also cuts down quite a bit on jitter. ****************************************************************************/ -static void filterIntuosStylus(WacomCommonPtr common, WacomFilterStatePtr state, WacomDeviceStatePtr ds) +static void filterIntuosStylus(WacomCommonPtr common, + WacomFilterStatePtr state, WacomDeviceStatePtr ds) { int x=0, y=0, tx=0, ty=0, i; @@ -244,7 +246,8 @@ int xf86WcmFilterCoord(WacomCommonPtr common, WacomChannelPtr pChannel, WacomDeviceState *pLast; int *x, *y, i; - DBG(10, common->debugLevel, ErrorF("xf86WcmFilterCoord with " "common->wcmRawSample = %d \n", common->wcmRawSample)); + DBG(10, common->debugLevel, ErrorF("xf86WcmFilterCoord with " + "common->wcmRawSample = %d \n", common->wcmRawSample)); x = pChannel->rawFilter.x; y = pChannel->rawFilter.y; diff --git a/src/xdrv/wcmUSB.c b/src/xdrv/wcmUSB.c index f9303ab..904aa64 100755 --- a/src/xdrv/wcmUSB.c +++ b/src/xdrv/wcmUSB.c @@ -505,7 +505,7 @@ static struct Bool usbWcmInit(LocalDevicePtr local, char* id, float *version) { int i; - short sID[4]; + struct input_id sID; unsigned long keys[NBITS(KEY_MAX)]; WacomDevicePtr priv = (WacomDevicePtr)local->private; WacomCommonPtr common = priv->common; @@ -514,13 +514,13 @@ Bool usbWcmInit(LocalDevicePtr local, char* id, float *version) *version = 0.0; /* fetch vendor, product, and model name */ - ioctl(local->fd, EVIOCGID, sID); + ioctl(local->fd, EVIOCGID, &sID); ioctl(local->fd, EVIOCGNAME(sizeof(id)), id); /* vendor is wacom */ - if (sID[1] == 0x056A) + if (sID.vendor == 0x056A) { - common->tablet_id = sID[2]; + common->tablet_id = sID.product; for (i = 0; i < sizeof (WacomModelDesc) / sizeof (WacomModelDesc [0]); i++) if (common->tablet_id == WacomModelDesc [i].model_id) @@ -572,7 +572,7 @@ Bool usbWcmInit(LocalDevicePtr local, char* id, float *version) } else { - ErrorF("%x is not supported by linuxwacom.\n", sID[1]); + ErrorF("%x is not supported by linuxwacom.\n", sID.vendor); return FALSE; } @@ -642,7 +642,7 @@ static void usbInitProtocol4(WacomCommonPtr common, const char* id, int usbWcmGetRanges(LocalDevicePtr local) { - int nValues[5]; + struct input_absinfo absinfo; unsigned long ev[NBITS(EV_MAX)]; unsigned long abs[NBITS(ABS_MAX)]; WacomDevicePtr priv = (WacomDevicePtr)local->private; @@ -670,56 +670,56 @@ int usbWcmGetRanges(LocalDevicePtr local) } /* max x */ - if (ioctl(local->fd, EVIOCGABS(ABS_X), nValues) < 0) + if (ioctl(local->fd, EVIOCGABS(ABS_X), &absinfo) < 0) { ErrorF("WACOM: unable to ioctl xmax value.\n"); return !Success; } - common->wcmMaxX = nValues[2]; /* no pen if it is 1 */ + common->wcmMaxX = absinfo.maximum; /* max y */ - if (ioctl(local->fd, EVIOCGABS(ABS_Y), nValues) < 0) + if (ioctl(local->fd, EVIOCGABS(ABS_Y), &absinfo) < 0) { ErrorF("WACOM: unable to ioctl ymax value.\n"); return !Success; } - common->wcmMaxY = nValues[2]; /* no pen if it is 1 */ + common->wcmMaxY = absinfo.maximum; /* max finger strip X for tablets with Expresskeys * or touch logical X for TabletPCs with touch */ - if (ioctl(local->fd, EVIOCGABS(ABS_RX), nValues) == 0) + if (ioctl(local->fd, EVIOCGABS(ABS_RX), &absinfo) == 0) { if (common->wcmTouchDefault) - common->wcmMaxTouchX = nValues[2]; + common->wcmMaxTouchX = absinfo.maximum; else - common->wcmMaxStripX = nValues[2]; + common->wcmMaxStripX = absinfo.maximum; DBG(3, common->debugLevel, ErrorF("%s - usbWcmGetRanges: Got ABS_RX %d\n", - local->name, nValues[2])); + local->name, absinfo.maximum)); } /* max finger strip y for tablets with Expresskeys * or touch logical Y for TabletPCs with touch */ - if (ioctl(local->fd, EVIOCGABS(ABS_RY), nValues) == 0) + if (ioctl(local->fd, EVIOCGABS(ABS_RY), &absinfo) == 0) { if (common->wcmTouchDefault) - common->wcmMaxTouchY = nValues[2]; + common->wcmMaxTouchY = absinfo.maximum; else - common->wcmMaxStripY = nValues[2]; + common->wcmMaxStripY = absinfo.maximum; } /* touch physical X for TabletPCs with touch */ - if (ioctl(local->fd, EVIOCGABS(ABS_Z), nValues) == 0) + if (ioctl(local->fd, EVIOCGABS(ABS_Z), &absinfo) == 0) { if (common->wcmTouchDefault) - common->wcmTouchResolX = nValues[2]; + common->wcmTouchResolX = absinfo.maximum; } /* touch physical Y for TabletPCs with touch */ - if (ioctl(local->fd, EVIOCGABS(ABS_RZ), nValues) == 0) + if (ioctl(local->fd, EVIOCGABS(ABS_RZ), &absinfo) == 0) { if (common->wcmTouchDefault) - common->wcmTouchResolY = nValues[2]; + common->wcmTouchResolY = absinfo.maximum; } if (common->wcmTouchDefault && common->wcmTouchResolX) @@ -740,20 +740,12 @@ int usbWcmGetRanges(LocalDevicePtr local) } /* max z cannot be configured */ - if (ioctl(local->fd, EVIOCGABS(ABS_PRESSURE), nValues) < 0) - { - ErrorF("WACOM: unable to ioctl press max value.\n"); - return !Success; - } - common->wcmMaxZ = nValues[2]; + if (ioctl(local->fd, EVIOCGABS(ABS_PRESSURE), &absinfo) == 0) + common->wcmMaxZ = absinfo.maximum; /* max distance */ - if (ioctl(local->fd, EVIOCGABS(ABS_DISTANCE), nValues) < 0) - { - ErrorF("WACOM: unable to ioctl press max distance.\n"); - return !Success; - } - common->wcmMaxDist = nValues[2]; + if (ioctl(local->fd, EVIOCGABS(ABS_DISTANCE), &absinfo) == 0) + common->wcmMaxDist = absinfo.maximum; return Success; } diff --git a/src/xdrv/xf86Wacom.c b/src/xdrv/xf86Wacom.c index af3fd82..10e6c09 100755 --- a/src/xdrv/xf86Wacom.c +++ b/src/xdrv/xf86Wacom.c @@ -33,8 +33,6 @@ * Aaron Optimizer Digulla <digulla@hepe.com>, * Jonathan Layes <jonathan@layes.com>, * John Joganic <jej@j-arkadia.com>. - * - * Support for hot plug-n-play by * Magnus Vigerlöf <Magnus.Vigerlof@ipbo.se>. */ @@ -86,14 +84,21 @@ * 2009-10-06 47-pc0.8.4-3 - Minor fix in TwinView setting * 2009-10-15 47-pc0.8.4-4 - added calibration-only wacomcpl * 2009-10-19 47-pc0.8.5 - Added support for TPC (0xE2, 0xE3 & 0x9F) + * 2009-10-31 47-pc0.8.5-1 - Avoid duplicated devices for Xorg 1.4 and later */ -static const char identification[] = "$Identification: 47-0.8.5 $"; +static const char identification[] = "$Identification: 47-0.8.5-1 $"; /****************************************************************************/ #include "xf86Wacom.h" #include "wcmFilter.h" +#ifdef WCM_XORG_XSERVER_1_4 + #include <fcntl.h> + #ifndef _XF86_ANSIC_H + #include <sys/stat.h> + #endif +#endif static int xf86WcmDevOpen(DeviceIntPtr pWcm); static void xf86WcmDevReadInput(LocalDevicePtr local); @@ -803,16 +808,26 @@ static int xf86WcmRegisterX11Devices (LocalDevicePtr local) return TRUE; } -#ifdef LINUX_INPUT -static Bool xf86WcmIsWacomDevice (int fd, CARD16 vendor) +#ifdef WCM_XORG_XSERVER_1_4 +Bool xf86WcmIsWacomDevice (char* fname, struct input_id* id) { - struct input_id id; - ioctl(fd, EVIOCGID, &id); - if (id.vendor == vendor) + int fd = -1; + + fd = open(fname, O_RDONLY); + if (fd < 0) + return FALSE; + + ioctl(fd, EVIOCGID, id); + close(fd); + + if (id->vendor == 0x056a) return TRUE; - return FALSE; + else + return FALSE; } +#endif /* WCM_XORG_XSERVER_1_4 */ +#ifdef LINUX_INPUT /***************************************************************************** * xf86WcmEventAutoDevProbe -- Probe for right input device ****************************************************************************/ @@ -832,13 +847,10 @@ char *xf86WcmEventAutoDevProbe (LocalDevicePtr local) char fname[64]; int fd = -1; Bool is_wacom; + struct input_id id; sprintf(fname, DEV_INPUT_EVENT, i); - SYSCALL(fd = open(fname, O_RDONLY)); - if (fd < 0) - continue; - is_wacom = xf86WcmIsWacomDevice(fd, 0x056a); - SYSCALL(close(fd)); + is_wacom = xf86WcmIsWacomDevice(fname, &id); if (is_wacom) { ErrorF ("%s Wacom probed device to be %s (waited %d msec)\n", @@ -867,7 +879,14 @@ static int xf86WcmDevOpen(DeviceIntPtr pWcm) LocalDevicePtr local = (LocalDevicePtr)pWcm->public.devicePrivate; WacomDevicePtr priv = (WacomDevicePtr)PRIVATE(pWcm); WacomCommonPtr common = priv->common; - +#ifdef WCM_XORG_XSERVER_1_4 + #ifdef _XF86_ANSIC_H + struct xf86stat st; + #else + struct stat st; + #endif +#endif + DBG(10, priv->debugLevel, ErrorF("xf86WcmDevOpen\n")); /* Device has been open and not autoprobed */ @@ -897,6 +916,25 @@ static int xf86WcmDevOpen(DeviceIntPtr pWcm) local->fd = -1; return FALSE; } +#ifdef WCM_XORG_XSERVER_1_4 + #ifdef _XF86_ANSIC_H + if (xf86fstat(local->fd, &st) == -1) + #else + if (fstat(local->fd, &st) == -1) + #endif + { + /* can not access major/minor */ + DBG(1, priv->debugLevel, xf86Msg(X_ERROR, "%s: stat failed (%s). " + "cannot check status.\n", local->name, strerror(errno))); + + /* older systems don't support the required ioctl. + * So, we have to let it pass */ + common->min_maj = 0; + } + else + common->min_maj = st.st_rdev; +#endif /* WCM_XORG_XSERVER_1_4 */ + common->fd = local->fd; common->fd_refs = 1; } @@ -968,12 +1006,12 @@ void xf86WcmReadPacket(LocalDevicePtr local) if (len <= 0) { - ErrorF("Error reading wacom device : %s\n", strerror(errno)); - /* In case of error, we assume the device has been * disconnected. So we close it and iterate over all * wcmDevices to actually close associated devices. */ WacomDevicePtr wDev = common->wcmDevices; + xf86Msg(X_ERROR, "Error reading wacom device : %s\n", + strerror(errno)); for(; wDev; wDev = wDev->next) { if (wDev->local->fd >= 0) diff --git a/src/xdrv/xf86WacomDefs.h b/src/xdrv/xf86WacomDefs.h index 3660a80..833bf70 100755 --- a/src/xdrv/xf86WacomDefs.h +++ b/src/xdrv/xf86WacomDefs.h @@ -364,6 +364,7 @@ struct _WacomCommonRec int tablet_id; /* USB tablet ID */ int fd; /* file descriptor to tablet */ int fd_refs; /* number of references to fd; if =0, fd is invalid */ + dev_t min_maj; /* minor/major number */ /* These values are in tablet coordinates */ int wcmMaxX; /* tablet logical max X value */ |