[PATCH evdev 4/5] Dummy process MT events.
Benjamin Tissoires
tissoire at cena.fr
Sun Mar 28 04:58:12 PDT 2010
In case the driver receive a mt event, it stores it at the first
available place, i.e. it does not overrides older mt values.
At the end, in the EV_SYNC event, it only send the values it has
filled.
Signed-off-by: Benjamin Tissoires <tissoire at cena.fr>
---
src/evdev.c | 31 ++++++++++++++++++++++++++++---
src/evdev.h | 1 +
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index 7e59601..76af8dc 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -422,6 +422,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->current_num_multitouch > EVDEV_MAX_TOUCHPOINTS)
+ pEvdev->current_num_multitouch = EVDEV_MAX_TOUCHPOINTS;
if (pEvdev->swap_axes) {
int tmp = v[0];
@@ -448,7 +450,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->mt_first_axis +
+ pEvdev->current_num_multitouch * pEvdev->mt_num_valuators;
*first_v = 0;
}
}
@@ -551,7 +554,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->current_num_multitouch < EVDEV_MAX_TOUCHPOINTS) {
+ /* MT value -> store it at the first available place */
+ pEvdev->vals[pEvdev->axis_map[ev->code] +
+ pEvdev->current_num_multitouch * 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)
@@ -693,6 +704,17 @@ EvdevProcessSyncEvent(InputInfoPtr pInfo, struct input_event *ev)
pEvdev->num_queue = 0;
pEvdev->abs = 0;
pEvdev->rel = 0;
+ pEvdev->current_num_multitouch = 0;
+}
+
+/**
+ * Take the mt-synchronization input event and process it accordingly.
+ */
+static void
+EvdevProcessMTSyncReport(InputInfoPtr pInfo, struct input_event *ev)
+{
+ EvdevPtr pEvdev = pInfo->private;
+ pEvdev->current_num_multitouch++;
}
/**
@@ -713,7 +735,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 383a904..0dba366 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -198,6 +198,7 @@ typedef struct {
unsigned int mt_first_axis;
unsigned int mt_num_valuators;
+ unsigned int current_num_multitouch;
} EvdevRec, *EvdevPtr;
/* Event posting functions */
--
1.6.6.1
More information about the xorg-devel
mailing list