mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 18:10:28 +01:00
udev: check wacom devices for a paired product id
The newer Wacom Cintiqs have touch devices with a different PID than the pen device. Use the new libwacom_get_paired_device call where available to pair the two devices and give them the same device group. This isn't that important just yet, so no need to force users to update to a new libwacom version. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
parent
90f6e43562
commit
8a8c72983f
3 changed files with 89 additions and 3 deletions
19
configure.ac
19
configure.ac
|
|
@ -208,7 +208,26 @@ AC_ARG_ENABLE(libwacom,
|
|||
if test "x$use_libwacom" = "xyes"; then
|
||||
PKG_CHECK_MODULES(LIBWACOM, [libwacom >= 0.12], [HAVE_LIBWACOM="yes"])
|
||||
AC_DEFINE(HAVE_LIBWACOM, 1, [Build with libwacom])
|
||||
|
||||
OLD_LIBS=$LIBS
|
||||
OLD_CFLAGS=$CFLAGS
|
||||
LIBS="$LIBS $LIBWACOM_LIBS"
|
||||
CFLAGS="$CFLAGS $LIBWACOM_CFLAGS"
|
||||
AC_MSG_CHECKING([if libwacom_get_paired_device is available])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[#include <libwacom/libwacom.h>]],
|
||||
[[libwacom_get_paired_device(NULL)]])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
AC_DEFINE(HAVE_LIBWACOM_GET_PAIRED_DEVICE, [1],
|
||||
[libwacom_get_paired_device() is available])
|
||||
[libwacom_have_get_paired_device=yes]],
|
||||
[AC_MSG_RESULT([no])
|
||||
[libwacom_have_get_paired_device=no]])
|
||||
LIBS=$OLD_LIBS
|
||||
CFLAGS=$OLD_CFLAGS
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_LIBWACOM_GET_PAIRED_DEVICE,
|
||||
[test "x$libwacom_have_get_paired_device" == "xyes"])
|
||||
|
||||
AM_CONDITIONAL(HAVE_VALGRIND, [test "x$VALGRIND" != "x"])
|
||||
AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes"])
|
||||
|
|
|
|||
|
|
@ -7,9 +7,16 @@ litest_rules = 80-libinput-device-groups-litest.rules \
|
|||
noinst_SCRIPTS = $(litest_rules)
|
||||
|
||||
libinput_device_group_SOURCES = libinput-device-group.c
|
||||
libinput_device_group_CFLAGS = $(LIBUDEV_CFLAGS) $(GCC_CFLAGS)
|
||||
libinput_device_group_CFLAGS = -I$(top_srcdir)/src \
|
||||
$(LIBUDEV_CFLAGS) \
|
||||
$(GCC_CFLAGS)
|
||||
libinput_device_group_LDADD = $(LIBUDEV_LIBS)
|
||||
|
||||
if HAVE_LIBWACOM_GET_PAIRED_DEVICE
|
||||
libinput_device_group_CFLAGS += $(LIBWACOM_CFLAGS)
|
||||
libinput_device_group_LDADD += $(LIBWACOM_LIBS)
|
||||
endif
|
||||
|
||||
libinput_model_quirks_SOURCES = libinput-model-quirks.c
|
||||
libinput_model_quirks_CFLAGS = \
|
||||
-I$(top_srcdir)/src \
|
||||
|
|
|
|||
|
|
@ -21,11 +21,49 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libudev.h>
|
||||
|
||||
#include "libinput-util.h"
|
||||
|
||||
#if HAVE_LIBWACOM_GET_PAIRED_DEVICE
|
||||
#include <libwacom/libwacom.h>
|
||||
|
||||
static void
|
||||
wacom_handle_paired(struct udev_device *device,
|
||||
int *vendor_id,
|
||||
int *product_id)
|
||||
{
|
||||
WacomDeviceDatabase *db = NULL;
|
||||
WacomDevice *tablet = NULL;
|
||||
const WacomMatch *paired;
|
||||
|
||||
db = libwacom_database_new();
|
||||
if (!db)
|
||||
goto out;
|
||||
|
||||
tablet = libwacom_new_from_usbid(db, *vendor_id, *product_id, NULL);
|
||||
if (!tablet)
|
||||
goto out;
|
||||
paired = libwacom_get_paired_device(tablet);
|
||||
if (!paired)
|
||||
goto out;
|
||||
|
||||
*vendor_id = libwacom_match_get_vendor_id(paired);
|
||||
*product_id = libwacom_match_get_product_id(paired);
|
||||
|
||||
out:
|
||||
if (tablet)
|
||||
libwacom_destroy(tablet);
|
||||
if (db)
|
||||
libwacom_database_destroy(db);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int rc = 1;
|
||||
|
|
@ -34,6 +72,7 @@ int main(int argc, char **argv)
|
|||
const char *syspath,
|
||||
*phys = NULL;
|
||||
const char *product;
|
||||
int bustype, vendor_id, product_id, version;
|
||||
char group[1024];
|
||||
char *str;
|
||||
|
||||
|
|
@ -73,8 +112,29 @@ int main(int argc, char **argv)
|
|||
on that*/
|
||||
product = udev_device_get_property_value(device, "PRODUCT");
|
||||
if (!product)
|
||||
product = "";
|
||||
snprintf(group, sizeof(group), "%s:%s", product, phys);
|
||||
product = "00/00/00/00";
|
||||
|
||||
if (sscanf(product,
|
||||
"%x/%x/%x/%x",
|
||||
&bustype,
|
||||
&vendor_id,
|
||||
&product_id,
|
||||
&version) != 4) {
|
||||
snprintf(group, sizeof(group), "%s:%s", product, phys);
|
||||
} else {
|
||||
#if HAVE_LIBWACOM_GET_PAIRED_DEVICE
|
||||
if (vendor_id == VENDOR_ID_WACOM)
|
||||
wacom_handle_paired(device, &vendor_id, &product_id);
|
||||
#endif
|
||||
snprintf(group,
|
||||
sizeof(group),
|
||||
"%x/%x/%x/%x:%s",
|
||||
bustype,
|
||||
vendor_id,
|
||||
product_id,
|
||||
version,
|
||||
phys);
|
||||
}
|
||||
|
||||
str = strstr(group, "/input");
|
||||
if (str)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue