wacom: Fall back to the generic tablet provided by libwacom

Whether libwacom knows about a tablet has no effect on whether the
tablet works, only whether we know how to map it, which styli are
available, etc.

Instead of pretending there is no tablet connected let's use the
libwacom fallback tablet instead. As of libwacom 2.11 that defaults to a
built-in tablet (the vast majority of devices these days) which means we
can at least map this to an output, calibrate it etc.
This commit is contained in:
Peter Hutterer 2024-04-12 16:09:10 +10:00 committed by Felipe Borges
parent 59e0d08e56
commit b82621a36c

View file

@ -40,6 +40,8 @@ struct _CcWacomDevice {
GsdDevice *device;
WacomDevice *wdevice;
gboolean is_fallback;
char *description;
};
static void cc_wacom_device_initable_iface_init (GInitableIface *iface);
@ -107,6 +109,7 @@ cc_wacom_device_finalize (GObject *object)
{
CcWacomDevice *device = CC_WACOM_DEVICE (object);
g_clear_pointer (&device->description, g_free);
g_clear_pointer (&device->wdevice, libwacom_destroy);
G_OBJECT_CLASS (cc_wacom_device_parent_class)->finalize (object);
@ -145,6 +148,10 @@ cc_wacom_device_initable_init (GInitable *initable,
node_path = gsd_device_get_device_file (device->device);
wacom_error = libwacom_error_new ();
device->wdevice = libwacom_new_from_path (wacom_db, node_path, WFALLBACK_NONE, wacom_error);
if (!device->wdevice) {
device->wdevice = libwacom_new_from_path (wacom_db, node_path, WFALLBACK_GENERIC, wacom_error);
device->is_fallback = TRUE;
}
if (!device->wdevice) {
g_debug ("libwacom_new_from_path() failed: %s", libwacom_error_get_message (wacom_error));
@ -154,6 +161,15 @@ cc_wacom_device_initable_init (GInitable *initable,
}
libwacom_error_free (&wacom_error);
if (device->is_fallback) {
g_autofree gchar *learn_more_link = NULL;
/* Translators: This will be presented as the text of a link to the documentation */
learn_more_link = g_strdup_printf ("<a href='help:gnome-help/tablet-unknown'>%s</a>", _("learn more"));
/* Translators: %s is a link to the documentation with the label "learn more" */
device->description = g_strdup_printf (_("This device is unknown and may present wrong capabilities — %s."), learn_more_link);
}
return TRUE;
}
@ -419,6 +435,9 @@ cc_wacom_device_get_description (CcWacomDevice *device)
g_return_val_if_fail (CC_IS_WACOM_DEVICE (device), NULL);
if (device->is_fallback)
return device->description;
integration_flags = libwacom_get_integration_flags (device->wdevice);
if (integration_flags & WACOM_DEVICE_INTEGRATED_SYSTEM) {