On Thu, 2012-04-19 at 09:23 +1000, Peter Hutterer wrote: > On Wed, Apr 18, 2012 at 10:44:39AM +0100, Bastien Nocera wrote: > > On Wed, 2012-04-18 at 14:52 +1000, Peter Hutterer wrote: > > > Don't hardcode a single stylus definition file, scan the directory for > > > .stylus files > > > > What's the use? > > largely for the test-case in the third patchset I've sent out. I'm also not > sure why we have named .tablet files but only one hardcoded .stylus file. > having libwacom just take the same approach for both seems more consistent.
Having separate files for each tablet was necessary given the sheer number of tablets. The stylus definitions are smaller and self-contained. But if this allows for automated testing, I'm all for it. > Cheers, > Peter > > > > > > Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> > > > --- > > > libwacom/libwacom-database.c | 37 +++++++++++++++++++++++++++++++++++-- > > > libwacom/libwacomint.h | 1 - > > > 2 files changed, 35 insertions(+), 3 deletions(-) > > > > > > diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c > > > index 5a6d212..fcc9f03 100644 > > > --- a/libwacom/libwacom-database.c > > > +++ b/libwacom/libwacom-database.c > > > @@ -37,6 +37,7 @@ > > > #include <stdio.h> > > > > > > #define TABLET_SUFFIX ".tablet" > > > +#define STYLUS_SUFFIX ".stylus" > > > #define FEATURES_GROUP "Features" > > > #define DEVICE_GROUP "Device" > > > #define BUTTONS_GROUP "Buttons" > > > @@ -396,6 +397,24 @@ scandir_tablet_filter(const struct dirent *entry) > > > return !strcmp(&name[len - suffix_len], TABLET_SUFFIX); > > > } > > > > > > +static int > > > +scandir_stylus_filter(const struct dirent *entry) > > > +{ > > > + const char *name = entry->d_name; > > > + int len, suffix_len; > > > + > > > + if (!name || name[0] == '.') > > > + return 0; > > > + > > > + len = strlen(name); > > > + suffix_len = strlen(STYLUS_SUFFIX); > > > + if (len <= suffix_len) > > > + return 0; > > > + > > > + return !strcmp(&name[len - suffix_len], STYLUS_SUFFIX); > > > +} > > > + > > > + > > > WacomDeviceDatabase * > > > libwacom_database_new_for_path (const char *datadir) > > > { > > > @@ -435,12 +454,26 @@ libwacom_database_new_for_path (const char *datadir) > > > free(files); > > > > > > /* Load styli */ > > > - path = g_build_filename (datadir, STYLUS_DATA_FILE, NULL); > > > + n = scandir(datadir, &files, scandir_stylus_filter, alphasort); > > > + if (n <= 0) { > > > + libwacom_database_destroy(db); > > > + return NULL; > > > + } > > > + > > > db->stylus_ht = g_hash_table_new_full (g_direct_hash, > > > g_direct_equal, > > > NULL, > > > (GDestroyNotify) > > > libwacom_stylus_destroy); > > > - libwacom_parse_stylus_keyfile(db, path); > > > + nfiles = n; > > > + while(n--) { > > > + path = g_build_filename (datadir, files[n]->d_name, NULL); > > > + libwacom_parse_stylus_keyfile(db, path); > > > + g_free(path); > > > + } > > > + > > > + while(nfiles--) > > > + free(files[nfiles]); > > > + free(files); > > > > > > /* If we couldn't load _anything_ then something's wrong */ > > > if (g_hash_table_size (db->device_ht) == 0 && > > > diff --git a/libwacom/libwacomint.h b/libwacom/libwacomint.h > > > index 66202b0..5dcff6a 100644 > > > --- a/libwacom/libwacomint.h > > > +++ b/libwacom/libwacomint.h > > > @@ -54,7 +54,6 @@ > > > > > > > > > #define GENERIC_DEVICE_MATCH "generic" > > > -#define STYLUS_DATA_FILE "libwacom.stylus" > > > > > > typedef enum { > > > IS_BUILTIN_UNSET = -1, > > > > ------------------------------------------------------------------------------ For Developers, A Lot Can Happen In A Second. Boundary is the first to Know...and Tell You. Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! http://p.sf.net/sfu/Boundary-d2dvs2 _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel