On Tue, Feb 24, 2015 at 11:53:55AM -0500, Benjamin Tissoires wrote: > On Tue, Feb 24, 2015 at 1:21 AM, Peter Hutterer > <peter.hutte...@who-t.net> wrote: > > A tablet hotplug event is rare and not a time-critical event, so we load the > > database on tablet init and throw it away again. > > > > Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> > > --- > > configure.ac | 14 ++++++++++++++ > > src/Makefile.am | 2 ++ > > src/evdev-tablet.c | 45 > > ++++++++++++++++++++++++++++++++++++++++++++- > > test/tablet.c | 13 ++++++++++++- > > test/valgrind.suppressions | 18 ++++++++++++++++++ > > 5 files changed, 90 insertions(+), 2 deletions(-) > > > > diff --git a/configure.ac b/configure.ac > > index 1a4eb3a..95c822a 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -165,6 +165,19 @@ if test "x$build_tests" = "xyes"; then > > AC_PATH_PROG(VALGRIND, [valgrind]) > > fi > > > > +AC_ARG_ENABLE(libwacom, > > + AS_HELP_STRING([--enable-libwacom], > > + [Use libwacom for tablet identification > > (default=enabled)]), > > + [use_libwacom="$enableval"], > > + [use_libwacom="yes"]) > > +if test "x$use_libwacom" = "xyes"; then > > + PKG_CHECK_MODULES(LIBWACOM, [libwacom], [HAVE_LIBWACOM="yes"]) > > + AC_DEFINE(HAVE_LIBWACOM, 1, [Build with libwacom]) > > +else > > + HAVE_LIBWACOM="no" > > +fi > > +AC_SUBST(HAVE_LIBWACOM) > > + > > AM_CONDITIONAL(HAVE_VALGRIND, [test "x$VALGRIND" != "x"]) > > AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes"]) > > AM_CONDITIONAL(BUILD_DOCS, [test "x$build_documentation" = "xyes"]) > > @@ -186,6 +199,7 @@ AC_MSG_RESULT([ > > Prefix ${prefix} > > udev base dir ${UDEV_DIR} > > > > + libwacom enabled ${HAVE_LIBWACOM} > > Build documentation ${build_documentation} > > Build tests ${build_tests} > > Tests use valgrind ${VALGRIND} > > diff --git a/src/Makefile.am b/src/Makefile.am > > index 2442794..e807e23 100644 > > --- a/src/Makefile.am > > +++ b/src/Makefile.am > > @@ -31,12 +31,14 @@ libinput_la_SOURCES = \ > > libinput_la_LIBADD = $(MTDEV_LIBS) \ > > $(LIBUDEV_LIBS) \ > > $(LIBEVDEV_LIBS) \ > > + $(LIBWACOM_LIBS) \ > > libinput-util.la > > > > libinput_la_CFLAGS = -I$(top_srcdir)/include \ > > $(MTDEV_CFLAGS) \ > > $(LIBUDEV_CFLAGS) \ > > $(LIBEVDEV_CFLAGS) \ > > + $(LIBWACOM_CFLAGS) \ > > $(GCC_CFLAGS) > > EXTRA_libinput_la_DEPENDENCIES = $(srcdir)/libinput.sym > > > > diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c > > index 479d680..14fb44f 100644 > > --- a/src/evdev-tablet.c > > +++ b/src/evdev-tablet.c > > @@ -27,6 +27,10 @@ > > #include <stdbool.h> > > #include <string.h> > > > > +#if HAVE_LIBWACOM > > +#include <libwacom/libwacom.h> > > +#endif > > + > > #define tablet_set_status(tablet_,s_) (tablet_)->status |= (s_) > > #define tablet_unset_status(tablet_,s_) (tablet_)->status &= ~(s_) > > #define tablet_has_status(tablet_,s_) (!!((tablet_)->status & (s_))) > > @@ -645,6 +649,45 @@ tablet_init(struct tablet_dispatch *tablet, > > return 0; > > } > > > > +static void > > +tablet_init_left_handed(struct evdev_device *device) > > +{ > > +#if HAVE_LIBWACOM > > + struct libinput *libinput = device->base.seat->libinput; > > + WacomDeviceDatabase *db; > > + WacomDevice *d = NULL; > > + WacomError *error; > > + int vid, pid; > > + > > + vid = evdev_device_get_id_vendor(device); > > + pid = evdev_device_get_id_product(device); > > + > > + db = libwacom_database_new(); > > + if (!db) > > + return; > > + error = libwacom_error_new(); > > + d = libwacom_new_from_usbid(db, vid, pid, error); > > + > > + if (d) { > > + if (libwacom_is_reversible(d)) > > + evdev_init_left_handed(device, > > + tablet_change_to_left_handed); > > + } else if (libwacom_error_get_code(error) == WERROR_UNKNOWN_MODEL) { > > + log_info(libinput, "Tablet unknown to libwacom\n"); > > + } else { > > + log_error(libinput, > > + "libwacom error: %s\n", > > + libwacom_error_get_message(error)); > > + } > > + > > + if (error) > > + libwacom_error_free(&error); > > + if (d) > > + libwacom_destroy(d); > > + libwacom_database_destroy(db); > > +#endif > > +} > > + > > struct evdev_dispatch * > > evdev_tablet_create(struct evdev_device *device) > > { > > @@ -659,7 +702,7 @@ evdev_tablet_create(struct evdev_device *device) > > return NULL; > > } > > > > - evdev_init_left_handed(device, tablet_change_to_left_handed); > > + tablet_init_left_handed(device); > > > > return &tablet->base; > > } > > diff --git a/test/tablet.c b/test/tablet.c > > index dc5402f..096c9b2 100644 > > --- a/test/tablet.c > > +++ b/test/tablet.c > > @@ -383,6 +383,7 @@ END_TEST > > > > START_TEST(left_handed) > > { > > +#if HAVE_LIBWACOM > > struct litest_device *dev = litest_current_device(); > > struct libinput *li = dev->libinput; > > struct libinput_event *event; > > @@ -491,6 +492,15 @@ START_TEST(left_handed) > > > > libinput_event_destroy(event); > > } > > +#endif > > +} > > +END_TEST > > + > > +START_TEST(no_left_handed) > > +{ > > + struct litest_device *dev = litest_current_device(); > > + > > + > > ck_assert(!libinput_device_config_left_handed_is_available(dev->libinput_device)); > > } > > END_TEST > > > > @@ -1109,7 +1119,8 @@ main(int argc, char **argv) > > litest_add("tablet:proximity", bad_distance_events, LITEST_TABLET | > > LITEST_DISTANCE, LITEST_ANY); > > litest_add("tablet:motion", motion, LITEST_TABLET, LITEST_ANY); > > litest_add("tablet:motion", motion_event_state, LITEST_TABLET, > > LITEST_ANY); > > - litest_add("tablet:left_handed", left_handed, LITEST_TABLET, > > LITEST_ANY); > > + litest_add_for_device("tablet:left_handed", left_handed, > > LITEST_WACOM_INTUOS); > > + litest_add_for_device("tablet:left_handed", no_left_handed, > > LITEST_WACOM_CINTIQ); > > If libwacom is not available, won't these two tests fail? And do we care?
yes, and no :) if someone wants to write test-cases for the non-libwacom case which I consider an exception they're welcome to do so. Cheers, Peter > > litest_add("tablet:normalization", normalization, LITEST_TABLET, > > LITEST_ANY); > > litest_add("tablet:pad", pad_buttons_ignored, LITEST_TABLET, > > LITEST_ANY); > > > > diff --git a/test/valgrind.suppressions b/test/valgrind.suppressions > > index 3ba7f29..fc9251a 100644 > > --- a/test/valgrind.suppressions > > +++ b/test/valgrind.suppressions > > @@ -7,3 +7,21 @@ > > fun:litest_run > > fun:main > > } > > +{ > > + <g_type_register_static> > > + Memcheck:Leak > > + ... > > + fun:g_type_register_static > > +} > > +{ > > + <g_type_register_static> > > + Memcheck:Leak > > + ... > > + fun:g_type_register_fundamental > > +} > > +{ > > + <g_type_register_static> > > + Memcheck:Leak > > + ... > > + fun:g_malloc0 > > +} > > -- > > 2.1.0 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel