Bug 16666

Summary: Aiptek tablet driver does not report pressure sensitivity - missing sanity check
Product: xorg Reporter: Adrian Winchell <adrian>
Component: Input/aiptekAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED WONTFIX QA Contact: Xorg Project Team <xorg-team>
Severity: major    
Priority: medium    
Version: 7.3 (2007.09)   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard: 2011BRB_Reviewed
i915 platform: i915 features:

Description Adrian Winchell 2008-07-10 13:09:49 UTC
In xf86Aiptek.c, line 421-423:
    if (z > device->zMax) {
        z = device->zMax;
    }

When zMax (optional parameter in xorg.conf) is not specified, it is never changed from VALUE_NA (-1). The z-axis (Pressure) reported by the kernel driver is clipped to -1, resulting in no pressure sensitivity from the tablet.

This can be hacked around by simply changing the test to: (z > device->zMax && device->zMax > 0).
Another easy hack would be to simply typecast zMax to unsigned before comparing it - instead of comparing vs -1, it'd be MAXINT.

Ideally though, asking the tablet what its maximum pressure sensitivity is would be preferable.

I am using an Aiptek 12000U on Gentoo. The above test switch fixed pressure sensitivity for me.
Comment 1 Peter Hutterer 2008-07-16 05:02:07 UTC
On Thu, Jul 10, 2008 at 01:09:49PM -0700, bugzilla-daemon@freedesktop.org wrote:
> When zMax (optional parameter in xorg.conf) is not specified, it is never
> changed from VALUE_NA (-1). The z-axis (Pressure) reported by the kernel driver
> is clipped to -1, resulting in no pressure sensitivity from the tablet.
> 
> This can be hacked around by simply changing the test to: (z > device->zMax &&
> device->zMax > 0).
> Another easy hack would be to simply typecast zMax to unsigned before comparing
> it - instead of comparing vs -1, it'd be MAXINT.

wouldn't the better fix be to actually specify the pressure in the config file?

> Ideally though, asking the tablet what its maximum pressure sensitivity is
> would be preferable.

agreed, this would be the best solution. Do you know how to query the device?
Comment 2 Adrian Winchell 2008-07-21 07:47:43 UTC
(In reply to comment #1)
> wouldn't the better fix be to actually specify the pressure in the config file?
> 
Not really. The ZMin/ZMax functions are intended for clipping the pressure value to an appropriate range - when they're omitted, the driver should simply return whatever value the tablet's kernel driver offers even if it's ludicrous (65535 on a 512-level tablet? Is your desk OK?), or clip it to the known range of the tablet. If you request the range of the driver with the xinput utility, it "knows" that Z-axis is supposed to be 0-512. I'm not sure where in this source file that's assumed or detected, but it should be clipping to those values, however they're obtained, by default - not setting the maximum value to -1 on an unsigned range!

> 
> agreed, this would be the best solution. Do you know how to query the device?
> 

No I don't. I've only worked with xf86AiptekHIDReadInput and xf86AiptekSendEvents to fix logic errors so I can draw with my tablet. I do know the kernel side of the driver establishes some extra stuff in sysfs (older versions put it in proc), but I don't see anything particularly obvious for getting the dimensions. When this driver was originally written, all Aipteks had a max of 512 pressure levels, but that's changed with the introduction of their new "Slim Tablet 12-inch" which has 1024. Not sure if that tablet works with this driver, though - I have the 12000U. As I said above though - this info is already dealt with somewhere within the driver, but I'm not sure how or where.


I'll take a look at the driver source again when I get a chance, and see if I can figure anything out. :P
Comment 3 Peter Hutterer 2008-07-22 00:34:19 UTC
> --- Comment #2 from Adrian Winchell <adrian@winchell.us>  2008-07-21 07:47:43 PST ---
> Not really. The ZMin/ZMax functions are intended for clipping the pressure
> value to an appropriate range - when they're omitted, the driver should simply
> return whatever value the tablet's kernel driver offers even if it's ludicrous
> (65535 on a 512-level tablet? Is your desk OK?), or clip it to the known range
> of the tablet. If you request the range of the driver with the xinput utility,
> it "knows" that Z-axis is supposed to be 0-512. I'm not sure where in this
> source file that's assumed or detected, but it should be clipping to those
> values, however they're obtained, by default - not setting the maximum value to
> -1 on an unsigned range!


xf86AiptekOpenDevice inits the Z axis with a range of 0-512 (line 1520).
So - without looking in detail at the code - this means something is dodgy. If
the device reports 512, then zMax should always be 512 by default, unless
explicitly specified otherwise. In which case the valuator should be set up
with the different value.

the default setting to -1 when the axis is initialized with 512 is definitely
wrong. The driver is not supposed to clip except for special reasons.
Comment 4 Adam Jackson 2018-05-15 16:05:33 UTC
commit cd0ace3b30f78f30f52759837b8117e71298b760
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Sep 27 11:21:05 2011 +1000

    This driver is unmaintained, warn users.
    
    This driver will not see any further fixes unless users write them
    and test them.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.