From d07c43f9f19dc0ee38aaf44947cfc396f437490e Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 3 Aug 2010 15:01:50 +0200 Subject: 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 --- src/touch-dev.c | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'src/touch-dev.c') 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 @@ #include #include #include "evbuf.h" -#include "mtdev-plumbing.h" - -#define DIM_TOUCH 32 +#include "mtdev-details.h" struct touch_dev_impl { int id[DIM_TOUCH]; int slot; int status; - touch_prop_mask_t mask[1]; + grail_mask_t mask[DIM_TOUCH_BYTES]; touch_prop_t prop[DIM_TOUCH_PROP]; struct evbuf evbuf; struct mtdev mtdev; }; +static inline void set_info(struct touch_dev_caps *caps, int code, + const struct input_absinfo *info) +{ + grail_mask_set(caps->mask, code); + caps->info[code] = *info; +} + +static void set_caps(struct touch_dev_caps *caps, + const struct mtdev_caps *mtcaps) +{ + if (mtcaps->has_abs[MTDEV_POSITION_X]) + set_info(caps, TP_POS_X, &mtcaps->abs[MTDEV_POSITION_X]); + if (mtcaps->has_abs[MTDEV_POSITION_Y]) + set_info(caps, TP_POS_Y, &mtcaps->abs[MTDEV_POSITION_Y]); + if (mtcaps->has_abs[MTDEV_TOUCH_MAJOR]) + set_info(caps, TP_TOUCH_MAJOR, &mtcaps->abs[MTDEV_TOUCH_MAJOR]); + if (mtcaps->has_abs[MTDEV_TOUCH_MINOR]) + set_info(caps, TP_TOUCH_MINOR, &mtcaps->abs[MTDEV_TOUCH_MINOR]); + if (mtcaps->has_abs[MTDEV_WIDTH_MAJOR]) + set_info(caps, TP_WIDTH_MAJOR, &mtcaps->abs[MTDEV_WIDTH_MAJOR]); + if (mtcaps->has_abs[MTDEV_WIDTH_MINOR]) + set_info(caps, TP_WIDTH_MINOR, &mtcaps->abs[MTDEV_WIDTH_MINOR]); + if (mtcaps->has_abs[MTDEV_ORIENTATION]) + set_info(caps, TP_ORIENTATION, &mtcaps->abs[MTDEV_ORIENTATION]); + if (mtcaps->has_abs[MTDEV_PRESSURE]) + set_info(caps, TP_PRESSURE, &mtcaps->abs[MTDEV_PRESSURE]); +} + static int touch_get_fetched(struct touch_dev_impl *x, struct input_event* ev, int ev_max) { @@ -58,14 +84,9 @@ static int touch_get_fetched(struct touch_dev_impl *x, return count; } -static inline int has_any_prop(const touch_prop_mask_t *mask) -{ - return mask[0] != 0; -} - static inline void set_prop(struct touch_dev_impl *x, int code, int value) { - x->mask[code >> 5] |= 1U << (code & 31); + grail_mask_set(x->mask, code); x->prop[code] = value; } @@ -76,7 +97,8 @@ static void finish_touch(struct touch_dev *dev, dev->destroy(dev, x->slot); if (x->status > 0 && dev->create) dev->create(dev, x->slot, x->mask, x->prop); - if (x->status == 0 && has_any_prop(x->mask) && dev->modify) + if (x->status == 0 && dev->modify && + grail_mask_count(x->mask, sizeof(x->mask))) dev->modify(dev, x->slot, x->mask, x->prop); x->status = 0; memset(x->mask, 0, sizeof(x->mask)); @@ -157,6 +179,7 @@ int touch_dev_open(struct touch_dev *dev, int fd) goto error; for (i = 0; i < DIM_TOUCH; i++) x->id[i] = MT_ID_NULL; + set_caps(&dev->caps, &x->mtdev.caps); dev->impl = x; return 0; error: -- cgit v1.2.3