Re: [Linuxwacom-devel] [PATCH] lib: use kernel flags if available
On Fri, Oct 12, 2012 at 2:41 AM, Olivier Fourdan ofour...@redhat.com wrote: Peter Hutterer said the following on 10/12/2012 06:37 AM: [...] + *builtin = (flag (direct_flag | pointer_flag) == direct_flag) + ? IS_BUILTIN_TRUE : IS_BUILTIN_FALSE; please expand this to a normal condition - this is too nested to be easily readable. Updated patch attached. Got rid of the 2 additional vars as they did not really help with readability. Cheers, Olivier. + if (flag == (1 INPUT_PROP_DIRECT)) + *builtin = IS_BUILTIN_TRUE; + else + *builtin = IS_BUILTIN_FALSE; + Not quite correct, since there could be properties added in the future whose bits we'd need to set in addition to INPUT_PROP_DIRECT. Third time's the charm? Jason --- When you're rife with devastation / There's a simple explanation: You're a toymaker's creation / Trapped inside a crystal ball. And whichever way he tilts it / Know that we must be resilient We won't let them break our spirits / As we sing our silly song. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
Re: [Linuxwacom-devel] [PATCH] lib: use kernel flags if available
Jason Gerecke said the following on 10/12/2012 06:43 PM: On Fri, Oct 12, 2012 at 2:41 AM, Olivier Fourdanofour...@redhat.com wrote: Peter Hutterer said the following on 10/12/2012 06:37 AM: [...] + *builtin = (flag (direct_flag | pointer_flag) == direct_flag) + ? IS_BUILTIN_TRUE : IS_BUILTIN_FALSE; please expand this to a normal condition - this is too nested to be easily readable. Updated patch attached. Got rid of the 2 additional vars as they did not really help with readability. Cheers, Olivier. +if (flag == (1 INPUT_PROP_DIRECT)) +*builtin = IS_BUILTIN_TRUE; +else +*builtin = IS_BUILTIN_FALSE; + Not quite correct, since there could be properties added in the future whose bits we'd need to set in addition to INPUT_PROP_DIRECT. Third time's the charm? You may have cut too much out and missed the = on flag mask just before: + flag= (1 INPUT_PROP_DIRECT) | (1 INPUT_PROP_POINTER); + if (flag == (1 INPUT_PROP_DIRECT)) + *builtin = IS_BUILTIN_TRUE; + else + *builtin = IS_BUILTIN_FALSE; + So it should be correct :) Cheers, Olivier -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
Re: [Linuxwacom-devel] [PATCH] lib: use kernel flags if available
On Fri, Oct 12, 2012 at 10:52 AM, Olivier Fourdan ofour...@redhat.com wrote: Jason Gerecke said the following on 10/12/2012 06:43 PM: On Fri, Oct 12, 2012 at 2:41 AM, Olivier Fourdanofour...@redhat.com wrote: Peter Hutterer said the following on 10/12/2012 06:37 AM: [...] + *builtin = (flag (direct_flag | pointer_flag) == direct_flag) + ? IS_BUILTIN_TRUE : IS_BUILTIN_FALSE; please expand this to a normal condition - this is too nested to be easily readable. Updated patch attached. Got rid of the 2 additional vars as they did not really help with readability. Cheers, Olivier. + if (flag == (1 INPUT_PROP_DIRECT)) + *builtin = IS_BUILTIN_TRUE; + else + *builtin = IS_BUILTIN_FALSE; + Not quite correct, since there could be properties added in the future whose bits we'd need to set in addition to INPUT_PROP_DIRECT. Third time's the charm? You may have cut too much out and missed the = on flag mask just before: + flag= (1 INPUT_PROP_DIRECT) | (1 INPUT_PROP_POINTER); + if (flag == (1 INPUT_PROP_DIRECT)) + *builtin = IS_BUILTIN_TRUE; + else + *builtin = IS_BUILTIN_FALSE; + So it should be correct :) Cheers, Olivier Whoops! You're right, of course :) Jason --- When you're rife with devastation / There's a simple explanation: You're a toymaker's creation / Trapped inside a crystal ball. And whichever way he tilts it / Know that we must be resilient We won't let them break our spirits / As we sing our silly song. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
[Linuxwacom-devel] [PATCH] lib: use kernel flags if available
As discussed on the mailing list, replace the cryptic hex values with bit shifts from linux/input.h (if available, adds a check to configure.ac for that as well). From 6083b1e619d35d98ba5339baeef50ffb1590a957 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan ofour...@redhat.com Date: Thu, 11 Oct 2012 10:32:10 +0200 Subject: [PATCH] lib: use kernel flags if available to identify screen tablets if not set in the database. To properly ensure that you're getting a touchscreen, check DIRECT flag is set but not POINTER. Signed-off-by: Olivier Fourdan ofour...@redhat.com --- configure.ac|1 + libwacom/libwacom.c | 20 +--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 432f0e7..64571ef 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,7 @@ AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no]) AM_CONDITIONAL(HAVE_DOXYGEN, test x$HAVE_DOXYGEN = xyes) PKG_CHECK_MODULES(GLIB, glib-2.0 gudev-1.0) +AC_CHECK_HEADERS(linux/input.h) AC_CONFIG_FILES([Makefile data/Makefile diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c index fe850a2..e380d83 100644 --- a/libwacom/libwacom.c +++ b/libwacom/libwacom.c @@ -34,6 +34,19 @@ #include string.h #include gudev/gudev.h +#ifdef HAVE_LINUX_INPUT_H +#include linux/input.h +#endif + +/* Defined in linux/input.h but older versions may be missing these definitions */ +#ifndef INPUT_PROP_POINTER +#define INPUT_PROP_POINTER 0x00 /* needs a pointer */ +#endif + +#ifndef INPUT_PROP_DIRECT +#define INPUT_PROP_DIRECT 0x01 /* direct input devices */ +#endif + static const WacomDevice * libwacom_get_device(WacomDeviceDatabase *db, const char *match) { @@ -162,11 +175,12 @@ get_device_info (const char *path, sysfs_path = g_build_filename (/sys/class/input, devname, device/properties, NULL); if (g_file_get_contents (sysfs_path, contents, NULL, NULL)) { int flag; + int direct_flag = (1 INPUT_PROP_DIRECT); + int pointer_flag = (1 INPUT_PROP_POINTER); - /* 0x01: POINTER flag - * 0x02: DIRECT flag */ flag = atoi(contents); - *builtin = (flag 0x02) == 0x02 ? IS_BUILTIN_TRUE : IS_BUILTIN_FALSE; + *builtin = (flag (direct_flag | pointer_flag) == direct_flag) + ? IS_BUILTIN_TRUE : IS_BUILTIN_FALSE; g_free (contents); } g_free (sysfs_path); -- 1.7.1 -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
Re: [Linuxwacom-devel] [PATCH] lib: use kernel flags if available
On Thu, Oct 11, 2012 at 10:37:45AM +0200, Olivier Fourdan wrote: As discussed on the mailing list, replace the cryptic hex values with bit shifts from linux/input.h (if available, adds a check to configure.ac for that as well). From 6083b1e619d35d98ba5339baeef50ffb1590a957 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan ofour...@redhat.com Date: Thu, 11 Oct 2012 10:32:10 +0200 Subject: [PATCH] lib: use kernel flags if available to identify screen tablets if not set in the database. To properly ensure that you're getting a touchscreen, check DIRECT flag is set but not POINTER. Signed-off-by: Olivier Fourdan ofour...@redhat.com --- configure.ac|1 + libwacom/libwacom.c | 20 +--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 432f0e7..64571ef 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,7 @@ AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no]) AM_CONDITIONAL(HAVE_DOXYGEN, test x$HAVE_DOXYGEN = xyes) PKG_CHECK_MODULES(GLIB, glib-2.0 gudev-1.0) +AC_CHECK_HEADERS(linux/input.h) AC_CONFIG_FILES([Makefile data/Makefile diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c index fe850a2..e380d83 100644 --- a/libwacom/libwacom.c +++ b/libwacom/libwacom.c @@ -34,6 +34,19 @@ #include string.h #include gudev/gudev.h +#ifdef HAVE_LINUX_INPUT_H +#include linux/input.h +#endif + +/* Defined in linux/input.h but older versions may be missing these definitions */ +#ifndef INPUT_PROP_POINTER +#define INPUT_PROP_POINTER 0x00/* needs a pointer */ +#endif + +#ifndef INPUT_PROP_DIRECT +#define INPUT_PROP_DIRECT0x01/* direct input devices */ +#endif + static const WacomDevice * libwacom_get_device(WacomDeviceDatabase *db, const char *match) { @@ -162,11 +175,12 @@ get_device_info (const char *path, sysfs_path = g_build_filename (/sys/class/input, devname, device/properties, NULL); if (g_file_get_contents (sysfs_path, contents, NULL, NULL)) { int flag; + int direct_flag = (1 INPUT_PROP_DIRECT); + int pointer_flag = (1 INPUT_PROP_POINTER); - /* 0x01: POINTER flag - * 0x02: DIRECT flag */ flag = atoi(contents); - *builtin = (flag 0x02) == 0x02 ? IS_BUILTIN_TRUE : IS_BUILTIN_FALSE; + *builtin = (flag (direct_flag | pointer_flag) == direct_flag) + ? IS_BUILTIN_TRUE : IS_BUILTIN_FALSE; please expand this to a normal condition - this is too nested to be easily readable. Cheers, Peter g_free (contents); } g_free (sysfs_path); -- 1.7.1 -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel