evdev: log configured device info

Bring back the device configure logging that was originally part of
Weston's evdev.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
Add a log_bug macro

For logging when things happen which should not happen. We may want to do
something more fancy in the future but for now this suffices.

Modelled after log_bug in libevdev.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
evdev: Use temporary variable when passing libevdev pointer

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
evdev: Dynamically allocate slot array

Don't have a hard coded slot array size; instead allocate the array
needed according to the abs info reported by either libmtdev or libevdev.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
evdev: Avoid double touch down/up events

When the kernel sends multiple touch down or touch up for the same slot
in a row, ignore any such subsequent event ensuring libinput always
produces 1 x touch down -> [n x touch motion] -> 1 x touch up event
series.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
test: Test handling of many touch points

libinput currently handles 16 per device touch points. Test that we
behave as expected when a device has an even higher number of active
touch points.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
test: Check that libinput doesn't send double touch down/up events

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
test: Fix test device type validity check

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Introduce seat wide button and key count API

Compositors will need to keep provide virtual devices of supported
generic device types (pointer, keyboard, touch etc). Events from each
device capable of a certain device type abstraction should be combined
as if it was only one device.

For key and button events this means counting presses of every key or
button. With this patch, libinput provides two new API for doing just
this; libinput_event_pointer_get_seat_button_count() and
libinput_event_keyboard_get_seat_key_count().

With these functions, a compositor can sort out what key or button events
that should be ignored for a virtual device. This could for example
look like:

event = libinput_get_event(libinput);
switch (libinput_event_get_type(event)) {
...
case LIBINPUT_EVENT_POINTER_BUTTON:
	device = libinput_event_get_device(event);
	seat = libinput_event_get_seat(device);
	pevent = libinput_event_get_pointer_event(event);

	if (libinput_event_pointer_get_button_state(pevent) &&
	    libinput_event_pointer_get_seat_button_count(pevent) == 1)
		notify_pointer_button_press(seat);
	else if (libinput_event_pointer_get_button_state(pevent) &&
		 libinput_event_pointer_get_seat_button_count(pevent) == 0)
		notify_pointer_button_release(seat);
	break;
...
}

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
test: Add ability to add test devices to existing libinput context

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
test: Test seat wide button and key count helpers

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
touchpad: Silence -Wmaybe-uninitialized compiler warning

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Fix doc typo

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Remove doc references to non-existing function

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Fix doc typo in function name

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Fix doc typo

The infinitive reads a bit odd there.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
evdev: indentation fix

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
tools: add newline before function name

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test: fix a couple of memleaks in the tests

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>