Re: [PATCH v2 libinput 1/5] tablet: move the libwacom check for left-handed-ness into a helper function
On Fri, Apr 15, 2016 at 12:00:25PM +0100, Carlos Garnacho wrote: > Hey!, > > On Mon, Apr 11, 2016 at 5:15 AM, Peter Hutterer > wrote: > > Signed-off-by: Peter Hutterer > > --- > > Changes since v1: > > - new in this version > > > > src/evdev-tablet.c | 38 +- > > src/evdev.c| 52 > > > > src/evdev.h| 3 +++ > > 3 files changed, 56 insertions(+), 37 deletions(-) > > > > diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c > > index 9a1ac52..3c3ebcf 100644 > > --- a/src/evdev-tablet.c > > +++ b/src/evdev-tablet.c > > @@ -1571,45 +1571,9 @@ tablet_init_accel(struct tablet_dispatch *tablet, > > struct evdev_device *device) > > 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; > > - const char *devnode; > > - > > - db = libwacom_database_new(); > > - if (!db) { > > - log_info(libinput, > > -"Failed to initialize libwacom context.\n"); > > - return; > > - } > > - error = libwacom_error_new(); > > - devnode = udev_device_get_devnode(device->udev_device); > > - > > - d = libwacom_new_from_path(db, > > - devnode, > > - WFALLBACK_NONE, > > - error); > > - > > - if (d) { > > - if (libwacom_is_reversible(d)) > > + if (evdev_tablet_has_left_handed(device)) > > 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 > > } > > > > static int > > diff --git a/src/evdev.c b/src/evdev.c > > index 6bb8986..a5511c5 100644 > > --- a/src/evdev.c > > +++ b/src/evdev.c > > @@ -43,6 +43,10 @@ > > #include "filter.h" > > #include "libinput-private.h" > > > > +#if HAVE_LIBWACOM > > +#include > > +#endif > > + > > #define DEFAULT_WHEEL_CLICK_ANGLE 15 > > #define DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT ms2us(200) > > > > @@ -2858,3 +2862,51 @@ evdev_device_destroy(struct evdev_device *device) > > free(device->mt.slots); > > free(device); > > } > > + > > +bool > > +evdev_tablet_has_left_handed(struct evdev_device *device) > > +{ > > +#if HAVE_LIBWACOM > > + struct libinput *libinput = device->base.seat->libinput; > > + WacomDeviceDatabase *db; > > + WacomDevice *d = NULL; > > + WacomError *error; > > + const char *devnode; > > + bool has_left_handed = false; > > + > > + db = libwacom_database_new(); > > + if (!db) { > > + log_info(libinput, > > +"Failed to initialize libwacom context.\n"); > > + goto out; > > + } > > + > > + error = libwacom_error_new(); > > + devnode = udev_device_get_devnode(device->udev_device); > > + > > + d = libwacom_new_from_path(db, > > + devnode, > > + WFALLBACK_NONE, > > + error); > > + > > + if (d) { > > + if (libwacom_is_reversible(d)) > > + has_left_handed = true; > > + } 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); > > + > > +out: > > + return has_left_handed; > > +#endif > > +} > > This function should have a return value (I guess false is safe?) if > HAVE_LIBWACOM is not defined. fixed, thanks. Cheers, Peter ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH v2 libinput 1/5] tablet: move the libwacom check for left-handed-ness into a helper function
Hey!, On Mon, Apr 11, 2016 at 5:15 AM, Peter Hutterer wrote: > Signed-off-by: Peter Hutterer > --- > Changes since v1: > - new in this version > > src/evdev-tablet.c | 38 +- > src/evdev.c| 52 > src/evdev.h| 3 +++ > 3 files changed, 56 insertions(+), 37 deletions(-) > > diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c > index 9a1ac52..3c3ebcf 100644 > --- a/src/evdev-tablet.c > +++ b/src/evdev-tablet.c > @@ -1571,45 +1571,9 @@ tablet_init_accel(struct tablet_dispatch *tablet, > struct evdev_device *device) > 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; > - const char *devnode; > - > - db = libwacom_database_new(); > - if (!db) { > - log_info(libinput, > -"Failed to initialize libwacom context.\n"); > - return; > - } > - error = libwacom_error_new(); > - devnode = udev_device_get_devnode(device->udev_device); > - > - d = libwacom_new_from_path(db, > - devnode, > - WFALLBACK_NONE, > - error); > - > - if (d) { > - if (libwacom_is_reversible(d)) > + if (evdev_tablet_has_left_handed(device)) > 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 > } > > static int > diff --git a/src/evdev.c b/src/evdev.c > index 6bb8986..a5511c5 100644 > --- a/src/evdev.c > +++ b/src/evdev.c > @@ -43,6 +43,10 @@ > #include "filter.h" > #include "libinput-private.h" > > +#if HAVE_LIBWACOM > +#include > +#endif > + > #define DEFAULT_WHEEL_CLICK_ANGLE 15 > #define DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT ms2us(200) > > @@ -2858,3 +2862,51 @@ evdev_device_destroy(struct evdev_device *device) > free(device->mt.slots); > free(device); > } > + > +bool > +evdev_tablet_has_left_handed(struct evdev_device *device) > +{ > +#if HAVE_LIBWACOM > + struct libinput *libinput = device->base.seat->libinput; > + WacomDeviceDatabase *db; > + WacomDevice *d = NULL; > + WacomError *error; > + const char *devnode; > + bool has_left_handed = false; > + > + db = libwacom_database_new(); > + if (!db) { > + log_info(libinput, > +"Failed to initialize libwacom context.\n"); > + goto out; > + } > + > + error = libwacom_error_new(); > + devnode = udev_device_get_devnode(device->udev_device); > + > + d = libwacom_new_from_path(db, > + devnode, > + WFALLBACK_NONE, > + error); > + > + if (d) { > + if (libwacom_is_reversible(d)) > + has_left_handed = true; > + } 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); > + > +out: > + return has_left_handed; > +#endif > +} This function should have a return value (I guess false is safe?) if HAVE_LIBWACOM is not defined. Cheers, Carlos ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH v2 libinput 1/5] tablet: move the libwacom check for left-handed-ness into a helper function
Signed-off-by: Peter Hutterer --- Changes since v1: - new in this version src/evdev-tablet.c | 38 +- src/evdev.c| 52 src/evdev.h| 3 +++ 3 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 9a1ac52..3c3ebcf 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -1571,45 +1571,9 @@ tablet_init_accel(struct tablet_dispatch *tablet, struct evdev_device *device) 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; - const char *devnode; - - db = libwacom_database_new(); - if (!db) { - log_info(libinput, -"Failed to initialize libwacom context.\n"); - return; - } - error = libwacom_error_new(); - devnode = udev_device_get_devnode(device->udev_device); - - d = libwacom_new_from_path(db, - devnode, - WFALLBACK_NONE, - error); - - if (d) { - if (libwacom_is_reversible(d)) + if (evdev_tablet_has_left_handed(device)) 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 } static int diff --git a/src/evdev.c b/src/evdev.c index 6bb8986..a5511c5 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -43,6 +43,10 @@ #include "filter.h" #include "libinput-private.h" +#if HAVE_LIBWACOM +#include +#endif + #define DEFAULT_WHEEL_CLICK_ANGLE 15 #define DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT ms2us(200) @@ -2858,3 +2862,51 @@ evdev_device_destroy(struct evdev_device *device) free(device->mt.slots); free(device); } + +bool +evdev_tablet_has_left_handed(struct evdev_device *device) +{ +#if HAVE_LIBWACOM + struct libinput *libinput = device->base.seat->libinput; + WacomDeviceDatabase *db; + WacomDevice *d = NULL; + WacomError *error; + const char *devnode; + bool has_left_handed = false; + + db = libwacom_database_new(); + if (!db) { + log_info(libinput, +"Failed to initialize libwacom context.\n"); + goto out; + } + + error = libwacom_error_new(); + devnode = udev_device_get_devnode(device->udev_device); + + d = libwacom_new_from_path(db, + devnode, + WFALLBACK_NONE, + error); + + if (d) { + if (libwacom_is_reversible(d)) + has_left_handed = true; + } 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); + +out: + return has_left_handed; +#endif +} diff --git a/src/evdev.h b/src/evdev.h index 4a5d807..f5e7bed 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -454,6 +454,9 @@ int evdev_init_left_handed(struct evdev_device *device, void (*change_to_left_handed)(struct evdev_device *)); +bool +evdev_tablet_has_left_handed(struct evdev_device *device); + static inline uint32_t evdev_to_left_handed(struct evdev_device *device, uint32_t button) -- 2.5.5 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel