The slowness comes from followings.
- fork process to run sendevent command;
/dev/input/eventX - in
- write event data to above file - in
- close the file - in
I got it faster by changing the
sendevent_main() as follows.
- open the file with a list of events;
- create a loop and do followings
3.1 read the event one by one from above file
3.2 write the event one by one to `/dev/input/eventX'
- close files.
So in above changes, the event read and write is done in a loop without overhead of
close for each event as before.
With this change, it is much faster to send event to
But it brings in another problem, some events' behavior is NOT correct as expected. Is it sending event too fast to be handled by application?
I am still checking and changing the code, such as add
usleep(10000) between event sending. But it goes back to the original slowness.