Skip to content

Commit

Permalink
input-raw: Don't require to have the EV_KEY event type
Browse files Browse the repository at this point in the history
We already didn't require to have BTN_TOUCH or BTN_LEFT because
multitouch type A and B can do without them. And since these are the
only EV_KEY event code we check, we obviously can remove the requirement
for the EV_KEY type.

Fixes #102

Signed-off-by: Martin Kepplinger <martink@posteo.de>
  • Loading branch information
merge committed Sep 4, 2017
1 parent 8cf75a1 commit b8594cc
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions plugins/input-raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,9 @@ static int check_fd(struct tslib_input *i)
"tslib: Warning: Selected device uses a different version of the event protocol than tslib was compiled for\n");

if ((ioctl(ts->fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) ||
!(evbit[BIT_WORD(EV_ABS)] & BIT_MASK(EV_ABS)) ||
!(evbit[BIT_WORD(EV_KEY)] & BIT_MASK(EV_KEY))) {
!(evbit[BIT_WORD(EV_ABS)] & BIT_MASK(EV_ABS))) {
fprintf(stderr,
"tslib: Selected device is not a touchscreen (must support ABS and KEY event types)\n");
"tslib: Selected device is not a touchscreen (must support ABS event type)\n");
return -1;
}

Expand All @@ -252,25 +251,37 @@ 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;
}
/* Remember whether we have a multitouch device. We need to know for ABS_X,
* ABS_Y and ABS_PRESSURE data.
*/
if ((absbit[BIT_WORD(ABS_MT_POSITION_X)] & BIT_MASK(ABS_MT_POSITION_X)) &&
(absbit[BIT_WORD(ABS_MT_POSITION_Y)] & BIT_MASK(ABS_MT_POSITION_Y)))
i->mt = 1;

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

/* for multitouch type B, tracking id is enough for pen down/up. type A
* has pen down/up through the list of (empty) SYN_MT_REPORT
* only for singletouch we need BTN_TOUCH or BTN_LEFT
*/
if (!(keybit[BIT_WORD(BTN_TOUCH)] & BIT_MASK(BTN_TOUCH) ||
keybit[BIT_WORD(BTN_LEFT)] & BIT_MASK(BTN_LEFT)) && !i->mt) {
fprintf(stderr,
"tslib: Selected device is not a touchscreen (missing BTN_TOUCH or BTN_LEFT)\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);

/* Remember whether we have a multitouch device. We need to know for ABS_X,
* ABS_Y and ABS_PRESSURE data.
*/
if ((absbit[BIT_WORD(ABS_MT_POSITION_X)] & BIT_MASK(ABS_MT_POSITION_X)) &&
(absbit[BIT_WORD(ABS_MT_POSITION_Y)] & BIT_MASK(ABS_MT_POSITION_Y)))
i->mt = 1;

/* Since some touchscreens (eg. infrared) physically can't measure pressure,
* the input system doesn't report it on those. Tslib relies on pressure, thus
* we set it to constant 255. It's still controlled by BTN_TOUCH/BTN_LEFT -
Expand All @@ -295,15 +306,6 @@ static int check_fd(struct tslib_input *i)
!(absbit[BIT_WORD(ABS_MT_TRACKING_ID)] & BIT_MASK(ABS_MT_TRACKING_ID)))
i->type_a = 1;

/* for multitouch type B, tracking id is enough for pen down/up. type A
* has pen down/up through the list of (empty) SYN_MT_REPORT */
if (!(keybit[BIT_WORD(BTN_TOUCH)] & BIT_MASK(BTN_TOUCH) ||
keybit[BIT_WORD(BTN_LEFT)] & BIT_MASK(BTN_LEFT)) && i->mt != 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 b8594cc

Please sign in to comment.