diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/grail-bits.h | 33 | ||||
| -rw-r--r-- | include/grail.h | 25 |
2 files changed, 41 insertions, 17 deletions
diff --git a/include/grail-bits.h b/include/grail-bits.h index c151c11..dfe5367 100644 --- a/include/grail-bits.h +++ b/include/grail-bits.h | |||
| @@ -27,6 +27,26 @@ | |||
| 27 | extern "C" { | 27 | extern "C" { |
| 28 | #endif | 28 | #endif |
| 29 | 29 | ||
| 30 | /* Macros that set symbol visibilities in shared libraries properly. | ||
| 31 | * Adapted from http://gcc.gnu.org/wiki/Visibility | ||
| 32 | */ | ||
| 33 | |||
| 34 | #if defined _WIN32 || defined __CYGWIN__ | ||
| 35 | #ifdef BUILDING_GRAIL | ||
| 36 | #define GRAIL_PUBLIC __declspec(dllexport) | ||
| 37 | #else | ||
| 38 | #define GRAIL_PUBLIC __declspec(dllimport) | ||
| 39 | #endif | ||
| 40 | #define GRAIL_PRIVATE | ||
| 41 | #else | ||
| 42 | #if defined __GNUC__ | ||
| 43 | #define GRAIL_PUBLIC __attribute__ ((visibility("default"))) | ||
| 44 | #define GRAIL_PRIVATE __attribute__ ((visibility("hidden"))) | ||
| 45 | #else | ||
| 46 | #error "Unsupported compiler." | ||
| 47 | #endif | ||
| 48 | #endif | ||
| 49 | |||
| 30 | typedef unsigned char grail_mask_t; | 50 | typedef unsigned char grail_mask_t; |
| 31 | 51 | ||
| 32 | static inline void grail_mask_set(grail_mask_t *mask, int i) | 52 | static inline void grail_mask_set(grail_mask_t *mask, int i) |
| @@ -52,12 +72,15 @@ static inline int grail_mask_get(const grail_mask_t *mask, int i) | |||
| 52 | return (mask[i >> 3] >> (i & 7)) & 1; | 72 | return (mask[i >> 3] >> (i & 7)) & 1; |
| 53 | } | 73 | } |
| 54 | 74 | ||
| 55 | void grail_mask_set_mask(grail_mask_t *a, const grail_mask_t *b, int bytes); | 75 | void GRAIL_PUBLIC grail_mask_set_mask(grail_mask_t *a, const grail_mask_t *b, |
| 56 | void grail_mask_clear_mask(grail_mask_t *a, const grail_mask_t *b, int bytes); | 76 | int bytes); |
| 77 | void GRAIL_PUBLIC grail_mask_clear_mask(grail_mask_t *a, const grail_mask_t *b, | ||
| 78 | int bytes); | ||
| 57 | 79 | ||
| 58 | int grail_mask_count(const grail_mask_t *mask, int bytes); | 80 | int GRAIL_PUBLIC grail_mask_count(const grail_mask_t *mask, int bytes); |
| 59 | int grail_mask_get_first(const grail_mask_t *mask, int bytes); | 81 | int GRAIL_PUBLIC grail_mask_get_first(const grail_mask_t *mask, int bytes); |
| 60 | int grail_mask_get_next(int i, const grail_mask_t *mask, int bytes); | 82 | int GRAIL_PUBLIC grail_mask_get_next(int i, const grail_mask_t *mask, |
| 83 | int bytes); | ||
| 61 | 84 | ||
| 62 | #define grail_mask_foreach(i, mask, bytes) \ | 85 | #define grail_mask_foreach(i, mask, bytes) \ |
| 63 | for (i = grail_mask_get_first(mask, bytes); \ | 86 | for (i = grail_mask_get_first(mask, bytes); \ |
diff --git a/include/grail.h b/include/grail.h index d61197d..d21d9e8 100644 --- a/include/grail.h +++ b/include/grail.h | |||
| @@ -179,7 +179,7 @@ struct grail { | |||
| 179 | * | 179 | * |
| 180 | * Returns zero on success, negative error number otherwise. | 180 | * Returns zero on success, negative error number otherwise. |
| 181 | */ | 181 | */ |
| 182 | int grail_open(struct grail *ge, int fd); | 182 | int GRAIL_PUBLIC grail_open(struct grail *ge, int fd); |
| 183 | 183 | ||
| 184 | /** | 184 | /** |
| 185 | * grail_idle - check state of kernel device | 185 | * grail_idle - check state of kernel device |
| @@ -190,7 +190,7 @@ int grail_open(struct grail *ge, int fd); | |||
| 190 | * Returns true if the device is idle, i.e., there are no fetched | 190 | * Returns true if the device is idle, i.e., there are no fetched |
| 191 | * events in the pipe and there is nothing to fetch from the device. | 191 | * events in the pipe and there is nothing to fetch from the device. |
| 192 | */ | 192 | */ |
| 193 | int grail_idle(struct grail *ge, int fd, int ms); | 193 | int GRAIL_PUBLIC grail_idle(struct grail *ge, int fd, int ms); |
| 194 | 194 | ||
| 195 | /** | 195 | /** |
| 196 | * grail_pull - pull and process available events from the kernel device | 196 | * grail_pull - pull and process available events from the kernel device |
| @@ -206,7 +206,7 @@ int grail_idle(struct grail *ge, int fd, int ms); | |||
| 206 | * On success, returns the number of events read. Otherwise, | 206 | * On success, returns the number of events read. Otherwise, |
| 207 | * a standard negative error number is returned. | 207 | * a standard negative error number is returned. |
| 208 | */ | 208 | */ |
| 209 | int grail_pull(struct grail *ge, int fd); | 209 | int GRAIL_PUBLIC grail_pull(struct grail *ge, int fd); |
| 210 | 210 | ||
| 211 | /** | 211 | /** |
| 212 | * grail_close - close the grail device | 212 | * grail_close - close the grail device |
| @@ -216,7 +216,7 @@ int grail_pull(struct grail *ge, int fd); | |||
| 216 | * Deallocates all memory associated with grail, and clears the grail | 216 | * Deallocates all memory associated with grail, and clears the grail |
| 217 | * structure. | 217 | * structure. |
| 218 | */ | 218 | */ |
| 219 | void grail_close(struct grail *ge, int fd); | 219 | void GRAIL_PUBLIC grail_close(struct grail *ge, int fd); |
| 220 | 220 | ||
| 221 | /** | 221 | /** |
| 222 | * grail_set_bbox - set the grail unit bounding box | 222 | * grail_set_bbox - set the grail unit bounding box |
| @@ -226,9 +226,9 @@ void grail_close(struct grail *ge, int fd); | |||
| 226 | * | 226 | * |
| 227 | * Sets the box within which the device coordinates should be presented. | 227 | * Sets the box within which the device coordinates should be presented. |
| 228 | */ | 228 | */ |
| 229 | void grail_set_bbox(struct grail *ge, | 229 | void GRAIL_PUBLIC grail_set_bbox(struct grail *ge, |
| 230 | const struct grail_coord *min, | 230 | const struct grail_coord *min, |
| 231 | const struct grail_coord *max); | 231 | const struct grail_coord *max); |
| 232 | 232 | ||
| 233 | /** | 233 | /** |
| 234 | * grail_filter_abs_events - filter kernel motion events | 234 | * grail_filter_abs_events - filter kernel motion events |
| @@ -241,7 +241,7 @@ void grail_set_bbox(struct grail *ge, | |||
| 241 | * stream. | 241 | * stream. |
| 242 | * | 242 | * |
| 243 | */ | 243 | */ |
| 244 | void grail_filter_abs_events(struct grail *ge, int usage); | 244 | void GRAIL_PUBLIC grail_filter_abs_events(struct grail *ge, int usage); |
| 245 | 245 | ||
| 246 | /** | 246 | /** |
| 247 | * grail_get_units - get device coordinate ranges | 247 | * grail_get_units - get device coordinate ranges |
| @@ -255,8 +255,9 @@ void grail_filter_abs_events(struct grail *ge, int usage); | |||
| 255 | * function. This function reports the device coordinate ranges. | 255 | * function. This function reports the device coordinate ranges. |
| 256 | * | 256 | * |
| 257 | */ | 257 | */ |
| 258 | void grail_get_units(const struct grail *ge, | 258 | void GRAIL_PUBLIC grail_get_units(const struct grail *ge, |
| 259 | struct grail_coord *min, struct grail_coord *max); | 259 | struct grail_coord *min, |
| 260 | struct grail_coord *max); | ||
| 260 | 261 | ||
| 261 | /** | 262 | /** |
| 262 | * grail_get_contacts - get current contact state | 263 | * grail_get_contacts - get current contact state |
| @@ -267,8 +268,8 @@ void grail_get_units(const struct grail *ge, | |||
| 267 | * Extract the contact state as currently seen by grail. | 268 | * Extract the contact state as currently seen by grail. |
| 268 | * | 269 | * |
| 269 | */ | 270 | */ |
| 270 | int grail_get_contacts(const struct grail *ge, | 271 | int GRAIL_PUBLIC grail_get_contacts(const struct grail *ge, |
| 271 | struct grail_contact *touch, int max_touch); | 272 | struct grail_contact *touch, int max_touch); |
| 272 | 273 | ||
| 273 | #ifdef __cplusplus | 274 | #ifdef __cplusplus |
| 274 | } | 275 | } |
