evdev_tablet_has_left_handed(struct evdev_device *device)
{
	bool has_left_handed = false;
#if HAVE_LIBWACOM
	struct libinput *li = evdev_libinput_context(device);
	WacomDeviceDatabase *db = NULL;
	WacomDevice *d = NULL;
	WacomError *error;
	const char *devnode;

	db = libinput_libwacom_ref(li);
	if (!db)
		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) {
		evdev_log_info(device,
			       "tablet '%s' unknown to libwacom\n",
			       device->devname);
	} else {
		evdev_log_error(device,
				"libwacom error: %s\n",
				libwacom_error_get_message(error));
	}

	if (error)
		libwacom_error_free(&error);
	if (d)
		libwacom_destroy(d);
	if (db)
		libinput_libwacom_unref(li);

out:
#endif
	return has_left_handed;
}
evdev_tablet_has_left_handed(struct evdev_device *device)
{
	bool has_left_handed = false;
#if HAVE_LIBWACOM
	struct libinput *li = evdev_libinput_context(device);
	WacomDeviceDatabase *db = NULL;
	WacomDevice *d = NULL;
	WacomError *error;
	const char *devnode;

	db = libinput_libwacom_ref(li);
	if (!db)
		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) {
		evdev_log_info(device,
			       "tablet '%s' unknown to libwacom\n",
			       device->devname);
	} else {
		evdev_log_error(device,
				"libwacom error: %s\n",
				libwacom_error_get_message(error));
	}

	if (error)
		libwacom_error_free(&error);
	if (d)
		libwacom_destroy(d);
	if (db)
		libinput_libwacom_unref(li);

out:
#endif
	return has_left_handed;
}