Skip to content

Commit

Permalink
input-raw: fix fd checking for multitouch type A protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
merge committed Mar 30, 2017
1 parent b537f75 commit 5cd5add
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions plugins/input-raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,15 @@ static int check_fd(struct tslib_input *i)
}
}

if (ioctl(ts->fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) {
fprintf(stderr, "tslib: ioctl EVIOCGBIT error)\n");
return -1;
}


if (evbit[BIT_WORD(EV_SYN)] & BIT_MASK(EV_SYN))
i->using_syn = 1;

/* read device info and set special device nr */
get_special_device(i);

Expand All @@ -262,14 +271,6 @@ static int check_fd(struct tslib_input *i)
if (!(absbit[BIT_WORD(ABS_PRESSURE)] & BIT_MASK(ABS_PRESSURE)))
i->no_pressure = 1;

if ((ioctl(ts->fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) ||
!(keybit[BIT_WORD(BTN_TOUCH)] & BIT_MASK(BTN_TOUCH) ||
keybit[BIT_WORD(BTN_LEFT)] & BIT_MASK(BTN_LEFT))) {
fprintf(stderr,
"tslib: Selected device is not a touchscreen (must support BTN_TOUCH or BTN_LEFT events)\n");
return -1;
}

/* Remember whether we have a multitouch device. We need to know for ABS_X,
* ABS_Y and ABS_PRESSURE data.
*/
Expand All @@ -283,9 +284,6 @@ static int check_fd(struct tslib_input *i)
if (i->mt && !(absbit[BIT_WORD(ABS_MT_PRESSURE)] & BIT_MASK(ABS_MT_PRESSURE)))
i->no_pressure = 1;

if (evbit[BIT_WORD(EV_SYN)] & BIT_MASK(EV_SYN))
i->using_syn = 1;

if ((ioctl(ts->fd, EVIOCGBIT(EV_SYN, sizeof(synbit)), synbit)) == -1)
fprintf(stderr, "tslib: ioctl error\n");

Expand All @@ -294,6 +292,13 @@ static int check_fd(struct tslib_input *i)
!(absbit[BIT_WORD(ABS_MT_SLOT)] & BIT_MASK(ABS_MT_SLOT)))
i->type_a = 1;

if (!(keybit[BIT_WORD(BTN_TOUCH)] & BIT_MASK(BTN_TOUCH) ||
keybit[BIT_WORD(BTN_LEFT)] & BIT_MASK(BTN_LEFT)) && i->type_a != 1) {
fprintf(stderr,
"tslib: Selected device is not a touchscreen (missing BTN_TOUCH or BTN_LEFT)\n");
return -1;
}

if (i->grab_events == GRAB_EVENTS_WANTED) {
if (ioctl(ts->fd, EVIOCGRAB, (void *)1)) {
fprintf(stderr,
Expand Down

0 comments on commit 5cd5add

Please sign in to comment.