summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPing Cheng <pingc@wacom.com>2013-06-07 15:34:03 -0700
committerJason Gerecke <killertofu@gmail.com>2013-07-10 14:09:36 -0700
commit67daf21bdb7b32c27818bffaf56849a522d23477 (patch)
tree87f5af185b2d4bd224d333caaef45efae947e59a
parentd0a5c68b2582fc6bdcee1d949913f78c0651b1a6 (diff)
downloadxf86-input-wacom-67daf21bdb7b32c27818bffaf56849a522d23477.tar.gz
Unify wcmFingerMultitouch and wcmSendTouchEvent
Signed-off-by: Ping Cheng <pingc@wacom.com> Acked-by: Jason Gerecke <killertofu@gmail.com>
-rw-r--r--src/wcmTouchFilter.c71
1 files changed, 26 insertions, 45 deletions
diff --git a/src/wcmTouchFilter.c b/src/wcmTouchFilter.c
index b1b1685..bfd19de 100644
--- a/src/wcmTouchFilter.c
+++ b/src/wcmTouchFilter.c
@@ -101,60 +101,41 @@ static void getStateHistory(WacomCommonPtr common, WacomDeviceState states[], in
* the multitouch API available in XI2.2.
*
* @param[in] priv
- * @param[in] channel Channel to send a touch event for
+ * @param[in] contact_id ID of the contact to send event for
*/
static void
-wcmSendTouchEvent(WacomDevicePtr priv, WacomChannelPtr channel)
+wcmSendTouchEvent(WacomDevicePtr priv, int contact_id)
{
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 16
- ValuatorMask *mask = priv->common->touch_mask;
- WacomDeviceState state = channel->valid.state;
- WacomDeviceState oldstate = channel->valid.states[1];
- int type = -1;
-
- wcmRotateAndScaleCoordinates (priv->pInfo, &state.x, &state.y);
-
- valuator_mask_set(mask, 0, state.x);
- valuator_mask_set(mask, 1, state.y);
-
- if (!state.proximity) {
- DBG(6, priv->common, "This is a touch end event\n");
- type = XI_TouchEnd;
- }
- else if (!oldstate.proximity) {
- DBG(6, priv->common, "This is a touch begin event\n");
- type = XI_TouchBegin;
- }
- else {
- DBG(6, priv->common, "This is a touch update event\n");
- type = XI_TouchUpdate;
- }
+ WacomChannelPtr channel = getContactNumber(priv->common, contact_id);
- xf86PostTouchEvent(priv->pInfo->dev, state.serial_num - 1, type, 0, mask);
-#endif
-}
+ if (channel) {
+ WacomDeviceState state = channel->valid.state;
+ ValuatorMask *mask = priv->common->touch_mask;
+ WacomDeviceState oldstate = channel->valid.states[1];
+ int type = -1;
-/**
- * Send multitouch data to X server when ABI_XINPUT_VERSION >= 16 and
- * in driver gesture is not enabled.
- *
- * @param[in] priv
- * @param[in] contact_id ID of the contact to send event for
- */
-static void
-wcmFingerMultitouch(WacomDevicePtr priv, int contact_id) {
- int i;
+ wcmRotateAndScaleCoordinates (priv->pInfo, &state.x, &state.y);
- for (i = 0; i < MAX_CHANNELS; i++) {
- WacomChannelPtr channel = priv->common->wcmChannel+i;
- WacomDeviceState state = channel->valid.state;
- if (state.device_type != TOUCH_ID)
- continue;
+ valuator_mask_set(mask, 0, state.x);
+ valuator_mask_set(mask, 1, state.y);
- if (state.serial_num == contact_id + 1) {
- wcmSendTouchEvent(priv, channel);
+ if (!state.proximity) {
+ DBG(6, priv->common, "This is a touch end event\n");
+ type = XI_TouchEnd;
+ }
+ else if (!oldstate.proximity) {
+ DBG(6, priv->common, "This is a touch begin event\n");
+ type = XI_TouchBegin;
}
+ else {
+ DBG(6, priv->common, "This is a touch update event\n");
+ type = XI_TouchUpdate;
+ }
+
+ xf86PostTouchEvent(priv->pInfo->dev, contact_id, type, 0, mask);
}
+#endif
}
static double touchDistance(WacomDeviceState ds0, WacomDeviceState ds1)
@@ -356,7 +337,7 @@ void wcmGestureFilter(WacomDevicePtr priv, int touch_id)
/* Send multitouch data to X if appropriate */
if (!common->wcmGesture)
{
- wcmFingerMultitouch(priv, touch_id);
+ wcmSendTouchEvent(priv, touch_id);
return;
}
#endif