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 --- include/grail-bits.h | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/grail-touch.h | 35 ++++++++++++++------------- include/grail.h | 52 ++++++++++++++--------------------------- 3 files changed, 99 insertions(+), 53 deletions(-) create mode 100644 include/grail-bits.h (limited to 'include') 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 @@ +/***************************************************************************** + * + * grail - Gesture Recognition And Instantiation Library + * + * Copyright (C) 2010 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Authors: + * Henrik Rydberg + * + ****************************************************************************/ + +#ifndef _GRAIL_BITS_H +#define _GRAIL_BITS_H + +typedef unsigned char grail_mask_t; + +static inline void grail_mask_set(grail_mask_t *mask, int i) +{ + mask[i >> 3] |= (1 << (i & 7)); +} + +static inline void grail_mask_clear(grail_mask_t *mask, int i) +{ + mask[i >> 3] &= ~(1 << (i & 7)); +} + +static inline void grail_mask_modify(grail_mask_t *mask, int i, int v) +{ + if (v) + grail_mask_set(mask, i); + else + grail_mask_clear(mask, i); +} + +static inline int grail_mask_get(const grail_mask_t *mask, int i) +{ + return (mask[i >> 3] >> (i & 7)) & 1; +} + +void grail_mask_set_mask(grail_mask_t *a, const grail_mask_t *b, int bytes); +void grail_mask_clear_mask(grail_mask_t *a, const grail_mask_t *b, int bytes); + +int grail_mask_count(const grail_mask_t *mask, int bytes); +int grail_mask_get_first(const grail_mask_t *mask, int bytes); +int grail_mask_get_next(int i, const grail_mask_t *mask, int bytes); + +#define grail_mask_foreach(i, mask, bytes) \ + for (i = grail_mask_get_first(mask, bytes); \ + i >= 0; \ + i = grail_mask_get_next(i, mask, bytes)) + +#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 @@ #ifndef _GRAIL_TOUCH_H #define _GRAIL_TOUCH_H +#include #include -#define DIM_TOUCHES 32 +#define DIM_TOUCH 32 +#define DIM_TOUCH_BYTES ((DIM_TOUCH + 7) >> 3) typedef int touch_prop_t; -typedef unsigned touch_prop_mask_t; typedef __u64 touch_time_t; enum touch_prop_list { @@ -45,29 +46,37 @@ enum touch_prop_list { DIM_TOUCH_PROP }; +#define DIM_TOUCH_PROP_BYTES ((DIM_TOUCH_PROP + 7) >> 3) + struct touch { int active; int slot; - int next; touch_prop_t prop[DIM_TOUCH_PROP]; }; struct touch_frame { - int ntouch; - int slot; + int nactive; int ncreate, nmodify, ndestroy; touch_time_t time; - struct touch touch[DIM_TOUCHES]; + grail_mask_t touches[DIM_TOUCH_BYTES]; + struct touch *active[DIM_TOUCH]; + struct touch touch[DIM_TOUCH]; +}; + +struct touch_dev_caps { + grail_mask_t mask[DIM_TOUCH_PROP_BYTES]; + struct input_absinfo info[DIM_TOUCH_PROP]; }; struct touch_dev { void (*event)(struct touch_dev *dev, const struct input_event *ev); void (*create)(struct touch_dev *dev, int slot, - const touch_prop_mask_t *mask, const touch_prop_t *prop); + const grail_mask_t *mask, const touch_prop_t *prop); void (*modify)(struct touch_dev *dev, int slot, - const touch_prop_mask_t *mask, const touch_prop_t *prop); + const grail_mask_t *mask, const touch_prop_t *prop); void (*destroy)(struct touch_dev *dev, int slot); void (*sync)(struct touch_dev *dev, const struct input_event *syn); + struct touch_dev_caps caps; struct touch_dev_impl *impl; void *priv; }; @@ -81,16 +90,6 @@ struct touch_engine { void *priv; }; -static inline int has_prop(const touch_prop_mask_t *mask, int code) -{ - return (mask[code >> 5] >> (code & 31)) & 1; -} - -static inline int next_slot(const struct touch_frame *frame, int slot) -{ - return frame->touch[slot].next; -} - int touch_dev_open(struct touch_dev *dev, int fd); int touch_dev_idle(struct touch_dev *dev, int fd, int ms); int 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 @@ #ifndef _GRAIL_H #define _GRAIL_H +#include #include -#define GRAIL_STATUS_BEGIN 0 -#define GRAIL_STATUS_UPDATE 1 -#define GRAIL_STATUS_END 2 - #define DIM_GRAIL_TYPE 64 -#define DIM_GRAIL_TYPE_BYTES (DIM_GRAIL_TYPE >> 3) +#define DIM_GRAIL_TYPE_BYTES ((DIM_GRAIL_TYPE + 7) >> 3) -#define GRAIL_TYPE_MOVE 0 -#define GRAIL_TYPE_VSCROLL 1 -#define GRAIL_TYPE_HSCROLL 2 -#define GRAIL_TYPE_SCROLL 3 +#define DIM_GRAIL_PROP 16 +#define DIM_GRAIL_PROP_BYTES ((DIM_GRAIL_PROP + 7) >> 3) -#define DIM_GRAIL_PROP 8 +#define GRAIL_TYPE_MOVE 0 +#define GRAIL_TYPE_SCROLL 1 +#define GRAIL_TYPE_ZOOM 2 +#define GRAIL_TYPE_ROTATE 3 +#define GRAIL_TYPE_SZRCOMBO 4 -static const int GRAIL_NPROP[] = { - 2, /* MOVE */ - 1, /* VSCROLL */ - 1, /* HSCROLL */ - 2, /* SCROLL */ -}; +#define GRAIL_STATUS_BEGIN 0 +#define GRAIL_STATUS_UPDATE 1 +#define GRAIL_STATUS_END 2 -typedef unsigned char grail_mask_t; -typedef int grail_prop_t; +typedef float grail_prop_t; typedef __u64 grail_time_t; -static inline void grail_set_mask(grail_mask_t *mask, int i) -{ - mask[i >> 3] |= (1 << (i & 7)); -} - -static inline void grail_clear_mask(grail_mask_t *mask, int i) -{ - mask[i >> 3] &= ~(1 << (i & 7)); -} - -static inline int grail_get_mask(const grail_mask_t *mask, int i) -{ - return (mask[i >> 3] >> (i & 7)) & 1; -} - struct grail_coord { - int x, y; + float x, y; }; struct grail_client_id { @@ -85,6 +65,8 @@ struct grail_event { int type; int id; int status; + int ntouch; + int nprop; struct grail_coord pos; struct grail_client_id client_id; grail_time_t time; @@ -95,7 +77,7 @@ struct grail { int (*get_clients)(struct grail *ge, struct grail_client_info *client, int max_clients, const struct grail_coord *coords, int num_coords, - const grail_mask_t *types); + const grail_mask_t *types, int num_types); void (*event)(struct grail *ge, const struct input_event *ev); void (*gesture)(struct grail *ge, -- cgit v1.2.3