diff options
author | pingc <pingc> | 2008-01-22 19:26:10 +0000 |
---|---|---|
committer | pingc <pingc> | 2008-01-22 19:26:10 +0000 |
commit | 883d6ad68d8591bba7fc1b46968ecf1f8b2e6dec (patch) | |
tree | 02ec1a7013b2a581ad419c4ba0a5e26ed410b2f2 | |
parent | b15f8391dcecc3235a2f8048b1ffc38d64bda289 (diff) | |
download | xf86-input-wacom-release-0.7.9-7.tar.gz |
Prepare for hot-plug support on Xorg 7.3release-0.7.9-7
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | src/2.6.16/wacom_wac.c | 4 | ||||
-rwxr-xr-x | src/2.6.19/wacom_wac.c | 4 | ||||
-rwxr-xr-x | src/include/Xwacom.h | 3 | ||||
-rwxr-xr-x | src/util/wacusb.c | 6 | ||||
-rwxr-xr-x | src/util/wcmAction.c | 7 | ||||
-rwxr-xr-x | src/util/xsetwacom.c | 24 | ||||
-rwxr-xr-x | src/wacomxi/wacomcpl-exec | 10 | ||||
-rwxr-xr-x | src/xdrv/Makefile.am | 25 | ||||
-rwxr-xr-x | src/xdrv/wcmCommon.c | 218 | ||||
-rwxr-xr-x | src/xdrv/wcmConfig.c | 14 | ||||
-rwxr-xr-x | src/xdrv/wcmISDV4.c | 20 | ||||
-rwxr-xr-x | src/xdrv/wcmSerial.c | 188 | ||||
-rwxr-xr-x | src/xdrv/wcmUSB.c | 25 | ||||
-rw-r--r-- | src/xdrv/wcmXCommand.c | 205 | ||||
-rwxr-xr-x | src/xdrv/xf86Wacom.c | 252 | ||||
-rwxr-xr-x | src/xdrv/xf86Wacom.h | 424 | ||||
-rwxr-xr-x | src/xdrv/xf86WacomDefs.h | 443 |
19 files changed, 983 insertions, 899 deletions
@@ -1,3 +1,9 @@ +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 diff --git a/configure.in b/configure.in index 30bfd3f..1534c84 100644 --- a/configure.in +++ b/configure.in @@ -94,6 +94,7 @@ if test "$WCM_ISLINUX" != yes; then WCM_PATCH_WACDUMP="(no USB)" WCM_PATCH_WACOMDRV="(no USB)" else + AC_DEFINE(WCM_ENABLE_LINUXINPUT,,[Enable the Linux Input subsystem]) WCM_PATCH_WACDUMP= WCM_PATCH_WACOMDRV= @@ -295,9 +296,6 @@ else fi fi fi - if test "$WCM_ENV_KERNEL" = yes; then - AC_DEFINE(WCM_ENABLE_LINUXINPUT,,[Enable the Linux Input subsystem]) - fi fi dnl ======================================================= diff --git a/src/2.6.16/wacom_wac.c b/src/2.6.16/wacom_wac.c index 28e4b35..5681e97 100644 --- a/src/2.6.16/wacom_wac.c +++ b/src/2.6.16/wacom_wac.c @@ -449,7 +449,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo) wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]); wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]); - if((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) | + if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) | data[2] | (data[3] & 0x1f) | data[4]) wacom_report_key(wcombo, wacom->tool[1], 1); else @@ -465,7 +465,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo) return result-1; /* Only large I3 and I1 & I2 support Lense Cursor */ - if((wacom->tool[idx] == BTN_TOOL_LENS) + if ((wacom->tool[idx] == BTN_TOOL_LENS) && ((wacom->features->type == INTUOS3) || (wacom->features->type == INTUOS3S))) return 0; diff --git a/src/2.6.19/wacom_wac.c b/src/2.6.19/wacom_wac.c index 94f1109..d009211 100755 --- a/src/2.6.19/wacom_wac.c +++ b/src/2.6.19/wacom_wac.c @@ -439,7 +439,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo) wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]); wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]); - if((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) | + if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) | data[2] | (data[3] & 0x1f) | data[4]) wacom_report_key(wcombo, wacom->tool[1], 1); else @@ -455,7 +455,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo) return result-1; /* Only large I3 and I1 & I2 support Lense Cursor */ - if((wacom->tool[idx] == BTN_TOOL_LENS) + if ((wacom->tool[idx] == BTN_TOOL_LENS) && ((wacom->features->type == INTUOS3) || (wacom->features->type == INTUOS3S))) return 0; diff --git a/src/include/Xwacom.h b/src/include/Xwacom.h index 5a20ec8..90f3401 100755 --- a/src/include/Xwacom.h +++ b/src/include/Xwacom.h @@ -1,6 +1,6 @@ /* * Copyright 2003 by John Joganic <john@joganic.com> - * Copyright 2003 - 2007 by Ping Cheng <pingc@wacom.com> + * Copyright 2003 - 2008 by Ping Cheng <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 @@ -152,6 +152,7 @@ #define AC_KEY 0x00010000 /* Emit key events */ #define AC_MODETOGGLE 0x00020000 /* Toggle absolute/relative mode */ #define AC_DBLCLICK 0x00030000 /* Emit a button1 double-click event */ +#define AC_DISPLAYTOGGLE 0x00040000 /* Toggle among screens */ #define AC_TYPE 0x000f0000 /* The mask to isolate event type bits */ #define AC_NUM_KEYS 0x0ff00000 /* The mask to isolate number of keys to send */ #define AC_CORE 0x10000000 /* Always emit a core event */ diff --git a/src/util/wacusb.c b/src/util/wacusb.c index 3591115..0ed392a 100755 --- a/src/util/wacusb.c +++ b/src/util/wacusb.c @@ -2,7 +2,7 @@ ** wacusb.c ** ** Copyright (C) 2002 - 2004 - John E. Joganic -** Copyright (C) 2003 - 2007 - Ping Cheng +** Copyright (C) 2003 - 2008 - Ping Cheng ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License @@ -251,12 +251,15 @@ static int USBIdentifyModel(USBTABLET* pUSB); { "CTF-420-U", "Wacom Volito2 4x5", 2, 0x62 }, { "CTF-220-U", "Wacom Volito2 2x3", 3, 0x63 }, { "CTF-421-U", "Wacom PenPartner2", 4, 0x64 }, + { "CTF_430-U", "Wacom Bamboo1", 5, 0x69 }, { NULL } }; static USBSUBTYPE xBamboo[] = { { "MTE_450", "Wacom Bamboo", 1, 0x65 }, + { "CTE_450", "Wacom BambooFun 4x5", 2, 0x17 }, + { "CTE_650", "Wacom BambooFun 6x8", 3, 0x18 }, { NULL } }; @@ -269,6 +272,7 @@ static int USBIdentifyModel(USBTABLET* pUSB); static USBSUBTYPE xCintiqV5[] = { { "DTZ-21ux", "Wacom Cintiq 21UX", 1, 0x3F }, + { "DTZ-12wx", "Wacom Cintiq 12WX", 2, 0x6C }, { NULL } }; diff --git a/src/util/wcmAction.c b/src/util/wcmAction.c index c47f655..6ddc035 100755 --- a/src/util/wcmAction.c +++ b/src/util/wcmAction.c @@ -1,7 +1,7 @@ /***************************************************************************** ** wcmAction.c ** -** Copyright (C) 2007 - Ping Cheng +** Copyright (C) 2007 - 2008 - Ping Cheng ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License @@ -19,6 +19,7 @@ ** ** REVISION HISTORY ** 2007-02-06 0.0.1-pc - Support keystrokes +** 2008-01-17 0.0.2-pc - Add Display Toggle */ /* This pseudo-header file is included both from the X11 driver, and from @@ -41,7 +42,8 @@ static ACTIONCODE action_code [] = { "KEY", AC_KEY }, { "BUTTON", AC_BUTTON }, { "MODETOGGLE", AC_MODETOGGLE }, - { "DBLCLICK", AC_DBLCLICK } + { "DBLCLICK", AC_DBLCLICK }, + { "DISPLAYTOGGLE", AC_DISPLAYTOGGLE } }; static ACTIONCODE modifier_code [] = @@ -238,6 +240,7 @@ int xf86WcmDecode (const char *dev, const char *but, const char *ev, unsigned * } case AC_MODETOGGLE: case AC_DBLCLICK: + case AC_DISPLAYTOGGLE: break; case AC_KEY: if (!strlen(ev_p)) diff --git a/src/util/xsetwacom.c b/src/util/xsetwacom.c index ced0020..c832526 100755 --- a/src/util/xsetwacom.c +++ b/src/util/xsetwacom.c @@ -2,7 +2,7 @@ ** xsetwacom.c ** ** Copyright (C) 2003 - John E. Joganic -** Copyright (C) 2004-2007 - Ping Cheng +** Copyright (C) 2004-2008 - 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 @@ -31,10 +31,11 @@ ** 2007-05-18 0.1.2 - PC - Support DebugLevel options ** 2007-06-05 0.1.3 - PC - Support Suppress and TwinView options ** 2007-07-24 0.1.4 - PC - Support Screen_No option +** 2008-01-17 0.1.5 - PC - Add DISPLAYTOGGLE command ** ****************************************************************************/ -#define XSETWACOM_VERSION "0.1.4" +#define XSETWACOM_VERSION "0.1.5" #include "../include/util-config.h" @@ -695,7 +696,8 @@ static int ListParam(WACOMCONFIG *hConfig, char** argv) "\tKEY: Emit a key event\n" "\tBUTTON: Emit a button event\n" "\tDBLCLICK: Emit a double-click button event\n" - "\tMODETOGGLE: Toggle absolute/relative tablet mode\n" + "\tMODETOGGLE: Toggle absolute/relative tablet mode\n"); + printf ("\tDISPLAYTOGGLE: Toggle cursor movement among screens\n" " Modifier: use \"xsetwacom list mod\"\n" "\tto see a list of modifiers and specific keys\n" " CODE: Button number if emit a button event \n" @@ -989,7 +991,7 @@ static int Set(WACOMCONFIG * hConfig, char** argv) static void DisplayValue (WACOMDEVICE *hDev, const char *devname, PARAMINFO *p, int disperr, int valu) { - int value, sl, i; + int value = 0, sl = 0, i = 0; char strval [200] = ""; unsigned keys[256]; if (WacomConfigGetRawParam (hDev, p->nParamID, &value, valu, keys)) @@ -1035,18 +1037,21 @@ static void DisplayValue (WACOMDEVICE *hDev, const char *devname, PARAMINFO *p, sl += snprintf (strval + sl, sizeof (strval) - sl, "CORE "); switch (value & AC_TYPE) { - case AC_BUTTON: + case AC_BUTTON: sl += snprintf (strval + sl, sizeof (strval) - sl, "BUTTON "); break; - case AC_KEY: + case AC_KEY: sl += snprintf (strval + sl, sizeof (strval) - sl, "KEY "); break; - case AC_MODETOGGLE: + case AC_MODETOGGLE: sl += snprintf (strval + sl, sizeof (strval) - sl, "MODETOGGLE "); break; - case AC_DBLCLICK: + case AC_DBLCLICK: sl += snprintf (strval + sl, sizeof (strval) - sl, "DBLCLICK "); break; + case AC_DISPLAYTOGGLE: + sl += snprintf (strval + sl, sizeof (strval) - sl, "DISPLAYTOGGLE "); + break; } if ((value & AC_TYPE) != AC_KEY) { @@ -1117,7 +1122,8 @@ static void DisplayValue (WACOMDEVICE *hDev, const char *devname, PARAMINFO *p, default: if ( ((value & AC_TYPE) != AC_KEY) && ((value & AC_TYPE) != AC_MODETOGGLE) && - ((value & AC_TYPE) != AC_DBLCLICK) ) + ((value & AC_TYPE) != AC_DBLCLICK) && + ((value & AC_TYPE) != AC_DISPLAYTOGGLE) ) printf ("%d\n", value); else printf ("%s\n", strval); diff --git a/src/wacomxi/wacomcpl-exec b/src/wacomxi/wacomcpl-exec index 179f774..0866716 100755 --- a/src/wacomxi/wacomcpl-exec +++ b/src/wacomxi/wacomcpl-exec @@ -463,11 +463,13 @@ proc createDeviceList {} { while { $dev != "" } { set index [ expr $index+1 ] set type [ lindex $infoString $index ] - set index [ expr $index+1 ] - set getDeviceModel($dev,type) $type - set getDeviceModel($dev,model) [ exec xsetwacom get $dev TabletID ] - set devices "$devices $dev" + if { [catch { exec xsetwacom get $dev TabletID } model] == 0} { + set getDeviceModel($dev,type) $type + set getDeviceModel($dev,model) $model + set devices "$devices $dev" + set index [ expr $index+1 ] + } set dev [ lindex $infoString $index ] } diff --git a/src/xdrv/Makefile.am b/src/xdrv/Makefile.am index a4666bb..6e965ac 100755 --- a/src/xdrv/Makefile.am +++ b/src/xdrv/Makefile.am @@ -43,17 +43,7 @@ XF86OBJS = xf86Wacom.o wcmSerial.o wcmUSB.o wcmISDV4.o \ wcmXCommand.o wcmCommon.o wcmCompat.o wcmConfig.o \ wcmFilter.o -xf86Wacom.o: xf86Wacom.c wcmFilter.h ../include/Xwacom.h -wcmXCommand.o: wcmXCommand.c wcmFilter.h ../include/Xwacom.h -wcmSerial.o: wcmSerial.c wcmSerial.h wcmFilter.h -wcmISDV4.o: wcmISDV4.c wcmSerial.h wcmFilter.h -wcmUSB.o: wcmUSB.c wcmFilter.h -wcmCommon.o: wcmCommon.c -wcmCompat.o: wcmCompat.c -wcmConfig.o: wcmConfig.c wcmFilter.h -wcmFilter.o: wcmFilter.c wcmFilter.h - -$(XF86OBJS): xf86Wacom.h ../include/Xwacom.h Makefile +$(XF86OBJS): $(CC) $(CFLAGS) $(WCM_DEPFLAGS) $(DLLOADER) -pipe $(WCM_CLEVEL) \ -pedantic -Wall -Wpointer-arith $(NO_MERGE_CONSTANTS) \ $(NO_STACK_PROTECTOR) -I$(srcdir) $(DRIVER_INCLUDES) \ @@ -61,9 +51,18 @@ $(XF86OBJS): xf86Wacom.h ../include/Xwacom.h Makefile -o $@ -c $(srcdir)/$(subst .o,.c,$@) if WCM_DLLOADER -wacom_drv.so: $(XF86OBJS) +wacom_drv.so: .depend $(XF86OBJS) $(CC) -shared -nostdlib -o wacom_drv.so $(XF86OBJS) -Bstatic -lgcc else -wacom_drv.o: $(XF86OBJS) +wacom_drv.o: .depend $(XF86OBJS) $(LD) -r $(XF86OBJS) -o wacom_drv.o endif + +depend: .depend + +.depend: Makefile + @rm -f .depend + $(CC) -MM $(CFLAGS) $(DEPFLAGS) $(DRIVER_INCLUDES) $(XF86OBJS:%.o=%.c) > .depend + +-include .depend + diff --git a/src/xdrv/wcmCommon.c b/src/xdrv/wcmCommon.c index 535807d..1f13d32 100755 --- a/src/xdrv/wcmCommon.c +++ b/src/xdrv/wcmCommon.c @@ -21,7 +21,7 @@ #include "../include/Xwacom.h" /* - #if XF86_VERSION_MAJOR < 4 +#if XF86_VERSION_MAJOR < 4 * * There is a bug in XFree86 for combined left click and * other button. It'll lost left up when releases. @@ -42,6 +42,9 @@ WacomDeviceClass* wcmDeviceClasses[] = NULL }; +extern int xf86WcmDevSwitchModeCall(LocalDevicePtr local, int mode); +extern void xf86WcmChangeScreen(LocalDevicePtr local, int value); + /***************************************************************************** * Static functions ****************************************************************************/ @@ -70,9 +73,7 @@ void xf86WcmMappingFactor(LocalDevicePtr local) priv->sizeY = priv->bottomY - priv->topY - 2*priv->tvoffsetY; priv->maxWidth = 0, priv->maxHeight = 0; - if (priv->screen_no != -1) - priv->currentScreen = priv->screen_no; - else if (priv->currentScreen == -1) + if (!(priv->flags & ABSOLUTE_FLAG) || !priv->wcmMMonitor) { /* Get the current screen that the cursor is in */ #if defined WCM_XFREE86 || GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0 @@ -82,14 +83,29 @@ void xf86WcmMappingFactor(LocalDevicePtr local) if (miPointerGetScreen(local->dev)) priv->currentScreen = miPointerGetScreen(local->dev)->myNum; #endif - + } + else + { + if (priv->screen_no != -1) + priv->currentScreen = priv->screen_no; + else if (priv->currentScreen == -1) + { + /* Get the current screen that the cursor is in */ +#if defined WCM_XFREE86 || GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0 + if (miPointerCurrentScreen()) + priv->currentScreen = miPointerCurrentScreen()->myNum; +#else + if (miPointerGetScreen(local->dev)) + priv->currentScreen = miPointerGetScreen(local->dev)->myNum; +#endif + } } if (priv->currentScreen == -1) /* tool on the tablet */ priv->currentScreen = 0; if ( ((priv->twinview != TV_NONE) || /* TwinView & whole desktop */ /* stay in one screen at a time (multimonitor) */ - !priv->common->wcmMMonitor || + !priv->wcmMMonitor || /* always stay in the configured screen */ (screenInfo.numScreens > 1 && priv->screen_no != -1)) && (priv->flags & ABSOLUTE_FLAG) ) @@ -171,7 +187,7 @@ static void xf86WcmSetScreen(LocalDevicePtr local, int *value0, int *value1) } xf86WcmMappingFactor(local); - if (!(priv->flags & ABSOLUTE_FLAG) || screenInfo.numScreens == 1 || !priv->common->wcmMMonitor) + if (!(priv->flags & ABSOLUTE_FLAG) || screenInfo.numScreens == 1 || !priv->wcmMMonitor) return; v0 = v0 - priv->topX; @@ -541,18 +557,22 @@ static void sendAButton(LocalDevicePtr local, int button, int mask, break; case AC_MODETOGGLE: - if (!mask) - break; - - if (priv->flags & ABSOLUTE_FLAG) + if (mask) { - priv->flags &= ~ABSOLUTE_FLAG; - xf86ReplaceStrOption(local->options, "Mode", "Relative"); + int mode = Absolute; + if (is_absolute) + mode = Relative; + xf86WcmDevSwitchModeCall(local, mode); } - else + break; + + case AC_DISPLAYTOGGLE: + if (mask) { - priv->flags |= ABSOLUTE_FLAG; - xf86ReplaceStrOption(local->options, "Mode", "Absolute"); + int screen = priv->screen_no; + if (++screen >= priv->numScreen && priv->numScreen > 1) + screen = -1; + xf86WcmChangeScreen(local, screen); } break; @@ -882,15 +902,7 @@ void xf86WcmSendEvents(LocalDevicePtr local, const WacomDeviceState* ds) x, y, z, v3, v4, v5, id, serial, is_button ? "true" : "false", buttons)); -/* if (x > priv->bottomX) - x = priv->bottomX; - if (x < priv->topX) - x = priv->topX; - if (y > priv->bottomY) - y = priv->bottomY; - if (y < priv->topY) - y = priv->topY; -*/ priv->currentX = x; + priv->currentX = x; priv->currentY = y; /* update the old records */ @@ -1055,6 +1067,7 @@ void xf86WcmSendEvents(LocalDevicePtr local, const WacomDeviceState* ds) priv->oldStripY = 0; priv->oldRot = 0; priv->oldThrottle = 0; + priv->devReverseCount = 0; } } @@ -1112,10 +1125,12 @@ Bool xf86WcmOpen(LocalDevicePtr local) WacomDevicePtr priv = (WacomDevicePtr)local->private; WacomCommonPtr common = priv->common; WacomDeviceClass** ppDevCls; + char id[BUFFER_SIZE]; + float version; DBG(1, priv->debugLevel, ErrorF("opening %s\n", common->wcmDevice)); - local->fd = xf86WcmOpenTablet(local); + local->fd = xf86OpenSerial(local->options); if (local->fd < 0) { ErrorF("Error opening %s : %s\n", common->wcmDevice, @@ -1134,7 +1149,14 @@ Bool xf86WcmOpen(LocalDevicePtr local) } /* Initialize the tablet */ - return common->wcmDevCls->Init(local); + if(common->wcmDevCls->Init(local, id, &version) != Success || + xf86WcmInitTablet(local, id, version) != Success) + { + xf86CloseSerial(local->fd); + local->fd = -1; + return !Success; + } + return Success; } /* reset raw data counters for filters */ @@ -1602,13 +1624,13 @@ static void commonDispatchDevice(WacomCommonPtr common, unsigned int channel, * xf86WcmInitTablet -- common initialization for all tablets ****************************************************************************/ -int xf86WcmInitTablet(LocalDevicePtr local, WacomModelPtr model, - const char* id, float version) +int xf86WcmInitTablet(LocalDevicePtr local, const char* id, float version) { - WacomCommonPtr common = ((WacomDevicePtr)(local->private))->common; + WacomCommonPtr common = ((WacomDevicePtr)(local->private))->common; WacomToolPtr toollist = common->wcmTool; WacomToolAreaPtr arealist; int temp; + WacomModelPtr model = common->wcmModel; /* Initialize the tablet */ model->Initialize(common,id,version); @@ -1700,9 +1722,6 @@ int xf86WcmInitTablet(LocalDevicePtr local, WacomModelPtr model, if (model->Start && (model->Start(local) != Success)) return !Success; - /*set the model */ - common->wcmModel = model; - return Success; } @@ -1731,3 +1750,136 @@ static void transPressureCurve(WacomDevicePtr pDev, WacomDeviceStatePtr pState) FILTER_PRESSURE_RES; } } + +/***************************************************************************** + * xf86WcmInitialTVScreens + ****************************************************************************/ + +static void xf86WcmInitialTVScreens(LocalDevicePtr local) +{ + WacomDevicePtr priv = (WacomDevicePtr)local->private; + + if (priv->twinview == TV_NONE) + return; + + priv->numScreen = 2; + + if (priv->twinview == TV_LEFT_RIGHT) + { + /* it does not need the offset if always map to a specific screen */ + if (priv->screen_no == -1) + { + priv->tvoffsetX = 60; + priv->tvoffsetY = 0; + } + + /* default resolution */ + if(!priv->tvResolution[0]) + { + priv->tvResolution[0] = screenInfo.screens[0]->width/2; + priv->tvResolution[1] = screenInfo.screens[0]->height; + priv->tvResolution[2] = priv->tvResolution[0]; + priv->tvResolution[3] = priv->tvResolution[1]; + } + } + else if (priv->twinview == TV_ABOVE_BELOW) + { + /* it does not need the offset if always map to a specific screen */ + if (priv->screen_no == -1) + { + priv->tvoffsetX = 0; + priv->tvoffsetY = 60; + } + + /* default resolution */ + if(!priv->tvResolution[0]) + { + priv->tvResolution[0] = screenInfo.screens[0]->width; + priv->tvResolution[1] = screenInfo.screens[0]->height/2; + priv->tvResolution[2] = priv->tvResolution[0]; + priv->tvResolution[3] = priv->tvResolution[1]; + } + } + + /* initial screen info */ + priv->screenTopX[0] = 0; + priv->screenTopY[0] = 0; + priv->screenBottomX[0] = priv->tvResolution[0]; + priv->screenBottomY[0] = priv->tvResolution[1]; + if (priv->twinview == TV_ABOVE_BELOW) + { + priv->screenTopX[1] = 0; + priv->screenTopY[1] = priv->tvResolution[1]; + priv->screenBottomX[1] = priv->tvResolution[2]; + priv->screenBottomY[1] = priv->tvResolution[1] + priv->tvResolution[3]; + } + if (priv->twinview == TV_LEFT_RIGHT) + { + priv->screenTopX[1] = priv->tvResolution[0]; + priv->screenTopY[1] = 0; + priv->screenBottomX[1] = priv->tvResolution[0] + priv->tvResolution[2]; + priv->screenBottomY[1] = priv->tvResolution[3]; + } + + DBG(10, priv->debugLevel, ErrorF("xf86WcmInitialTVScreens for \"%s\" " + "topX0=%d topY0=%d bottomX0=%d bottomY0=%d " + "topX1=%d topY1=%d bottomX1=%d bottomY1=%d \n", + local->name, priv->screenTopX[0], priv->screenTopY[0], + priv->screenBottomX[0], priv->screenBottomY[0], + priv->screenTopX[1], priv->screenTopY[1], + priv->screenBottomX[1], priv->screenBottomY[1])); +} + +/***************************************************************************** + * xf86WcmInitialScreens + ****************************************************************************/ + +void xf86WcmInitialScreens(LocalDevicePtr local) +{ + WacomDevicePtr priv = (WacomDevicePtr)local->private; + int i; + + priv->tvoffsetX = 0; + priv->tvoffsetY = 0; + if (priv->twinview != TV_NONE) + { + xf86WcmInitialTVScreens(local); + return; + } + + /* initial screen info */ + priv->numScreen = screenInfo.numScreens; + priv->screenTopX[0] = 0; + priv->screenTopY[0] = 0; + priv->screenBottomX[0] = 0; + priv->screenBottomY[0] = 0; + for (i=0; i<screenInfo.numScreens; i++) + { +#ifdef WCM_XORG + priv->screenTopX[i] = dixScreenOrigins[i].x; + priv->screenTopY[i] = dixScreenOrigins[i].y; + priv->screenBottomX[i] = dixScreenOrigins[i].x; + priv->screenBottomY[i] = dixScreenOrigins[i].y; + + DBG(10, priv->debugLevel, ErrorF("xf86WcmInitialScreens from dix for \"%s\" " + "ScreenOrigins[%d].x=%d ScreenOrigins[%d].y=%d \n", + local->name, i, priv->screenTopX[i], i, priv->screenTopY[i])); +#else + if (i > 0) + { + /* only support left to right in this case */ + priv->screenTopX[i] = priv->screenBottomX[i-1]; + priv->screenTopY[i] = 0; + priv->screenBottomX[i] = priv->screenTopX[i]; + priv->screenBottomY[i] = 0; + } +#endif + priv->screenBottomX[i] += screenInfo.screens[i]->width; + priv->screenBottomY[i] += screenInfo.screens[i]->height; + + DBG(10, priv->debugLevel, ErrorF("xf86WcmInitialScreens for \"%s\" " + "topX[%d]=%d topY[%d]=%d bottomX[%d]=%d bottomY[%d]=%d \n", + local->name, i, priv->screenTopX[i], i, priv->screenTopY[i], + i, priv->screenBottomX[i], i, priv->screenBottomY[i])); + } +} diff --git a/src/xdrv/wcmConfig.c b/src/xdrv/wcmConfig.c index 7dcaef0..c1c4b58 100755 --- a/src/xdrv/wcmConfig.c +++ b/src/xdrv/wcmConfig.c @@ -1,6 +1,6 @@ /* * Copyright 1995-2002 by Frederic Lepied, France. <Lepied@XFree86.org> - * Copyright 2002-2007 by Ping Cheng, Wacom. <pingc@wacom.com> + * Copyright 2002-2008 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 @@ -170,6 +170,9 @@ LocalDevicePtr xf86WcmAllocate(char* name, int flag) priv->tvoffsetY = 0; /* none Y edge offset for TwinView setup */ for (i=0; i<4; i++) priv->tvResolution[i] = 0; /* unconfigured twinview resolution */ + priv->wcmMMonitor = 1; /* enabled (=1) to support multi-monitor desktop. */ + /* disabled (=0) when user doesn't want to move the */ + /* cursor from one screen to another screen */ /* JEJ - throttle sampling code */ priv->throttleValue = 0; @@ -198,9 +201,6 @@ LocalDevicePtr xf86WcmAllocate(char* name, int flag) common->wcmDevCls = &gWacomSerialDevice; /* device-specific functions */ common->wcmModel = NULL; /* model-specific functions */ common->wcmEraserID = 0; /* eraser id associated with the stylus */ - common->wcmMMonitor = 1; /* enabled (=1) to support multi-monitor desktop. */ - /* disabled (=0) when user doesn't want to move the */ - /* cursor from one screen to another screen */ common->wcmTPCButtonDefault = 0; /* default Tablet PC button support is off */ common->wcmTPCButton = common->wcmTPCButtonDefault; /* set Tablet PC button on/off */ @@ -787,10 +787,10 @@ static LocalDevicePtr xf86WcmInit(InputDriverPtr drv, IDevPtr dev, int flags) } /* Cursor stays in one monitor in a multimonitor setup */ - if ( !common->wcmMMonitor ) + if ( !priv->wcmMMonitor ) { - common->wcmMMonitor = xf86SetBoolOption(local->options, "MMonitor", 1); - if ( !common->wcmMMonitor ) + priv->wcmMMonitor = xf86SetBoolOption(local->options, "MMonitor", 1); + if ( !priv->wcmMMonitor ) xf86Msg(X_CONFIG, "%s: Cursor will stay in one monitor \n", common->wcmDevice); } diff --git a/src/xdrv/wcmISDV4.c b/src/xdrv/wcmISDV4.c index c60c108..3bf8a6f 100755 --- a/src/xdrv/wcmISDV4.c +++ b/src/xdrv/wcmISDV4.c @@ -22,7 +22,7 @@ #include "wcmFilter.h" static Bool isdv4Detect(LocalDevicePtr); -static Bool isdv4Init(LocalDevicePtr); +static Bool isdv4Init(LocalDevicePtr, char* id, float *version); static void isdv4InitISDV4(WacomCommonPtr, const char* id, float version); static int isdv4GetRanges(LocalDevicePtr); static int isdv4StartTablet(LocalDevicePtr); @@ -64,18 +64,18 @@ static Bool isdv4Detect(LocalDevicePtr local) * isdv4Init -- ****************************************************************************/ -static Bool isdv4Init(LocalDevicePtr local) +static Bool isdv4Init(LocalDevicePtr local, char* id, float *version) { int err; WacomDevicePtr priv = (WacomDevicePtr)local->private; WacomCommonPtr common = priv->common; - DBG(1, priv->debugLevel, ErrorF("initializing ISDV4 tablet\n")); + DBG(1, priv->debugLevel, ErrorF("initializing ISDV4 tablet\n")); /* Try 19200 first */ if (xf86WcmSetSerialSpeed(local->fd, common->wcmISDV4Speed) < 0) return !Success; - + /* Send stop command to the tablet */ err = xf86WcmWrite(local->fd, WC_ISDV4_STOP, strlen(WC_ISDV4_STOP)); if (err == -1) @@ -88,7 +88,15 @@ static Bool isdv4Init(LocalDevicePtr local) if (xf86WcmWait(250)) return !Success; - return xf86WcmInitTablet(local,&isdv4General,"ISDV4", common->wcmVersion); + if(id) + strcpy(id, "ISDV4"); + if(version) + *version = common->wcmVersion; + + /*set the model */ + common->wcmModel = &isdv4General; + + return Success; } /***************************************************************************** @@ -165,7 +173,7 @@ static int isdv4GetRanges(LocalDevicePtr local) if (common->wcmISDV4Speed != 38400) { common->wcmISDV4Speed = 38400; - return isdv4Init(local); + return isdv4Init(local, NULL, NULL); } else { diff --git a/src/xdrv/wcmSerial.c b/src/xdrv/wcmSerial.c index c24dc66..678ea1c 100755 --- a/src/xdrv/wcmSerial.c +++ b/src/xdrv/wcmSerial.c @@ -1,6 +1,6 @@ /* * Copyright 1995-2002 by Frederic Lepied, France. <Lepied@XFree86.org> - * Copyright 2002-2007 by Ping Cheng, Wacom Technology. <pingc@wacom.com> + * Copyright 2002-2008 by Ping Cheng, Wacom Technology. <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 @@ -23,9 +23,9 @@ /* Serial Support */ static Bool serialDetect(LocalDevicePtr pDev); -static Bool serialInit(LocalDevicePtr pDev); +static Bool serialInit(LocalDevicePtr pDev, char* id, float *version); -static int serialInitTablet(LocalDevicePtr local); +static int serialInitTablet(LocalDevicePtr local, char* id, float *version); static void serialInitIntuos(WacomCommonPtr common, const char* id, float version); static void serialInitIntuos2(WacomCommonPtr common, const char* id, float version); static void serialInitCintiq(WacomCommonPtr common, const char* id, float version); @@ -273,11 +273,11 @@ char* xf86WcmSendRequest(int fd, const char* request, char* answer, int maxlen) "after %d tries\n", request, MAXTRY); return NULL; } - + do { maxtry = MAXTRY; - + /* Read the first byte of the answer which must * be equal to the first byte of the request. */ @@ -293,7 +293,7 @@ char* xf86WcmSendRequest(int fd, const char* request, char* answer, int maxlen) return NULL; } } - maxtry--; + maxtry--; } while ((answer[0] != request[0]) && maxtry); if (maxtry == 0) @@ -307,7 +307,7 @@ char* xf86WcmSendRequest(int fd, const char* request, char* answer, int maxlen) /* Read the second byte of the answer which must be equal * to the second byte of the request. */ do - { + { maxtry = MAXTRY; do { @@ -321,9 +321,9 @@ char* xf86WcmSendRequest(int fd, const char* request, char* answer, int maxlen) return NULL; } } - maxtry--; + maxtry--; } while ((nr <= 0) && maxtry); - + if (maxtry == 0) { ErrorF("Wacom unable to read second byte of " @@ -335,7 +335,7 @@ char* xf86WcmSendRequest(int fd, const char* request, char* answer, int maxlen) if (answer[1] != request[1]) answer[0] = answer[1]; - + } while ((answer[0] == request[0]) && (answer[1] != request[1])); } while ((answer[0] != request[0]) && (answer[1] != request[1])); @@ -345,7 +345,7 @@ char* xf86WcmSendRequest(int fd, const char* request, char* answer, int maxlen) len = 2; maxtry = MAXTRY; do - { + { do { if ((nr = xf86WcmWaitForTablet(fd)) > 0) @@ -380,9 +380,9 @@ char* xf86WcmSendRequest(int fd, const char* request, char* answer, int maxlen) if (len <= 3) return NULL; - + answer[len-1] = '\0'; - + return answer; } @@ -391,17 +391,17 @@ static Bool serialDetect(LocalDevicePtr pDev) return 1; } -static Bool serialInit(LocalDevicePtr local) +static Bool serialInit(LocalDevicePtr local, char* id, float *version) { int err; WacomDevicePtr priv = (WacomDevicePtr)local->private; - DBG(1, priv->debugLevel, ErrorF("initializing serial tablet\n")); + DBG(1, priv->debugLevel, ErrorF("initializing serial tablet\n")); /* Set the speed of the serial link to 38400 */ if (xf86WcmSetSerialSpeed(local->fd, 38400) < 0) return !Success; - + /* Send reset to the tablet */ err = xf86WcmWrite(local->fd, WC_RESET_BAUD, strlen(WC_RESET_BAUD)); @@ -411,7 +411,7 @@ static Bool serialInit(LocalDevicePtr local) ErrorF("Wacom xf86WcmWrite error : %s\n", strerror(errno)); return !Success; } - + /* Wait 250 mSecs */ if (xf86WcmWait(250)) return !Success; @@ -423,7 +423,7 @@ static Bool serialInit(LocalDevicePtr local) ErrorF("Wacom xf86WcmWrite error : %s\n", strerror(errno)); return !Success; } - + /* Wait 75 mSecs */ if (xf86WcmWait(75)) return !Success; @@ -431,7 +431,7 @@ static Bool serialInit(LocalDevicePtr local) /* Set the speed of the serial link to 19200 */ if (xf86WcmSetSerialSpeed(local->fd, 19200) < 0) return !Success; - + /* Send reset to the tablet */ err = xf86WcmWrite(local->fd, WC_RESET_BAUD, strlen(WC_RESET_BAUD)); @@ -441,7 +441,7 @@ static Bool serialInit(LocalDevicePtr local) ErrorF("Wacom xf86WcmWrite error : %s\n", strerror(errno)); return !Success; } - + /* Wait 250 mSecs */ if (xf86WcmWait(250)) return !Success; @@ -453,7 +453,7 @@ static Bool serialInit(LocalDevicePtr local) ErrorF("Wacom xf86WcmWrite error : %s\n", strerror(errno)); return !Success; } - + /* Wait 75 mSecs */ if (xf86WcmWait(75)) return !Success; @@ -461,7 +461,7 @@ static Bool serialInit(LocalDevicePtr local) /* Set the speed of the serial link to 9600 */ if (xf86WcmSetSerialSpeed(local->fd, 9600) < 0) return !Success; - + /* Send reset to the tablet */ err = xf86WcmWrite(local->fd, WC_RESET_BAUD, strlen(WC_RESET_BAUD)); if (err == -1) @@ -469,7 +469,7 @@ static Bool serialInit(LocalDevicePtr local) ErrorF("Wacom xf86WcmWrite error : %s\n", strerror(errno)); return !Success; } - + /* Wait 250 mSecs */ if (xf86WcmWait(250)) return !Success; @@ -487,14 +487,7 @@ static Bool serialInit(LocalDevicePtr local) xf86WcmFlushTablet(local->fd); - if (serialInitTablet(local) == !Success) - { - xf86WcmClose(local->fd); - local->fd = -1; - return !Success; - } - - return Success; + return serialInitTablet(local, id, version); } /***************************************************************************** @@ -502,83 +495,70 @@ static Bool serialInit(LocalDevicePtr local) * Initialize the tablet ****************************************************************************/ - -static int serialInitTablet(LocalDevicePtr local) +static int serialInitTablet(LocalDevicePtr local, char* id, float *version) { int loop, idx; - char id[BUFFER_SIZE]; - float version; + char getID[BUFFER_SIZE]; WacomDevicePtr priv = (WacomDevicePtr)local->private; - WacomCommonPtr common = priv->common; + WacomCommonPtr common = priv->common; - WacomModelPtr model = NULL; + DBG(2, priv->debugLevel, ErrorF("reading model\n")); - /* if model is forced, initialize */ - if (model != NULL) + if (!xf86WcmSendRequest(local->fd, WC_MODEL, getID, sizeof(getID))) + return !Success; + + DBG(2, priv->debugLevel, ErrorF("%s\n", getID)); + + if (xf86Verbose) + ErrorF("%s Wacom tablet model : %s\n", + XCONFIG_PROBED, getID+2); + + /* Answer is in the form ~#Tablet-Model VRom_Version + * look for the first V from the end of the string + * this seems to be the better way to find the version + * of the ROM */ + for(loop=strlen(getID); loop>=0 && *(getID+loop) != 'V'; loop--); + for(idx=loop; idx<strlen(getID) && *(getID+idx) != '-'; idx++); + *(getID+idx) = '\0'; + + /* Extract version numbers */ + sscanf(getID+loop+1, "%f", version); + + /* Detect tablet model based on identifier */ + if (getID[2] == 'G' && getID[3] == 'D') { - id[0] = '\0'; - version = 0.0F; + common->wcmModel = &serialIntuos; + common->tablet_id = 0x20; + } + else if (getID[2] == 'X' && getID[3] == 'D') + { + common->wcmModel = &serialIntuos2; + common->tablet_id = 0x40; + } + else if ( (getID[2] == 'P' && getID[3] == 'L') || + (getID[2] == 'D' && getID[3] == 'T') ) + { + common->wcmModel = &serialCintiq; + common->tablet_id = 0x30; + } + else if (getID[2] == 'C' && getID[3] == 'T') + { + common->wcmModel = &serialPenPartner; + common->tablet_id = 0x00; + } + else if (getID[2] == 'E' && getID[3] == 'T') + { + common->wcmModel = &serialGraphire; + common->tablet_id = 0x10; } - - /* otherwise, query and initialize */ else { - DBG(2, priv->debugLevel, ErrorF("reading model\n")); - if (!xf86WcmSendRequest(local->fd, WC_MODEL, id, sizeof(id))) - return !Success; - - DBG(2, priv->debugLevel, ErrorF("%s\n", id)); - - if (xf86Verbose) - ErrorF("%s Wacom tablet model : %s\n", - XCONFIG_PROBED, id+2); - - /* Answer is in the form ~#Tablet-Model VRom_Version - * look for the first V from the end of the string - * this seems to be the better way to find the version - * of the ROM */ - for(loop=strlen(id); loop>=0 && *(id+loop) != 'V'; loop--); - for(idx=loop; idx<strlen(id) && *(id+idx) != '-'; idx++); - *(id+idx) = '\0'; - - /* Extract version numbers */ - sscanf(id+loop+1, "%f", &version); - - /* Detect tablet model based on identifier */ - if (id[2] == 'G' && id[3] == 'D') - { - model = &serialIntuos; - common->tablet_id = 0x20; - } - else if (id[2] == 'X' && id[3] == 'D') - { - model = &serialIntuos2; - common->tablet_id = 0x40; - } - else if ( (id[2] == 'P' && id[3] == 'L') || - (id[2] == 'D' && id[3] == 'T') ) - { - model = &serialCintiq; - common->tablet_id = 0x30; - } - else if (id[2] == 'C' && id[3] == 'T') - { - model = &serialPenPartner; - common->tablet_id = 0x00; - } - else if (id[2] == 'E' && id[3] == 'T') - { - model = &serialGraphire; - common->tablet_id = 0x10; - } - else - { - model = &serialProtocol4; - common->tablet_id = 0x03; - } + common->wcmModel = &serialProtocol4; + common->tablet_id = 0x03; } + sprintf(id, "%s", getID); - return xf86WcmInitTablet(local,model,id,version); + return Success; } static int serialParseGraphire(LocalDevicePtr local, const unsigned char* data) @@ -719,7 +699,7 @@ static int serialParseProtocol5(LocalDevicePtr local, const unsigned char* data) RESET_RELATIVE(*ds); DBG(7, common->debugLevel, ErrorF("packet header = %x\n", data[0])); - + /* Device ID packet */ if ((data[0] & 0xfc) == 0xc0) { @@ -745,7 +725,7 @@ static int serialParseProtocol5(LocalDevicePtr local, const unsigned char* data) ds->device_type = CURSOR_ID; else ds->device_type = ERASER_ID; - + DBG(6, common->debugLevel, ErrorF( "device_id=%x serial_num=%u type=%s\n", ds->device_id, ds->serial_num, @@ -1013,7 +993,7 @@ static void serialGetResolution(LocalDevicePtr local) int a, b; char buffer[BUFFER_SIZE], header[BUFFER_SIZE]; WacomDevicePtr priv = (WacomDevicePtr)local->private; - WacomCommonPtr common = priv->common; + WacomCommonPtr common = priv->common; if (!(common->wcmResolX && common->wcmResolY)) { @@ -1057,7 +1037,7 @@ static int serialGetRanges(LocalDevicePtr local) { char buffer[BUFFER_SIZE]; WacomDevicePtr priv = (WacomDevicePtr)local->private; - WacomCommonPtr common = priv->common; + WacomCommonPtr common = priv->common; if (!(common->wcmMaxX && common->wcmMaxY)) { @@ -1100,7 +1080,7 @@ static int serialResetCintiq(LocalDevicePtr local) int err; err = xf86WcmWrite(local->fd, WC_RESET, strlen(WC_RESET)); - + if (xf86WcmWait(75)) return !Success; err = xf86WcmWrite(local->fd, pl_setup_string, @@ -1126,7 +1106,7 @@ static int serialResetProtocol4(LocalDevicePtr local) int err; err = xf86WcmWrite(local->fd, WC_RESET, strlen(WC_RESET)); - + if (xf86WcmWait(75)) return !Success; err = xf86WcmWrite(local->fd, setup_string, @@ -1286,7 +1266,7 @@ static void serialParseP4Common(LocalDevicePtr local, ds->buttons = 0; ds->device_id = ERASER_DEVICE_ID; } - + DBG(8, common->debugLevel, ErrorF("serialParseP4Common %s\n", ds->device_type == CURSOR_ID ? "CURSOR" : ds->device_type == ERASER_ID ? "ERASER " : diff --git a/src/xdrv/wcmUSB.c b/src/xdrv/wcmUSB.c index c8a8aaa..c2c2c3d 100755 --- a/src/xdrv/wcmUSB.c +++ b/src/xdrv/wcmUSB.c @@ -46,7 +46,7 @@ #endif static Bool usbDetect(LocalDevicePtr); -Bool usbWcmInit(LocalDevicePtr pDev); +Bool usbWcmInit(LocalDevicePtr pDev, char* id, float *version); static void usbInitProtocol5(WacomCommonPtr common, const char* id, float version); @@ -350,7 +350,7 @@ static Bool usbDetect(LocalDevicePtr local) WacomDevicePtr priv = (WacomDevicePtr)local->private; DBG(1, priv->debugLevel, ErrorF("usbDetect\n")); - + SYSCALL(err = ioctl(local->fd, EVIOCGVERSION, &version)); if (err < 0) @@ -462,17 +462,16 @@ static struct { 0xC6, 5080, 5080, &usbCintiqV5 } /* Cintiq 12WX */ }; -Bool usbWcmInit(LocalDevicePtr local) +Bool usbWcmInit(LocalDevicePtr local, char* id, float *version) { int i; short sID[4]; - char id[BUFFER_SIZE]; - WacomModelPtr model = NULL; unsigned long keys[NBITS(KEY_MAX)]; WacomDevicePtr priv = (WacomDevicePtr)local->private; WacomCommonPtr common = priv->common; - DBG(1, priv->debugLevel, ErrorF("initializing USB tablet\n")); + DBG(1, priv->debugLevel, ErrorF("initializing USB tablet\n")); + *version = 0.0; /* fetch vendor, product, and model name */ ioctl(local->fd, EVIOCGID, sID); @@ -486,15 +485,15 @@ Bool usbWcmInit(LocalDevicePtr local) for (i = 0; i < sizeof (WacomModelDesc) / sizeof (WacomModelDesc [0]); i++) if (common->tablet_id == WacomModelDesc [i].model_id) { - model = WacomModelDesc [i].model; + common->wcmModel = WacomModelDesc [i].model; common->wcmResolX = WacomModelDesc [i].xRes; common->wcmResolY = WacomModelDesc [i].yRes; } } - if (!model) + if (!common->wcmModel) { - model = &usbUnknown; + common->wcmModel = &usbUnknown; common->wcmResolX = common->wcmResolY = 1016; } @@ -527,7 +526,7 @@ Bool usbWcmInit(LocalDevicePtr local) common->wcmFlags |= TILT_ENABLED_FLAG; - return xf86WcmInitTablet(local,model,id,0.0); + return Success; } static void usbInitProtocol5(WacomCommonPtr common, const char* id, @@ -536,7 +535,7 @@ static void usbInitProtocol5(WacomCommonPtr common, const char* id, common->wcmProtocolLevel = 5; common->wcmPktLength = sizeof(struct input_event); common->wcmCursorProxoutDistDefault - = PROXOUT_INTUOS_DISTANCE; + = PROXOUT_INTUOS_DISTANCE; /* reinitialize max here since 0 is for Graphire series */ common->wcmMaxCursorDist = 256; @@ -548,7 +547,7 @@ static void usbInitProtocol4(WacomCommonPtr common, const char* id, common->wcmProtocolLevel = 4; common->wcmPktLength = sizeof(struct input_event); common->wcmCursorProxoutDistDefault - = PROXOUT_GRAPHIRE_DISTANCE; + = PROXOUT_GRAPHIRE_DISTANCE; } int usbWcmGetRanges(LocalDevicePtr local) @@ -841,7 +840,7 @@ static void usbParseChannel(LocalDevicePtr local, int channel, int serial) { event = common->wcmEvents + i; DBG(11, common->debugLevel, ErrorF("usbParseChannel " - "event[%d]->type=%d code=%d value=%d\n", + "event[%d]->type=%d code=%d value=%d\n", i, event->type, event->code, event->value)); /* absolute events */ diff --git a/src/xdrv/wcmXCommand.c b/src/xdrv/wcmXCommand.c index 9a84742..8c39d6f 100644 --- a/src/xdrv/wcmXCommand.c +++ b/src/xdrv/wcmXCommand.c @@ -1,5 +1,5 @@ /* - * Copyright 2007 by Ping Cheng, Wacom Technology. <pingc@wacom.com> + * Copyright 2007-2008 by Ping Cheng, Wacom Technology. <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 @@ -34,6 +34,7 @@ extern void xf86WcmInitialScreens(LocalDevicePtr local); /***************************************************************************** * xf86WcmSetPadCoreMode ****************************************************************************/ + int xf86WcmSetPadCoreMode(LocalDevicePtr local) { WacomDevicePtr priv = (WacomDevicePtr)local->private; @@ -55,6 +56,88 @@ int xf86WcmSetPadCoreMode(LocalDevicePtr local) } /***************************************************************************** +* xf86WcmDevSwitchModeCall -- +*****************************************************************************/ + +int xf86WcmDevSwitchModeCall(LocalDevicePtr local, int mode) +{ + WacomDevicePtr priv = (WacomDevicePtr)local->private; + int is_absolute = priv->flags & ABSOLUTE_FLAG; + + DBG(3, priv->debugLevel, ErrorF("xf86WcmSwitchModeCall for %s to mode=%d\n", + local->name, mode)); + + /* Pad is always in relative mode when it's a core device. + * Always in absolute mode when it is not a core device. + */ + if (IsPad(priv)) + return xf86WcmSetPadCoreMode(local); + + if ((mode == Absolute) && !is_absolute) + { + priv->flags |= ABSOLUTE_FLAG; + xf86ReplaceStrOption(local->options, "Mode", "Absolute"); + xf86WcmMappingFactor(local); + xf86WcmInitialCoordinates(local, 0); + xf86WcmInitialCoordinates(local, 1); + } + else if ((mode == Relative) && is_absolute) + { + priv->flags &= ~ABSOLUTE_FLAG; + xf86ReplaceStrOption(local->options, "Mode", "Relative"); + xf86WcmMappingFactor(local); + xf86WcmInitialCoordinates(local, 0); + xf86WcmInitialCoordinates(local, 1); + } + else if ( (mode != Absolute) && (mode != Relative)) + { + DBG(10, priv->debugLevel, ErrorF("xf86WcmSwitchModeCall" + " for %s invalid mode=%d\n", local->name, mode)); + return BadMatch; + } + + return Success; +} + +/***************************************************************************** +* xf86WcmDevSwitchMode -- +*****************************************************************************/ + +int xf86WcmDevSwitchMode(ClientPtr client, DeviceIntPtr dev, int mode) +{ + LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate; + WacomDevicePtr priv = (WacomDevicePtr)local->private; + + DBG(3, priv->debugLevel, ErrorF("xf86WcmSwitchMode dev=%p mode=%d\n", + (void *)dev, mode)); + + /* Share this call with sendAButton in wcmCommon.c */ + return xf86WcmDevSwitchModeCall(local, mode); +} + +/***************************************************************************** + * xf86WcmChangeScreen + ****************************************************************************/ + +void xf86WcmChangeScreen(LocalDevicePtr local, int value) +{ + WacomDevicePtr priv = (WacomDevicePtr)local->private; + + if (priv->screen_no != value) + { + priv->screen_no = value; + xf86ReplaceIntOption(local->options, "ScreenNo", value); + } + + if (priv->screen_no != -1) + priv->currentScreen = priv->screen_no; + xf86WcmInitialScreens(local); + xf86WcmMappingFactor(local); + xf86WcmInitialCoordinates(local, 0); + xf86WcmInitialCoordinates(local, 1); +} + +/***************************************************************************** * xf86WcmSetParam ****************************************************************************/ @@ -216,23 +299,8 @@ static int xf86WcmSetParam(LocalDevicePtr local, int param, int value) int is_absolute = priv->flags & ABSOLUTE_FLAG; if ((value < 0) || (value > 1)) return BadValue; if (value != is_absolute) - { - if (IsPad(priv)) - return xf86WcmSetPadCoreMode(local); - - if (value) - { - priv->flags |= ABSOLUTE_FLAG; - xf86ReplaceStrOption(local->options, "Mode", "Absolute"); - } - else - { - priv->flags &= ~ABSOLUTE_FLAG; - xf86ReplaceStrOption(local->options, "Mode", "Relative"); - } - xf86WcmMappingFactor(local); - xf86WcmInitialCoordinates(local, 0); - xf86WcmInitialCoordinates(local, 1); + { + xf86WcmDevSwitchModeCall(local, value); } break; } @@ -264,9 +332,9 @@ static int xf86WcmSetParam(LocalDevicePtr local, int param, int value) case XWACOM_PARAM_MMT: if ((value != 0) && (value != 1)) return BadValue; - else if (common->wcmMMonitor != value) + else if (priv->wcmMMonitor != value) { - common->wcmMMonitor = value; + priv->wcmMMonitor = value; if (value) xf86ReplaceStrOption(local->options, "MMonitor", "on"); else @@ -278,7 +346,7 @@ static int xf86WcmSetParam(LocalDevicePtr local, int param, int value) case XWACOM_PARAM_TPCBUTTON: if ((value != 0) && (value != 1)) return BadValue; - else if (common->wcmMMonitor != value) + else if (common->wcmTPCButton != value) { common->wcmTPCButton = value; if (value) @@ -304,30 +372,7 @@ static int xf86WcmSetParam(LocalDevicePtr local, int param, int value) return BadValue; else if (priv->screen_no != value) { - priv->screen_no = value; - if (priv->twinview != TV_NONE) - { - xf86WcmInitialScreens(local); - if (priv->screen_no == -1) - { - if (priv->twinview == TV_LEFT_RIGHT) - priv->tvoffsetX = 60; - else - priv->tvoffsetY = 60; - } - else - { - priv->tvoffsetX = 0; - priv->tvoffsetY = 0; - } - } - if (priv->screen_no != -1) - priv->currentScreen = priv->screen_no; - xf86WcmInitialScreens(local); - xf86WcmMappingFactor(local); - xf86WcmInitialCoordinates(local, 0); - xf86WcmInitialCoordinates(local, 1); - xf86ReplaceIntOption(local->options, "ScreenNo", value); + xf86WcmChangeScreen(local, value); } break; case XWACOM_PARAM_TWINVIEW: @@ -336,23 +381,7 @@ static int xf86WcmSetParam(LocalDevicePtr local, int param, int value) if ((value > 2) || (value < 0) || screenInfo.numScreens != 1) return BadValue; priv->twinview = value; - xf86WcmInitialScreens(local); - xf86WcmMappingFactor(local); - xf86WcmInitialCoordinates(local, 0); - xf86WcmInitialCoordinates(local, 1); - switch(value) { - case TV_NONE: - xf86ReplaceStrOption(local->options, "TwinView", "None"); - break; - case TV_ABOVE_BELOW: - xf86ReplaceStrOption(local->options, "TwinView", "Vertical"); - break; - case TV_LEFT_RIGHT: - xf86ReplaceStrOption(local->options, "TwinView", "Horizontal"); - break; - default: - return BadValue; - } + xf86WcmChangeScreen(local, priv->screen_no); } break; case XWACOM_PARAM_TVRESOLUTION0: @@ -390,8 +419,7 @@ static int xf86WcmSetParam(LocalDevicePtr local, int param, int value) return BadValue; priv->tvResolution[sNum++] = value & 0xffff; priv->tvResolution[sNum] = (value >> 16) & 0xffff; - xf86WcmInitialScreens(local); - xf86WcmMappingFactor(local); + xf86WcmChangeScreen(local, priv->screen_no); DBG(10, priv->debugLevel, ErrorF("xf86WcmSetParam " "to ResX=%d ResY=%d \n", value & 0xffff, (value >> 16) & 0xffff)); @@ -818,7 +846,7 @@ static int xf86WcmGetParam(LocalDevicePtr local, int param) case XWACOM_PARAM_XYDEFAULT: return -1; case XWACOM_PARAM_MMT: - return common->wcmMMonitor; + return priv->wcmMMonitor; case XWACOM_PARAM_TPCBUTTON: return common->wcmTPCButton; case XWACOM_PARAM_CURSORPROX: @@ -1001,51 +1029,7 @@ static int xf86WcmGetDefaultParam(LocalDevicePtr local, int param) DBG(10, priv->debugLevel, ErrorF("xf86WcmGetDefaultParam invalid param %d\n",param)); return -1; } - -/***************************************************************************** -* xf86WcmDevSwitchMode -- -*****************************************************************************/ - -int xf86WcmDevSwitchMode(ClientPtr client, DeviceIntPtr dev, int mode) -{ - LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate; - WacomDevicePtr priv = (WacomDevicePtr)local->private; - int is_absolute = priv->flags & ABSOLUTE_FLAG; - - DBG(3, priv->debugLevel, ErrorF("xf86WcmSwitchMode dev=%p mode=%d\n", (void *)dev, mode)); - - /* Pad is always in relative mode when it's a core device. - * Always in absolute mode when it is not a core device. - */ - if (IsPad(priv)) - return xf86WcmSetPadCoreMode(local); - - if ((mode == Absolute) && !is_absolute) - { - priv->flags |= ABSOLUTE_FLAG; - xf86ReplaceStrOption(local->options, "Mode", "Absolute"); - xf86WcmMappingFactor(local); - xf86WcmInitialCoordinates(local, 0); - xf86WcmInitialCoordinates(local, 1); - } - else if ((mode == Relative) && is_absolute) - { - priv->flags &= ~ABSOLUTE_FLAG; - xf86ReplaceStrOption(local->options, "Mode", "Relative"); - xf86WcmMappingFactor(local); - xf86WcmInitialCoordinates(local, 0); - xf86WcmInitialCoordinates(local, 1); - } - else if ( (mode != Absolute) && (mode != Relative)) - { - DBG(10, priv->debugLevel, ErrorF("xf86WcmSwitchMode dev=%p invalid mode=%d\n", - (void *)dev, mode)); - return BadMatch; - } - - return Success; -} - + /***************************************************************************** * xf86WcmDevChangeControl -- ****************************************************************************/ @@ -1122,4 +1106,3 @@ int xf86WcmDevChangeControl(LocalDevicePtr local, xDeviceCtl* control) r [i] = local->dev->valuator->axes [i].resolution; return rc; } - diff --git a/src/xdrv/xf86Wacom.c b/src/xdrv/xf86Wacom.c index 3a60a31..e694298 100755 --- a/src/xdrv/xf86Wacom.c +++ b/src/xdrv/xf86Wacom.c @@ -31,8 +31,11 @@ * Frederic Lepied <lepied@xfree86.org>, * Brion Vibber <brion@pobox.com>, * Aaron Optimizer Digulla <digulla@hepe.com>, - * Jonathan Layes <jonathan@layes.com>. - * John Joganic <jej@j-arkadia.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>. */ /* @@ -61,9 +64,10 @@ * 2007-12-07 47-pc0.7.9-4 - Support Cintiq 12WX and Bamboo * 2007-12-20 47-pc0.7.9-5 - multimonitor support update * 2008-01-08 47-pc0.7.9-6 - Configure script change for Xorg 7.3 support + * 2008-01-17 47-pc0.7.9-7 - Preparing for hotplug-aware driver */ -static const char identification[] = "$Identification: 47-0.7.9-6 $"; +static const char identification[] = "$Identification: 47-0.7.9-7 $"; /****************************************************************************/ @@ -79,11 +83,11 @@ static Bool xf86WcmDevConvert(LocalDevicePtr local, int first, int num, int v0, int v1, int v2, int v3, int v4, int v5, int* x, int* y); static Bool xf86WcmDevReverseConvert(LocalDevicePtr local, int x, int y, int* valuators); -static void xf86WcmInitialTVScreens(LocalDevicePtr local); extern Bool usbWcmInit(LocalDevicePtr pDev); extern int usbWcmGetRanges(LocalDevicePtr local); extern int xf86WcmDevChangeControl(LocalDevicePtr local, xDeviceCtl* control); extern int xf86WcmDevSwitchMode(ClientPtr client, DeviceIntPtr dev, int mode); +extern void xf86WcmInitialScreens(LocalDevicePtr local); WacomModule gWacomModule = { @@ -102,6 +106,10 @@ WacomModule gWacomModule = xf86WcmDevReverseConvert, }; +static void xf86WcmKbdLedCallback(DeviceIntPtr di, LedCtrl * lcp) +{ +} + static int xf86WcmInitArea(LocalDevicePtr local) { WacomDevicePtr priv = (WacomDevicePtr)local->private; @@ -294,133 +302,6 @@ void xf86WcmInitialCoordinates(LocalDevicePtr local, int axes) } /***************************************************************************** - * xf86WcmInitialTVScreens - ****************************************************************************/ - -static void xf86WcmInitialTVScreens(LocalDevicePtr local) -{ - WacomDevicePtr priv = (WacomDevicePtr)local->private; - - if (priv->twinview == TV_NONE) - return; - - priv->numScreen = 2; - - if (priv->twinview == TV_LEFT_RIGHT) - { - /* it does not need the offset if always map to a specific screen */ - if (priv->screen_no == -1) - priv->tvoffsetX = 60; - - /* default resolution */ - if(!priv->tvResolution[0]) - { - priv->tvResolution[0] = screenInfo.screens[0]->width/2; - priv->tvResolution[1] = screenInfo.screens[0]->height; - priv->tvResolution[2] = priv->tvResolution[0]; - priv->tvResolution[3] = priv->tvResolution[1]; - } - } - else if (priv->twinview == TV_ABOVE_BELOW) - { - /* it does not need the offset if always map to a specific screen */ - if (priv->screen_no == -1) - priv->tvoffsetY = 60; - - /* default resolution */ - if(!priv->tvResolution[0]) - { - priv->tvResolution[0] = screenInfo.screens[0]->width; - priv->tvResolution[1] = screenInfo.screens[0]->height/2; - priv->tvResolution[2] = priv->tvResolution[0]; - priv->tvResolution[3] = priv->tvResolution[1]; - } - } - - /* initial screen info */ - priv->screenTopX[0] = 0; - priv->screenTopY[0] = 0; - priv->screenBottomX[0] = priv->tvResolution[0]; - priv->screenBottomY[0] = priv->tvResolution[1]; - if (priv->twinview == TV_ABOVE_BELOW) - { - priv->screenTopX[1] = 0; - priv->screenTopY[1] = priv->tvResolution[1]; - priv->screenBottomX[1] = priv->tvResolution[2]; - priv->screenBottomY[1] = priv->tvResolution[1] + priv->tvResolution[3]; - } - if (priv->twinview == TV_LEFT_RIGHT) - { - priv->screenTopX[1] = priv->tvResolution[0]; - priv->screenTopY[1] = 0; - priv->screenBottomX[1] = priv->tvResolution[0] + priv->tvResolution[2]; - priv->screenBottomY[1] = priv->tvResolution[3]; - } - - DBG(10, priv->debugLevel, ErrorF("xf86WcmInitialTVScreens for \"%s\" " - "topX0=%d topY0=%d bottomX0=%d bottomY0=%d " - "topX1=%d topY1=%d bottomX1=%d bottomY1=%d \n", - local->name, priv->screenTopX[0], priv->screenTopY[0], - priv->screenBottomX[0], priv->screenBottomY[0], - priv->screenTopX[1], priv->screenTopY[1], - priv->screenBottomX[1], priv->screenBottomY[1])); -} - -/***************************************************************************** - * xf86WcmInitialScreens - ****************************************************************************/ - -void xf86WcmInitialScreens(LocalDevicePtr local) -{ - WacomDevicePtr priv = (WacomDevicePtr)local->private; - int i; - - priv->tvoffsetX = 0; - priv->tvoffsetY = 0; - if (priv->twinview != TV_NONE) - { - xf86WcmInitialTVScreens(local); - return; - } - - /* initial screen info */ - priv->numScreen = screenInfo.numScreens; - priv->screenTopX[0] = 0; - priv->screenTopY[0] = 0; - priv->screenBottomX[0] = 0; - priv->screenBottomY[0] = 0; - for (i=0; i<screenInfo.numScreens; i++) - { -#ifdef WCM_XORG - priv->screenTopX[i] = dixScreenOrigins[i].x; - priv->screenTopY[i] = dixScreenOrigins[i].y; - priv->screenBottomX[i] = dixScreenOrigins[i].x; - priv->screenBottomY[i] = dixScreenOrigins[i].y; - - DBG(10, priv->debugLevel, ErrorF("xf86WcmInitialScreens from dix for \"%s\" " - "ScreenOrigins[%d].x=%d ScreenOrigins[%d].y=%d \n", - local->name, i, priv->screenTopX[i], i, priv->screenTopY[i])); -#else - if (i > 0) - { - /* only support left to right in this case */ - priv->screenTopX[i] = priv->screenBottomX[i-1]; - priv->screenTopY[i] = 0; - priv->screenBottomX[i] = priv->screenTopX[i]; - priv->screenBottomY[i] = 0; - } -#endif - priv->screenBottomX[i] += screenInfo.screens[i]->width; - priv->screenBottomY[i] += screenInfo.screens[i]->height; - - DBG(10, priv->debugLevel, ErrorF("xf86WcmInitialScreens for \"%s\" " - "topX[%d]=%d topY[%d]=%d bottomX[%d]=%d bottomY[%d]=%d \n", - local->name, i, priv->screenTopX[i], i, priv->screenTopY[i], - i, priv->screenBottomX[i], i, priv->screenBottomY[i])); - } -} - -/***************************************************************************** * xf86WcmRegisterX11Devices -- * Register the X11 input devices with X11 core. ****************************************************************************/ @@ -429,7 +310,7 @@ static int xf86WcmRegisterX11Devices (LocalDevicePtr local) { WacomDevicePtr priv = (WacomDevicePtr)local->private; WacomCommonPtr common = priv->common; - CARD8 butmap[MAX_BUTTONS]; + CARD8 butmap[MAX_BUTTONS+1]; int nbaxes, nbbuttons, nbkeys; int loop; @@ -505,41 +386,50 @@ static int xf86WcmRegisterX11Devices (LocalDevicePtr local) } - if (nbkeys) + /* only initial KeyClass and LedFeedbackClass once */ + if (!priv->wcmInitKeyClassCount) { - KeySymsRec wacom_keysyms; - KeySym keymap[256]; - - for (loop = 0; loop < nbkeys; loop++) - if ((priv->button [loop] & AC_TYPE) == AC_KEY) - keymap [loop] = priv->button [loop] & AC_CODE; - else - keymap [loop] = NoSymbol; - for(loop = nbkeys; loop<256; loop++) - keymap [loop] = NoSymbol; - - /* There seems to be a long-standing misunderstanding about - * how a keymap should be defined. All tablet drivers from - * stock X11 source tree are doing it wrong: they leave first - * 8 keysyms as VoidSymbol's, and are passing 8 as minimum - * key code. But if you look at SetKeySymsMap() from - * programs/Xserver/dix/devices.c you will see that - * Xserver does not require first 8 keysyms; it supposes - * that the map begins at minKeyCode. - * - * It could be that this assumption is a leftover from - * earlier XFree86 versions, but that's out of our scope. - * This also means that no keys on extended input devices - * with their own keycodes (e.g. tablets) were EVER used. - */ - wacom_keysyms.map = keymap; - /* minKeyCode = 8 because this is the min legal key code */ - wacom_keysyms.minKeyCode = 8; - wacom_keysyms.maxKeyCode = 255; - wacom_keysyms.mapWidth = 1; - if (InitKeyClassDeviceStruct(local->dev, &wacom_keysyms, NULL) == FALSE) + if (nbkeys) { - ErrorF("unable to init key class device\n"); + KeySymsRec wacom_keysyms; + KeySym keymap[256]; + + for (loop = 0; loop < nbkeys; loop++) + if ((priv->button [loop] & AC_TYPE) == AC_KEY) + keymap [loop] = priv->button [loop] & AC_CODE; + else + keymap [loop] = NoSymbol; + for(loop = nbkeys; loop<256; loop++) + keymap [loop] = NoSymbol; + + /* There seems to be a long-standing misunderstanding about + * how a keymap should be defined. All tablet drivers from + * stock X11 source tree are doing it wrong: they leave first + * 8 keysyms as VoidSymbol's, and are passing 8 as minimum + * key code. But if you look at SetKeySymsMap() from + * programs/Xserver/dix/devices.c you will see that + * Xserver does not require first 8 keysyms; it supposes + * that the map begins at minKeyCode. + * + * It could be that this assumption is a leftover from + * earlier XFree86 versions, but that's out of our scope. + * This also means that no keys on extended input devices + * with their own keycodes (e.g. tablets) were EVER used. + */ + wacom_keysyms.map = keymap; + /* minKeyCode = 8 because this is the min legal key code */ + wacom_keysyms.minKeyCode = 8; + wacom_keysyms.maxKeyCode = 255; + wacom_keysyms.mapWidth = 1; + if (InitKeyClassDeviceStruct(local->dev, &wacom_keysyms, NULL) == FALSE) + { + ErrorF("unable to init key class device\n"); + return FALSE; + } + } + + if(InitLedFeedbackClassDeviceStruct (local->dev, xf86WcmKbdLedCallback) == FALSE) { + ErrorF("unable to init led feedback device struct\n"); return FALSE; } } @@ -807,11 +697,13 @@ static int xf86WcmDevProc(DeviceIntPtr pWcm, int what) */ case DEVICE_INIT: priv->wcmDevOpenCount = 0; + priv->wcmInitKeyClassCount = 0; if (!xf86WcmDevOpen(pWcm)) { DBG(1, priv->debugLevel, ErrorF("xf86WcmProc INIT FAILED\n")); return !Success; } + priv->wcmInitKeyClassCount++; priv->wcmDevOpenCount++; break; @@ -870,11 +762,12 @@ static Bool xf86WcmDevConvert(LocalDevicePtr local, int first, int num, if (priv->flags & ABSOLUTE_FLAG) { + int leftPadding = 0; + int topPadding = 0; + v0 = v0 - priv->topX - priv->tvoffsetX; v1 = v1 - priv->topY - priv->tvoffsetY; - int leftPadding = 0; - int topPadding = 0; if (priv->twinview == TV_NONE) { if (priv->screen_no == -1) @@ -896,7 +789,30 @@ static Bool xf86WcmDevConvert(LocalDevicePtr local, int first, int num, temp = ((double)v1 * priv->factorY + 0.5); *y += temp; - DBG(6, priv->debugLevel, ErrorF("Wacom converted v0=%d v1=%d to x=%d y=%d\n", v0, v1, *x, *y)); + DBG(6, priv->debugLevel, ErrorF("xf86WcmDevConvert v0=%d v1=%d to x=%d y=%d\n", v0, v1, *x, *y)); + if ((priv->screen_no != -1 || !priv->wcmMMonitor) && (priv->flags & ABSOLUTE_FLAG)) + { + DBG(6, priv->debugLevel, ErrorF("xf86WcmDevConvert restricted (%d,%d)", *x, *y)); + if (priv->twinview == TV_NONE) + { + if (*x < 1) *x = 0; + if (*y < 1) *y = 0; + if (*x >= priv->screenBottomX[priv->currentScreen] - priv->screenTopX[priv->currentScreen]) + *x = priv->screenBottomX[priv->currentScreen] - priv->screenTopX[priv->currentScreen]-1; + if (*y >= priv->screenBottomY[priv->currentScreen] - priv->screenTopY[priv->currentScreen]) + *y = priv->screenBottomY[priv->currentScreen] - priv->screenTopY[priv->currentScreen]-1; + } + else + { + if (*x < priv->screenTopX[priv->currentScreen]+1) *x = priv->screenTopX[priv->currentScreen]; + if (*y < priv->screenTopY[priv->currentScreen]+1) *y = priv->screenTopY[priv->currentScreen]; + if (*x >= priv->screenBottomX[priv->currentScreen]) + *x = priv->screenBottomX[priv->currentScreen]-1; + if (*y >= priv->screenBottomY[priv->currentScreen]) + *y = priv->screenBottomY[priv->currentScreen]-1; + } + DBG(6, priv->debugLevel, ErrorF(" to x=%d y=%d\n", *x, *y)); + } return TRUE; } diff --git a/src/xdrv/xf86Wacom.h b/src/xdrv/xf86Wacom.h index 1f47026..ee54898 100755 --- a/src/xdrv/xf86Wacom.h +++ b/src/xdrv/xf86Wacom.h @@ -112,64 +112,20 @@ ****************************************************************************/ #define ABS(x) ((x) > 0 ? (x) : -(x)) -#define mils(res) (res * 100 / 2.54) /* resolution */ /***************************************************************************** * General Defines ****************************************************************************/ -#define DEFAULT_SPEED 1.0 /* default relative cursor speed */ -#define MAX_ACCEL 7 /* number of acceleration levels */ -#define DEFAULT_SUPPRESS 2 /* default suppress */ -#define MAX_SUPPRESS 100 /* max value of suppress */ -#define BUFFER_SIZE 256 /* size of reception buffer */ #define XI_STYLUS "STYLUS" /* X device name for the stylus */ #define XI_CURSOR "CURSOR" /* X device name for the cursor */ #define XI_ERASER "ERASER" /* X device name for the eraser */ #define XI_PAD "PAD" /* X device name for the I3 Pad */ -#define MAX_VALUE 100 /* number of positions */ -#define MAXTRY 3 /* max number of try to receive magic number */ -#define MAX_COORD_RES 1270.0 /* Resolution of the returned MaxX and MaxY */ - -/* Default max distance to the tablet at which a proximity-out event is generated for - * cursor device (e.g. mouse). - */ -#define PROXOUT_INTUOS_DISTANCE 10 -#define PROXOUT_GRAPHIRE_DISTANCE 42 - -#define HEADER_BIT 0x80 -#define ZAXIS_SIGN_BIT 0x40 -#define ZAXIS_BIT 0x04 -#define ZAXIS_BITS 0x3F -#define POINTER_BIT 0x20 -#define PROXIMITY_BIT 0x40 -#define BUTTON_FLAG 0x08 -#define BUTTONS_BITS 0x78 -#define TILT_SIGN_BIT 0x40 -#define TILT_BITS 0x3F - -/* defines to discriminate second side button and the eraser */ -#define ERASER_PROX 4 -#define OTHER_PROX 1 - -/****************************************************************************** - * Forward Declarations - *****************************************************************************/ - -typedef struct _WacomModule WacomModule; -typedef struct _WacomModel WacomModel, *WacomModelPtr; -typedef struct _WacomDeviceRec WacomDeviceRec, *WacomDevicePtr; -typedef struct _WacomDeviceState WacomDeviceState, *WacomDeviceStatePtr; -typedef struct _WacomChannel WacomChannel, *WacomChannelPtr; -typedef struct _WacomCommonRec WacomCommonRec, *WacomCommonPtr; -typedef struct _WacomFilterState WacomFilterState, *WacomFilterStatePtr; -typedef struct _WacomDeviceClass WacomDeviceClass, *WacomDeviceClassPtr; -typedef struct _WacomTool WacomTool, *WacomToolPtr; -typedef struct _WacomToolArea WacomToolArea, *WacomToolAreaPtr; /****************************************************************************** * WacomModule - all globals are packed in a single structure to keep the * global namespaces as clean as possible. *****************************************************************************/ +typedef struct _WacomModule WacomModule; struct _WacomModule { @@ -192,379 +148,8 @@ struct _WacomModule extern WacomModule gWacomModule; -/****************************************************************************** - * WacomModel - model-specific device capabilities - *****************************************************************************/ - -struct _WacomModel -{ - const char* name; - - void (*Initialize)(WacomCommonPtr common, const char* id, float version); - void (*GetResolution)(LocalDevicePtr local); - int (*GetRanges)(LocalDevicePtr local); - int (*Reset)(LocalDevicePtr local); - int (*EnableTilt)(LocalDevicePtr local); - int (*EnableSuppress)(LocalDevicePtr local); - int (*SetLinkSpeed)(LocalDevicePtr local); - int (*Start)(LocalDevicePtr local); - int (*Parse)(LocalDevicePtr local, const unsigned char* data); - int (*FilterRaw)(WacomCommonPtr common, WacomChannelPtr pChannel, - WacomDeviceStatePtr ds); - int (*DetectConfig)(LocalDevicePtr local); -}; - -/****************************************************************************** - * WacomDeviceRec - *****************************************************************************/ - -#define DEVICE_ID(flags) ((flags) & 0x0f) -#define STYLUS_DEVICE_ID 0x02 -#define CURSOR_DEVICE_ID 0x06 -#define ERASER_DEVICE_ID 0x0A -#define PAD_DEVICE_ID 0x0F - -#define STYLUS_ID 0x00000001 -#define CURSOR_ID 0x00000002 -#define ERASER_ID 0x00000004 -#define PAD_ID 0x00000008 -#define ABSOLUTE_FLAG 0x00000010 -#define KEEP_SHAPE_FLAG 0x00000020 -#define BAUD_19200_FLAG 0x00000040 -#define BUTTONS_ONLY_FLAG 0x00000080 -#define TPCBUTTONS_FLAG 0x00000100 -#define TPCBUTTONONE_FLAG 0x00000200 -#define COREEVENT_FLAG 0x00000400 - -#define IsCursor(priv) (DEVICE_ID((priv)->flags) == CURSOR_ID) -#define IsStylus(priv) (DEVICE_ID((priv)->flags) == STYLUS_ID) -#define IsEraser(priv) (DEVICE_ID((priv)->flags) == ERASER_ID) -#define IsPad(priv) (DEVICE_ID((priv)->flags) == PAD_ID) - -typedef int (*FILTERFUNC)(WacomDevicePtr pDev, WacomDeviceStatePtr pState); - -/* FILTERFUNC return values: - * -1 - data should be discarded - * 0 - data is valid */ - -#define FILTER_PRESSURE_RES 2048 /* maximum points in pressure curve */ -#define MAX_BUTTONS 32 /* maximum number of tablet buttons */ -#define MAX_MOUSE_BUTTONS 16 /* maximum number of buttons-on-pointer - * (which are treated as mouse buttons, - * not as keys like tablet menu buttons). - * For backword compability support, - * tablet buttons besides the strips are - * treated as buttons */ - -struct _WacomDeviceRec -{ - /* configuration fields */ - struct _WacomDeviceRec *next; - LocalDevicePtr local; - int debugLevel; - - unsigned int flags; /* various flags (type, abs, touch...) */ - int topX; /* X top */ - int topY; /* Y top */ - int bottomX; /* X bottom */ - int bottomY; /* Y bottom */ - int sizeX; /* active X size */ - int sizeY; /* active Y size */ - double factorX; /* X factor */ - double factorY; /* Y factor */ - unsigned int serial; /* device serial number */ - int screen_no; /* associated screen */ - int screenTopX[32]; /* left cordinate of the associated screen */ - int screenTopY[32]; /* top cordinate of the associated screen */ - int screenBottomX[32]; /* right cordinate of the associated screen */ - int screenBottomY[32]; /* bottom cordinate of the associated screen */ - int maxWidth; /* max active screen width */ - int maxHeight; /* max active screen height */ - int button[MAX_BUTTONS];/* buttons assignments */ - unsigned keys[MAX_BUTTONS][256]; /* keystrokes assigned to buttons */ - int relup; - unsigned rupk[256]; /* keystrokes assigned to relative wheel up event (default is button 4) */ - int reldn; - unsigned rdnk[256]; /* keystrokes assigned to relative wheel down event (default is button 5) */ - int wheelup; - unsigned wupk[256]; /* keystrokes assigned to absolute wheel or throttle up event (default is button 4) */ - int wheeldn; - unsigned wdnk[256]; /* keystrokes assigned to absolute wheel or throttle down event (default is button 5) */ - int striplup; - unsigned slupk[256]; /* keystrokes assigned to left strip up event (default is button 4) */ - int stripldn; - unsigned sldnk[256]; /* keystrokes assigned to left strip up event (default is button 5) */ - int striprup; - unsigned srupk[256]; /* keystrokes assigned to right strip up event (default is button 4) */ - int striprdn; - unsigned srdnk[256]; /* keystrokes assigned to right strip up event (default is button 4) */ - int nbuttons; /* number of buttons for this subdevice */ - int naxes; /* number of axes */ - - WacomCommonPtr common;/* common info pointer */ - - /* state fields */ - int currentX; /* current X position */ - int currentY; /* current Y position */ - int currentSX; /* current screen X position */ - int currentSY; /* current screen Y position */ - int oldX; /* previous X position */ - int oldY; /* previous Y position */ - int oldZ; /* previous pressure */ - int oldTiltX; /* previous tilt in x direction */ - int oldTiltY; /* previous tilt in y direction */ - int oldWheel; /* previous wheel value */ - int oldRot; /* previous rotation value */ - int oldStripX; /* previous left strip value */ - int oldStripY; /* previous right strip value */ - int oldThrottle; /* previous throttle value */ - int oldButtons; /* previous buttons state */ - int oldProximity; /* previous proximity */ - int hardProx; /* previous hardware proximity */ - int old_device_id; /* last in prox device id */ - int old_serial; /* last in prox tool serial number */ - int devReverseCount; /* Relative ReverseConvert called twice each movement*/ - double speed; /* relative mode speed */ - int accel; /* relative mode acceleration */ - int numScreen; /* number of configured screens */ - int currentScreen; /* current screen in display */ - int twinview; /* using twinview mode of gfx card */ - int tvoffsetX; /* X edge offset for TwinView setup */ - int tvoffsetY; /* Y edge offset for TwinView setup */ - int tvResolution[4]; /* twinview screens' resultion */ - int wcmDevOpenCount; /* Device open count */ - - /* JEJ - throttle */ - int throttleStart; /* time in ticks for last wheel movement */ - int throttleLimit; /* time in ticks for next wheel movement */ - int throttleValue; /* current throttle value */ - - /* JEJ - filters */ - int* pPressCurve; /* pressure curve */ - int nPressCtrl[4]; /* control points for curve */ - - WacomToolPtr tool; /* The common tool-structure for this device */ - WacomToolAreaPtr toolarea; /* The area defined for this device */ -}; - -/****************************************************************************** - * WacomDeviceState - *****************************************************************************/ - -#define MAX_SAMPLES 20 -#define DEFAULT_SAMPLES 4 - -#define PEN(ds) ((((ds)->device_id) & 0x07ff) == 0x0022 || \ - (((ds)->device_id) & 0x07ff) == 0x0042 || \ - (((ds)->device_id) & 0x07ff) == 0x0052) -#define STROKING_PEN(ds) ((((ds)->device_id) & 0x07ff) == 0x0032) -#define AIRBRUSH(ds) ((((ds)->device_id) & 0x07ff) == 0x0112) -#define MOUSE_4D(ds) ((((ds)->device_id) & 0x07ff) == 0x0094) -#define MOUSE_2D(ds) ((((ds)->device_id) & 0x07ff) == 0x0007) -#define LENS_CURSOR(ds) ((((ds)->device_id) & 0x07ff) == 0x0096) -#define INKING_PEN(ds) ((((ds)->device_id) & 0x07ff) == 0x0012) -#define STYLUS_TOOL(ds) (PEN(ds) || STROKING_PEN(ds) || INKING_PEN(ds) || \ - AIRBRUSH(ds)) -#define CURSOR_TOOL(ds) (MOUSE_4D(ds) || LENS_CURSOR(ds) || MOUSE_2D(ds)) - -struct _WacomDeviceState -{ - LocalDevicePtr local; - int device_id; /* tool id reported from the physical device */ - int device_type; - unsigned int serial_num; - int x; - int y; - int buttons; - int pressure; - int tiltx; - int tilty; - int stripx; - int stripy; - int rotation; - int abswheel; - int relwheel; - int distance; - int throttle; - int discard_first; - int proximity; - int sample; /* wraps every 24 days */ -}; - -struct _WacomFilterState -{ - int npoints; - int x[MAX_SAMPLES]; - int y[MAX_SAMPLES]; - int tiltx[MAX_SAMPLES]; - int tilty[MAX_SAMPLES]; - int statex; - int statey; -}; - -struct _WacomChannel -{ - /* data stored in this structure is raw data from the tablet, prior - * to transformation and user-defined filtering. Suppressed values - * will not be included here, and hardware filtering may occur between - * the work stage and the valid state. */ - - WacomDeviceState work; /* next state */ - - /* the following struct contains the current known state of the - * device channel, as well as the previous MAX_SAMPLES states - * for use in detecting hardware defects, jitter, trends, etc. */ - - /* the following union contains the current known state of the - * device channel, as well as the previous MAX_SAMPLES states - * for use in detecting hardware defects, jitter, trends, etc. */ - union - { - WacomDeviceState state; /* current state */ - WacomDeviceState states[MAX_SAMPLES]; /* states 0..MAX */ - } valid; - - int nSamples; - WacomFilterState rawFilter; -}; - -/****************************************************************************** - * WacomDeviceClass - *****************************************************************************/ - -struct _WacomDeviceClass -{ - Bool (*Detect)(LocalDevicePtr local); /* detect device */ - Bool (*Init)(LocalDevicePtr local); /* initialize device */ - void (*Read)(LocalDevicePtr local); /* reads device */ -}; - -#ifdef WCM_ENABLE_LINUXINPUT - extern WacomDeviceClass gWacomUSBDevice; -#endif - - extern WacomDeviceClass gWacomISDV4Device; - extern WacomDeviceClass gWacomSerialDevice; - -/****************************************************************************** - * WacomCommonRec - *****************************************************************************/ - -#define TILT_REQUEST_FLAG 1 -#define TILT_ENABLED_FLAG 2 -#define RAW_FILTERING_FLAG 4 -#ifdef WCM_ENABLE_LINUXINPUT -/* set if the /dev/input driver should wait for SYN_REPORT events as the - end of record indicator */ -#define USE_SYN_REPORTS_FLAG 8 -#endif - -#define DEVICE_ISDV4 0x000C - -#define MAX_CHANNELS 2 - -struct _WacomCommonRec -{ - char* wcmDevice; /* device file name */ - unsigned char wcmFlags; /* various flags (handle tilt) */ - int debugLevel; - 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 */ - - /* These values are in tablet coordinates */ - int wcmMaxX; /* tablet max X value */ - int wcmMaxY; /* tablet max Y value */ - int wcmMaxZ; /* tablet max Z value */ - int wcmMaxDist; /* tablet max distance value */ - int wcmResolX; /* tablet X resolution in points/inch */ - int wcmResolY; /* tablet Y resolution in points/inch */ - /* tablet Z resolution is equivalent - * to wcmMaxZ which is equal to 100% - * pressure */ - - /* These values are in user coordinates */ - int wcmUserResolX; /* user-defined X resolution */ - int wcmUserResolY; /* user-defined Y resolution */ - int wcmUserResolZ; /* user-defined Z resolution, - * value equal to 100% pressure */ - - int wcmMaxStripX; /* Maximum fingerstrip X */ - int wcmMaxStripY; /* Maximum fingerstrip Y */ - - int nbuttons; /* total number of buttons */ - int npadkeys; /* number of pad keys in the above array */ - int padkey_code[MAX_BUTTONS];/* hardware codes for buttons */ - - WacomDevicePtr wcmDevices; /* list of devices sharing same port */ - int wcmPktLength; /* length of a packet */ - int wcmProtocolLevel; /* 4 for Wacom IV, 5 for Wacom V */ - float wcmVersion; /* ROM version */ - int wcmForceDevice; /* force device type (used by ISD V4) */ - int wcmRotate; /* rotate screen (for TabletPC) */ - int wcmThreshold; /* Threshold for button pressure */ - WacomChannel wcmChannel[MAX_CHANNELS]; /* channel device state */ - unsigned int wcmLinkSpeed; /* serial link speed */ - unsigned int wcmISDV4Speed; /* serial ISDV4 link speed */ - - WacomDeviceClassPtr wcmDevCls; /* device class functions */ - WacomModelPtr wcmModel; /* model-specific functions */ - char * wcmEraserID; /* eraser associated with the stylus */ - int wcmMMonitor; /* disable/enable moving across screens in multi-monitor desktop */ - int wcmTPCButton; /* set Tablet PC button on/off */ - int wcmTPCButtonDefault; /* Tablet PC button default */ - int wcmMaxCursorDist; /* Max mouse distance reported so far */ - int wcmCursorProxoutDist; /* Max mouse distance for proxy-out max/256 units */ - int wcmCursorProxoutDistDefault; /* Default max mouse distance for proxy-out */ - int wcmSuppress; /* transmit position on delta > supress */ - int wcmRawSample; /* Number of raw data used to filter an event */ - - int bufpos; /* position with buffer */ - unsigned char buffer[BUFFER_SIZE]; /* data read from device */ - -#ifdef WCM_ENABLE_LINUXINPUT - int wcmLastToolSerial; - int wcmEventCnt; - struct input_event wcmEvents[MAX_USB_EVENTS]; /* events for current change */ -#endif - - WacomToolPtr wcmTool; /* List of unique tools */ -}; - -#define HANDLE_TILT(comm) ((comm)->wcmFlags & TILT_ENABLED_FLAG) -#define RAW_FILTERING(comm) ((comm)->wcmFlags & RAW_FILTERING_FLAG) -#ifdef WCM_ENABLE_LINUXINPUT -#define USE_SYN_REPORTS(comm) ((comm)->wcmFlags & USE_SYN_REPORTS_FLAG) -#endif - -/****************************************************************************** - * WacomTool - *****************************************************************************/ -struct _WacomTool -{ - WacomToolPtr next; /* Next tool in list */ - - int typeid; /* Tool type */ - int serial; /* Serial id, 0 == no serial id */ - - WacomToolAreaPtr current; /* Current area in-prox */ - WacomToolAreaPtr arealist; /* List of defined areas */ -}; - -/****************************************************************************** - * WacomToolArea - *****************************************************************************/ -struct _WacomToolArea -{ - WacomToolAreaPtr next; - - int topX; /* Top X/Y */ - int topY; - int bottomX; /* Bottom X/Y */ - int bottomY; - - LocalDevicePtr device; /* The InputDevice connected to this area */ -}; +/* The rest are defined in a separate .h-file */ +#include "xf86WacomDefs.h" /***************************************************************************** * XFree86 V4 Inlined Functions and Prototypes @@ -572,7 +157,6 @@ struct _WacomToolArea #define xf86WcmFlushTablet(fd) xf86FlushInput(fd) #define xf86WcmWaitForTablet(fd) xf86WaitForInput((fd), 1000000) -#define xf86WcmOpenTablet(local) xf86OpenSerial((local)->options) #define xf86WcmSetSerialSpeed(fd,rate) xf86SetSerialSpeed((fd),(rate)) #define xf86WcmRead(a,b,c) xf86ReadSerial((a),(b),(c)) @@ -613,7 +197,7 @@ LocalDevicePtr xf86WcmAllocatePad(void); Bool xf86WcmOpen(LocalDevicePtr local); /* common tablet initialization regime */ -int xf86WcmInitTablet(LocalDevicePtr local, WacomModelPtr model, const char* id, float version); +int xf86WcmInitTablet(LocalDevicePtr local, const char* id, float version); /* standard packet handler */ void xf86WcmReadPacket(LocalDevicePtr local); diff --git a/src/xdrv/xf86WacomDefs.h b/src/xdrv/xf86WacomDefs.h new file mode 100755 index 0000000..f531185 --- /dev/null +++ b/src/xdrv/xf86WacomDefs.h @@ -0,0 +1,443 @@ +/* + * Copyright 1995-2002 by Frederic Lepied, France. <Lepied@XFree86.org> + * Copyright 2002-2008 by Ping Cheng, Wacom Technology. <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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __XF86_XF86WACOMDEFS_H +#define __XF86_XF86WACOMDEFS_H + +/***************************************************************************** + * General Defines + ****************************************************************************/ +#ifdef WCM_ENABLE_LINUXINPUT +#include <asm/types.h> +#include <linux/input.h> +#define MAX_USB_EVENTS 32 +#endif /* WCM_ENABLE_LINUXINPUT */ + +#define DEFAULT_SPEED 1.0 /* default relative cursor speed */ +#define MAX_ACCEL 7 /* number of acceleration levels */ +#define DEFAULT_SUPPRESS 2 /* default suppress */ +#define MAX_SUPPRESS 100 /* max value of suppress */ +#define BUFFER_SIZE 256 /* size of reception buffer */ +#define MAXTRY 3 /* max number of try to receive magic number */ + +/* Default max distance to the tablet at which a proximity-out event is generated for + * cursor device (e.g. mouse). + */ +#define PROXOUT_INTUOS_DISTANCE 10 +#define PROXOUT_GRAPHIRE_DISTANCE 42 + +#define HEADER_BIT 0x80 +#define ZAXIS_SIGN_BIT 0x40 +#define ZAXIS_BIT 0x04 +#define ZAXIS_BITS 0x3F +#define POINTER_BIT 0x20 +#define PROXIMITY_BIT 0x40 +#define BUTTON_FLAG 0x08 +#define BUTTONS_BITS 0x78 +#define TILT_SIGN_BIT 0x40 +#define TILT_BITS 0x3F + +/* defines to discriminate second side button and the eraser */ +#define ERASER_PROX 4 +#define OTHER_PROX 1 + +/****************************************************************************** + * Forward Declarations + *****************************************************************************/ + +typedef struct _WacomModel WacomModel, *WacomModelPtr; +typedef struct _WacomDeviceRec WacomDeviceRec, *WacomDevicePtr; +typedef struct _WacomDeviceState WacomDeviceState, *WacomDeviceStatePtr; +typedef struct _WacomChannel WacomChannel, *WacomChannelPtr; +typedef struct _WacomCommonRec WacomCommonRec, *WacomCommonPtr; +typedef struct _WacomFilterState WacomFilterState, *WacomFilterStatePtr; +typedef struct _WacomDeviceClass WacomDeviceClass, *WacomDeviceClassPtr; +typedef struct _WacomTool WacomTool, *WacomToolPtr; +typedef struct _WacomToolArea WacomToolArea, *WacomToolAreaPtr; + +/****************************************************************************** + * WacomModel - model-specific device capabilities + *****************************************************************************/ + +struct _WacomModel +{ + const char* name; + + void (*Initialize)(WacomCommonPtr common, const char* id, float version); + void (*GetResolution)(LocalDevicePtr local); + int (*GetRanges)(LocalDevicePtr local); + int (*Reset)(LocalDevicePtr local); + int (*EnableTilt)(LocalDevicePtr local); + int (*EnableSuppress)(LocalDevicePtr local); + int (*SetLinkSpeed)(LocalDevicePtr local); + int (*Start)(LocalDevicePtr local); + int (*Parse)(LocalDevicePtr local, const unsigned char* data); + int (*FilterRaw)(WacomCommonPtr common, WacomChannelPtr pChannel, + WacomDeviceStatePtr ds); + int (*DetectConfig)(LocalDevicePtr local); +}; + +/****************************************************************************** + * WacomDeviceRec + *****************************************************************************/ + +#define DEVICE_ID(flags) ((flags) & 0x0f) +#define STYLUS_DEVICE_ID 0x02 +#define CURSOR_DEVICE_ID 0x06 +#define ERASER_DEVICE_ID 0x0A +#define PAD_DEVICE_ID 0x0F + +#define STYLUS_ID 0x00000001 +#define CURSOR_ID 0x00000002 +#define ERASER_ID 0x00000004 +#define PAD_ID 0x00000008 +#define ABSOLUTE_FLAG 0x00000010 +#define KEEP_SHAPE_FLAG 0x00000020 +#define BAUD_19200_FLAG 0x00000040 +#define BUTTONS_ONLY_FLAG 0x00000080 +#define TPCBUTTONS_FLAG 0x00000100 +#define TPCBUTTONONE_FLAG 0x00000200 +#define COREEVENT_FLAG 0x00000400 + +#define IsCursor(priv) (DEVICE_ID((priv)->flags) == CURSOR_ID) +#define IsStylus(priv) (DEVICE_ID((priv)->flags) == STYLUS_ID) +#define IsEraser(priv) (DEVICE_ID((priv)->flags) == ERASER_ID) +#define IsPad(priv) (DEVICE_ID((priv)->flags) == PAD_ID) + +#define FILTER_PRESSURE_RES 2048 /* maximum points in pressure curve */ +#define MAX_BUTTONS 32 /* maximum number of tablet buttons */ +#define MAX_MOUSE_BUTTONS 16 /* maximum number of buttons-on-pointer + * (which are treated as mouse buttons, + * not as keys like tablet menu buttons). + * For backword compability support, + * tablet buttons besides the strips are + * treated as buttons */ + +struct _WacomDeviceRec +{ + /* configuration fields */ + struct _WacomDeviceRec *next; + LocalDevicePtr local; + int debugLevel; + + unsigned int flags; /* various flags (type, abs, touch...) */ + int topX; /* X top */ + int topY; /* Y top */ + int bottomX; /* X bottom */ + int bottomY; /* Y bottom */ + int sizeX; /* active X size */ + int sizeY; /* active Y size */ + double factorX; /* X factor */ + double factorY; /* Y factor */ + unsigned int serial; /* device serial number */ + int screen_no; /* associated screen */ + int screenTopX[32]; /* left cordinate of the associated screen */ + int screenTopY[32]; /* top cordinate of the associated screen */ + int screenBottomX[32]; /* right cordinate of the associated screen */ + int screenBottomY[32]; /* bottom cordinate of the associated screen */ + int maxWidth; /* max active screen width */ + int maxHeight; /* max active screen height */ + int button[MAX_BUTTONS];/* buttons assignments */ + unsigned keys[MAX_BUTTONS][256]; /* keystrokes assigned to buttons */ + int relup; + unsigned rupk[256]; /* keystrokes assigned to relative wheel up event (default is button 4) */ + int reldn; + unsigned rdnk[256]; /* keystrokes assigned to relative wheel down event (default is button 5) */ + int wheelup; + unsigned wupk[256]; /* keystrokes assigned to absolute wheel or throttle up event (default is button 4) */ + int wheeldn; + unsigned wdnk[256]; /* keystrokes assigned to absolute wheel or throttle down event (default is button 5) */ + int striplup; + unsigned slupk[256]; /* keystrokes assigned to left strip up event (default is button 4) */ + int stripldn; + unsigned sldnk[256]; /* keystrokes assigned to left strip up event (default is button 5) */ + int striprup; + unsigned srupk[256]; /* keystrokes assigned to right strip up event (default is button 4) */ + int striprdn; + unsigned srdnk[256]; /* keystrokes assigned to right strip up event (default is button 4) */ + int nbuttons; /* number of buttons for this subdevice */ + int naxes; /* number of axes */ + + WacomCommonPtr common;/* common info pointer */ + + /* state fields */ + int currentX; /* current X position */ + int currentY; /* current Y position */ + int currentSX; /* current screen X position */ + int currentSY; /* current screen Y position */ + int oldX; /* previous X position */ + int oldY; /* previous Y position */ + int oldZ; /* previous pressure */ + int oldTiltX; /* previous tilt in x direction */ + int oldTiltY; /* previous tilt in y direction */ + int oldWheel; /* previous wheel value */ + int oldRot; /* previous rotation value */ + int oldStripX; /* previous left strip value */ + int oldStripY; /* previous right strip value */ + int oldThrottle; /* previous throttle value */ + int oldButtons; /* previous buttons state */ + int oldProximity; /* previous proximity */ + int hardProx; /* previous hardware proximity */ + int old_device_id; /* last in prox device id */ + int old_serial; /* last in prox tool serial number */ + int devReverseCount; /* Relative ReverseConvert called twice each movement*/ + double speed; /* relative mode speed */ + int accel; /* relative mode acceleration */ + int numScreen; /* number of configured screens */ + int currentScreen; /* current screen in display */ + int twinview; /* using twinview mode of gfx card */ + int tvoffsetX; /* X edge offset for TwinView setup */ + int tvoffsetY; /* Y edge offset for TwinView setup */ + int tvResolution[4]; /* twinview screens' resultion */ + int wcmMMonitor; /* disable/enable moving across screens in multi-monitor desktop */ + int wcmDevOpenCount; /* Device open count */ + int wcmInitKeyClassCount; /* Device InitKeyClassDeviceStruct count */ + + /* JEJ - throttle */ + int throttleStart; /* time in ticks for last wheel movement */ + int throttleLimit; /* time in ticks for next wheel movement */ + int throttleValue; /* current throttle value */ + + /* JEJ - filters */ + int* pPressCurve; /* pressure curve */ + int nPressCtrl[4]; /* control points for curve */ + + WacomToolPtr tool; /* The common tool-structure for this device */ + WacomToolAreaPtr toolarea; /* The area defined for this device */ +}; + +/****************************************************************************** + * WacomDeviceState + *****************************************************************************/ + +#define MAX_SAMPLES 20 +#define DEFAULT_SAMPLES 4 + +#define PEN(ds) ((((ds)->device_id) & 0x07ff) == 0x0022 || \ + (((ds)->device_id) & 0x07ff) == 0x0042 || \ + (((ds)->device_id) & 0x07ff) == 0x0052) +#define STROKING_PEN(ds) ((((ds)->device_id) & 0x07ff) == 0x0032) +#define AIRBRUSH(ds) ((((ds)->device_id) & 0x07ff) == 0x0112) +#define MOUSE_4D(ds) ((((ds)->device_id) & 0x07ff) == 0x0094) +#define MOUSE_2D(ds) ((((ds)->device_id) & 0x07ff) == 0x0007) +#define LENS_CURSOR(ds) ((((ds)->device_id) & 0x07ff) == 0x0096) +#define INKING_PEN(ds) ((((ds)->device_id) & 0x07ff) == 0x0012) +#define STYLUS_TOOL(ds) (PEN(ds) || STROKING_PEN(ds) || INKING_PEN(ds) || \ + AIRBRUSH(ds)) +#define CURSOR_TOOL(ds) (MOUSE_4D(ds) || LENS_CURSOR(ds) || MOUSE_2D(ds)) + +struct _WacomDeviceState +{ + LocalDevicePtr local; + int device_id; /* tool id reported from the physical device */ + int device_type; + unsigned int serial_num; + int x; + int y; + int buttons; + int pressure; + int tiltx; + int tilty; + int stripx; + int stripy; + int rotation; + int abswheel; + int relwheel; + int distance; + int throttle; + int discard_first; + int proximity; + int sample; /* wraps every 24 days */ +}; + +struct _WacomFilterState +{ + int npoints; + int x[MAX_SAMPLES]; + int y[MAX_SAMPLES]; + int tiltx[MAX_SAMPLES]; + int tilty[MAX_SAMPLES]; + int statex; + int statey; +}; + +struct _WacomChannel +{ + /* data stored in this structure is raw data from the tablet, prior + * to transformation and user-defined filtering. Suppressed values + * will not be included here, and hardware filtering may occur between + * the work stage and the valid state. */ + + WacomDeviceState work; /* next state */ + + /* the following struct contains the current known state of the + * device channel, as well as the previous MAX_SAMPLES states + * for use in detecting hardware defects, jitter, trends, etc. */ + + /* the following union contains the current known state of the + * device channel, as well as the previous MAX_SAMPLES states + * for use in detecting hardware defects, jitter, trends, etc. */ + union + { + WacomDeviceState state; /* current state */ + WacomDeviceState states[MAX_SAMPLES]; /* states 0..MAX */ + } valid; + + int nSamples; + WacomFilterState rawFilter; +}; + +/****************************************************************************** + * WacomDeviceClass + *****************************************************************************/ + +struct _WacomDeviceClass +{ + Bool (*Detect)(LocalDevicePtr local); /* detect device */ + Bool (*Init)(LocalDevicePtr local, char* id, float *version); /* initialize device */ + void (*Read)(LocalDevicePtr local); /* reads device */ +}; + +#ifdef WCM_ENABLE_LINUXINPUT + extern WacomDeviceClass gWacomUSBDevice; +#endif + + extern WacomDeviceClass gWacomISDV4Device; + extern WacomDeviceClass gWacomSerialDevice; + +/****************************************************************************** + * WacomCommonRec + *****************************************************************************/ + +#define TILT_REQUEST_FLAG 1 +#define TILT_ENABLED_FLAG 2 +#define RAW_FILTERING_FLAG 4 +#ifdef WCM_ENABLE_LINUXINPUT +/* set if the /dev/input driver should wait for SYN_REPORT events as the + end of record indicator */ +#define USE_SYN_REPORTS_FLAG 8 +#endif + +#define DEVICE_ISDV4 0x000C + +#define MAX_CHANNELS 2 + +struct _WacomCommonRec +{ + char* wcmDevice; /* device file name */ + unsigned char wcmFlags; /* various flags (handle tilt) */ + int debugLevel; + 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 */ + + /* These values are in tablet coordinates */ + int wcmMaxX; /* tablet max X value */ + int wcmMaxY; /* tablet max Y value */ + int wcmMaxZ; /* tablet max Z value */ + int wcmMaxDist; /* tablet max distance value */ + int wcmResolX; /* tablet X resolution in points/inch */ + int wcmResolY; /* tablet Y resolution in points/inch */ + /* tablet Z resolution is equivalent + * to wcmMaxZ which is equal to 100% + * pressure */ + + /* These values are in user coordinates */ + int wcmUserResolX; /* user-defined X resolution */ + int wcmUserResolY; /* user-defined Y resolution */ + int wcmUserResolZ; /* user-defined Z resolution, + * value equal to 100% pressure */ + + int wcmMaxStripX; /* Maximum fingerstrip X */ + int wcmMaxStripY; /* Maximum fingerstrip Y */ + + int nbuttons; /* total number of buttons */ + int npadkeys; /* number of pad keys in the above array */ + int padkey_code[MAX_BUTTONS];/* hardware codes for buttons */ + + WacomDevicePtr wcmDevices; /* list of devices sharing same port */ + int wcmPktLength; /* length of a packet */ + int wcmProtocolLevel; /* 4 for Wacom IV, 5 for Wacom V */ + float wcmVersion; /* ROM version */ + int wcmForceDevice; /* force device type (used by ISD V4) */ + int wcmRotate; /* rotate screen (for TabletPC) */ + int wcmThreshold; /* Threshold for button pressure */ + WacomChannel wcmChannel[MAX_CHANNELS]; /* channel device state */ + unsigned int wcmLinkSpeed; /* serial link speed */ + unsigned int wcmISDV4Speed; /* serial ISDV4 link speed */ + + WacomDeviceClassPtr wcmDevCls; /* device class functions */ + WacomModelPtr wcmModel; /* model-specific functions */ + char * wcmEraserID; /* eraser associated with the stylus */ + int wcmTPCButton; /* set Tablet PC button on/off */ + int wcmTPCButtonDefault; /* Tablet PC button default */ + int wcmMaxCursorDist; /* Max mouse distance reported so far */ + int wcmCursorProxoutDist; /* Max mouse distance for proxy-out max/256 units */ + int wcmCursorProxoutDistDefault; /* Default max mouse distance for proxy-out */ + int wcmSuppress; /* transmit position on delta > supress */ + int wcmRawSample; /* Number of raw data used to filter an event */ + + int bufpos; /* position with buffer */ + unsigned char buffer[BUFFER_SIZE]; /* data read from device */ + +#ifdef WCM_ENABLE_LINUXINPUT + int wcmLastToolSerial; + int wcmEventCnt; + struct input_event wcmEvents[MAX_USB_EVENTS]; /* events for current change */ +#endif + + WacomToolPtr wcmTool; /* List of unique tools */ +}; + +#define HANDLE_TILT(comm) ((comm)->wcmFlags & TILT_ENABLED_FLAG) +#define RAW_FILTERING(comm) ((comm)->wcmFlags & RAW_FILTERING_FLAG) +#ifdef WCM_ENABLE_LINUXINPUT +#define USE_SYN_REPORTS(comm) ((comm)->wcmFlags & USE_SYN_REPORTS_FLAG) +#endif + +/****************************************************************************** + * WacomTool + *****************************************************************************/ +struct _WacomTool +{ + WacomToolPtr next; /* Next tool in list */ + + int typeid; /* Tool type */ + int serial; /* Serial id, 0 == no serial id */ + + WacomToolAreaPtr current; /* Current area in-prox */ + WacomToolAreaPtr arealist; /* List of defined areas */ +}; + +/****************************************************************************** + * WacomToolArea + *****************************************************************************/ +struct _WacomToolArea +{ + WacomToolAreaPtr next; + + int topX; /* Top X/Y */ + int topY; + int bottomX; /* Bottom X/Y */ + int bottomY; + + LocalDevicePtr device; /* The InputDevice connected to this area */ +}; + +#endif /*__XF86_XF86WACOMDEFS_H */ |