Lines Matching refs:fd
40 int ret, fd = -1;
46 fd = open(path, O_RDONLY);
48 if (fd < 0 && errno == ENOENT)
51 if (fd < 0) {
56 ret = ioctl(fd, EVIOCGNAME(sizeof(name)), name);
65 return fd;
66 close(fd);
74 int fd;
78 fd = try_open_device();
79 if (fd > 0)
80 return fd;
124 int fd;
127 fd = open(uinput_paths[i], O_WRONLY | O_NONBLOCK);
129 if (fd > 0) {
132 return fd;
135 if (fd < 0 && errno != ENOENT) {
146 int fd;
149 fd = try_open_uinput();
150 if (fd > 0)
151 return fd;
155 fd = try_open_uinput();
156 if (fd > 0) {
158 return fd;
170 void send_event(int fd, int event, int code, int value)
178 SAFE_WRITE(NULL, SAFE_WRITE_ALL, fd, &ev, sizeof(ev));
181 void send_rel_move(int fd, int x, int y)
183 send_event(fd, EV_REL, REL_X, x);
184 send_event(fd, EV_REL, REL_Y, y);
185 send_event(fd, EV_SYN, 0, 0);
188 void create_device(int fd)
201 SAFE_WRITE(NULL, SAFE_WRITE_ALL, fd, &uidev, sizeof(uidev));
202 SAFE_IOCTL(NULL, fd, UI_DEV_CREATE, NULL);
210 destroy_device(fd);
214 void setup_mouse_events(int fd)
216 SAFE_IOCTL(NULL, fd, UI_SET_EVBIT, EV_KEY);
217 SAFE_IOCTL(NULL, fd, UI_SET_KEYBIT, BTN_LEFT);
218 SAFE_IOCTL(NULL, fd, UI_SET_EVBIT, EV_REL);
219 SAFE_IOCTL(NULL, fd, UI_SET_RELBIT, REL_X);
220 SAFE_IOCTL(NULL, fd, UI_SET_RELBIT, REL_Y);
223 void destroy_device(int fd)
225 SAFE_IOCTL(NULL, fd, UI_DEV_DESTROY, NULL);
226 SAFE_CLOSE(NULL, fd);
249 int no_events_queued(int fd, int stray_sync_event)
251 struct pollfd fds = {.fd = fd, .events = POLLIN};
258 res = read(fd, &ev, sizeof(ev));