diff options
| author | Henrik Rydberg <rydberg@bitmath.org> | 2010-08-03 15:01:50 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-08-05 22:48:38 +0200 |
| commit | d07c43f9f19dc0ee38aaf44947cfc396f437490e (patch) | |
| tree | 2f9af561594a1de5553ba85b69b50bee421d5507 /src/touch-dev.c | |
| parent | 342a43e7b2ceec1dd200bffa24b052fec33f5bdc (diff) | |
Introduce zoom, rotate and combo gestures
Introduce grail_mask bit functions, and add new gestures as separate
functions, referring to the same move model.
Signed-off-by: Henrik Rydberg <rydberg@bitmath.org>
Diffstat (limited to 'src/touch-dev.c')
| -rw-r--r-- | src/touch-dev.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/touch-dev.c b/src/touch-dev.c index b7efb35..3c3036c 100644 --- a/src/touch-dev.c +++ b/src/touch-dev.c | |||
| @@ -27,20 +27,46 @@ | |||
| 27 | #include <string.h> | 27 | #include <string.h> |
| 28 | #include <errno.h> | 28 | #include <errno.h> |
| 29 | #include "evbuf.h" | 29 | #include "evbuf.h" |
| 30 | #include "mtdev-plumbing.h" | 30 | #include "mtdev-details.h" |
| 31 | |||
| 32 | #define DIM_TOUCH 32 | ||
| 33 | 31 | ||
| 34 | struct touch_dev_impl { | 32 | struct touch_dev_impl { |
| 35 | int id[DIM_TOUCH]; | 33 | int id[DIM_TOUCH]; |
| 36 | int slot; | 34 | int slot; |
| 37 | int status; | 35 | int status; |
| 38 | touch_prop_mask_t mask[1]; | 36 | grail_mask_t mask[DIM_TOUCH_BYTES]; |
| 39 | touch_prop_t prop[DIM_TOUCH_PROP]; | 37 | touch_prop_t prop[DIM_TOUCH_PROP]; |
| 40 | struct evbuf evbuf; | 38 | struct evbuf evbuf; |
| 41 | struct mtdev mtdev; | 39 | struct mtdev mtdev; |
| 42 | }; | 40 | }; |
| 43 | 41 | ||
| 42 | static inline void set_info(struct touch_dev_caps *caps, int code, | ||
| 43 | const struct input_absinfo *info) | ||
| 44 | { | ||
| 45 | grail_mask_set(caps->mask, code); | ||
| 46 | caps->info[code] = *info; | ||
| 47 | } | ||
| 48 | |||
| 49 | static void set_caps(struct touch_dev_caps *caps, | ||
| 50 | const struct mtdev_caps *mtcaps) | ||
| 51 | { | ||
| 52 | if (mtcaps->has_abs[MTDEV_POSITION_X]) | ||
| 53 | set_info(caps, TP_POS_X, &mtcaps->abs[MTDEV_POSITION_X]); | ||
| 54 | if (mtcaps->has_abs[MTDEV_POSITION_Y]) | ||
| 55 | set_info(caps, TP_POS_Y, &mtcaps->abs[MTDEV_POSITION_Y]); | ||
| 56 | if (mtcaps->has_abs[MTDEV_TOUCH_MAJOR]) | ||
| 57 | set_info(caps, TP_TOUCH_MAJOR, &mtcaps->abs[MTDEV_TOUCH_MAJOR]); | ||
| 58 | if (mtcaps->has_abs[MTDEV_TOUCH_MINOR]) | ||
| 59 | set_info(caps, TP_TOUCH_MINOR, &mtcaps->abs[MTDEV_TOUCH_MINOR]); | ||
| 60 | if (mtcaps->has_abs[MTDEV_WIDTH_MAJOR]) | ||
| 61 | set_info(caps, TP_WIDTH_MAJOR, &mtcaps->abs[MTDEV_WIDTH_MAJOR]); | ||
| 62 | if (mtcaps->has_abs[MTDEV_WIDTH_MINOR]) | ||
| 63 | set_info(caps, TP_WIDTH_MINOR, &mtcaps->abs[MTDEV_WIDTH_MINOR]); | ||
| 64 | if (mtcaps->has_abs[MTDEV_ORIENTATION]) | ||
| 65 | set_info(caps, TP_ORIENTATION, &mtcaps->abs[MTDEV_ORIENTATION]); | ||
| 66 | if (mtcaps->has_abs[MTDEV_PRESSURE]) | ||
| 67 | set_info(caps, TP_PRESSURE, &mtcaps->abs[MTDEV_PRESSURE]); | ||
| 68 | } | ||
| 69 | |||
| 44 | static int touch_get_fetched(struct touch_dev_impl *x, | 70 | static int touch_get_fetched(struct touch_dev_impl *x, |
| 45 | struct input_event* ev, int ev_max) | 71 | struct input_event* ev, int ev_max) |
| 46 | { | 72 | { |
| @@ -58,14 +84,9 @@ static int touch_get_fetched(struct touch_dev_impl *x, | |||
| 58 | return count; | 84 | return count; |
| 59 | } | 85 | } |
| 60 | 86 | ||
| 61 | static inline int has_any_prop(const touch_prop_mask_t *mask) | ||
| 62 | { | ||
| 63 | return mask[0] != 0; | ||
| 64 | } | ||
| 65 | |||
| 66 | static inline void set_prop(struct touch_dev_impl *x, int code, int value) | 87 | static inline void set_prop(struct touch_dev_impl *x, int code, int value) |
| 67 | { | 88 | { |
| 68 | x->mask[code >> 5] |= 1U << (code & 31); | 89 | grail_mask_set(x->mask, code); |
| 69 | x->prop[code] = value; | 90 | x->prop[code] = value; |
| 70 | } | 91 | } |
| 71 | 92 | ||
| @@ -76,7 +97,8 @@ static void finish_touch(struct touch_dev *dev, | |||
| 76 | dev->destroy(dev, x->slot); | 97 | dev->destroy(dev, x->slot); |
| 77 | if (x->status > 0 && dev->create) | 98 | if (x->status > 0 && dev->create) |
| 78 | dev->create(dev, x->slot, x->mask, x->prop); | 99 | dev->create(dev, x->slot, x->mask, x->prop); |
| 79 | if (x->status == 0 && has_any_prop(x->mask) && dev->modify) | 100 | if (x->status == 0 && dev->modify && |
| 101 | grail_mask_count(x->mask, sizeof(x->mask))) | ||
| 80 | dev->modify(dev, x->slot, x->mask, x->prop); | 102 | dev->modify(dev, x->slot, x->mask, x->prop); |
| 81 | x->status = 0; | 103 | x->status = 0; |
| 82 | memset(x->mask, 0, sizeof(x->mask)); | 104 | memset(x->mask, 0, sizeof(x->mask)); |
| @@ -157,6 +179,7 @@ int touch_dev_open(struct touch_dev *dev, int fd) | |||
| 157 | goto error; | 179 | goto error; |
| 158 | for (i = 0; i < DIM_TOUCH; i++) | 180 | for (i = 0; i < DIM_TOUCH; i++) |
| 159 | x->id[i] = MT_ID_NULL; | 181 | x->id[i] = MT_ID_NULL; |
| 182 | set_caps(&dev->caps, &x->mtdev.caps); | ||
| 160 | dev->impl = x; | 183 | dev->impl = x; |
| 161 | return 0; | 184 | return 0; |
| 162 | error: | 185 | error: |
