Skip to content

Commit 7c49061

Browse files
committed
tslib.c: get pressure resolution from device or tslib respectively
For non-pressure devices, tslib creates pressure values between 0 and 255. For all others, tslib takes the device's values too, so we should do so too. Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com>
1 parent 4827c56 commit 7c49061

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/tslib.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct ts_priv {
7878
struct tsdev *ts;
7979
int height;
8080
int width;
81+
int pmax;
8182
struct ts_sample last;
8283
ValuatorMask *valuators;
8384
int8_t abs_x_only;
@@ -296,10 +297,10 @@ static int xf86TslibControlProc(DeviceIntPtr device, int what)
296297
InitValuatorAxisStruct(device, 2,
297298
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE),
298299
0, /* min val */
299-
255, /* max val */
300-
256, /* resolution */
300+
priv->pmax, /* max val */
301+
priv->pmax + 1, /* resolution */
301302
0, /* min_res */
302-
256, /* max_res */
303+
priv->pmax + 1, /* max_res */
303304
Absolute);
304305
} else {
305306
InitValuatorAxisStruct(device, 0,
@@ -323,10 +324,10 @@ static int xf86TslibControlProc(DeviceIntPtr device, int what)
323324
InitValuatorAxisStruct(device, 2,
324325
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_PRESSURE),
325326
0, /* min val */
326-
255, /* max val */
327-
256, /* resolution */
327+
priv->pmax, /* max val */
328+
priv->pmax + 1, /* resolution */
328329
0, /* min_res */
329-
256, /* max_res */
330+
priv->pmax + 1, /* max_res */
330331
Absolute);
331332
}
332333

@@ -540,6 +541,16 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
540541
return BadValue;
541542
}
542543
priv->height = absinfo.maximum;
544+
545+
if (!(absbit[BIT_WORD(ABS_PRESSURE)] & BIT_MASK(ABS_PRESSURE))) {
546+
priv->pmax = 255; /* tslib internal */
547+
} else {
548+
if (ioctl(pInfo->fd, EVIOCGABS(ABS_PRESSURE), &absinfo) < 0) {
549+
xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOGABS failed");
550+
return BadValue;
551+
}
552+
priv->pmax = absinfo.maximum;
553+
}
543554
} else {
544555
if (ioctl(pInfo->fd, EVIOCGABS(ABS_MT_POSITION_X), &absinfo) < 0) {
545556
xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOGABS failed");
@@ -552,6 +563,16 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
552563
return BadValue;
553564
}
554565
priv->height = absinfo.maximum;
566+
567+
if (!(absbit[BIT_WORD(ABS_MT_PRESSURE)] & BIT_MASK(ABS_MT_PRESSURE))) {
568+
priv->pmax = 255; /* tslib internal */
569+
} else {
570+
if (ioctl(pInfo->fd, EVIOCGABS(ABS_MT_PRESSURE), &absinfo) < 0) {
571+
xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOGABS failed");
572+
return BadValue;
573+
}
574+
priv->pmax = absinfo.maximum;
575+
}
555576
}
556577

557578
/* Return the configured device */

0 commit comments

Comments
 (0)