56
58
dev_mouse.id.product = BTNX_PRODUCT_MOUSE;
57
59
dev_mouse.id.version = 0;
58
60
strcpy(dev_mouse.name, UMOUSE_NAME);
59
ignore = write(uinput_mouse_fd, &dev_mouse, sizeof(dev_mouse));
62
rem = sizeof(dev_mouse);
63
buf = (unsigned char *)&dev_mouse;
65
written = write(uinput_mouse_fd, buf, rem);
72
} while (written >= 0 || errno == EINTR);
74
perror(OUT_PRE "Error writing to uinput device");
75
exit(BTNX_ERROR_WRITE_UINPUT);
62
78
memset(&dev_kbd, 0, sizeof(dev_kbd));
63
79
dev_kbd.id.bustype = 0;
65
81
dev_kbd.id.product = BTNX_PRODUCT_KBD;
66
82
dev_kbd.id.version = 0;
67
83
strcpy(dev_kbd.name, UKBD_NAME);
68
ignore = write(uinput_kbd_fd, &dev_kbd, sizeof(dev_kbd));
85
rem = sizeof(dev_kbd);
86
buf = (unsigned char *)&dev_kbd;
88
written = write(uinput_kbd_fd, buf, rem);
95
} while (written >= 0 || errno == EINTR);
97
perror(OUT_PRE "Error writing to uinput device");
98
exit(BTNX_ERROR_WRITE_UINPUT);
70
101
ioctl(uinput_mouse_fd, UI_SET_EVBIT, EV_REL);
71
102
ioctl(uinput_mouse_fd, UI_SET_RELBIT, REL_X);
115
147
event.type = EV_KEY;
116
148
event.code = bev->mod[i];
117
149
event.value = bev->pressed;
118
ignore = write(uinput_kbd_fd, &event, sizeof(event));
152
buf = (unsigned char *)&event;
154
written = write(uinput_kbd_fd, buf, rem);
161
} while (written >= 0 || errno == EINTR);
163
perror(OUT_PRE "Error writing to uinput device");
164
exit(BTNX_ERROR_WRITE_UINPUT);
120
167
event.type = EV_SYN;
121
event.code = SYN_REPORT;
123
ignore = write(uinput_kbd_fd, &event, sizeof(event));
168
event.code = SYN_REPORT;
172
buf = (unsigned char *)&event;
174
written = write(uinput_kbd_fd, buf, rem);
181
} while (written >= 0 || errno == EINTR);
183
perror(OUT_PRE "Error writing to uinput device");
184
exit(BTNX_ERROR_WRITE_UINPUT);
144
206
else if (bev->keycode == REL_WHEELBACK)
145
207
event.value = -1;
146
ignore = write(fd, &event, sizeof(event));
210
buf = (unsigned char *)&event;
212
written = write(fd, buf, rem);
219
} while (written >= 0 || errno == EINTR);
221
perror(OUT_PRE "Error writing to uinput device");
222
exit(BTNX_ERROR_WRITE_UINPUT);
150
228
event.type = EV_KEY;
151
229
event.code = bev->keycode;
152
230
event.value = bev->pressed;
153
ignore = write(fd, &event, sizeof(event));
233
buf = (unsigned char *)&event;
235
written = write(fd, buf, rem);
242
} while (written >= 0 || errno == EINTR);
244
perror(OUT_PRE "Error writing to uinput device");
245
exit(BTNX_ERROR_WRITE_UINPUT);
156
250
event.type = EV_SYN;
157
251
event.code = SYN_REPORT;
159
ignore = write(fd, &event, sizeof(event));
256
buf = (unsigned char *)&event;
258
written = write(fd, buf, rem);
265
} while (written >= 0 || errno == EINTR);
267
perror(OUT_PRE "Error writing to uinput device");
268
exit(BTNX_ERROR_WRITE_UINPUT);
162
273
/* Send a key combo event, either press or release */