summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@bitmath.org>2010-07-13 11:26:46 +0200
committerHenrik Rydberg <rydberg@bitmath.org>2010-07-13 11:26:46 +0200
commit3b837806891de6cf77d4d74d04567e7e68c82fc0 (patch)
tree88073a81fa5be071f52a0999134fbd93d2881819 /include
Gesture Recognition And Instantiation Library (grail)
The aim of this first commit is to get down to hard testing of concepts, and the library currently has two test programs, touch and grail, which can be run on commandline. Touch tests the touch interface, and grail tests the gesture interface. Expect thinking errors and some glitches. Other than that, the code runs fine. Signed-off-by: Henrik Rydberg <rydberg@bitmath.org>
Diffstat (limited to 'include')
-rw-r--r--include/gesture-buffer.h62
-rw-r--r--include/gesture-client.h48
-rw-r--r--include/gesture-dev.h47
-rw-r--r--include/gesture.h57
-rw-r--r--include/grail.h31
-rw-r--r--include/touch-dev.h49
-rw-r--r--include/touch-engine.h56
-rw-r--r--include/touch.h57
8 files changed, 407 insertions, 0 deletions
diff --git a/include/gesture-buffer.h b/include/gesture-buffer.h
new file mode 100644
index 0000000..49a6dd1
--- /dev/null
+++ b/include/gesture-buffer.h
@@ -0,0 +1,62 @@
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_GESTURE_BUFFER_H
26#define _GRAIL_GESTURE_BUFFER_H
27
28#include <gesture.h>
29
30#define DIM_GESTURE_EVENTS 512
31
32struct gebuf {
33 int head;
34 int tail;
35 struct gesture_event buffer[DIM_GESTURE_EVENTS];
36};
37
38static inline void gebuf_clear(struct gebuf *gebuf)
39{
40 gebuf->head = gebuf->tail = 0;
41}
42
43static inline int gebuf_empty(const struct gebuf *gebuf)
44{
45 return gebuf->head == gebuf->tail;
46}
47
48static inline void gebuf_put(struct gebuf *gebuf,
49 const struct gesture_event *ev)
50{
51 gebuf->buffer[gebuf->head++] = *ev;
52 gebuf->head &= DIM_GESTURE_EVENTS - 1;
53}
54
55static inline void gebuf_get(struct gebuf *gebuf,
56 struct gesture_event *ev)
57{
58 *ev = gebuf->buffer[gebuf->tail++];
59 gebuf->tail &= DIM_GESTURE_EVENTS - 1;
60}
61
62#endif
diff --git a/include/gesture-client.h b/include/gesture-client.h
new file mode 100644
index 0000000..f507eb4
--- /dev/null
+++ b/include/gesture-client.h
@@ -0,0 +1,48 @@
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_GESTURE_CLIENT_H
26#define _GRAIL_GESTURE_CLIENT_H
27
28#include <gesture.h>
29
30struct gesture_client {
31 void (*gesture)(struct gesture_client *client,
32 const struct gesture_event *ev);
33 int priority[DIM_GESTURE_TYPE];
34 struct client_impl *impl;
35 void *priv;
36};
37
38int client_init(struct gesture_client *client, void *priv);
39
40void client_flag(struct gesture_client *client,
41 const struct gesture_flag *flag);
42void client_event(struct gesture_client *client,
43 const struct gesture_event *ev);
44void client_sync(struct gesture_client *client);
45
46void client_destroy(struct gesture_client *client);
47
48#endif
diff --git a/include/gesture-dev.h b/include/gesture-dev.h
new file mode 100644
index 0000000..635fc2f
--- /dev/null
+++ b/include/gesture-dev.h
@@ -0,0 +1,47 @@
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_GESTURE_DEV_H
26#define _GRAIL_GESTURE_DEV_H
27
28#include <gesture-client.h>
29
30struct gesture_dev {
31 struct gedev_impl *impl;
32 void *priv;
33};
34
35int gedev_init(struct gesture_dev *dev, void *priv);
36int gedev_attach_client(struct gesture_dev *dev,
37 struct gesture_client *client);
38
39void gedev_flag(struct gesture_dev *dev, const struct gesture_flag *flag);
40void gedev_event(struct gesture_dev *dev, const struct gesture_event *ev);
41void gedev_sync(struct gesture_dev *dev);
42
43void gedev_detach_client(struct gesture_dev *dev,
44 struct gesture_client *client);
45void gedev_destroy(struct gesture_dev *dev);
46
47#endif
diff --git a/include/gesture.h b/include/gesture.h
new file mode 100644
index 0000000..b4f2d5c
--- /dev/null
+++ b/include/gesture.h
@@ -0,0 +1,57 @@
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_GESTURE_H
26#define _GRAIL_GESTURE_H
27
28#include <touch-dev.h>
29
30#define DIM_GESTURE_PROP 8
31typedef int gesture_prop_t;
32
33enum gesture_type {
34 GE_MOVE,
35 GE_VSCROLL,
36 DIM_GESTURE_TYPE
37};
38
39enum gesture_state {
40 GS_CANCEL,
41 GS_BEGIN,
42 GS_END
43};
44
45struct gesture_flag {
46 enum gesture_type type;
47 touch_time_t time;
48 enum gesture_state state;
49};
50
51struct gesture_event {
52 enum gesture_type type;
53 touch_time_t time;
54 gesture_prop_t prop[DIM_GESTURE_PROP];
55};
56
57#endif
diff --git a/include/grail.h b/include/grail.h
new file mode 100644
index 0000000..b2f4a0d
--- /dev/null
+++ b/include/grail.h
@@ -0,0 +1,31 @@
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 <touch-engine.h>
29#include <gesture-dev.h>
30
31#endif
diff --git a/include/touch-dev.h b/include/touch-dev.h
new file mode 100644
index 0000000..4ecd61b
--- /dev/null
+++ b/include/touch-dev.h
@@ -0,0 +1,49 @@
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_DEV_H
26#define _GRAIL_TOUCH_DEV_H
27
28#include <touch.h>
29
30typedef __u64 touch_time_t;
31
32struct touch_dev {
33 void (*event)(struct touch_dev *dev, const struct input_event *ev);
34 void (*create)(struct touch_dev *dev, int slot,
35 const touch_prop_mask_t *mask, const touch_prop_t *prop);
36 void (*modify)(struct touch_dev *dev, int slot,
37 const touch_prop_mask_t *mask, const touch_prop_t *prop);
38 void (*destroy)(struct touch_dev *dev, int slot);
39 void (*sync)(struct touch_dev *dev, touch_time_t time);
40 struct touch_dev_impl *impl;
41 void *priv;
42};
43
44int touch_dev_open(struct touch_dev *dev, int fd);
45int touch_dev_idle(struct touch_dev *dev, int fd, int ms);
46int touch_dev_pull(struct touch_dev *dev, int fd);
47void touch_dev_close(struct touch_dev *dev, int fd);
48
49#endif
diff --git a/include/touch-engine.h b/include/touch-engine.h
new file mode 100644
index 0000000..389c2a7
--- /dev/null
+++ b/include/touch-engine.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_TOUCH_ENGINE_H
26#define _GRAIL_TOUCH_ENGINE_H
27
28#include <touch-dev.h>
29
30#define DIM_TOUCHES 32
31
32struct touch_frame {
33 int ntouch;
34 int slot;
35 struct touch touch[DIM_TOUCHES];
36};
37
38static inline int next_slot(const struct touch_frame *frame, int slot)
39{
40 return frame->touch[slot].next;
41}
42
43struct touch_engine {
44 void (*sync)(struct touch_engine *engine, touch_time_t time);
45 struct touch_frame frame;
46 void *priv;
47};
48
49void touch_engine_init(struct touch_engine *engine,
50 void (*sync)(struct touch_engine *engine,
51 touch_time_t time),
52 void *priv);
53void touch_engine_attach(struct touch_engine *engine, struct touch_dev *dev);
54void touch_engine_detach(struct touch_engine *engine, struct touch_dev *dev);
55
56#endif
diff --git a/include/touch.h b/include/touch.h
new file mode 100644
index 0000000..56c0044
--- /dev/null
+++ b/include/touch.h
@@ -0,0 +1,57 @@
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 <mtdev.h>
29
30enum touch_prop_list {
31 TP_POS_X,
32 TP_POS_Y,
33 TP_TOUCH_MAJOR,
34 TP_TOUCH_MINOR,
35 TP_WIDTH_MAJOR,
36 TP_WIDTH_MINOR,
37 TP_ORIENTATION,
38 TP_PRESSURE,
39 DIM_TOUCH_PROP
40};
41
42typedef int touch_prop_t;
43typedef unsigned touch_prop_mask_t;
44
45struct touch {
46 int active;
47 int slot;
48 int next;
49 touch_prop_t prop[DIM_TOUCH_PROP];
50};
51
52static inline int has_prop(const touch_prop_mask_t *mask, int code)
53{
54 return (mask[code >> 5] >> (code & 31)) & 1;
55}
56
57#endif