libwacom
Wacom model identification library
Loading...
Searching...
No Matches
libwacom context

Functions to create and manage libwacom context. More...

Typedefs

typedef struct _WacomError WacomError
 
typedef struct _WacomDeviceDatabase WacomDeviceDatabase
 

Enumerations

enum  WacomErrorCode {
  WERROR_NONE , WERROR_BAD_ALLOC , WERROR_INVALID_PATH , WERROR_INVALID_DB ,
  WERROR_BAD_ACCESS , WERROR_UNKNOWN_MODEL , WERROR_BUG_CALLER
}
 Possible error codes. More...
 

Functions

WacomErrorlibwacom_error_new (void)
 Allocate a new structure for error reporting.
 
void libwacom_error_free (WacomError **error)
 Free the error and associated memory.
 
enum WacomErrorCode libwacom_error_get_code (WacomError *error)
 
const char * libwacom_error_get_message (WacomError *error)
 
WacomDeviceDatabaselibwacom_database_new (void)
 Loads the Tablet and Stylus databases, to be used in libwacom_new_*() functions.
 
WacomDeviceDatabaselibwacom_database_new_for_path (const char *datadir)
 Loads the Tablet and Stylus databases, to be used in libwacom_new_*() functions, from the datadir given in the argument.
 
void libwacom_database_destroy (WacomDeviceDatabase *db)
 Free all memory used by the database.
 
WacomDeviceDatabaselibwacom_database_ref (WacomDeviceDatabase *db)
 Increase the refcount of the database by one.
 
WacomDeviceDatabaselibwacom_database_unref (WacomDeviceDatabase *db)
 Decrease the refcount of the database by one.
 

Detailed Description

Functions to create and manage libwacom context.

Typedef Documentation

◆ WacomDeviceDatabase

typedef struct _WacomDeviceDatabase WacomDeviceDatabase

◆ WacomError

typedef struct _WacomError WacomError

Enumeration Type Documentation

◆ WacomErrorCode

Possible error codes.

Enumerator
WERROR_NONE 

No error has occurred.

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_BUG_CALLER 

A bug in the caller.

Function Documentation

◆ libwacom_database_destroy()

void libwacom_database_destroy ( WacomDeviceDatabase db)

Free all memory used by the database.

This call is equivalent to libwacom_database_unref() and assumes the caller only has one reference to the database. If the caller obtained multiple references using libwacom_database_ref(), libwacom_database_unref() should be used instead.

Parameters
dbA Tablet and Stylus database.

◆ libwacom_database_new()

WacomDeviceDatabase * libwacom_database_new ( void  )

Loads the Tablet and Stylus databases, to be used in libwacom_new_*() functions.

Returns
A new database or NULL on error.

◆ libwacom_database_new_for_path()

WacomDeviceDatabase * libwacom_database_new_for_path ( const char *  datadir)

Loads the Tablet and Stylus databases, to be used 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.

Returns
A new database or NULL on error.

◆ libwacom_database_ref()

WacomDeviceDatabase * libwacom_database_ref ( WacomDeviceDatabase db)

Increase the refcount of the database by one.

Parameters
dbA Tablet and Stylus database.
Returns
The database passed in as argument.
Since
2.19

◆ libwacom_database_unref()

WacomDeviceDatabase * libwacom_database_unref ( WacomDeviceDatabase db)

Decrease the refcount of the database by one.

Once the refcount hits zero, all memory used by the database is released.

Parameters
dbA Tablet and Stylus database.
Returns
Always NULL.
Since
2.19

◆ libwacom_error_free()

void libwacom_error_free ( WacomError **  error)

Free the error and associated memory.

Resets error to NULL.

Parameters
errorA reference to a error struct.
See also
libwacom_error_new

◆ libwacom_error_get_code()

enum WacomErrorCode libwacom_error_get_code ( WacomError error)
Returns
The code for this error.

◆ libwacom_error_get_message()

const char * libwacom_error_get_message ( WacomError error)
Returns
A human-readable message for this error

◆ libwacom_error_new()

WacomError * libwacom_error_new ( void  )

Allocate a new structure for error reporting.

Returns
A newly allocated error structure or NULL if the allocation failed.