Description:fix event bug

Match-id-aef1933cd1d171762417513d47a58a94fe246e4d
This commit is contained in:
xxxx
2022-08-22 16:45:06 +08:00
parent b3e979b5d3
commit e4d0d40ef0
2 changed files with 9 additions and 12 deletions
+7 -11
View File
@@ -177,12 +177,15 @@ size_t InputHub::GetEvents(RawEvent* buffer, size_t bufferSize)
}
continue;
}
struct input_event readBuffer[bufferSize];
int32_t readSize = read(eventItem.data.fd, readBuffer, sizeof(struct input_event) * capacity);
size_t count = ReadInputEvent(readSize, *GetDeviceByFdLocked(eventItem.data.fd));
Device* device = GetSupportDeviceByFd(eventItem.data.fd);
if (!device) {
continue;
}
if (eventItem.events & EPOLLIN) {
event += CollectEvent(event, capacity, bufferSize, device);
event += CollectEvent(event, capacity, device, readBuffer, count);
if (capacity == 0) {
pendingEventIndex_ -= 1;
@@ -197,17 +200,10 @@ size_t InputHub::GetEvents(RawEvent* buffer, size_t bufferSize)
return event - buffer;
}
size_t InputHub::CollectEvent(RawEvent* buffer, size_t& capacity, size_t bufferSize, Device* device)
size_t InputHub::CollectEvent(RawEvent* buffer, size_t& capacity, Device* device, struct input_event readBuffer[],
const size_t count)
{
struct input_event readBuffer[bufferSize];
if (bufferSize < capacity) {
DHLOGE("capacity: %d should not lager than bufferSize: %d\n", capacity, bufferSize);
return 0;
}
int32_t readSize = read(device->fd, readBuffer, sizeof(struct input_event) * capacity);
size_t count = ReadInputEvent(readSize, *device);
std::vector<bool> needFilted(bufferSize, false);
std::vector<bool> needFilted(capacity, false);
if (device->classes == INPUT_DEVICE_CLASS_TOUCH_MT) {
HandleTouchScreenEvent(readBuffer, count, needFilted, device);
}
+2 -1
View File
@@ -118,7 +118,8 @@ private:
Device* device);
int32_t QueryLocalTouchScreenInfo(int fd);
bool CheckTouchPointRegion(struct input_event readBuffer[], const AbsInfo& absInfo, Device* device);
size_t CollectEvent(RawEvent* buffer, size_t& capacity, size_t bufferSize, Device* device);
size_t CollectEvent(RawEvent* buffer, size_t& capacity, Device* device, struct input_event readBuffer[],
const size_t count);
int epollFd_;
int iNotifyFd_;