summaryrefslogtreecommitdiff
path: root/src/wcmConfig.c
diff options
context:
space:
mode:
authorPing Cheng <pinglinux@gmail.com>2011-04-03 16:07:38 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2011-04-04 10:43:36 +1000
commit1de7a780a392e363450967dfab8c3dd065fd0348 (patch)
tree1dba788084a421e062f89539ae4e2e3c1a457e9b /src/wcmConfig.c
parent307ad96795605fc39d2c454e4c7efde94ecbed3c (diff)
downloadxf86-input-wacom-1de7a780a392e363450967dfab8c3dd065fd0348.tar.gz
Centralize pen and touch arbitration
With the introduction of multi-touch, the chances of getting touch events while pen is in prox have been increased. One obvious use case is that the touch events could be used for gestures while pen is in prox. However, we do not want two cursors compete on the screen. Link the pen and touch device once during the initialization stage instead of every time when we receive a pen event. Then, centralize pen and touch arbitration process so we can store the touch data in wcmUSB.c instead of discarding them. The touch events will only be ignored if it is a single touch event that causes a cursor movement while pen is in prox. Some cleanup in wcmUSB.c is needed. It will be considered when we make MAX_CHANNEL a dynamic value based on MAX_FINGERS. The MAX_FINGERS is going to be the maximum of ABS_MT_SLOT that we retrieve from the kernel. That brings us to the state to support XInput 2.1 and devices that have dynamic number of fingers. Note: this patch is based on the assumption that all devices connected to the same system have unique product IDs. That is, no two or more identical devices are connected. Identical devices will be properly linked when we find a decent way to distinguish them in the driver. Signed-off-by: Ping Cheng <pinglinux@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/wcmConfig.c')
-rw-r--r--src/wcmConfig.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 6235d3c..f989fb0 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -397,6 +397,51 @@ wcmInitModel(InputInfoPtr pInfo)
return TRUE;
}
+/**
+ * Link the touch tool to the pen of the same device
+ * so we can arbitrate the events when posting them.
+ */
+static void wcmLinkTouchAndPen(InputInfoPtr pInfo)
+{
+ WacomDevicePtr priv = pInfo->private;
+ WacomCommonPtr common = priv->common;
+ InputInfoPtr device = xf86FirstLocalDevice();
+ WacomCommonPtr tmpcommon = NULL;
+ WacomDevicePtr tmppriv = NULL;
+ Bool touch_device_assigned = FALSE;
+
+ /* Lookup to find the associated pen and touch */
+ for (; device != NULL; device = device->next)
+ {
+ if (!strcmp(device->drv->driverName, "wacom"))
+ {
+ tmppriv = (WacomDevicePtr) device->private;
+ tmpcommon = tmppriv->common;
+ touch_device_assigned = (common->wcmTouchDevice ||
+ tmpcommon->wcmTouchDevice);
+
+ /* skip the same tool or already linked devices */
+ if ((tmppriv == priv) || touch_device_assigned)
+ continue;
+
+ if (tmpcommon->tablet_id == common->tablet_id)
+ {
+ if (IsTouch(tmppriv) && IsPen(priv))
+ common->wcmTouchDevice = tmppriv;
+ else if (IsTouch(priv) && IsPen(tmppriv))
+ tmpcommon->wcmTouchDevice = priv;
+
+ if (common->wcmTouchDevice ||
+ tmpcommon->wcmTouchDevice)
+ {
+ common->tablet_type |= WCM_PENTOUCH;
+ tmpcommon->tablet_type |= WCM_PENTOUCH;
+ }
+ }
+ }
+ }
+}
+
/* wcmPreInit - called for each input devices with the driver set to
* "wacom" */
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
@@ -518,6 +563,12 @@ static int wcmPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
pInfo->fd = -1;
}
+ /* only link them once per port. We need to try for both pen and touch
+ * since we do not know which tool (touch or pen) will be added first.
+ */
+ if (IsTouch(priv) || (IsPen(priv) && !common->wcmTouchDevice))
+ wcmLinkTouchAndPen(pInfo);
+
return Success;
SetupProc_fail: