summaryrefslogtreecommitdiff
path: root/src/gesture-dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gesture-dev.c')
-rw-r--r--src/gesture-dev.c105
1 files changed, 0 insertions, 105 deletions
diff --git a/src/gesture-dev.c b/src/gesture-dev.c
deleted file mode 100644
index 46c77d7..0000000
--- a/src/gesture-dev.c
+++ /dev/null
@@ -1,105 +0,0 @@
1/*****************************************************************************
2 *
3 * grail - Gesture Recognition And Instantiation Library
4 *
5 * Copyright (C) 2010 Canonical Ltd.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Henrik Rydberg <rydberg@bitmath.org>
22 *
23 ****************************************************************************/
24
25#include <grail-gesture.h>
26#include <malloc.h>
27#include <string.h>
28#include <errno.h>
29
30#define DIM_CLIENT 32
31
32struct gedev_impl {
33 int nclient;
34 struct gesture_client *client[DIM_CLIENT];
35};
36
37int gedev_init(struct gesture_dev *dev, void *priv)
38{
39 struct gedev_impl *x;
40 x = calloc(1, sizeof(*x));
41 if (!x)
42 return -ENOMEM;
43 dev->impl = x;
44 dev->priv = priv;
45 return 0;
46}
47
48int gedev_attach_client(struct gesture_dev *dev,
49 struct gesture_client *client)
50{
51 struct gedev_impl *x = dev->impl;
52 if (x->nclient >= DIM_CLIENT)
53 return -ENOMEM;
54 x->client[x->nclient++] = client;
55 return 0;
56}
57
58void gedev_flag(struct gesture_dev *dev,
59 const struct gesture_flag *flag)
60{
61 struct gedev_impl *x = dev->impl;
62 int i;
63 for (i = 0; i < x->nclient; i++)
64 client_flag(x->client[i], flag);
65}
66
67void gedev_event(struct gesture_dev *dev,
68 const struct gesture_event *ev)
69{
70 struct gedev_impl *x = dev->impl;
71 int i;
72 for (i = 0; i < x->nclient; i++)
73 client_event(x->client[i], ev);
74}
75
76void gedev_sync(struct gesture_dev *dev)
77{
78 struct gedev_impl *x = dev->impl;
79 int i;
80 for (i = 0; i < x->nclient; i++)
81 client_sync(x->client[i]);
82}
83
84void gedev_detach_client(struct gesture_dev *dev,
85 struct gesture_client *client)
86{
87 struct gedev_impl *x = dev->impl;
88 int i, j;
89 for (i = 0; i < x->nclient; i++)
90 if (x->client[i] == client)
91 break;
92 if (i >= x->nclient)
93 return;
94 x->nclient--;
95 for (j = i; j < x->nclient; j++)
96 x->client[j] = x->client[j + 1];
97 for (j = x->nclient; j < DIM_CLIENT; j++)
98 x->client[j] = 0;
99}
100
101void gedev_destroy(struct gesture_dev *dev)
102{
103 free(dev->impl);
104 memset(dev, 0, sizeof(*dev));
105}