summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
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-touch.h (renamed from include/touch-dev.h)57
-rw-r--r--include/grail.h63
-rw-r--r--include/touch-engine.h56
-rw-r--r--include/touch.h57
8 files changed, 115 insertions, 332 deletions
diff --git a/include/gesture-buffer.h b/include/gesture-buffer.h
deleted file mode 100644
index 49a6dd1..0000000
--- a/include/gesture-buffer.h
+++ /dev/null
@@ -1,62 +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#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
deleted file mode 100644
index f507eb4..0000000
--- a/include/gesture-client.h
+++ /dev/null
@@ -1,48 +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#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
deleted file mode 100644
index 635fc2f..0000000
--- a/include/gesture-dev.h
+++ /dev/null
@@ -1,47 +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#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
deleted file mode 100644
index b4f2d5c..0000000
--- a/include/gesture.h
+++ /dev/null
@@ -1,57 +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#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/touch-dev.h b/include/grail-touch.h
index 4ecd61b..d6c9bf5 100644
--- a/include/touch-dev.h
+++ b/include/grail-touch.h
@@ -22,13 +22,36 @@
22 * 22 *
23 ****************************************************************************/ 23 ****************************************************************************/
24 24
25#ifndef _GRAIL_TOUCH_DEV_H 25#ifndef _GRAIL_TOUCH_H
26#define _GRAIL_TOUCH_DEV_H 26#define _GRAIL_TOUCH_H
27 27
28#include <touch.h> 28#include <mtdev.h>
29 29
30#define DIM_TOUCHES 32
31
32typedef int touch_prop_t;
33typedef unsigned touch_prop_mask_t;
30typedef __u64 touch_time_t; 34typedef __u64 touch_time_t;
31 35
36enum touch_prop_list {
37 TP_POS_X,
38 TP_POS_Y,
39 TP_TOUCH_MAJOR,
40 TP_TOUCH_MINOR,
41 TP_WIDTH_MAJOR,
42 TP_WIDTH_MINOR,
43 TP_ORIENTATION,
44 TP_PRESSURE,
45 DIM_TOUCH_PROP
46};
47
48struct touch {
49 int active;
50 int slot;
51 int next;
52 touch_prop_t prop[DIM_TOUCH_PROP];
53};
54
32struct touch_dev { 55struct touch_dev {
33 void (*event)(struct touch_dev *dev, const struct input_event *ev); 56 void (*event)(struct touch_dev *dev, const struct input_event *ev);
34 void (*create)(struct touch_dev *dev, int slot, 57 void (*create)(struct touch_dev *dev, int slot,
@@ -41,9 +64,37 @@ struct touch_dev {
41 void *priv; 64 void *priv;
42}; 65};
43 66
67struct touch_frame {
68 int ntouch;
69 int slot;
70 struct touch touch[DIM_TOUCHES];
71};
72
73struct touch_engine {
74 void (*sync)(struct touch_engine *engine, touch_time_t time);
75 struct touch_frame frame;
76 void *priv;
77};
78
79static inline int has_prop(const touch_prop_mask_t *mask, int code)
80{
81 return (mask[code >> 5] >> (code & 31)) & 1;
82}
83
84static inline int next_slot(const struct touch_frame *frame, int slot)
85{
86 return frame->touch[slot].next;
87}
88
44int touch_dev_open(struct touch_dev *dev, int fd); 89int touch_dev_open(struct touch_dev *dev, int fd);
45int touch_dev_idle(struct touch_dev *dev, int fd, int ms); 90int touch_dev_idle(struct touch_dev *dev, int fd, int ms);
46int touch_dev_pull(struct touch_dev *dev, int fd); 91int touch_dev_pull(struct touch_dev *dev, int fd);
47void touch_dev_close(struct touch_dev *dev, int fd); 92void touch_dev_close(struct touch_dev *dev, int fd);
48 93
94void touch_engine_init(struct touch_engine *engine,
95 void (*sync)(struct touch_engine *engine,
96 touch_time_t time),
97 void *priv);
98void touch_engine_attach(struct touch_engine *engine, struct touch_dev *dev);
99
49#endif 100#endif
diff --git a/include/grail.h b/include/grail.h
index b2f4a0d..087cf0c 100644
--- a/include/grail.h
+++ b/include/grail.h
@@ -25,7 +25,66 @@
25#ifndef _GRAIL_H 25#ifndef _GRAIL_H
26#define _GRAIL_H 26#define _GRAIL_H
27 27
28#include <touch-engine.h> 28#include <grail-touch.h>
29#include <gesture-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
57struct gesture_dev {
58 struct gedev_impl *impl;
59 void *priv;
60};
61
62struct gesture_client {
63 void (*gesture)(struct gesture_client *client,
64 const struct gesture_event *ev);
65 int priority[DIM_GESTURE_TYPE];
66 struct client_impl *impl;
67 void *priv;
68};
69
70int client_init(struct gesture_client *client, void *priv);
71void client_flag(struct gesture_client *client,
72 const struct gesture_flag *flag);
73void client_event(struct gesture_client *client,
74 const struct gesture_event *ev);
75void client_sync(struct gesture_client *client);
76void client_destroy(struct gesture_client *client);
77
78int gedev_init(struct gesture_dev *dev, void *priv);
79int gedev_attach_client(struct gesture_dev *dev,
80 struct gesture_client *client);
81
82void gedev_flag(struct gesture_dev *dev, const struct gesture_flag *flag);
83void gedev_event(struct gesture_dev *dev, const struct gesture_event *ev);
84void gedev_sync(struct gesture_dev *dev);
85
86void gedev_detach_client(struct gesture_dev *dev,
87 struct gesture_client *client);
88void gedev_destroy(struct gesture_dev *dev);
30 89
31#endif 90#endif
diff --git a/include/touch-engine.h b/include/touch-engine.h
deleted file mode 100644
index 389c2a7..0000000
--- a/include/touch-engine.h
+++ /dev/null
@@ -1,56 +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#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
deleted file mode 100644
index 56c0044..0000000
--- a/include/touch.h
+++ /dev/null
@@ -1,57 +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#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