diff options
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | include/grail.h | 94 | ||||
| -rw-r--r-- | src/Makefile.am | 3 | ||||
| -rw-r--r-- | src/grail-api.c | 13 | ||||
| -rw-r--r-- | src/grail-event.c | 25 | ||||
| -rw-r--r-- | src/grail-legacy.c | 66 |
6 files changed, 126 insertions, 77 deletions
diff --git a/configure.ac b/configure.ac index f40631d..99569cc 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -12,7 +12,7 @@ AC_CONFIG_AUX_DIR([config-aux]) | |||
| 12 | AM_INIT_AUTOMAKE([foreign dist-bzip2]) | 12 | AM_INIT_AUTOMAKE([foreign dist-bzip2]) |
| 13 | AM_MAINTAINER_MODE | 13 | AM_MAINTAINER_MODE |
| 14 | 14 | ||
| 15 | LIB_VERSION=1:0:0 | 15 | LIB_VERSION=2:0:1 |
| 16 | AC_SUBST([LIB_VERSION]) | 16 | AC_SUBST([LIB_VERSION]) |
| 17 | 17 | ||
| 18 | # Initialize libtool | 18 | # Initialize libtool |
diff --git a/include/grail.h b/include/grail.h index d21d9e8..b208556 100644 --- a/include/grail.h +++ b/include/grail.h | |||
| @@ -26,11 +26,14 @@ | |||
| 26 | #include <linux/input.h> | 26 | #include <linux/input.h> |
| 27 | #include <grail-bits.h> | 27 | #include <grail-bits.h> |
| 28 | #include <grail-types.h> | 28 | #include <grail-types.h> |
| 29 | #include <utouch/frame.h> | ||
| 29 | 30 | ||
| 30 | #ifdef __cplusplus | 31 | #ifdef __cplusplus |
| 31 | extern "C" { | 32 | extern "C" { |
| 32 | #endif | 33 | #endif |
| 33 | 34 | ||
| 35 | #define GRAIL_VERSION 0x00011000 | ||
| 36 | |||
| 34 | #define DIM_GRAIL_TYPE 64 | 37 | #define DIM_GRAIL_TYPE 64 |
| 35 | #define DIM_GRAIL_TYPE_BYTES ((DIM_GRAIL_TYPE + 7) >> 3) | 38 | #define DIM_GRAIL_TYPE_BYTES ((DIM_GRAIL_TYPE + 7) >> 3) |
| 36 | 39 | ||
| @@ -41,8 +44,21 @@ extern "C" { | |||
| 41 | #define GRAIL_STATUS_UPDATE 1 | 44 | #define GRAIL_STATUS_UPDATE 1 |
| 42 | #define GRAIL_STATUS_END 2 | 45 | #define GRAIL_STATUS_END 2 |
| 43 | 46 | ||
| 44 | typedef float grail_prop_t; /* gesture properties */ | 47 | typedef float grail_prop_t; /* gesture properties */ |
| 45 | typedef __u64 grail_time_t; /* time in milliseconds */ | 48 | typedef utouch_frame_time_t grail_time_t; /* time in milliseconds */ |
| 49 | |||
| 50 | /** | ||
| 51 | * struct grail_get_version - get grail library version | ||
| 52 | * | ||
| 53 | * Report the version of the grail library, which can be different from | ||
| 54 | * the value of GRAIL_VERSION in this header file. | ||
| 55 | * | ||
| 56 | * This function allows for fallback options from major interface | ||
| 57 | * extensions within the same ABI version. For the normal cases of ABI | ||
| 58 | * agnostic or backwards incompatible changes, this function is not | ||
| 59 | * needed. | ||
| 60 | */ | ||
| 61 | unsigned int GRAIL_PUBLIC grail_get_version(void); | ||
| 46 | 62 | ||
| 47 | /** | 63 | /** |
| 48 | * struct grail_coord - coordinate in bounding box units | 64 | * struct grail_coord - coordinate in bounding box units |
| @@ -54,33 +70,6 @@ struct grail_coord { | |||
| 54 | }; | 70 | }; |
| 55 | 71 | ||
| 56 | /** | 72 | /** |
| 57 | * struct grail_contact - MT event information in bounding box units | ||
| 58 | * @id: Contact tracking id | ||
| 59 | * @tool_type: Tool type (ABS_MT_TOOL_TYPE) | ||
| 60 | * @pos: Position of contact (bbox units) | ||
| 61 | * @touch_major: Major axis of contact shape (bbox units) | ||
| 62 | * @touch_minor: Minor axis of contact shape (bbox units) | ||
| 63 | * @width_major: Major axis of perimeter (bbox units) | ||
| 64 | * @width_minor: Minor axis of perimeter (bbox units) | ||
| 65 | * @angle: Angle of orientation (vertical: 0 horizontal: +-M_PI_2) | ||
| 66 | * @pressure: Pressure of contact (min: 0 max: 1) | ||
| 67 | * | ||
| 68 | * Depending on the native support of the underlying device, some or all of | ||
| 69 | * the listed properties may be computed. | ||
| 70 | */ | ||
| 71 | struct grail_contact { | ||
| 72 | int id; | ||
| 73 | int tool_type; | ||
| 74 | struct grail_coord pos; | ||
| 75 | float touch_major; | ||
| 76 | float touch_minor; | ||
| 77 | float width_major; | ||
| 78 | float width_minor; | ||
| 79 | float angle; | ||
| 80 | float pressure; | ||
| 81 | }; | ||
| 82 | |||
| 83 | /** | ||
| 84 | * struct grail_client_id - Gesture client information | 73 | * struct grail_client_id - Gesture client information |
| 85 | * @client: Client id | 74 | * @client: Client id |
| 86 | * @root: Root window | 75 | * @root: Root window |
| @@ -231,19 +220,6 @@ void GRAIL_PUBLIC grail_set_bbox(struct grail *ge, | |||
| 231 | const struct grail_coord *max); | 220 | const struct grail_coord *max); |
| 232 | 221 | ||
| 233 | /** | 222 | /** |
| 234 | * grail_filter_abs_events - filter kernel motion events | ||
| 235 | * @ge: the grail device in use | ||
| 236 | * @usage: When true, filter kernel motion events. | ||
| 237 | * | ||
| 238 | * Single-finger pointer events are treated as pointer gestures in | ||
| 239 | * grail. When filter_motion_events is non-zero, the kernel events | ||
| 240 | * corresponding to pointer movement are removed from the event | ||
| 241 | * stream. | ||
| 242 | * | ||
| 243 | */ | ||
| 244 | void GRAIL_PUBLIC grail_filter_abs_events(struct grail *ge, int usage); | ||
| 245 | |||
| 246 | /** | ||
| 247 | * grail_get_units - get device coordinate ranges | 223 | * grail_get_units - get device coordinate ranges |
| 248 | * @ge: the grail device in use | 224 | * @ge: the grail device in use |
| 249 | * @min: minimum x and y coordinates | 225 | * @min: minimum x and y coordinates |
| @@ -260,17 +236,43 @@ void GRAIL_PUBLIC grail_get_units(const struct grail *ge, | |||
| 260 | struct grail_coord *max); | 236 | struct grail_coord *max); |
| 261 | 237 | ||
| 262 | /** | 238 | /** |
| 263 | * grail_get_contacts - get current contact state | 239 | * grail_get_contact_frame - get current contact frame |
| 264 | * @ge: the grail device in use | 240 | * @ge: the grail device in use |
| 265 | * @touch: array of contacts to be filled in | ||
| 266 | * @max_touch: maximum number of contacts supported by the array | ||
| 267 | * | 241 | * |
| 268 | * Extract the contact state as currently seen by grail. | 242 | * Return the contact frame current being processed. If called from |
| 243 | * within a gesture callback, it is guaranteed to return the frame | ||
| 244 | * corresponding to the gesture. | ||
| 245 | * | ||
| 246 | * The returned pointer can be NULL if no input has yet been extracted | ||
| 247 | * through the grail instance. | ||
| 269 | * | 248 | * |
| 249 | * The frame pointer is ABI agnostic, owned by the grail instance, and | ||
| 250 | * has grail scope. | ||
| 270 | */ | 251 | */ |
| 252 | const struct utouch_frame GRAIL_PUBLIC * | ||
| 253 | grail_get_contact_frame(const struct grail *ge); | ||
| 254 | |||
| 255 | #ifndef GRAIL_NO_LEGACY_API | ||
| 256 | |||
| 257 | struct grail_contact { | ||
| 258 | int id; | ||
| 259 | int tool_type; | ||
| 260 | struct grail_coord pos; | ||
| 261 | float touch_major; | ||
| 262 | float touch_minor; | ||
| 263 | float width_major; | ||
| 264 | float width_minor; | ||
| 265 | float angle; | ||
| 266 | float pressure; | ||
| 267 | }; | ||
| 268 | |||
| 269 | void GRAIL_PUBLIC grail_filter_abs_events(struct grail *ge, int usage); | ||
| 270 | |||
| 271 | int GRAIL_PUBLIC grail_get_contacts(const struct grail *ge, | 271 | int GRAIL_PUBLIC grail_get_contacts(const struct grail *ge, |
| 272 | struct grail_contact *touch, int max_touch); | 272 | struct grail_contact *touch, int max_touch); |
| 273 | 273 | ||
| 274 | #endif | ||
| 275 | |||
| 274 | #ifdef __cplusplus | 276 | #ifdef __cplusplus |
| 275 | } | 277 | } |
| 276 | #endif | 278 | #endif |
diff --git a/src/Makefile.am b/src/Makefile.am index c344342..b26574c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
| @@ -25,7 +25,8 @@ libutouch_grail_la_SOURCES = \ | |||
| 25 | grail-recognizer.h \ | 25 | grail-recognizer.h \ |
| 26 | grail-event.c \ | 26 | grail-event.c \ |
| 27 | grail-impl.h \ | 27 | grail-impl.h \ |
| 28 | grail-api.c | 28 | grail-api.c \ |
| 29 | grail-legacy.c | ||
| 29 | 30 | ||
| 30 | # These are flags required to properly set up | 31 | # These are flags required to properly set up |
| 31 | # the build. -fvisibility requires GCC > 4 (or clang) | 32 | # the build. -fvisibility requires GCC > 4 (or clang) |
diff --git a/src/grail-api.c b/src/grail-api.c index 1236205..6ef4b7d 100644 --- a/src/grail-api.c +++ b/src/grail-api.c | |||
| @@ -20,9 +20,9 @@ | |||
| 20 | * | 20 | * |
| 21 | ****************************************************************************/ | 21 | ****************************************************************************/ |
| 22 | 22 | ||
| 23 | #include "grail-impl.h" | ||
| 23 | #include "grail-inserter.h" | 24 | #include "grail-inserter.h" |
| 24 | #include "grail-recognizer.h" | 25 | #include "grail-recognizer.h" |
| 25 | #include "grail-impl.h" | ||
| 26 | #include <string.h> | 26 | #include <string.h> |
| 27 | #include <stdio.h> | 27 | #include <stdio.h> |
| 28 | #include <unistd.h> | 28 | #include <unistd.h> |
| @@ -35,10 +35,9 @@ | |||
| 35 | #define DIM_FRAMES 100 | 35 | #define DIM_FRAMES 100 |
| 36 | #define FRAME_RATE 100 | 36 | #define FRAME_RATE 100 |
| 37 | 37 | ||
| 38 | void GRAIL_PUBLIC grail_filter_abs_events(struct grail *ge, int usage) | 38 | unsigned int GRAIL_PUBLIC grail_get_version(void) |
| 39 | { | 39 | { |
| 40 | struct grail_impl *x = ge->impl; | 40 | return GRAIL_VERSION; |
| 41 | x->filter_abs = usage; | ||
| 42 | } | 41 | } |
| 43 | 42 | ||
| 44 | int GRAIL_PUBLIC grail_open(struct grail *ge, int fd) | 43 | int GRAIL_PUBLIC grail_open(struct grail *ge, int fd) |
| @@ -152,6 +151,12 @@ void GRAIL_PUBLIC grail_get_units(const struct grail *ge, | |||
| 152 | max->y = s->max_y; | 151 | max->y = s->max_y; |
| 153 | } | 152 | } |
| 154 | 153 | ||
| 154 | const struct utouch_frame GRAIL_PUBLIC * | ||
| 155 | grail_get_contact_frame(const struct grail *ge) | ||
| 156 | { | ||
| 157 | return ge->impl->frame; | ||
| 158 | } | ||
| 159 | |||
| 155 | static void flush_events(struct grail *ge) | 160 | static void flush_events(struct grail *ge) |
| 156 | { | 161 | { |
| 157 | struct grail_impl *impl = ge->impl; | 162 | struct grail_impl *impl = ge->impl; |
diff --git a/src/grail-event.c b/src/grail-event.c index bb75a06..0c565ea 100644 --- a/src/grail-event.c +++ b/src/grail-event.c | |||
| @@ -117,28 +117,3 @@ void gin_send_event(struct grail *ge, struct slot_state *s, | |||
| 117 | grailbuf_put(&impl->gbuf, &gev); | 117 | grailbuf_put(&impl->gbuf, &gev); |
| 118 | } | 118 | } |
| 119 | } | 119 | } |
| 120 | |||
| 121 | int GRAIL_PUBLIC grail_get_contacts(const struct grail *ge, | ||
| 122 | struct grail_contact *touch, int max_touch) | ||
| 123 | { | ||
| 124 | const struct gesture_inserter *gin = ge->gin; | ||
| 125 | const struct utouch_frame *frame = ge->impl->frame; | ||
| 126 | int i; | ||
| 127 | if (frame->num_active < max_touch) | ||
| 128 | max_touch = frame->num_active; | ||
| 129 | for (i = 0; i < max_touch; i++) { | ||
| 130 | struct grail_contact *t = &touch[i]; | ||
| 131 | const struct utouch_contact *ct = frame->active[i]; | ||
| 132 | t->id = ct->id; | ||
| 133 | t->tool_type = ct->tool_type; | ||
| 134 | t->pos.x = ct->x; | ||
| 135 | t->pos.y = ct->y; | ||
| 136 | t->touch_major = ct->touch_major; | ||
| 137 | t->touch_minor = ct->touch_minor; | ||
| 138 | t->width_major = ct->width_major; | ||
| 139 | t->width_minor = ct->width_minor; | ||
| 140 | t->angle = ct->orientation; | ||
| 141 | t->pressure = ct->pressure; | ||
| 142 | } | ||
| 143 | return max_touch; | ||
| 144 | } | ||
diff --git a/src/grail-legacy.c b/src/grail-legacy.c new file mode 100644 index 0000000..779595b --- /dev/null +++ b/src/grail-legacy.c | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | /***************************************************************************** | ||
| 2 | * | ||
| 3 | * grail - Gesture Recognition And Instantiation Library | ||
| 4 | * | ||
| 5 | * Copyright (C) 2010 Canonical Ltd. | ||
| 6 | * Copyright (C) 2010 Henrik Rydberg <rydberg@bitmath.org> | ||
| 7 | * | ||
| 8 | * This program is free software: you can redistribute it and/or modify it | ||
| 9 | * under the terms of the GNU General Public License as published by the | ||
| 10 | * Free Software Foundation, either version 3 of the License, or (at your | ||
| 11 | * option) any later version. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, but | ||
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License along | ||
| 19 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | * | ||
| 21 | ****************************************************************************/ | ||
| 22 | |||
| 23 | #include <grail.h> | ||
| 24 | #include "grail-inserter.h" | ||
| 25 | #include <string.h> | ||
| 26 | #include <stdio.h> | ||
| 27 | #include <unistd.h> | ||
| 28 | #include <fcntl.h> | ||
| 29 | #include <malloc.h> | ||
| 30 | #include <errno.h> | ||
| 31 | #include <stdlib.h> | ||
| 32 | |||
| 33 | #ifndef GRAIL_NO_LEGACY_ABI | ||
| 34 | |||
| 35 | void GRAIL_PUBLIC grail_filter_abs_events(struct grail *ge, int usage) | ||
| 36 | { | ||
| 37 | struct grail_impl *x = ge->impl; | ||
| 38 | x->filter_abs = usage; | ||
| 39 | } | ||
| 40 | |||
| 41 | int GRAIL_PUBLIC grail_get_contacts(const struct grail *ge, | ||
| 42 | struct grail_contact *touch, int max_touch) | ||
| 43 | { | ||
| 44 | const struct gesture_inserter *gin = ge->gin; | ||
| 45 | const struct utouch_frame *frame = ge->impl->frame; | ||
| 46 | int i; | ||
| 47 | if (frame->num_active < max_touch) | ||
| 48 | max_touch = frame->num_active; | ||
| 49 | for (i = 0; i < max_touch; i++) { | ||
| 50 | struct grail_contact *t = &touch[i]; | ||
| 51 | const struct utouch_contact *ct = frame->active[i]; | ||
| 52 | t->id = ct->id; | ||
| 53 | t->tool_type = ct->tool_type; | ||
| 54 | t->pos.x = ct->x; | ||
| 55 | t->pos.y = ct->y; | ||
| 56 | t->touch_major = ct->touch_major; | ||
| 57 | t->touch_minor = ct->touch_minor; | ||
| 58 | t->width_major = ct->width_major; | ||
| 59 | t->width_minor = ct->width_minor; | ||
| 60 | t->angle = ct->orientation; | ||
| 61 | t->pressure = ct->pressure; | ||
| 62 | } | ||
| 63 | return max_touch; | ||
| 64 | } | ||
| 65 | |||
| 66 | #endif | ||
