3 #include <linux/input.h>
21 snprintf(name, sizeof(name), "/dev/input/event%d", i);
22 fd = open(name, O_RDONLY);
26 /* check supported events */
27 ret = ioctl(fd, EVIOCGBIT(0, sizeof(support)), &support);
29 printf("ioctl failed on %s\n", name);
33 if (!(support & (1 << EV_KEY)))
35 if (!(support & (1 << EV_ABS)))
38 ioctl(fd, EVIOCGNAME(sizeof(name)), name);
39 printf("found \"%s\" (type %08x)\n", name, support);
48 printf("no suitable devs\n");
52 ret = ioperm(888, 3, 1);
58 outb(0xc0, 890); /* switch to output mode, TL and TR high */
59 outb(0x0f, 888); /* Dx high */
63 struct input_event ev;
66 rd = read(fd, &ev, sizeof(ev));
67 if (rd < (int) sizeof(ev)) {
68 perror("in_evdev: error reading");
72 if (ev.type == EV_KEY) {
87 else if (ev.type == EV_ABS)
89 if (ev.code == ABS_X) {
92 else if (ev.value > 128)
97 if (ev.code == ABS_Y) {
100 else if (ev.value > 128)
105 outb(~dpad & 0x0f, 888);