diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-08-19 21:17:42 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-08-19 21:17:42 +0200 |
| commit | baf35a3b761172aeeefd7e761b7e29995a37a9e8 (patch) | |
| tree | 93c3a4f8e139b70db8c42d8b69e3bbc80e05a6b7 /src/grail-event.c | |
| parent | bb964fa8bcebee82093cec8da8081eb1366aea96 (diff) | |
Add grail_contact and a method to retrieve the current contacts
This patch adds the possibility to extract the current set of
contacts from the grail state.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/grail-event.c')
| -rw-r--r-- | src/grail-event.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/grail-event.c b/src/grail-event.c new file mode 100644 index 0000000..6479cc0 --- /dev/null +++ b/src/grail-event.c | |||
| @@ -0,0 +1,51 @@ | |||
| 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-inserter.h" | ||
| 24 | #include "grail-impl.h" | ||
| 25 | #include <math.h> | ||
| 26 | |||
| 27 | int grail_get_contacts(const struct grail *ge, | ||
| 28 | struct grail_contact *touch, int max_touch) | ||
| 29 | { | ||
| 30 | const struct touch_dev *dev = &ge->impl->dev; | ||
| 31 | const struct gesture_inserter *gin = ge->gin; | ||
| 32 | const struct touch_frame *frame = &dev->frame; | ||
| 33 | int i; | ||
| 34 | if (frame->nactive < max_touch) | ||
| 35 | max_touch = frame->nactive; | ||
| 36 | for (i = 0; i < max_touch; i++) { | ||
| 37 | struct grail_contact *t = &touch[i]; | ||
| 38 | const struct touch *ct = frame->active[i]; | ||
| 39 | t->id = ct->id; | ||
| 40 | t->tool_type = ct->tool_type; | ||
| 41 | t->pos.x = gin_prop_x(gin, ct->x); | ||
| 42 | t->pos.y = gin_prop_y(gin, ct->y); | ||
| 43 | t->touch_major = gin->scale_r * ct->touch_major; | ||
| 44 | t->touch_minor = gin->scale_r * ct->touch_minor; | ||
| 45 | t->width_major = gin->scale_r * ct->width_major; | ||
| 46 | t->width_minor = gin->scale_r * ct->width_minor; | ||
| 47 | t->angle = touch_angle(dev, ct->orientation); | ||
| 48 | t->pressure = touch_pressure(dev, ct->pressure); | ||
| 49 | } | ||
| 50 | return max_touch; | ||
| 51 | } | ||
