On Wed, 2012-04-18 at 14:57 +1000, Peter Hutterer wrote: > Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
Signed-off-by: Bastien Nocera <had...@hadess.net> > --- > libwacom/libwacom.c | 239 > +++++++++++++++++++++++++-------------------------- > libwacom/libwacom.h | 60 ++++++------- > 2 files changed, 149 insertions(+), 150 deletions(-) > > diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c > index a8fcc7e..f8d104a 100644 > --- a/libwacom/libwacom.c > +++ b/libwacom/libwacom.c > @@ -216,130 +216,130 @@ libwacom_copy(const WacomDevice *device) > static const WacomDevice * > libwacom_new (WacomDeviceDatabase *db, int vendor_id, int product_id, > WacomBusType bus, WacomError *error) > { > - const WacomDevice *device; > - char *match; > + const WacomDevice *device; > + char *match; > > - if (!db) { > - libwacom_error_set(error, WERROR_INVALID_DB, "db is NULL"); > - return NULL; > - } > + if (!db) { > + libwacom_error_set(error, WERROR_INVALID_DB, "db is NULL"); > + return NULL; > + } > > - match = make_match_string(bus, vendor_id, product_id); > - device = libwacom_get_device(db, match); > - g_free (match); > + match = make_match_string(bus, vendor_id, product_id); > + device = libwacom_get_device(db, match); > + g_free (match); > > - return device; > + return device; > } > > WacomDevice* > libwacom_new_from_path(WacomDeviceDatabase *db, const char *path, int > fallback, WacomError *error) > { > - int vendor_id, product_id; > - WacomBusType bus; > - const WacomDevice *device; > - WacomDevice *ret; > - IsBuiltin builtin; > - char *name; > - > - if (!db) { > - libwacom_error_set(error, WERROR_INVALID_DB, "db is NULL"); > - return NULL; > - } > - > - if (!path) { > - libwacom_error_set(error, WERROR_INVALID_PATH, "path is NULL"); > - return NULL; > - } > - > - if (!get_device_info (path, &vendor_id, &product_id, &name, &bus, > &builtin, error)) > - return NULL; > - > - device = libwacom_new (db, vendor_id, product_id, bus, error); > - if (device != NULL) > - ret = libwacom_copy(device); > - else if (!fallback) > - goto bail; > - > - if (device == NULL && fallback) { > - device = libwacom_get_device(db, "generic"); > - if (device == NULL) > - goto bail; > - > - ret = libwacom_copy(device); > - > - if (name != NULL) { > - g_free (ret->name); > - ret->name = name; > - } > - } else { > - g_free (name); > - } > - > - /* for multiple-match devices, set to the one we requested */ > - libwacom_update_match(ret, bus, vendor_id, product_id); > - > - if (device) { > - if (builtin == IS_BUILTIN_TRUE) > - ret->features |= FEATURE_BUILTIN; > - else if (builtin == IS_BUILTIN_FALSE) > - ret->features &= ~FEATURE_BUILTIN; > - > - return ret; > - } > + int vendor_id, product_id; > + WacomBusType bus; > + const WacomDevice *device; > + WacomDevice *ret; > + IsBuiltin builtin; > + char *name; > + > + if (!db) { > + libwacom_error_set(error, WERROR_INVALID_DB, "db is NULL"); > + return NULL; > + } > + > + if (!path) { > + libwacom_error_set(error, WERROR_INVALID_PATH, "path is NULL"); > + return NULL; > + } > + > + if (!get_device_info (path, &vendor_id, &product_id, &name, &bus, > &builtin, error)) > + return NULL; > + > + device = libwacom_new (db, vendor_id, product_id, bus, error); > + if (device != NULL) > + ret = libwacom_copy(device); > + else if (!fallback) > + goto bail; > + > + if (device == NULL && fallback) { > + device = libwacom_get_device(db, "generic"); > + if (device == NULL) > + goto bail; > + > + ret = libwacom_copy(device); > + > + if (name != NULL) { > + g_free (ret->name); > + ret->name = name; > + } > + } else { > + g_free (name); > + } > + > + /* for multiple-match devices, set to the one we requested */ > + libwacom_update_match(ret, bus, vendor_id, product_id); > + > + if (device) { > + if (builtin == IS_BUILTIN_TRUE) > + ret->features |= FEATURE_BUILTIN; > + else if (builtin == IS_BUILTIN_FALSE) > + ret->features &= ~FEATURE_BUILTIN; > + > + return ret; > + } > > bail: > - g_free (name); > - libwacom_error_set(error, WERROR_UNKNOWN_MODEL, NULL); > - return NULL; > + g_free (name); > + libwacom_error_set(error, WERROR_UNKNOWN_MODEL, NULL); > + return NULL; > } > > WacomDevice* > libwacom_new_from_usbid(WacomDeviceDatabase *db, int vendor_id, int > product_id, WacomError *error) > { > - const WacomDevice *device; > + const WacomDevice *device; > > - if (!db) { > - libwacom_error_set(error, WERROR_INVALID_DB, "db is NULL"); > - return NULL; > - } > + if (!db) { > + libwacom_error_set(error, WERROR_INVALID_DB, "db is NULL"); > + return NULL; > + } > > - device = libwacom_new(db, vendor_id, product_id, WBUSTYPE_USB, error); > + device = libwacom_new(db, vendor_id, product_id, WBUSTYPE_USB, error); > > - if (device) > - return libwacom_copy(device); > + if (device) > + return libwacom_copy(device); > > - libwacom_error_set(error, WERROR_UNKNOWN_MODEL, NULL); > - return NULL; > + libwacom_error_set(error, WERROR_UNKNOWN_MODEL, NULL); > + return NULL; > } > > WacomDevice* > libwacom_new_from_name(WacomDeviceDatabase *db, const char *name, WacomError > *error) > { > - const WacomDevice *device; > - GList *keys, *l; > + const WacomDevice *device; > + GList *keys, *l; > > - if (!db) { > - libwacom_error_set(error, WERROR_INVALID_DB, "db is NULL"); > - return NULL; > - } > + if (!db) { > + libwacom_error_set(error, WERROR_INVALID_DB, "db is NULL"); > + return NULL; > + } > > - device = NULL; > - keys = g_hash_table_get_values (db->device_ht); > - for (l = keys; l; l = l->next) { > - WacomDevice *d = l->data; > + device = NULL; > + keys = g_hash_table_get_values (db->device_ht); > + for (l = keys; l; l = l->next) { > + WacomDevice *d = l->data; > > - if (g_strcmp0 (d->name, name) == 0) { > - device = d; > - break; > + if (g_strcmp0 (d->name, name) == 0) { > + device = d; > + break; > + } > } > - } > - g_list_free (keys); > + g_list_free (keys); > > - if (device) > - return libwacom_copy(device); > + if (device) > + return libwacom_copy(device); > > - libwacom_error_set(error, WERROR_UNKNOWN_MODEL, NULL); > - return NULL; > + libwacom_error_set(error, WERROR_UNKNOWN_MODEL, NULL); > + return NULL; > } > > void > @@ -395,115 +395,114 @@ libwacom_update_match(WacomDevice *device, > WacomBusType bus, int vendor_id, int > > int libwacom_get_vendor_id(WacomDevice *device) > { > - return device->matches[device->match]->vendor_id; > + return device->matches[device->match]->vendor_id; > } > > const char* libwacom_get_name(WacomDevice *device) > { > - return device->name; > + return device->name; > } > > int libwacom_get_product_id(WacomDevice *device) > { > - return device->matches[device->match]->product_id; > + return device->matches[device->match]->product_id; > } > > const char* libwacom_get_match(WacomDevice *device) > { > - return device->matches[device->match]->match; > + return device->matches[device->match]->match; > } > > WacomMatch** libwacom_get_matches(WacomDevice *device, int *nmatches) > { > - *nmatches = device->nmatches; > - return device->matches; > + *nmatches = device->nmatches; > + return device->matches; > } > > int libwacom_get_width(WacomDevice *device) > { > - return device->width; > + return device->width; > } > > int libwacom_get_height(WacomDevice *device) > { > - return device->height; > + return device->height; > } > > -WacomClass > -libwacom_get_class(WacomDevice *device) > +WacomClass libwacom_get_class(WacomDevice *device) > { > - return device->cls; > + return device->cls; > } > > int libwacom_has_stylus(WacomDevice *device) > { > - return !!(device->features & FEATURE_STYLUS); > + return !!(device->features & FEATURE_STYLUS); > } > > int libwacom_has_touch(WacomDevice *device) > { > - return !!(device->features & FEATURE_TOUCH); > + return !!(device->features & FEATURE_TOUCH); > } > > int libwacom_get_num_buttons(WacomDevice *device) > { > - return device->num_buttons; > + return device->num_buttons; > } > > int *libwacom_get_supported_styli(WacomDevice *device, int *num_styli) > { > - *num_styli = device->num_styli; > - return device->supported_styli; > + *num_styli = device->num_styli; > + return device->supported_styli; > } > > int libwacom_has_ring(WacomDevice *device) > { > - return !!(device->features & FEATURE_RING); > + return !!(device->features & FEATURE_RING); > } > > int libwacom_has_ring2(WacomDevice *device) > { > - return !!(device->features & FEATURE_RING2); > + return !!(device->features & FEATURE_RING2); > } > > int libwacom_get_ring_num_modes(WacomDevice *device) > { > - return device->ring_num_modes; > + return device->ring_num_modes; > } > > int libwacom_get_ring2_num_modes(WacomDevice *device) > { > - return device->ring2_num_modes; > + return device->ring2_num_modes; > } > > int libwacom_get_num_strips(WacomDevice *device) > { > - return device->num_strips; > + return device->num_strips; > } > > int libwacom_get_strips_num_modes(WacomDevice *device) > { > - return device->strips_num_modes; > + return device->strips_num_modes; > } > > int libwacom_is_builtin(WacomDevice *device) > { > - return !!(device->features & FEATURE_BUILTIN); > + return !!(device->features & FEATURE_BUILTIN); > } > > int libwacom_is_reversible(WacomDevice *device) > { > - return !!(device->features & FEATURE_REVERSIBLE); > + return !!(device->features & FEATURE_REVERSIBLE); > } > > WacomBusType libwacom_get_bustype(WacomDevice *device) > { > - return device->matches[device->match]->bus; > + return device->matches[device->match]->bus; > } > > WacomButtonFlags > libwacom_get_button_flag(WacomDevice *device, > - char button) > + char button) > { > int index; > > diff --git a/libwacom/libwacom.h b/libwacom/libwacom.h > index 3fe02dd..6ba96eb 100644 > --- a/libwacom/libwacom.h > +++ b/libwacom/libwacom.h > @@ -95,50 +95,50 @@ typedef struct _WacomDeviceDatabase WacomDeviceDatabase; > * Possible error codes. > */ > enum WacomErrorCode { > - WERROR_NONE, /**< No error has occured */ > - WERROR_BAD_ALLOC, /**< Allocation error */ > - WERROR_INVALID_PATH, /**< A path specified is invalid */ > - WERROR_INVALID_DB, /**< The passed DB is invalid */ > - WERROR_BAD_ACCESS, /**< Invalid permissions to access the > path */ > - WERROR_UNKNOWN_MODEL, /**< Unsupported/unknown device */ > + WERROR_NONE, /**< No error has occured */ > + WERROR_BAD_ALLOC, /**< Allocation error */ > + WERROR_INVALID_PATH, /**< A path specified is invalid */ > + WERROR_INVALID_DB, /**< The passed DB is invalid */ > + WERROR_BAD_ACCESS, /**< Invalid permissions to access the > path */ > + WERROR_UNKNOWN_MODEL, /**< Unsupported/unknown device */ > }; > > /** > * Bus types for tablets. > */ > typedef enum { > - WBUSTYPE_UNKNOWN, /**< Unknown/unsupported bus type */ > - WBUSTYPE_USB, /**< USB tablet */ > - WBUSTYPE_SERIAL, /**< Serial tablet */ > - WBUSTYPE_BLUETOOTH /**< Bluetooth tablet */ > + WBUSTYPE_UNKNOWN, /**< Unknown/unsupported bus type */ > + WBUSTYPE_USB, /**< USB tablet */ > + WBUSTYPE_SERIAL, /**< Serial tablet */ > + WBUSTYPE_BLUETOOTH /**< Bluetooth tablet */ > } WacomBusType; > > /** > * Classes of devices. > */ > typedef enum { > - WCLASS_UNKNOWN, /**< Unknown/unsupported device class */ > - WCLASS_INTUOS3, /**< Any Intuos3 series */ > - WCLASS_INTUOS4, /**< Any Intuos4 series */ > - WCLASS_INTUOS5, /**< Any Intuos5 series */ > - WCLASS_CINTIQ, /**< Any Cintiq device */ > - WCLASS_BAMBOO, /**< Any Bamboo device */ > - WCLASS_GRAPHIRE, /**< Any Graphire device */ > - WCLASS_ISDV4, /**< Any serial ISDV4 device */ > + WCLASS_UNKNOWN, /**< Unknown/unsupported device class */ > + WCLASS_INTUOS3, /**< Any Intuos3 series */ > + WCLASS_INTUOS4, /**< Any Intuos4 series */ > + WCLASS_INTUOS5, /**< Any Intuos5 series */ > + WCLASS_CINTIQ, /**< Any Cintiq device */ > + WCLASS_BAMBOO, /**< Any Bamboo device */ > + WCLASS_GRAPHIRE, /**< Any Graphire device */ > + WCLASS_ISDV4, /**< Any serial ISDV4 device */ > } WacomClass; > > /** > * Class of stylus > */ > typedef enum { > - WSTYLUS_UNKNOWN, > - WSTYLUS_GENERAL, > - WSTYLUS_INKING, > - WSTYLUS_AIRBRUSH, > - WSTYLUS_CLASSIC, > - WSTYLUS_MARKER, > - WSTYLUS_STROKE, > - WSTYLUS_PUCK > + WSTYLUS_UNKNOWN, > + WSTYLUS_GENERAL, > + WSTYLUS_INKING, > + WSTYLUS_AIRBRUSH, > + WSTYLUS_CLASSIC, > + WSTYLUS_MARKER, > + WSTYLUS_STROKE, > + WSTYLUS_PUCK > } WacomStylusType; > > /** > @@ -207,10 +207,10 @@ WacomDeviceDatabase* libwacom_database_new(void); > WacomDeviceDatabase* libwacom_database_new_for_path(const char *datadir); > > /** > - * Free all memory used by the database. > - * > - * @param db A Tablet and Stylus database. > - */ > + * Free all memory used by the database. > + * > + * @param db A Tablet and Stylus database. > + */ > void libwacom_database_destroy(WacomDeviceDatabase *db); > > /** ------------------------------------------------------------------------------ Better than sec? Nothing is better than sec when it comes to monitoring Big Data applications. Try Boundary one-second resolution app monitoring today. Free. http://p.sf.net/sfu/Boundary-dev2dev _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel