libwacom
Wacom model identification library
libwacom.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2011 Red Hat, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software
5  * and its documentation for any purpose is hereby granted without
6  * fee, provided that the above copyright notice appear in all copies
7  * and that both that copyright notice and this permission notice
8  * appear in supporting documentation, and that the name of Red Hat
9  * not be used in advertising or publicity pertaining to distribution
10  * of the software without specific, written prior permission. Red
11  * Hat makes no representations about the suitability of this software
12  * for any purpose. It is provided "as is" without express or implied
13  * warranty.
14  *
15  * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17  * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Authors:
24  * Peter Hutterer (peter.hutterer@redhat.com)
25  */
26 
27 
29 #ifndef _LIBWACOM_H_
30 #define _LIBWACOM_H_
33 #include <stdint.h>
34 #include <stdio.h>
35 
36 #if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)
37 #define LIBWACOM_DEPRECATED __attribute__((deprecated))
38 #else
39 #define LIBWACOM_DEPRECATED
40 #endif /* __GNUC__ */
41 
95 typedef struct _WacomDevice WacomDevice;
96 
100 typedef struct _WacomBuilder WacomBuilder;
101 
105 typedef struct _WacomMatch WacomMatch;
106 
110 typedef struct _WacomStylus WacomStylus;
111 
115 typedef struct _WacomError WacomError;
116 
120 typedef struct _WacomDeviceDatabase WacomDeviceDatabase;
121 
125 #define WACOM_STYLUS_FALLBACK_ID 0xfffff
129 #define WACOM_ERASER_FALLBACK_ID 0xffffe
130 
144 };
145 
151 typedef enum {
157 } WacomBusType;
158 
164 typedef enum {
169 
178 typedef enum {
191 } WacomClass;
192 
198 typedef enum {
210 
216 typedef enum {
222 
228 typedef enum {
238  WACOM_BUTTON_OLED = (1 << 9),
247 
253 typedef enum {
266 
270 typedef enum {
274 
278 typedef enum {
280  WCOMPARE_MATCHES = (1 << 1),
282 
286 typedef enum {
293 
303 
314 
321 
328 
338 
350 
359 
389 
405 
423 WacomDevice* libwacom_new_from_usbid(const WacomDeviceDatabase *db, int vendor_id, int product_id, WacomError *error);
424 
438 WacomDevice* libwacom_new_from_name(const WacomDeviceDatabase *db, const char *name, WacomError *error);
439 
454 
463 void libwacom_print_device_description (int fd, const WacomDevice *device);
464 
465 
474 
487 
499 
506 const char* libwacom_get_name(const WacomDevice *device);
507 
514 const char* libwacom_get_model_name(const WacomDevice *device);
515 
523 const char* libwacom_get_layout_filename(const WacomDevice *device);
524 
536 
544 const char* libwacom_get_match(const WacomDevice *device);
545 
554 
572 
584 
595 int libwacom_get_width(const WacomDevice *device);
596 
607 int libwacom_get_height(const WacomDevice *device);
608 
615 int libwacom_has_stylus(const WacomDevice *device);
616 
623 int libwacom_has_touch(const WacomDevice *device);
624 
634 
644 
652 const int *libwacom_get_supported_styli(const WacomDevice *device, int *num_styli);
653 
662 
671 
681 
689 
697 
705 
714 
722 
731 
739 
747 
755 const WacomStatusLEDs *libwacom_get_status_leds(const WacomDevice *device, int *num_leds);
756 
766  char button);
767 
777 
786 
794 
802 
811  char button);
812 
822  char button);
823 
834 
842 
849 const char *libwacom_stylus_get_name (const WacomStylus *stylus);
850 
858 const int *libwacom_stylus_get_paired_ids(const WacomStylus *stylus, int *num_paired_ids);
859 
867 
883 
900 
908 
916 
924 
932 
940 
949 void libwacom_print_stylus_description (int fd, const WacomStylus *stylus);
950 
953 const char *libwacom_match_get_name(const WacomMatch *match);
954 const char *libwacom_match_get_uniq(const WacomMatch *match);
958 const char* libwacom_match_get_match_string(const WacomMatch *match);
968 
973 
977 void libwacom_builder_set_usbid(WacomBuilder *builder, int vendor_id, int product_id);
978 
986 void libwacom_builder_set_device_name(WacomBuilder *builder, const char *name);
987 
994 void libwacom_builder_set_match_name(WacomBuilder *builder, const char *name);
995 
999 void libwacom_builder_set_uniq(WacomBuilder *builder, const char *uniq);
1000 
1001 
1003 #endif /* _LIBWACOM_H_ */
1006 /* vim: set noexpandtab tabstop=8 shiftwidth=8: */
WacomError * libwacom_error_new(void)
Allocate a new structure for error reporting.
void libwacom_error_free(WacomError **error)
Free the error and associated memory.
struct _WacomDeviceDatabase WacomDeviceDatabase
Definition: libwacom.h:120
const char * libwacom_error_get_message(WacomError *error)
WacomDeviceDatabase * libwacom_database_new_for_path(const char *datadir)
Loads the Tablet and Stylus databases, to be used in libwacom_new_*() functions, from the prefix path...
enum WacomErrorCode libwacom_error_get_code(WacomError *error)
WacomErrorCode
Possible error codes.
Definition: libwacom.h:136
struct _WacomError WacomError
Definition: libwacom.h:115
WacomDeviceDatabase * libwacom_database_new(void)
Loads the Tablet and Stylus databases, to be used in libwacom_new_*() functions.
void libwacom_database_destroy(WacomDeviceDatabase *db)
Free all memory used by the database.
@ WERROR_NONE
No error has occured.
Definition: libwacom.h:137
@ WERROR_BAD_ALLOC
Allocation error.
Definition: libwacom.h:138
@ WERROR_UNKNOWN_MODEL
Unsupported/unknown device.
Definition: libwacom.h:142
@ WERROR_INVALID_DB
The passed DB is invalid.
Definition: libwacom.h:140
@ WERROR_BUG_CALLER
A bug in the caller.
Definition: libwacom.h:143
@ WERROR_BAD_ACCESS
Invalid permissions to access the path.
Definition: libwacom.h:141
@ WERROR_INVALID_PATH
A path specified is invalid.
Definition: libwacom.h:139
int libwacom_get_dial2_num_modes(const WacomDevice *device)
int libwacom_has_ring2(const WacomDevice *device) LIBWACOM_DEPRECATED
int libwacom_has_stylus(const WacomDevice *device)
WacomDevice ** libwacom_list_devices_from_database(const WacomDeviceDatabase *db, WacomError *error)
Returns the list of devices in the given database.
int libwacom_get_num_strips(const WacomDevice *device)
WacomStatusLEDs
Definition: libwacom.h:286
int libwacom_get_strips_num_modes(const WacomDevice *device)
int libwacom_get_width(const WacomDevice *device)
Retrieve the width of the device.
int libwacom_get_ring_num_modes(const WacomDevice *device)
int libwacom_get_num_dials(const WacomDevice *device)
int libwacom_has_touch(const WacomDevice *device)
int libwacom_has_ring(const WacomDevice *device) LIBWACOM_DEPRECATED
const char * libwacom_match_get_name(const WacomMatch *match)
const char * libwacom_get_layout_filename(const WacomDevice *device)
struct _WacomBuilder WacomBuilder
Definition: libwacom.h:100
const WacomMatch ** libwacom_get_matches(const WacomDevice *device)
const WacomStatusLEDs * libwacom_get_status_leds(const WacomDevice *device, int *num_leds)
int libwacom_get_product_id(const WacomDevice *device)
int libwacom_get_button_led_group(const WacomDevice *device, char button)
void libwacom_print_device_description(int fd, const WacomDevice *device)
Print the description of this device to the given file.
int libwacom_get_vendor_id(const WacomDevice *device)
const WacomMatch * libwacom_get_paired_device(const WacomDevice *device)
Return the match string of the paired device for this device.
void libwacom_destroy(WacomDevice *device)
Remove the device and free all memory and references to it.
WacomButtonFlags
Capabilities of the various tablet buttons.
Definition: libwacom.h:228
int libwacom_get_dial_num_modes(const WacomDevice *device)
const char * libwacom_get_name(const WacomDevice *device)
int libwacom_is_builtin(const WacomDevice *device) LIBWACOM_DEPRECATED
WacomIntegrationFlags libwacom_get_integration_flags(const WacomDevice *device)
WacomIntegrationFlags
Tablet integration.
Definition: libwacom.h:164
WacomDevice * libwacom_new_from_path(const WacomDeviceDatabase *db, const char *path, WacomFallbackFlags fallback, WacomError *error)
Create a new device reference from the given device path.
WacomBusType libwacom_match_get_bustype(const WacomMatch *match)
int libwacom_get_button_evdev_code(const WacomDevice *device, char button)
int libwacom_compare(const WacomDevice *a, const WacomDevice *b, WacomCompareFlags flags)
Compare the two devices for equal-ness.
uint32_t libwacom_match_get_vendor_id(const WacomMatch *match)
WacomCompareFlags
Definition: libwacom.h:278
uint32_t libwacom_match_get_product_id(const WacomMatch *match)
int libwacom_is_reversible(const WacomDevice *device)
WacomBusType libwacom_get_bustype(const WacomDevice *device)
WacomButtonFlags libwacom_get_button_flag(const WacomDevice *device, char button)
WacomClass
Classes of devices.
Definition: libwacom.h:178
WacomBusType
Bus types for tablets.
Definition: libwacom.h:151
WacomFallbackFlags
Definition: libwacom.h:270
int libwacom_get_num_buttons(const WacomDevice *device)
Tablet buttons are numbered 'A' through to 'A' + number of buttons.
int libwacom_get_height(const WacomDevice *device)
Retrieve the height of the device.
const char * libwacom_get_model_name(const WacomDevice *device)
LIBWACOM_DEPRECATED WacomClass libwacom_get_class(const WacomDevice *device)
WacomDevice * libwacom_new_from_builder(const WacomDeviceDatabase *db, const WacomBuilder *builder, WacomFallbackFlags fallback, WacomError *error)
Create a new device reference for the given builder.
const char * libwacom_match_get_uniq(const WacomMatch *match)
int libwacom_get_num_keys(const WacomDevice *device)
Tablet keys indices are numbered from zero.
int libwacom_get_ring2_num_modes(const WacomDevice *device)
int libwacom_has_touchswitch(const WacomDevice *device)
struct _WacomMatch WacomMatch
Definition: libwacom.h:105
struct _WacomDevice WacomDevice
Definition: libwacom.h:95
WacomDevice * libwacom_new_from_usbid(const WacomDeviceDatabase *db, int vendor_id, int product_id, WacomError *error)
Create a new device reference from the given vendor/product IDs.
WacomDevice * libwacom_new_from_name(const WacomDeviceDatabase *db, const char *name, WacomError *error)
Create a new device reference from the given name.
const char * libwacom_get_match(const WacomDevice *device)
const char * libwacom_match_get_match_string(const WacomMatch *match)
int libwacom_get_num_rings(const WacomDevice *device)
@ WACOM_STATUS_LED_TOUCHSTRIP2
Definition: libwacom.h:291
@ WACOM_STATUS_LED_UNAVAILABLE
Definition: libwacom.h:287
@ WACOM_STATUS_LED_RING
Definition: libwacom.h:288
@ WACOM_STATUS_LED_RING2
Definition: libwacom.h:289
@ WACOM_STATUS_LED_TOUCHSTRIP
Definition: libwacom.h:290
@ WACOM_BUTTON_POSITION_BOTTOM
Definition: libwacom.h:233
@ WACOM_BUTTON_TOUCHSTRIPS_MODESWITCH
Definition: libwacom.h:244
@ WACOM_BUTTON_NONE
Definition: libwacom.h:229
@ WACOM_BUTTON_RINGS_MODESWITCH
Definition: libwacom.h:243
@ WACOM_BUTTON_DIRECTION
Definition: libwacom.h:242
@ WACOM_BUTTON_TOUCHSTRIP2_MODESWITCH
Definition: libwacom.h:237
@ WACOM_BUTTON_POSITION_TOP
Definition: libwacom.h:232
@ WACOM_BUTTON_RING2_MODESWITCH
Definition: libwacom.h:235
@ WACOM_BUTTON_DIALS_MODESWITCH
Definition: libwacom.h:245
@ WACOM_BUTTON_POSITION_LEFT
Definition: libwacom.h:230
@ WACOM_BUTTON_POSITION_RIGHT
Definition: libwacom.h:231
@ WACOM_BUTTON_MODESWITCH
Definition: libwacom.h:241
@ WACOM_BUTTON_DIAL2_MODESWITCH
Definition: libwacom.h:240
@ WACOM_BUTTON_OLED
Definition: libwacom.h:238
@ WACOM_BUTTON_TOUCHSTRIP_MODESWITCH
Definition: libwacom.h:236
@ WACOM_BUTTON_RING_MODESWITCH
Definition: libwacom.h:234
@ WACOM_BUTTON_DIAL_MODESWITCH
Definition: libwacom.h:239
@ WACOM_DEVICE_INTEGRATED_DISPLAY
Definition: libwacom.h:166
@ WACOM_DEVICE_INTEGRATED_NONE
Definition: libwacom.h:165
@ WACOM_DEVICE_INTEGRATED_SYSTEM
Definition: libwacom.h:167
@ WCOMPARE_NORMAL
compare the device only
Definition: libwacom.h:279
@ WCOMPARE_MATCHES
compare all possible matches too
Definition: libwacom.h:280
@ WCLASS_INTUOS3
Any Intuos3 series.
Definition: libwacom.h:180
@ WCLASS_REMOTE
Any Wacom Remote.
Definition: libwacom.h:190
@ WCLASS_CINTIQ
Any Cintiq device.
Definition: libwacom.h:183
@ WCLASS_UNKNOWN
Unknown/unsupported device class.
Definition: libwacom.h:179
@ WCLASS_INTUOS2
Any Intuos2 series.
Definition: libwacom.h:188
@ WCLASS_GRAPHIRE
Any Graphire device.
Definition: libwacom.h:185
@ WCLASS_INTUOS5
Any Intuos5 series.
Definition: libwacom.h:182
@ WCLASS_INTUOS
Any Intuos series.
Definition: libwacom.h:187
@ WCLASS_PEN_DISPLAYS
Any "interactive pen display".
Definition: libwacom.h:189
@ WCLASS_ISDV4
Any serial ISDV4 device.
Definition: libwacom.h:186
@ WCLASS_INTUOS4
Any Intuos4 series.
Definition: libwacom.h:181
@ WCLASS_BAMBOO
Any Bamboo device.
Definition: libwacom.h:184
@ WBUSTYPE_I2C
I2C tablet.
Definition: libwacom.h:156
@ WBUSTYPE_USB
USB tablet.
Definition: libwacom.h:153
@ WBUSTYPE_UNKNOWN
Unknown/unsupported bus type.
Definition: libwacom.h:152
@ WBUSTYPE_SERIAL
Serial tablet.
Definition: libwacom.h:154
@ WBUSTYPE_BLUETOOTH
Bluetooth tablet.
Definition: libwacom.h:155
@ WFALLBACK_GENERIC
Definition: libwacom.h:272
@ WFALLBACK_NONE
Definition: libwacom.h:271
WacomStylusType libwacom_stylus_get_type(const WacomStylus *stylus)
int libwacom_stylus_has_wheel(const WacomStylus *stylus)
WacomAxisTypeFlags libwacom_stylus_get_axes(const WacomStylus *stylus)
const WacomStylus * libwacom_stylus_get_for_id(const WacomDeviceDatabase *db, int id)
Get the WacomStylus for the given tool ID.
int libwacom_stylus_has_lens(const WacomStylus *stylus)
int libwacom_stylus_get_id(const WacomStylus *stylus)
WacomEraserType
Type of eraser on a stylus.
Definition: libwacom.h:216
const char * libwacom_stylus_get_name(const WacomStylus *stylus)
WacomStylusType
Class of stylus.
Definition: libwacom.h:198
WacomEraserType libwacom_stylus_get_eraser_type(const WacomStylus *stylus)
void libwacom_print_stylus_description(int fd, const WacomStylus *stylus)
Print the description of this stylus to the given file.
int libwacom_stylus_has_eraser(const WacomStylus *stylus)
Check if the given stylus is paired with a separate eraser.
const int * libwacom_stylus_get_paired_ids(const WacomStylus *stylus, int *num_paired_ids)
int libwacom_stylus_get_num_buttons(const WacomStylus *stylus)
const int * libwacom_get_supported_styli(const WacomDevice *device, int *num_styli)
struct _WacomStylus WacomStylus
Definition: libwacom.h:110
int libwacom_stylus_is_eraser(const WacomStylus *stylus)
Check if the given stylus may act like an eraser.
WacomAxisTypeFlags
Axis type for a stylus.
Definition: libwacom.h:253
@ WACOM_ERASER_UNKNOWN
Definition: libwacom.h:217
@ WACOM_ERASER_NONE
No eraser is present on the stylus.
Definition: libwacom.h:218
@ WACOM_ERASER_BUTTON
Eraser is a button alongside any other stylus buttons.
Definition: libwacom.h:220
@ WACOM_ERASER_INVERT
Eraser is a separate tool on the opposite end of the stylus.
Definition: libwacom.h:219
@ WSTYLUS_MARKER
Definition: libwacom.h:204
@ WSTYLUS_AIRBRUSH
Definition: libwacom.h:202
@ WSTYLUS_3D
Definition: libwacom.h:207
@ WSTYLUS_MOBILE
Definition: libwacom.h:208
@ WSTYLUS_CLASSIC
Definition: libwacom.h:203
@ WSTYLUS_INKING
Definition: libwacom.h:201
@ WSTYLUS_GENERAL
Definition: libwacom.h:200
@ WSTYLUS_STROKE
Definition: libwacom.h:205
@ WSTYLUS_PUCK
Definition: libwacom.h:206
@ WSTYLUS_UNKNOWN
Definition: libwacom.h:199
@ WACOM_AXIS_TYPE_NONE
Definition: libwacom.h:254
@ WACOM_AXIS_TYPE_ROTATION_Z
Rotation in the z-axis.
Definition: libwacom.h:258
@ WACOM_AXIS_TYPE_PRESSURE
Tip pressure.
Definition: libwacom.h:262
@ WACOM_AXIS_TYPE_SLIDER
A absolute-position slider like the wheel on the airbrush.
Definition: libwacom.h:264
@ WACOM_AXIS_TYPE_TILT
Tilt in x and y direction.
Definition: libwacom.h:256
@ WACOM_AXIS_TYPE_DISTANCE
Distance to surface.
Definition: libwacom.h:260
void libwacom_builder_set_uniq(WacomBuilder *builder, const char *uniq)
Change the uniq to the given uniq, overriding the currently set one (if any).
void libwacom_builder_set_usbid(WacomBuilder *builder, int vendor_id, int product_id)
Change the vendor and product id to the given ids, overriding the currently set ones (if any).
void libwacom_builder_set_bustype(WacomBuilder *builder, WacomBusType bustype)
Change the bustype to the given bustype, overriding the currently set one (if any).
void libwacom_builder_set_match_name(WacomBuilder *builder, const char *name)
Change the match name to the given name, overriding the currently set one (if any).
WacomBuilder * libwacom_builder_new(void)
Create a new builder to be used into libwacom_new_from_builder().
void libwacom_builder_destroy(WacomBuilder *builder)
void libwacom_builder_set_device_name(WacomBuilder *builder, const char *name)
Change the device name to the given name, overriding the currently set one (if any).
#define LIBWACOM_DEPRECATED
Definition: libwacom.h:39