In case the driver receives 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 sends the values it has filled. Signed-off-by: Benjamin Tissoires <[email protected]> --- 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 10fe81b..39a5047 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -412,6 +412,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]; @@ -438,7 +440,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; } } @@ -540,7 +543,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) @@ -682,6 +693,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 does not make 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++; } /** @@ -702,7 +729,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 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
