libwacom
Wacom model identification library
|
00001 /* 00002 * Copyright © 2011 Red Hat, Inc. 00003 * 00004 * Permission to use, copy, modify, distribute, and sell this software 00005 * and its documentation for any purpose is hereby granted without 00006 * fee, provided that the above copyright notice appear in all copies 00007 * and that both that copyright notice and this permission notice 00008 * appear in supporting documentation, and that the name of Red Hat 00009 * not be used in advertising or publicity pertaining to distribution 00010 * of the software without specific, written prior permission. Red 00011 * Hat makes no representations about the suitability of this software 00012 * for any purpose. It is provided "as is" without express or implied 00013 * warranty. 00014 * 00015 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 00016 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 00017 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 00018 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00019 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00020 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 00021 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00022 * 00023 * Authors: 00024 * Peter Hutterer (peter.hutterer@redhat.com) 00025 */ 00026 00027 #ifdef HAVE_CONFIG_H 00028 #include "config.h" 00029 #endif 00030 00031 00033 #ifndef _LIBWACOM_H_ 00034 #define _LIBWACOM_H_ 00035 00037 #include <stdint.h> 00038 #include <stdio.h> 00082 typedef struct _WacomDevice WacomDevice; 00083 00084 typedef struct _WacomMatch WacomMatch; 00085 00086 typedef struct _WacomStylus WacomStylus; 00087 00088 typedef struct _WacomError WacomError; 00089 00090 typedef struct _WacomDeviceDatabase WacomDeviceDatabase; 00091 00092 #define WACOM_STYLUS_FALLBACK_ID 0xfffff 00093 #define WACOM_ERASER_FALLBACK_ID 0xffffe 00094 00098 enum WacomErrorCode { 00099 WERROR_NONE, 00100 WERROR_BAD_ALLOC, 00101 WERROR_INVALID_PATH, 00102 WERROR_INVALID_DB, 00103 WERROR_BAD_ACCESS, 00104 WERROR_UNKNOWN_MODEL, 00105 }; 00106 00110 typedef enum { 00111 WBUSTYPE_UNKNOWN, 00112 WBUSTYPE_USB, 00113 WBUSTYPE_SERIAL, 00114 WBUSTYPE_BLUETOOTH 00115 } WacomBusType; 00116 00120 typedef enum { 00121 WCLASS_UNKNOWN, 00122 WCLASS_INTUOS3, 00123 WCLASS_INTUOS4, 00124 WCLASS_INTUOS5, 00125 WCLASS_CINTIQ, 00126 WCLASS_BAMBOO, 00127 WCLASS_GRAPHIRE, 00128 WCLASS_ISDV4, 00129 WCLASS_INTUOS, 00130 WCLASS_INTUOS2, 00131 WCLASS_PEN_DISPLAYS, 00132 } WacomClass; 00133 00137 typedef enum { 00138 WSTYLUS_UNKNOWN, 00139 WSTYLUS_GENERAL, 00140 WSTYLUS_INKING, 00141 WSTYLUS_AIRBRUSH, 00142 WSTYLUS_CLASSIC, 00143 WSTYLUS_MARKER, 00144 WSTYLUS_STROKE, 00145 WSTYLUS_PUCK 00146 } WacomStylusType; 00147 00151 typedef enum { 00152 WACOM_BUTTON_NONE = 0, 00153 WACOM_BUTTON_POSITION_LEFT = (1 << 1), 00154 WACOM_BUTTON_POSITION_RIGHT = (1 << 2), 00155 WACOM_BUTTON_POSITION_TOP = (1 << 3), 00156 WACOM_BUTTON_POSITION_BOTTOM = (1 << 4), 00157 WACOM_BUTTON_RING_MODESWITCH = (1 << 5), 00158 WACOM_BUTTON_RING2_MODESWITCH = (1 << 6), 00159 WACOM_BUTTON_TOUCHSTRIP_MODESWITCH = (1 << 7), 00160 WACOM_BUTTON_TOUCHSTRIP2_MODESWITCH = (1 << 8), 00161 WACOM_BUTTON_OLED = (1 << 9), 00162 WACOM_BUTTON_MODESWITCH = (WACOM_BUTTON_RING_MODESWITCH | WACOM_BUTTON_RING2_MODESWITCH | WACOM_BUTTON_TOUCHSTRIP_MODESWITCH | WACOM_BUTTON_TOUCHSTRIP2_MODESWITCH), 00163 WACOM_BUTTON_DIRECTION = (WACOM_BUTTON_POSITION_LEFT | WACOM_BUTTON_POSITION_RIGHT | WACOM_BUTTON_POSITION_TOP | WACOM_BUTTON_POSITION_BOTTOM), 00164 WACOM_BUTTON_RINGS_MODESWITCH = (WACOM_BUTTON_RING_MODESWITCH | WACOM_BUTTON_RING2_MODESWITCH), 00165 WACOM_BUTTON_TOUCHSTRIPS_MODESWITCH = (WACOM_BUTTON_TOUCHSTRIP_MODESWITCH | WACOM_BUTTON_TOUCHSTRIP2_MODESWITCH), 00166 } WacomButtonFlags; 00167 00168 typedef enum { 00169 WFALLBACK_NONE = 0, 00170 WFALLBACK_GENERIC = 1 00171 } WacomFallbackFlags; 00172 00173 typedef enum { 00174 WCOMPARE_NORMAL = 0, 00175 WCOMPARE_MATCHES = (1 << 1), 00176 } WacomCompareFlags; 00177 00184 WacomError* libwacom_error_new(void); 00185 00193 void libwacom_error_free(WacomError **error); 00194 00198 enum WacomErrorCode libwacom_error_get_code(WacomError *error); 00199 00203 const char* libwacom_error_get_message(WacomError *error); 00204 00211 WacomDeviceDatabase* libwacom_database_new(void); 00212 00221 WacomDeviceDatabase* libwacom_database_new_for_path(const char *datadir); 00222 00228 void libwacom_database_destroy(WacomDeviceDatabase *db); 00229 00242 WacomDevice* libwacom_new_from_path(WacomDeviceDatabase *db, const char *path, WacomFallbackFlags fallback, WacomError *error); 00243 00256 WacomDevice* libwacom_new_from_usbid(WacomDeviceDatabase *db, int vendor_id, int product_id, WacomError *error); 00257 00269 WacomDevice* libwacom_new_from_name(WacomDeviceDatabase *db, const char *name, WacomError *error); 00270 00282 WacomDevice** libwacom_list_devices_from_database(WacomDeviceDatabase *db, WacomError *error); 00283 00290 void libwacom_print_device_description (int fd, WacomDevice *device); 00291 00292 00298 void libwacom_destroy(WacomDevice *device); 00299 00309 int libwacom_compare(WacomDevice *a, WacomDevice *b, WacomCompareFlags flags); 00310 00315 WacomClass libwacom_get_class(WacomDevice *device); 00316 00321 const char* libwacom_get_name(WacomDevice *device); 00322 00327 int libwacom_get_vendor_id(WacomDevice *device); 00328 00334 const char* libwacom_get_match(WacomDevice *device); 00335 00341 const WacomMatch** libwacom_get_matches(WacomDevice *device); 00342 00347 int libwacom_get_product_id(WacomDevice *device); 00348 00357 int libwacom_get_width(WacomDevice *device); 00358 00367 int libwacom_get_height(WacomDevice *device); 00368 00373 int libwacom_has_stylus(WacomDevice *device); 00374 00379 int libwacom_has_touch(WacomDevice *device); 00380 00387 int libwacom_get_num_buttons(WacomDevice *device); 00388 00394 const int *libwacom_get_supported_styli(WacomDevice *device, int *num_styli); 00395 00400 int libwacom_has_ring(WacomDevice *device); 00401 00406 int libwacom_has_ring2(WacomDevice *device); 00407 00412 int libwacom_get_ring_num_modes(WacomDevice *device); 00413 00418 int libwacom_get_ring2_num_modes(WacomDevice *device); 00419 00425 int libwacom_get_num_strips(WacomDevice *device); 00426 00431 int libwacom_get_strips_num_modes(WacomDevice *device); 00432 00438 int libwacom_is_builtin(WacomDevice *device); 00439 00445 int libwacom_is_reversible(WacomDevice *device); 00446 00451 WacomBusType libwacom_get_bustype(WacomDevice *device); 00452 00453 /* 00454 * @param device The tablet to query 00455 * @param button The ID of the button to check for, between 'A' and 'Z' 00456 * @return a WacomButtonFlags with information about the button 00457 */ 00458 WacomButtonFlags libwacom_get_button_flag(WacomDevice *device, 00459 char button); 00460 00468 const WacomStylus *libwacom_stylus_get_for_id (WacomDeviceDatabase *db, int id); 00469 00474 int libwacom_stylus_get_id (const WacomStylus *stylus); 00475 00480 const char *libwacom_stylus_get_name (const WacomStylus *stylus); 00481 00486 int libwacom_stylus_get_num_buttons (const WacomStylus *stylus); 00487 00492 int libwacom_stylus_has_eraser (const WacomStylus *stylus); 00493 00498 int libwacom_stylus_is_eraser (const WacomStylus *stylus); 00499 00504 int libwacom_stylus_has_lens (const WacomStylus *stylus); 00505 00510 WacomStylusType libwacom_stylus_get_type (const WacomStylus *stylus); 00511 00518 void libwacom_print_stylus_description (int fd, const WacomStylus *stylus); 00519 00520 WacomBusType libwacom_match_get_bustype(const WacomMatch *match); 00521 uint32_t libwacom_match_get_product_id(const WacomMatch *match); 00522 uint32_t libwacom_match_get_vendor_id(const WacomMatch *match); 00523 const char* libwacom_match_get_match_string(const WacomMatch *match); 00524 00525 #endif /* _LIBWACOM_H_ */ 00526 00527 /* vim: set noexpandtab tabstop=8 shiftwidth=8: */