diff options
Diffstat (limited to 'src')
| -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 |
4 files changed, 77 insertions, 30 deletions
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 | ||
