Skip to content

Commit 6ced70f

Browse files
committed
Merge branch 'get_eventpath'
2 parents 4b96cb6 + 5e63bfc commit 6ced70f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/tslib.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include <sys/time.h>
5151
#include <time.h>
5252
#include <stdint.h>
53+
#include <fcntl.h>
5354

5455
#if defined (__FreeBSD__)
5556
#include <dev/evdev/input.h>
@@ -388,6 +389,7 @@ xf86TslibUninit(__attribute__ ((unused)) InputDriverPtr drv,
388389
free(priv->samp_mt);
389390
free(priv->last_mt);
390391
#endif
392+
close(pInfo->fd);
391393
valuator_mask_free(&priv->valuators);
392394
xf86TslibControlProc(pInfo->dev, DEVICE_OFF);
393395
ts_close(priv->ts);
@@ -463,8 +465,6 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
463465

464466
priv->slots = 0;
465467

466-
pInfo->fd = ts_fd(priv->ts);
467-
468468
ts_error_fn = errfn;
469469

470470
/* process generic options */
@@ -475,6 +475,21 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
475475
if (!priv->valuators)
476476
return BadValue;
477477

478+
#ifdef TSLIB_VERSION_EVENTPATH
479+
pInfo->fd = open(ts_get_eventpath(priv->ts), O_RDONLY);
480+
#else
481+
if (!s) {
482+
xf86IDrvMsg(pInfo, X_ERROR, "Please provide Option path or Device");
483+
return BadValue;
484+
}
485+
486+
pInfo->fd = open(s, O_RDONLY);
487+
#endif
488+
if (pInfo->fd == -1) {
489+
xf86IDrvMsg(pInfo, X_ERROR, "Couldn't open %s\n", s);
490+
return BadValue;
491+
}
492+
478493
if (ioctl(pInfo->fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) < 0) {
479494
xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT failed");
480495
return BadValue;

0 commit comments

Comments
 (0)