Touchscreen and mouse conflicting?

350 views
Skip to first unread message

cws

unread,
Feb 12, 2010, 3:42:29 PM2/12/10
to 0xlab-devel
I'm implementing a touchscreen driver on the 0xlab 1.6 android
release.

Using the "Dev Tools" 'Pointer location' app I get a "touch" at the
appropriate location but when I start to move my finger on the
touchscreen the app draws a line to the current position of the mouse
cursor. From then on no movement on the touchscreen is tracked until
I remove my finger; at that time the app draws a line to the location
I removed my finger from.

Might this be due to the mouse and touchscreen being active at the
same time? Is there a way to make them co-exists?

Thanks,
Curt

I'm using "/dev/uinput" to inject the touchscreen events. I'm
including the code for reference:

When a touch is detected:
memset(&event, 0, sizeof(event));
gettimeofday(&event.time, NULL);
event.type = EV_ABS;
event.code = ABS_X;
event.value = x;
write(uinp_fd, &event, sizeof(event));

event.type = EV_ABS;
event.code = ABS_Y;
event.value = y;
write(uinp_fd, &event, sizeof(event));

event.type = EV_ABS;
event.code = ABS_PRESSURE;
event.value = MAX_PRESSURE;
write(uinp_fd, &event, sizeof(event));

event.type = EV_KEY;
event.code = BTN_TOUCH;
event.value = 1;
write(uinp_fd, &event, sizeof(event));

event.type = EV_SYN;
event.code = SYN_REPORT;
event.value = 0;
write(uinp_fd, &event, sizeof(event));


When movement is detected:
memset(&event, 0, sizeof(event));
gettimeofday(&event.time, NULL);
event.type = EV_ABS;
event.code = ABS_X;
event.value = x;
write(uinp_fd, &event, sizeof(event));

event.type = EV_ABS;
event.code = ABS_Y;
event.value = y;
write(uinp_fd, &event, sizeof(event));

event.type = EV_ABS;
event.code = ABS_PRESSURE;
event.value = MAX_PRESSURE;
write(uinp_fd, &event, sizeof(event));

event.type = EV_SYN;
event.code = SYN_REPORT;
event.value = 0;
write(uinp_fd, &event, sizeof(event));


When touch is no longer detected:
memset(&event, 0, sizeof(event));
gettimeofday(&event.time, NULL);
event.type = EV_ABS;
event.code = ABS_PRESSURE;
event.value = MIN_PRESSURE;
write(uinp_fd, &event, sizeof(event));

event.type = EV_KEY;
event.code = BTN_TOUCH;
event.value = 0;
write(uinp_fd, &event, sizeof(event));

event.type = EV_SYN;
event.code = SYN_REPORT;
event.value = 0;
write(uinp_fd, &event, sizeof(event));


I setup using:

/* Globals */
static int uinp_fd = -1;
struct uinput_user_dev uinp; // uInput device structure
struct input_event event; // Input device structure

int setup_uinput_device()
{
// Open the input device
uinp_fd = open("/dev/uinput", O_WRONLY | O_NDELAY);
if (uinp_fd == NULL)
{
printf("Unable to open /dev/uinput\n");
return -1;
}
memset(&uinp,0,sizeof(uinp)); // Intialize the uInput device to NULL
strncpy(uinp.name, "Touch Screen", UINPUT_MAX_NAME_SIZE);
uinp.id.version = 4;
uinp.id.bustype = BUS_VIRTUAL;//BUS_USB;
//X
uinp.absmax[ABS_X] = MAX_X;
uinp.absmin[ABS_X] = MIN_X;
uinp.absfuzz[ABS_X] = 2;
uinp.absflat[ABS_X] = 0;
//Y
uinp.absmax[ABS_Y] = MAX_Y;
uinp.absmin[ABS_Y] = MIN_Y;
uinp.absfuzz[ABS_Y] = 2;
uinp.absflat[ABS_Y] = 0;
//ABS_PRESSURE
uinp.absmax[ABS_PRESSURE] = MAX_PRESSURE;
uinp.absmin[ABS_PRESSURE] = MIN_PRESSURE;
uinp.absfuzz[ABS_PRESSURE] = 1;
uinp.absflat[ABS_PRESSURE] = 0;

// Setup the uinput device
ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY);
ioctl(uinp_fd, UI_SET_EVBIT, EV_ABS);
ioctl(uinp_fd, UI_SET_KEYBIT, BTN_TOUCH);
ioctl(uinp_fd, UI_SET_ABSBIT, ABS_X);
ioctl(uinp_fd, UI_SET_ABSBIT, ABS_Y);
ioctl(uinp_fd, UI_SET_ABSBIT, ABS_PRESSURE);

/* Create input device into input sub-system */
write(uinp_fd, &uinp, sizeof(uinp));
if (ioctl(uinp_fd, UI_DEV_CREATE))
{
printf("Unable to create UINPUT device.");
return -1;
}
}

Project Kennel

unread,
Feb 12, 2010, 9:01:29 PM2/12/10
to 0xlab-devel
Hi,

This other post may be in relation to what you were seeing. I think
someone else had a similar problem.

The change can be found here,
http://code.google.com/p/0xdroid/issues/detail?id=59

Reply all
Reply to author
Forward
0 new messages