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 
85 typedef struct _WacomDevice WacomDevice;
86 
87 typedef struct _WacomMatch WacomMatch;
88 
89 typedef struct _WacomStylus WacomStylus;
90 
91 typedef struct _WacomError WacomError;
92 
93 typedef struct _WacomDeviceDatabase WacomDeviceDatabase;
94 
95 #define WACOM_STYLUS_FALLBACK_ID 0xfffff
96 #define WACOM_ERASER_FALLBACK_ID 0xffffe
97 
109 };
110 
114 typedef enum {
120 } WacomBusType;
121 
125 typedef enum {
130 
137 typedef enum {
150 } WacomClass;
151 
155 typedef enum {
167 
171 typedef enum {
177 
181 typedef enum {
191  WACOM_BUTTON_OLED = (1 << 9),
197 
201 typedef enum {
214 
215 typedef enum {
219 
220 typedef enum {
222  WCOMPARE_MATCHES = (1 << 1),
224 
225 typedef enum {
232 
240 
249 
254 
259 
267 
277 
284 
298 
314 WacomDevice* libwacom_new_from_usbid(const WacomDeviceDatabase *db, int vendor_id, int product_id, WacomError *error);
315 
327 WacomDevice* libwacom_new_from_name(const WacomDeviceDatabase *db, const char *name, WacomError *error);
328 
341 
348 void libwacom_print_device_description (int fd, const WacomDevice *device);
349 
350 
357 
368 
378 
383 const char* libwacom_get_name(const WacomDevice *device);
384 
389 const char* libwacom_get_model_name(const WacomDevice *device);
390 
396 const char* libwacom_get_layout_filename(const WacomDevice *device);
397 
407 
413 const char* libwacom_get_match(const WacomDevice *device);
414 
421 
437 
447 
456 int libwacom_get_width(const WacomDevice *device);
457 
466 int libwacom_get_height(const WacomDevice *device);
467 
472 int libwacom_has_stylus(const WacomDevice *device);
473 
478 int libwacom_has_touch(const WacomDevice *device);
479 
487 
493 const int *libwacom_get_supported_styli(const WacomDevice *device, int *num_styli);
494 
499 int libwacom_has_ring(const WacomDevice *device);
500 
505 int libwacom_has_ring2(const WacomDevice *device);
506 
512 
518 
524 
531 
537 
543 const WacomStatusLEDs *libwacom_get_status_leds(const WacomDevice *device, int *num_leds);
544 
552  char button);
553 
561 
568 
574 
580 
587  char button);
588 
596  char button);
597 
606 
612 
617 const char *libwacom_stylus_get_name (const WacomStylus *stylus);
618 
624 const int *libwacom_stylus_get_paired_ids(const WacomStylus *stylus, int *num_paired_ids);
625 
631 
645 
660 
666 
672 
678 
684 
690 
697 void libwacom_print_stylus_description (int fd, const WacomStylus *stylus);
698 
699 const char *libwacom_match_get_name(const WacomMatch *match);
703 const char* libwacom_match_get_match_string(const WacomMatch *match);
704 
706 #endif /* _LIBWACOM_H_ */
709 /* vim: set noexpandtab tabstop=8 shiftwidth=8: */
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)
WacomStylusType libwacom_stylus_get_type(const WacomStylus *stylus)
WacomStatusLEDs
Definition: libwacom.h:225
@ WACOM_STATUS_LED_TOUCHSTRIP2
Definition: libwacom.h:230
@ WACOM_STATUS_LED_UNAVAILABLE
Definition: libwacom.h:226
@ WACOM_STATUS_LED_RING
Definition: libwacom.h:227
@ WACOM_STATUS_LED_RING2
Definition: libwacom.h:228
@ WACOM_STATUS_LED_TOUCHSTRIP
Definition: libwacom.h:229
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_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.
WacomError * libwacom_error_new(void)
Allocate a new structure for error reporting.
int libwacom_has_touch(const WacomDevice *device)
int libwacom_stylus_has_lens(const WacomStylus *stylus)
const char * libwacom_match_get_name(const WacomMatch *match)
int libwacom_stylus_get_id(const WacomStylus *stylus)
const char * libwacom_get_layout_filename(const WacomDevice *device)
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)
WacomEraserType
Type of eraser on a stylus.
Definition: libwacom.h:171
@ WACOM_ERASER_UNKNOWN
Definition: libwacom.h:172
@ WACOM_ERASER_NONE
No eraser is present on the stylus.
Definition: libwacom.h:173
@ WACOM_ERASER_BUTTON
Eraser is a button alongside any other stylus buttons.
Definition: libwacom.h:175
@ WACOM_ERASER_INVERT
Eraser is a separate tool on the opposite end of the stylus.
Definition: libwacom.h:174
const char * libwacom_stylus_get_name(const WacomStylus *stylus)
void libwacom_print_device_description(int fd, const WacomDevice *device)
Print the description of this device to the given file.
void libwacom_error_free(WacomError **error)
Free the error and associated memory.
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.
struct _WacomDeviceDatabase WacomDeviceDatabase
Definition: libwacom.h:93
void libwacom_destroy(WacomDevice *device)
Remove the device and free all memory and references to it.
const char * libwacom_error_get_message(WacomError *error)
WacomStylusType
Class of stylus.
Definition: libwacom.h:155
@ WSTYLUS_MARKER
Definition: libwacom.h:161
@ WSTYLUS_AIRBRUSH
Definition: libwacom.h:159
@ WSTYLUS_3D
Definition: libwacom.h:164
@ WSTYLUS_MOBILE
Definition: libwacom.h:165
@ WSTYLUS_CLASSIC
Definition: libwacom.h:160
@ WSTYLUS_INKING
Definition: libwacom.h:158
@ WSTYLUS_GENERAL
Definition: libwacom.h:157
@ WSTYLUS_STROKE
Definition: libwacom.h:162
@ WSTYLUS_PUCK
Definition: libwacom.h:163
@ WSTYLUS_UNKNOWN
Definition: libwacom.h:156
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...
WacomEraserType libwacom_stylus_get_eraser_type(const WacomStylus *stylus)
WacomButtonFlags
Capabilities of the various tablet buttons.
Definition: libwacom.h:181
@ WACOM_BUTTON_POSITION_BOTTOM
Definition: libwacom.h:186
@ WACOM_BUTTON_TOUCHSTRIPS_MODESWITCH
Definition: libwacom.h:195
@ WACOM_BUTTON_NONE
Definition: libwacom.h:182
@ WACOM_BUTTON_RINGS_MODESWITCH
Definition: libwacom.h:194
@ WACOM_BUTTON_DIRECTION
Definition: libwacom.h:193
@ WACOM_BUTTON_TOUCHSTRIP2_MODESWITCH
Definition: libwacom.h:190
@ WACOM_BUTTON_POSITION_TOP
Definition: libwacom.h:185
@ WACOM_BUTTON_RING2_MODESWITCH
Definition: libwacom.h:188
@ WACOM_BUTTON_POSITION_LEFT
Definition: libwacom.h:183
@ WACOM_BUTTON_POSITION_RIGHT
Definition: libwacom.h:184
@ WACOM_BUTTON_MODESWITCH
Definition: libwacom.h:192
@ WACOM_BUTTON_OLED
Definition: libwacom.h:191
@ WACOM_BUTTON_TOUCHSTRIP_MODESWITCH
Definition: libwacom.h:189
@ WACOM_BUTTON_RING_MODESWITCH
Definition: libwacom.h:187
enum WacomErrorCode libwacom_error_get_code(WacomError *error)
const char * libwacom_get_name(const WacomDevice *device)
int libwacom_is_builtin(const WacomDevice *device) LIBWACOM_DEPRECATED
void libwacom_print_stylus_description(int fd, const WacomStylus *stylus)
Print the description of this stylus to the given file.
WacomIntegrationFlags libwacom_get_integration_flags(const WacomDevice *device)
WacomIntegrationFlags
Tablet integration.
Definition: libwacom.h:125
@ WACOM_DEVICE_INTEGRATED_DISPLAY
Definition: libwacom.h:127
@ WACOM_DEVICE_INTEGRATED_NONE
Definition: libwacom.h:126
@ WACOM_DEVICE_INTEGRATED_SYSTEM
Definition: libwacom.h:128
int libwacom_has_ring2(const WacomDevice *device)
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:220
@ WCOMPARE_NORMAL
compare the device only
Definition: libwacom.h:221
@ WCOMPARE_MATCHES
compare all possible matches too
Definition: libwacom.h:222
uint32_t libwacom_match_get_product_id(const WacomMatch *match)
int libwacom_stylus_has_eraser(const WacomStylus *stylus)
Check if the given stylus is paired with a separate eraser.
int libwacom_is_reversible(const WacomDevice *device)
const int * libwacom_stylus_get_paired_ids(const WacomStylus *stylus, int *num_paired_ids)
WacomBusType libwacom_get_bustype(const WacomDevice *device)
WacomButtonFlags libwacom_get_button_flag(const WacomDevice *device, char button)
WacomClass
Classes of devices.
Definition: libwacom.h:137
@ WCLASS_INTUOS3
Any Intuos3 series.
Definition: libwacom.h:139
@ WCLASS_REMOTE
Any Wacom Remote.
Definition: libwacom.h:149
@ WCLASS_CINTIQ
Any Cintiq device.
Definition: libwacom.h:142
@ WCLASS_UNKNOWN
Unknown/unsupported device class.
Definition: libwacom.h:138
@ WCLASS_INTUOS2
Any Intuos2 series.
Definition: libwacom.h:147
@ WCLASS_GRAPHIRE
Any Graphire device.
Definition: libwacom.h:144
@ WCLASS_INTUOS5
Any Intuos5 series.
Definition: libwacom.h:141
@ WCLASS_INTUOS
Any Intuos series.
Definition: libwacom.h:146
@ WCLASS_PEN_DISPLAYS
Any "interactive pen display".
Definition: libwacom.h:148
@ WCLASS_ISDV4
Any serial ISDV4 device.
Definition: libwacom.h:145
@ WCLASS_INTUOS4
Any Intuos4 series.
Definition: libwacom.h:140
@ WCLASS_BAMBOO
Any Bamboo device.
Definition: libwacom.h:143
WacomBusType
Bus types for tablets.
Definition: libwacom.h:114
@ WBUSTYPE_I2C
I2C tablet.
Definition: libwacom.h:119
@ WBUSTYPE_USB
USB tablet.
Definition: libwacom.h:116
@ WBUSTYPE_UNKNOWN
Unknown/unsupported bus type.
Definition: libwacom.h:115
@ WBUSTYPE_SERIAL
Serial tablet.
Definition: libwacom.h:117
@ WBUSTYPE_BLUETOOTH
Bluetooth tablet.
Definition: libwacom.h:118
WacomFallbackFlags
Definition: libwacom.h:215
@ WFALLBACK_GENERIC
Definition: libwacom.h:217
@ WFALLBACK_NONE
Definition: libwacom.h:216
#define LIBWACOM_DEPRECATED
Definition: libwacom.h:39
WacomErrorCode
Possible error codes.
Definition: libwacom.h:101
@ WERROR_NONE
No error has occured.
Definition: libwacom.h:102
@ WERROR_BAD_ALLOC
Allocation error.
Definition: libwacom.h:103
@ WERROR_UNKNOWN_MODEL
Unsupported/unknown device.
Definition: libwacom.h:107
@ WERROR_INVALID_DB
The passed DB is invalid.
Definition: libwacom.h:105
@ WERROR_BUG_CALLER
A bug in the caller.
Definition: libwacom.h:108
@ WERROR_BAD_ACCESS
Invalid permissions to access the path.
Definition: libwacom.h:106
@ WERROR_INVALID_PATH
A path specified is invalid.
Definition: libwacom.h:104
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)
int libwacom_get_ring2_num_modes(const WacomDevice *device)
int libwacom_has_touchswitch(const WacomDevice *device)
struct _WacomError WacomError
Definition: libwacom.h:91
WacomDeviceDatabase * libwacom_database_new(void)
Loads the Tablet and Stylus databases, to be used in libwacom_new_*() functions.
struct _WacomMatch WacomMatch
Definition: libwacom.h:87
int libwacom_stylus_get_num_buttons(const WacomStylus *stylus)
struct _WacomDevice WacomDevice
Definition: libwacom.h:85
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.
const int * libwacom_get_supported_styli(const WacomDevice *device, int *num_styli)
struct _WacomStylus WacomStylus
Definition: libwacom.h:89
int libwacom_stylus_is_eraser(const WacomStylus *stylus)
Check if the given stylus may act like an eraser.
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)
WacomAxisTypeFlags
Axis type for a stylus.
Definition: libwacom.h:201
@ WACOM_AXIS_TYPE_NONE
Definition: libwacom.h:202
@ WACOM_AXIS_TYPE_ROTATION_Z
Rotation in the z-axis.
Definition: libwacom.h:206
@ WACOM_AXIS_TYPE_PRESSURE
Tip pressure.
Definition: libwacom.h:210
@ WACOM_AXIS_TYPE_SLIDER
A absolute-position slider like the wheel on the airbrush.
Definition: libwacom.h:212
@ WACOM_AXIS_TYPE_TILT
Tilt in x and y direction.
Definition: libwacom.h:204
@ WACOM_AXIS_TYPE_DISTANCE
Distance to surface.
Definition: libwacom.h:208
const char * libwacom_match_get_match_string(const WacomMatch *match)
int libwacom_has_ring(const WacomDevice *device)
void libwacom_database_destroy(WacomDeviceDatabase *db)
Free all memory used by the database.