strange uinput behavior | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
I'm observing some strange behavior with xorg and uinput.
Attached is a simple testcase that creates a uinput device and sends a
KEY_ENTER event. In bad.c, when the device is only set up with a
KEY_ENTER key, the KEY_ENTER event is not observed in X. However, in
good.c, if another supported key (say KEY_A) is added to the uinput
device as well, the sending of the KEY_ENTER event works just fine.
Both of the testcases work as expected outside of X in the terminal
which leads to me to believe something is getting munged in X's input
layer.
--- bad.c 2008-08-21 19:06:20.000000000 -0400
+++ good.c 2008-08-21 19:02:34.000000000 -0400
@@ -26,6 +26,7 @@
dev.id.bustype = BUS_USB;
ioctl(fd, UI_SET_EVBIT, EV_KEY);
+ ioctl(fd, UI_SET_KEYBIT, KEY_A);
ioctl(fd, UI_SET_KEYBIT, KEY_ENTER);
write(fd, &dev, sizeof(dev));
This strageness is observable on Ubuntu Intrepid (xorg
(1:7.4~1ubuntu1)), but works as expected on Ubuntu Hardy (xorg (1:7.3
+10ubuntu10)).
Regards,
Jon Oberheide
--
Jon Oberheide <jon@xxxxxxxxxxxxx>
GnuPG Key: 1024D/F47C17FE
Fingerprint: B716 DA66 8173 6EDD 28F6 F184 5842 1C89 F47C 17FE
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
#include <linux/uinput.h>
int
main(void)
{
int fd;
struct input_event event;
struct uinput_user_dev dev;
fd = open("/dev/input/uinput", O_WRONLY | O_NDELAY);
if (!fd) {
printf("unable to open /dev/input/uinput\n");
return 1;
}
memset(&dev, 0, sizeof(dev));
strncpy(dev.name, "Test Device", UINPUT_MAX_NAME_SIZE);
dev.id.version = 4;
dev.id.bustype = BUS_USB;
ioctl(fd, UI_SET_EVBIT, EV_KEY);
ioctl(fd, UI_SET_KEYBIT, KEY_ENTER);
write(fd, &dev, sizeof(dev));
if (ioctl(fd, UI_DEV_CREATE)) {
printf("unable to create device\n");
return 1;
}
printf("device created...\n");
sleep(5);
printf("sending KEY_ENTER event...\n");
memset(&event, 0, sizeof(event));
event.type = EV_KEY;
event.code = KEY_ENTER;
event.value = 1;
write(fd, &event, sizeof(event));
event.value = 0;
write(fd, &event, sizeof(event));
ioctl(fd, UI_DEV_DESTROY);
close(fd);
return 0;
}
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
#include <linux/uinput.h>
int
main(void)
{
int fd;
struct input_event event;
struct uinput_user_dev dev;
fd = open("/dev/input/uinput", O_WRONLY | O_NDELAY);
if (!fd) {
printf("unable to open /dev/input/uinput\n");
return 1;
}
memset(&dev, 0, sizeof(dev));
strncpy(dev.name, "Test Device", UINPUT_MAX_NAME_SIZE);
dev.id.version = 4;
dev.id.bustype = BUS_USB;
ioctl(fd, UI_SET_EVBIT, EV_KEY);
ioctl(fd, UI_SET_KEYBIT, KEY_A);
ioctl(fd, UI_SET_KEYBIT, KEY_ENTER);
write(fd, &dev, sizeof(dev));
if (ioctl(fd, UI_DEV_CREATE)) {
printf("unable to create device\n");
return 1;
}
printf("device created...\n");
sleep(5);
printf("sending KEY_ENTER event...\n");
memset(&event, 0, sizeof(event));
event.type = EV_KEY;
event.code = KEY_ENTER;
event.value = 1;
write(fd, &event, sizeof(event));
event.value = 0;
write(fd, &event, sizeof(event));
ioctl(fd, UI_DEV_DESTROY);
close(fd);
return 0;
}
Attachment:
signature.asc
Description: This is a digitally signed message part
_______________________________________________ xorg mailing list xorg@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/xorg
[X Forum] [Devices] [XFree86] [XFree86 Newbie] [Site Home] [IETF Annouce] [Security] [Fontconfig] [Bugtraq] [Rubini] [Photo] [Yosemite] [MIPS Linux] [ARM Linux] [Linux Security] [Video for Linux] [Linux RAID] [Linux Resources]