[PATCH evdev 3/3] Dummy process of MT events (protocol A). (rev3)
Benjamin Tissoires
tissoire at cena.fr
Wed Jun 2 05:28:16 PDT 2010
The MT-protocol A is the one that sends SYN_MT_REPORT. It is opposed to
the new one based on MT_SLOTS (protocol B).
(see kernel_src/Documentation/input/multi-touch-protocol.txt)
The processing is "dummy" since there is no computation while receiving
mt events: it just stores it at the first available place, i.e. it does
not override older mt values. This is valid as this protocol forces the
device to send all the values at each frame.
Signed-off-by: Benjamin Tissoires <tissoire at cena.fr>
---
src/evdev.c | 36 +++++++++++++++++++++++++++++++++---
src/evdev.h | 1 +
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index 84b134c..5448d17 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -417,6 +417,8 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
*/
else if (pEvdev->abs && pEvdev->tool) {
memcpy(v, pEvdev->vals, sizeof(int) * pEvdev->num_vals);
+ if (pEvdev->mt_current_touchpoint > pEvdev->mt_max_touchpoints)
+ pEvdev->mt_current_touchpoint = pEvdev->mt_max_touchpoints;
if (pEvdev->swap_axes) {
int tmp = v[0];
@@ -443,7 +445,8 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
v[1] = (pEvdev->absinfo[ABS_Y].maximum - v[1] +
pEvdev->absinfo[ABS_Y].minimum);
- *num_v = pEvdev->num_vals;
+ *num_v = pEvdev->num_vals - (pEvdev->mt_max_touchpoints -
+ pEvdev->mt_current_touchpoint) * pEvdev->mt_num_valuators;
*first_v = 0;
}
}
@@ -545,7 +548,15 @@ EvdevProcessAbsoluteMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
if (EvdevWheelEmuFilterMotion(pInfo, ev))
return;
- pEvdev->vals[pEvdev->axis_map[ev->code]] = value;
+ if (ev->code < ABS_MT_TOUCH_MAJOR)
+ pEvdev->vals[pEvdev->axis_map[ev->code]] = value;
+ else if (pEvdev->mt_current_touchpoint < pEvdev->mt_max_touchpoints) {
+ /* MT value -> store it at the first available place */
+ pEvdev->vals[pEvdev->axis_map[ev->code] +
+ pEvdev->mt_current_touchpoint * pEvdev->mt_num_valuators] = value;
+ } else
+ return; /* mt-event, but not enough place to store it */
+
if (ev->code == ABS_X)
pEvdev->abs |= ABS_X_VALUE;
else if (ev->code == ABS_Y)
@@ -687,6 +698,22 @@ EvdevProcessSyncEvent(InputInfoPtr pInfo, struct input_event *ev)
pEvdev->num_queue = 0;
pEvdev->abs = 0;
pEvdev->rel = 0;
+ pEvdev->mt_current_touchpoint = 0;
+}
+
+/**
+ * Process the event SYN_MT_REPORT.
+ *
+ * This event is required only in the mt-protocol A (the oldest one). This
+ * protocol now handles devices that do not support touchpoint tracking, so
+ * the processing consists in incrementing mt_current_touchpoint to be able
+ * to place the next mt-event after this one in the list of valuators.
+ */
+static void
+EvdevProcessMTSyncReport(InputInfoPtr pInfo, struct input_event *ev)
+{
+ EvdevPtr pEvdev = pInfo->private;
+ pEvdev->mt_current_touchpoint++;
}
/**
@@ -707,7 +734,10 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
EvdevProcessKeyEvent(pInfo, ev);
break;
case EV_SYN:
- EvdevProcessSyncEvent(pInfo, ev);
+ if (ev->code == SYN_MT_REPORT)
+ EvdevProcessMTSyncReport(pInfo, ev);
+ else
+ EvdevProcessSyncEvent(pInfo, ev);
break;
}
}
diff --git a/src/evdev.h b/src/evdev.h
index 852f06c..49733a7 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -197,6 +197,7 @@ typedef struct {
unsigned int mt_num_valuators;
unsigned int mt_max_touchpoints; /* the number of simultaneous touchpoints
* the device can support */
+ unsigned int mt_current_touchpoint;
} EvdevRec, *EvdevPtr;
/* Event posting functions */
--
1.7.0.1
More information about the xorg-devel
mailing list