Hardware Reference
In-Depth Information
memset(&ev,0,sizeof(ev));
ev.type = EV_REL;
ev.code = REL_X;
ev.value = x;
rc = write(fd,&ev,sizeof(ev));
assert(rc == sizeof(ev));
ev.code = REL_Y;
ev.value = y;
rc = write(fd,&ev,sizeof(ev));
assert (rc == sizeof(ev));
}
Notice that the REL_X and REL_Y events are created separately. What if you want the
receiving application to avoid acting on these separately? The EV_SYN event helps out in
this regard (next).
Posting EV_SYN Events
The uinput driver postpones delivery of events until the EV_SYN event has been injected.
The SYN_REPORT type of EV_SYN event causes the queued events to be flushed out and
reported to the interested application. The following is an example:
static void
uinput_syn(int fd) {
struct input_event ev;
int rc;
memset(&ev,0,sizeof(ev));
ev.type = EV_SYN;
ev.code = SYN_REPORT;
ev.value = 0;
rc = write(fd,&ev,sizeof(ev));
assert(rc == sizeof(ev));
}
For a mouse relative movement event, for example, you can inject a REL_X and REL_Y ,
followed by a SYN_REPORT event to have them seen by the application as a group.
Closing uinput
There are two steps involved:
1.
Destruction of the /dev/input/event%d node
2.
Closing of the file descriptor
 
Search WWH ::




Custom Search