mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-04-20 00:10:40 +02:00
tablet: move the libwacom check for left-handed-ness into a helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com> Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
This commit is contained in:
parent
49b8d4ec44
commit
61e58a4c1f
3 changed files with 56 additions and 37 deletions
|
|
@ -1606,45 +1606,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
|
||||
|
|
|
|||
52
src/evdev.c
52
src/evdev.c
|
|
@ -43,6 +43,10 @@
|
|||
#include "filter.h"
|
||||
#include "libinput-private.h"
|
||||
|
||||
#if HAVE_LIBWACOM
|
||||
#include <libwacom/libwacom.h>
|
||||
#endif
|
||||
|
||||
#define DEFAULT_WHEEL_CLICK_ANGLE 15
|
||||
#define DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT ms2us(200)
|
||||
|
||||
|
|
@ -2876,3 +2880,51 @@ evdev_device_destroy(struct evdev_device *device)
|
|||
free(device->mt.slots);
|
||||
free(device);
|
||||
}
|
||||
|
||||
bool
|
||||
evdev_tablet_has_left_handed(struct evdev_device *device)
|
||||
{
|
||||
bool has_left_handed = false;
|
||||
#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");
|
||||
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:
|
||||
#endif
|
||||
return has_left_handed;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -456,6 +456,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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue