conf: add N-Trig DuoSense to our matched devices

That device has a pen and an eraser tool, as well as a touch device. Handle it
with the wacom driver by default, the evdev driver isn't quite up to scratch
here.

This also fixes a missing match in the .fdi file for the base N-Trig devices -
just in case.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Have Lenovo "ISD-V4" (0x6004) sensor use wacom driver

https://bugs.freedesktop.org/show_bug.cgi?id=66891

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Fix type mismatch in test suite

Add CONST which expands to either 'const' or nothing depending
on ABI version.
This eliminates a compiler error.

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Fix loads of 'redundand declaration' warnings in test suite

Most symbols in fake-symbols.h were already declared in the
Xserver header files from the SDK which are also included.
These produce loads of compiler warnings.
The few remaining ones can be added by including xf86_OSproc.h
and exevents.h.
Then then all function declarations for the stub functions
can be deleted.
Relying on SDK provided headers makes providing stub functions
cumbersome due to frequent non-atomic API/ABI changes.
To work around this one would have to avoid SDK headers completely,
though.

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Add missing symbol xf86PrintChipsets() for test suite

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Make tested static functions non-static for test suite

This gets rid of the hack which redefines 'static' to make
every static function in the driver non-static for the test
suite.
Instead we use a macro instead of 'static' in the function definition
of each function used in the test suite which we can set to empty
when compiling the test suite.
At the same time we create a declaration for each of those functions
which gets us rind of about a bazillion compiler warnings.

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Fix warning about discarding 'const' qualifier

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Fix '-Wuninitialized' warnings

Pinning variables to some value to fix warning about uninitialized
variable.

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Fix spurious '-Wshadow' warning

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Get rid of spurious 'format not a string literal' warnings

With '-Wformat-nonliteral' gcc kindly warns us that it cannot check the
arguments of a scanf statement as the format string is not literal.
This happens if the format string itself is pointer.
Since the list of format strings only has two elements the same thing
can be achieved in code directly.

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Remove test if pressure falls below the minPressure

This code is entirely irrelevant as it is called immediately after
rebasePressure() which already ensures that minPressure is the
minimum of minPressure and current pressure unless one mistrusts
the implementation of min().

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Avoid 'division by zero' in xf86ScaleAxis()

If minPressure == wcmMaxZ then the range left to scale is 0. Catch
this condition and act appropriately.

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Add more detailed messaging in code that handles abnormal situations

Log which serial numbers have been force-proxied out.

Signed-off-by: Egbert Eich <eich@suse.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Log when the pen device appears to be too worn out

Worn out pens have an initial pressure != 0. If this pressure
persists while the pen is in proximity and still exists when
going out of proximity, warn about worn out tool.
Some devices seem to send a zero pressure when going out of
proximity. Thus we record the last pressure when still in
proximity.
Also we count the number of events we have received while in
proximity so the risk of false reports on 'quick taps' is lower.

This condition may also occur intermittently on abusive operation.

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Free (WacomToolPtr)->name when freeing the tool list

Currently the name member is set in wcmParseSerials() only, however
it is dynamically allocated. thus free it when destroying the structure
which contains it.

Signed-off-by: Egbert Eich <eich@suse.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Improve wcmLinkTouchAndPen device matching

If a tablet has pen and touch interfaces, they appear to the system as
seperate devices. Because it is necessary for these devices to share
information, `wcmLinkTouchAndPen` was introduced to connect the two
"halves" of the single physical tablet together (similar to
how `wcmMatchDevice` links logical devices together).

`wcmLinkTouchAndPen` has a few bugs in its implementation which prevent
it from doing its job as well as it should. This patch introduces a new
funcation named `wcmIsSiblingDevice` which is responsible for
determining if two devices are part of the same tablet. It includes a
slightly stricter (but still imperfect) check to reduce the number of
false-positives in the linking process.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Update wcmTouchDevice for touch interface

To support arbitration, we only needed to access touch pointer
from pen interfaces. Now, we need to access touch pointer from
touch interfaces to update touch switch state.

Since other tools, such as PAD, can be associated with touch
interfaces, we can not assume the first tool created on touch
interface is a touch tool. Assign it to wcmTouchDevice to avoid
looping through the tool list everytime when we need to access it.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Support hardware touch switch

New Intuos series introduced a hardware switch to turn touch
events on/off. This patch retrieves its state from kernel by
checking if SW_MUTE_DEVICE is declared.

A new input property, WACOM_PROP_HARDWARE_TOUCH, is intoduced
to report touch status changed by end user through touch switch.

HardwareTouch, a new xsetwacom option, is added. This option
is read-only since the state can only be changed by end users.
This option is independent from the existing Touch option,
which can be considered as a software touch switch.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jason Gerecke <killertofu@gmail.com>