diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c index e107888a7..bfa12ec4c 100644 --- a/libwacom/libwacom-database.c +++ b/libwacom/libwacom-database.c @@ -1132,11 +1132,10 @@ stylus_compare(WacomStylusId *a, WacomStylusId *b) } static WacomDeviceDatabase * -database_new_for_paths (size_t npaths, const char **datadirs) +database_new_for_paths (char * const *datadirs) { WacomDeviceDatabase *db; - size_t n; - const char **datadir; + char * const *datadir; db = g_new0 (WacomDeviceDatabase, 1); db->device_ht = g_hash_table_new_full (g_str_hash, @@ -1148,12 +1147,12 @@ database_new_for_paths (size_t npaths, const char **datadirs) (GDestroyNotify) g_free, (GDestroyNotify) stylus_destroy); - for (datadir = datadirs, n = npaths; n--; datadir++) { + for (datadir = datadirs; *datadir; datadir++) { if (!load_stylus_files(db, *datadir)) goto error; } - for (datadir = datadirs, n = npaths; n--; datadir++) { + for (datadir = datadirs; *datadir; datadir++) { if (!load_tablet_files(db, *datadir)) goto error; } @@ -1175,18 +1174,27 @@ database_new_for_paths (size_t npaths, const char **datadirs) LIBWACOM_EXPORT WacomDeviceDatabase * libwacom_database_new_for_path (const char *datadir) { - return database_new_for_paths(1, &datadir); + WacomDeviceDatabase *db; + char **paths; + + paths = g_strsplit(datadir, ":", 0); + db = database_new_for_paths(paths); + + g_strfreev(paths); + + return db; } LIBWACOM_EXPORT WacomDeviceDatabase * libwacom_database_new (void) { - const char *datadir[] = { + char *datadir[] = { ETCDIR, DATADIR, + NULL, }; - return database_new_for_paths (2, datadir); + return database_new_for_paths(datadir); } LIBWACOM_EXPORT void diff --git a/libwacom/libwacom.h b/libwacom/libwacom.h index f07ba5f75..2882fcff3 100644 --- a/libwacom/libwacom.h +++ b/libwacom/libwacom.h @@ -354,10 +354,16 @@ WacomDeviceDatabase* libwacom_database_new(void); /** * Loads the Tablet and Stylus databases, to be used - * in libwacom_new_*() functions, from the prefix - * path passes. This is only useful for diagnostics + * in libwacom_new_*() functions, from the datadir + * given in the argument. This is only useful for diagnostics * applications. * + * The datadir must contain the libwacom .tablet files and optionally + * a layouts/ subdirectory for the svg files if any of the .tablet + * files references an svg. + * + * datadir may be a colon-separated list of directories. + * * @return A new database or NULL on error. * * @ingroup context