configure: both clients and drivers need the protocol headers

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
Add includes to isdv4.h

The header should include what it needs, not rely on other files to include
the required bits.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
isdv4: inline all isdv4 parsing functions

Stops compiler warning if any of them aren't used.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
tools: rearrange serial settings

If the device was't properly closed/reset after a crash, tcgetattr() will
fail. Ignore that error and apply the settings we want nonetheless, in most
cases the device will just come back normally.

And to do so, merge setting the baud rate together with the rest so we only
have one call. Otherwise we can't apply the baud rate settings without
potentially submitting garbage to the driver.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
tools: open serial devices with O_NOCTTY

Probably doesn't make much difference, but won't hurt if we ever send the
wrong path name.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
tools: use perror instead of fprintf

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
tools: drop double-call to tcsetattr

We merely modify the flags, might as well just send one call

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
tools: localise the remaining global variables

Only one left is verbosity now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
tools: split out the debugger into the actual debugger and shared code

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
tools: re-enable wait-for-tablet

We need this to actually time out, otherwise we can't tell whether we have the
wrong baud rate set. That's fine for a debugger where a human will terminate,
but not for the upcoming inputattach clone.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
tools: add colon after TOUCH output

For consistency with the TABLET output.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
tools: add an inputattach-like tool

Does more or less the same thing as inputattach, but tries to be a bit smarter
about the baud rate depending on the tablet model. And re-tries if the baud
rate is wrong.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
conf: ship a udev rule and a systemd service file for inputattach

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
tools: split the CFLAGS into binary-specific ones

Also, xsetwacom only needs the library, not the server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <killertofu@gmail.com>
wcmUSB: Don't directly dereference common->fd

common->fd is intended to share the fd between different InputInfo structs,
and that is the only thing it should be used for. With server managed fds,
the fd management will all be done by the server and common->fd will never
get set, so nothing outside of wcmDevOpen / wcmDevClose should use it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Add a wcmClose helper function

This is a preparation patch for adding server managed fds support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Add server managed fd handling

This mostly consists of skipping common fd handling when server managed fds
are in used, the rest is handled by xf86OpenSerial and our wcmClose
xf86CloseSerial wrapper.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Merge branch 'wacom-inputattach'
test: Use X11_LIBS when building xsetwacom_test

Missed in c49463f.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
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>