summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/grail-bits.h65
-rw-r--r--include/grail-touch.h35
-rw-r--r--include/grail.h52
3 files changed, 99 insertions, 53 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
index e07ffca..5bf0034 100644
--- a/include/grail-touch.h
+++ b/include/grail-touch.h
@@ -25,12 +25,13 @@
25#ifndef _GRAIL_TOUCH_H 25#ifndef _GRAIL_TOUCH_H
26#define _GRAIL_TOUCH_H 26#define _GRAIL_TOUCH_H
27 27
28#include <grail-bits.h>
28#include <mtdev.h> 29#include <mtdev.h>
29 30
30#define DIM_TOUCHES 32 31#define DIM_TOUCH 32
32#define DIM_TOUCH_BYTES ((DIM_TOUCH + 7) >> 3)
31 33
32typedef int touch_prop_t; 34typedef int touch_prop_t;
33typedef unsigned touch_prop_mask_t;
34typedef __u64 touch_time_t; 35typedef __u64 touch_time_t;
35 36
36enum touch_prop_list { 37enum touch_prop_list {
@@ -45,29 +46,37 @@ enum touch_prop_list {
45 DIM_TOUCH_PROP 46 DIM_TOUCH_PROP
46}; 47};
47 48
49#define DIM_TOUCH_PROP_BYTES ((DIM_TOUCH_PROP + 7) >> 3)
50
48struct touch { 51struct touch {
49 int active; 52 int active;
50 int slot; 53 int slot;
51 int next;
52 touch_prop_t prop[DIM_TOUCH_PROP]; 54 touch_prop_t prop[DIM_TOUCH_PROP];
53}; 55};
54 56
55struct touch_frame { 57struct touch_frame {
56 int ntouch; 58 int nactive;
57 int slot;
58 int ncreate, nmodify, ndestroy; 59 int ncreate, nmodify, ndestroy;
59 touch_time_t time; 60 touch_time_t time;
60 struct touch touch[DIM_TOUCHES]; 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];
61}; 69};
62 70
63struct touch_dev { 71struct touch_dev {
64 void (*event)(struct touch_dev *dev, const struct input_event *ev); 72 void (*event)(struct touch_dev *dev, const struct input_event *ev);
65 void (*create)(struct touch_dev *dev, int slot, 73 void (*create)(struct touch_dev *dev, int slot,
66 const touch_prop_mask_t *mask, const touch_prop_t *prop); 74 const grail_mask_t *mask, const touch_prop_t *prop);
67 void (*modify)(struct touch_dev *dev, int slot, 75 void (*modify)(struct touch_dev *dev, int slot,
68 const touch_prop_mask_t *mask, const touch_prop_t *prop); 76 const grail_mask_t *mask, const touch_prop_t *prop);
69 void (*destroy)(struct touch_dev *dev, int slot); 77 void (*destroy)(struct touch_dev *dev, int slot);
70 void (*sync)(struct touch_dev *dev, const struct input_event *syn); 78 void (*sync)(struct touch_dev *dev, const struct input_event *syn);
79 struct touch_dev_caps caps;
71 struct touch_dev_impl *impl; 80 struct touch_dev_impl *impl;
72 void *priv; 81 void *priv;
73}; 82};
@@ -81,16 +90,6 @@ struct touch_engine {
81 void *priv; 90 void *priv;
82}; 91};
83 92
84static inline int has_prop(const touch_prop_mask_t *mask, int code)
85{
86 return (mask[code >> 5] >> (code & 31)) & 1;
87}
88
89static inline int next_slot(const struct touch_frame *frame, int slot)
90{
91 return frame->touch[slot].next;
92}
93
94int touch_dev_open(struct touch_dev *dev, int fd); 93int touch_dev_open(struct touch_dev *dev, int fd);
95int touch_dev_idle(struct touch_dev *dev, int fd, int ms); 94int touch_dev_idle(struct touch_dev *dev, int fd, int ms);
96int touch_dev_fetch(struct touch_dev *dev, int fd); 95int touch_dev_fetch(struct touch_dev *dev, int fd);
diff --git a/include/grail.h b/include/grail.h
index de202b5..0570101 100644
--- a/include/grail.h
+++ b/include/grail.h
@@ -25,50 +25,30 @@
25#ifndef _GRAIL_H 25#ifndef _GRAIL_H
26#define _GRAIL_H 26#define _GRAIL_H
27 27
28#include <grail-bits.h>
28#include <linux/input.h> 29#include <linux/input.h>
29 30
30#define GRAIL_STATUS_BEGIN 0
31#define GRAIL_STATUS_UPDATE 1
32#define GRAIL_STATUS_END 2
33
34#define DIM_GRAIL_TYPE 64 31#define DIM_GRAIL_TYPE 64
35#define DIM_GRAIL_TYPE_BYTES (DIM_GRAIL_TYPE >> 3) 32#define DIM_GRAIL_TYPE_BYTES ((DIM_GRAIL_TYPE + 7) >> 3)
36 33
37#define GRAIL_TYPE_MOVE 0 34#define DIM_GRAIL_PROP 16
38#define GRAIL_TYPE_VSCROLL 1 35#define DIM_GRAIL_PROP_BYTES ((DIM_GRAIL_PROP + 7) >> 3)
39#define GRAIL_TYPE_HSCROLL 2
40#define GRAIL_TYPE_SCROLL 3
41 36
42#define DIM_GRAIL_PROP 8 37#define GRAIL_TYPE_MOVE 0
38#define GRAIL_TYPE_SCROLL 1
39#define GRAIL_TYPE_ZOOM 2
40#define GRAIL_TYPE_ROTATE 3
41#define GRAIL_TYPE_SZRCOMBO 4
43 42
44static const int GRAIL_NPROP[] = { 43#define GRAIL_STATUS_BEGIN 0
45 2, /* MOVE */ 44#define GRAIL_STATUS_UPDATE 1
46 1, /* VSCROLL */ 45#define GRAIL_STATUS_END 2
47 1, /* HSCROLL */
48 2, /* SCROLL */
49};
50 46
51typedef unsigned char grail_mask_t; 47typedef float grail_prop_t;
52typedef int grail_prop_t;
53typedef __u64 grail_time_t; 48typedef __u64 grail_time_t;
54 49
55static inline void grail_set_mask(grail_mask_t *mask, int i)
56{
57 mask[i >> 3] |= (1 << (i & 7));
58}
59
60static inline void grail_clear_mask(grail_mask_t *mask, int i)
61{
62 mask[i >> 3] &= ~(1 << (i & 7));
63}
64
65static inline int grail_get_mask(const grail_mask_t *mask, int i)
66{
67 return (mask[i >> 3] >> (i & 7)) & 1;
68}
69
70struct grail_coord { 50struct grail_coord {
71 int x, y; 51 float x, y;
72}; 52};
73 53
74struct grail_client_id { 54struct grail_client_id {
@@ -85,6 +65,8 @@ struct grail_event {
85 int type; 65 int type;
86 int id; 66 int id;
87 int status; 67 int status;
68 int ntouch;
69 int nprop;
88 struct grail_coord pos; 70 struct grail_coord pos;
89 struct grail_client_id client_id; 71 struct grail_client_id client_id;
90 grail_time_t time; 72 grail_time_t time;
@@ -95,7 +77,7 @@ struct grail {
95 int (*get_clients)(struct grail *ge, 77 int (*get_clients)(struct grail *ge,
96 struct grail_client_info *client, int max_clients, 78 struct grail_client_info *client, int max_clients,
97 const struct grail_coord *coords, int num_coords, 79 const struct grail_coord *coords, int num_coords,
98 const grail_mask_t *types); 80 const grail_mask_t *types, int num_types);
99 void (*event)(struct grail *ge, 81 void (*event)(struct grail *ge,
100 const struct input_event *ev); 82 const struct input_event *ev);
101 void (*gesture)(struct grail *ge, 83 void (*gesture)(struct grail *ge,