summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-08-06 21:11:17 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-08-06 21:11:17 +0200
commit7db9d8d76ff61c4802ac15559dcea6fa54ff567a (patch)
treeb67e040c0abeb0ab1fca72754a767dc9ab851461 /include
initial bzr repo at rev 27
Diffstat (limited to 'include')
-rw-r--r--include/grail-bits.h65
-rw-r--r--include/grail-touch.h107
-rw-r--r--include/grail-types.h56
-rw-r--r--include/grail.h94
4 files changed, 322 insertions, 0 deletions
diff --git a/include/grail-bits.h b/include/grail-bits.h
new file mode 100644
index 0000000..ca04c3f
--- /dev/null
+++ b/include/grail-bits.h
@@ -0,0 +1,65 @@
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#ifndef _GRAIL_BITS_H
26#define _GRAIL_BITS_H
27
28typedef unsigned char grail_mask_t;
29
30static inline void grail_mask_set(grail_mask_t *mask, int i)
31{
32 mask[i >> 3] |= (1 << (i & 7));
33}
34
35static inline void grail_mask_clear(grail_mask_t *mask, int i)
36{
37 mask[i >> 3] &= ~(1 << (i & 7));
38}
39
40static inline void grail_mask_modify(grail_mask_t *mask, int i, int v)
41{
42 if (v)
43 grail_mask_set(mask, i);
44 else
45 grail_mask_clear(mask, i);
46}
47
48static inline int grail_mask_get(const grail_mask_t *mask, int i)
49{
50 return (mask[i >> 3] >> (i & 7)) & 1;
51}
52
53void grail_mask_set_mask(grail_mask_t *a, const grail_mask_t *b, int bytes);
54void grail_mask_clear_mask(grail_mask_t *a, const grail_mask_t *b, int bytes);
55
56int grail_mask_count(const grail_mask_t *mask, int bytes);
57int grail_mask_get_first(const grail_mask_t *mask, int bytes);
58int grail_mask_get_next(int i, const grail_mask_t *mask, int bytes);
59
60#define grail_mask_foreach(i, mask, bytes) \
61 for (i = grail_mask_get_first(mask, bytes); \
62 i >= 0; \
63 i = grail_mask_get_next(i, mask, bytes))
64
65#endif
diff --git a/include/grail-touch.h b/include/grail-touch.h
new file mode 100644
index 0000000..5c2fab0
--- /dev/null
+++ b/include/grail-touch.h
@@ -0,0 +1,107 @@
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#ifndef _GRAIL_TOUCH_H
26#define _GRAIL_TOUCH_H
27
28#include <grail-bits.h>
29#include <mtdev.h>
30
31#define DIM_TOUCH 32
32#define DIM_TOUCH_BYTES ((DIM_TOUCH + 7) >> 3)
33
34typedef int touch_prop_t;
35typedef __u64 touch_time_t;
36
37enum touch_prop_list {
38 TP_POS_X,
39 TP_POS_Y,
40 TP_TOUCH_MAJOR,
41 TP_TOUCH_MINOR,
42 TP_WIDTH_MAJOR,
43 TP_WIDTH_MINOR,
44 TP_ORIENTATION,
45 TP_PRESSURE,
46 DIM_TOUCH_PROP
47};
48
49#define DIM_TOUCH_PROP_BYTES ((DIM_TOUCH_PROP + 7) >> 3)
50
51struct touch {
52 int active;
53 int slot;
54 touch_prop_t prop[DIM_TOUCH_PROP];
55};
56
57struct touch_frame {
58 int nactive;
59 int ncreate, nmodify, ndestroy;
60 touch_time_t time;
61 grail_mask_t touches[DIM_TOUCH_BYTES];
62 struct touch *active[DIM_TOUCH];
63 struct touch touch[DIM_TOUCH];
64};
65
66struct touch_dev_caps {
67 grail_mask_t mask[DIM_TOUCH_PROP_BYTES];
68 struct input_absinfo info[DIM_TOUCH_PROP];
69};
70
71struct touch_dev {
72 void (*event)(struct touch_dev *dev, const struct input_event *ev);
73 void (*create)(struct touch_dev *dev, int slot,
74 const grail_mask_t *mask, const touch_prop_t *prop);
75 void (*modify)(struct touch_dev *dev, int slot,
76 const grail_mask_t *mask, const touch_prop_t *prop);
77 void (*destroy)(struct touch_dev *dev, int slot);
78 void (*sync)(struct touch_dev *dev, const struct input_event *syn);
79 struct touch_dev_caps caps;
80 struct touch_dev_impl *impl;
81 void *priv;
82};
83
84struct touch_engine {
85 void (*event)(struct touch_engine *engine,
86 const struct input_event *ev);
87 void (*sync)(struct touch_engine *engine,
88 const struct input_event *syn);
89 struct touch_frame frame;
90 void *priv;
91};
92
93int touch_dev_open(struct touch_dev *dev, int fd);
94int touch_dev_idle(struct touch_dev *dev, int fd, int ms);
95int touch_dev_pull(struct touch_dev *dev, int fd);
96void touch_dev_close(struct touch_dev *dev, int fd);
97
98void touch_engine_init(struct touch_engine *engine,
99 void (*event)(struct touch_engine *engine,
100 const struct input_event *ev),
101 void (*sync)(struct touch_engine *engine,
102 const struct input_event *ev),
103 void *priv);
104void touch_engine_attach(struct touch_engine *engine, struct touch_dev *dev);
105void touch_engine_detach(struct touch_engine *engine, struct touch_dev *dev);
106
107#endif
diff --git a/include/grail-types.h b/include/grail-types.h
new file mode 100644
index 0000000..7de3d9a
--- /dev/null
+++ b/include/grail-types.h
@@ -0,0 +1,56 @@
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#ifndef _GRAIL_TYPES_H
26#define _GRAIL_TYPES_H
27
28#define GRAIL_TYPE_POINTER 0 /* reserved */
29
30#define GRAIL_TYPE_PAN 1 /* two-finger pan/scroll */
31#define GRAIL_TYPE_PINCH 2 /* two-finger pinch-to-zoom */
32#define GRAIL_TYPE_ROTATE 3 /* two-finger rotation */
33#define GRAIL_TYPE_COMBO2 4 /* two-finger combo */
34
35#define GRAIL_TYPE_SWIPE 5 /* three-finger pan */
36#define GRAIL_TYPE_SCALE 6 /* three-finger pinch */
37#define GRAIL_TYPE_TURN 7 /* three-finger rotate */
38#define GRAIL_TYPE_COMBO3 8 /* three-finger combo */
39
40#define GRAIL_TYPE_BRUSH 9 /* four-finger pan */
41#define GRAIL_TYPE_PICK 10 /* four-finger pinch */
42#define GRAIL_TYPE_WHIRL 11 /* four-finger rotate */
43#define GRAIL_TYPE_COMBO4 12 /* four-finger combo */
44
45#define GRAIL_TYPE_HAND 13 /* five-finger pan */
46#define GRAIL_TYPE_GRAB 14 /* five-finger pinch */
47#define GRAIL_TYPE_REVOLVE 15 /* five-finger rotate */
48#define GRAIL_TYPE_COMBO5 16 /* five-finger combo */
49
50#define GRAIL_TYPE_TAP1 17 /* single one-finger tap */
51#define GRAIL_TYPE_TAP2 18 /* single two-finger tap */
52#define GRAIL_TYPE_TAP3 19 /* single three-finger tap */
53#define GRAIL_TYPE_TAP4 20 /* single four-finger tap */
54#define GRAIL_TYPE_TAP5 21 /* single five-finger tap */
55
56#endif
diff --git a/include/grail.h b/include/grail.h
new file mode 100644
index 0000000..0fa4473
--- /dev/null
+++ b/include/grail.h
@@ -0,0 +1,94 @@
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#ifndef _GRAIL_H
26#define _GRAIL_H
27
28#include <grail-bits.h>
29#include <grail-types.h>
30#include <linux/input.h>
31
32#define DIM_GRAIL_TYPE 64
33#define DIM_GRAIL_TYPE_BYTES ((DIM_GRAIL_TYPE + 7) >> 3)
34
35#define DIM_GRAIL_PROP 16
36#define DIM_GRAIL_PROP_BYTES ((DIM_GRAIL_PROP + 7) >> 3)
37
38#define GRAIL_STATUS_BEGIN 0
39#define GRAIL_STATUS_UPDATE 1
40#define GRAIL_STATUS_END 2
41
42typedef float grail_prop_t;
43typedef __u64 grail_time_t;
44
45struct grail_coord {
46 float x, y;
47};
48
49struct grail_client_id {
50 int client;
51 int root, event, child;
52};
53
54struct grail_client_info {
55 struct grail_client_id id;
56 grail_mask_t mask[DIM_GRAIL_TYPE_BYTES];
57};
58
59struct grail_event {
60 int type;
61 int id;
62 int status;
63 int ntouch;
64 int nprop;
65 struct grail_coord pos;
66 struct grail_client_id client_id;
67 grail_time_t time;
68 grail_prop_t prop[DIM_GRAIL_PROP];
69};
70
71struct grail {
72 int (*get_clients)(struct grail *ge,
73 struct grail_client_info *client, int max_clients,
74 const struct grail_coord *coords, int num_coords,
75 const grail_mask_t *types, int type_bytes);
76 void (*event)(struct grail *ge,
77 const struct input_event *ev);
78 void (*gesture)(struct grail *ge,
79 const struct grail_event *ev);
80 struct grail_impl *impl;
81 struct gesture_inserter *gin;
82 struct gesture_recognizer *gru;
83 void *priv;
84};
85
86int grail_open(struct grail *ge, int fd);
87int grail_idle(struct grail *ge, int fd, int ms);
88int grail_pull(struct grail *ge, int fd);
89void grail_close(struct grail *ge, int fd);
90
91void grail_get_units(struct grail_coord *min, struct grail_coord *max,
92 const struct grail *ge);
93
94#endif