summaryrefslogtreecommitdiff
path: root/src/grail-legacy.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2011-04-28 15:41:49 +0200
committerHenrik Rydberg <rydberg@euromail.se>2011-04-28 16:58:51 +0200
commitb605a93a85d8ead753d87a2da5a0e40571d6f275 (patch)
treed67a4dcae7176e065da7e302503abf0934c07bc4 /src/grail-legacy.c
parentc3fdf90535e9e4a29d6d846071a50679d9646bcf (diff)
Expose utouch-frame through grail API
Start a gentle API change by exposing utouch-frame through grail, and deprecating the grail_contact struct. Old programs compile and run fine. To only use the new api, compile with -DGRAIL_NO_LEGACY_API. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/grail-legacy.c')
-rw-r--r--src/grail-legacy.c66
1 files changed, 66 insertions, 0 deletions
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
35void 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
41int 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