Daniel Kurtz has posted comments on this change.
Change subject: x11-drivers/xf86-input-evdev: Add SYN_DROPPED handling
......................................................................
Patch Set 10: (10 inline comments)
....................................................
File x11-drivers/xf86-input-evdev/files/evdev-2.7.3-Add-SYN_DROPPED-handling.patch
Line 164: +static void
If you return 1 from this function, you can use it like this, everywhere:
ev_count += EvdevInjectSyncInputEvent();
Line 173: + EvdevGetKernelTime(&ev.time, pEvdev->is_monotonic);
Well, this actually causes lots of overhead with many system calls fetching the current time. It might be faster to just use the 'sync begin time' for all injected events. Just double check that this works ok for higher layers.
Line 188: + return !Success;
Does !Success == 0?
How can you distinguish between failure, and "no events sync'ed"?
Line 360: + ValuatorMask *mt_vals[num_slots(device)];
It's generally not a good idea to use stack-allocated variable length arrays, since you have no way of detected out-of-memory conditions; you just get strange stack corruption or crashes.
Line 369: + /* Get all current slots axes, then check if there is any update required */
It's probably better to fetch all of the MTSlotInfo structs first, and then parse them to see what has changed. This should save you from having to copy the valuators first:
(1) read in the current ABS_MT_SLOT
(a) int curr_slot = pEvdev.curr_slot;
(b) Save EVIOCGABS(ABS_MT_SLOT) to new_curr_slot
(2) allocate enough MTSlotInfo reqs for all supported ABS_MT axes.
(3) use the ioctl to read in the current value of all of these axes.
(4) then, for each slot:
(a) for each req.code, compare the newly sync'ed value to the mapped valuator_mask value.
(b) if any value has changed, inject a kernel event
(i) Before the first value that changed, per slot, inject an extra "ABS_MT_SLOT" event to set the current slot:
MTSlotInfo req[_ABS_MT_LAST - _ABS_MT_FIRST + 1];
int num_injected_events = 0;
int curr_slot = pEvdev.curr_slot;
int new_curr_slot;
struct input_absinfo abs_mt_slot_info;
// Save current 'current_slot'
curr_slot = pEvdev.curr_slot;
// Sync new 'current_slot'
ioctl(pInfo->fd, EVIOCGABS(key), &abs_mt_slot_info);
new_curr_slot = abs_mt_slot_info->value;
// Read in current state of all supported ABS_MT fields
for (i = _ABS_MT_FIRST; i <= _ABS_MT_LAST; i++) {
if (EvdevBitIsSet(device->abs_bitmask, i))
ioctl(pInfo->fd, EVIOCGMTSLOTS((sizeof(MTSlotInfo))), &req[i]);
}
// For each slot, sync its values
for (i = min ; i < min + num_slots(pEvdev); i++) {
for (code = _ABS_MT_FIRST; code <= _ABS_MT_LAST; code++) {
int map = pEvdev->axis_map[code];
if (map == -1)
continue;
if (valuator_mask_get(pEvdev->last_mt_vals[i], map) != req[code].values[i]) {
// If this slot is not curr_slot, inject an ABS_MT_SLOT update
if (i != curr_slot) {
EvdevInjectSyncEvent(EV_ABS, ABS_MT_SLOT, i);
num_injected_events += 1;
curr_slot = i;
}
EvdevInjectSyncEvent(EV_ABS, code, req[code].values[i]);
num_injected_events += 1;
}
}
// If curr_slot has changed, and we haven't updated it yet, inject the update now
if (curr_slot != new_curr_slot) {
EvdevInjectSyncEvent(EV_ABS, ABS_MT_SLOT, new_curr_slot);
num_injected_events += 1;
}
return num_injected_events;
Line 384: + /* Sync all ABS_ axes first */
/* (1) sync all non-MT ABS axes */
Line 387: + /* Sync ABS_MT_ axes for all slots if exists */
/* (2) sync ABS_MT_ axes, if device has any */
Line 400: + EvdevInjectSyncInputEvent(pInfo, EV_SYN, SYN_REPORT, 0);
I think you want to move this down to EvdevSyncState()
Line 411: + int ev_count = 0;
You don't use ev_count?
Line 425: +
Debug message w/ number of sync'ed events would be nice.
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6aa3ad9a3708563181553198b0264052e0da9dd
Gerrit-PatchSet: 10
Gerrit-Project: chromiumos/overlays/chromiumos-overlay
Gerrit-Branch: master
Gerrit-Owner: Chung-yih Wang <
cyw...@chromium.org>