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