diff options
Diffstat (limited to 'include/grail-touch.h')
| -rw-r--r-- | include/grail-touch.h | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/include/grail-touch.h b/include/grail-touch.h new file mode 100644 index 0000000..d6c9bf5 --- /dev/null +++ b/include/grail-touch.h | |||
| @@ -0,0 +1,100 @@ | |||
| 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 | |||
| 30 | #define DIM_TOUCHES 32 | ||
| 31 | |||
| 32 | typedef int touch_prop_t; | ||
| 33 | typedef unsigned touch_prop_mask_t; | ||
| 34 | typedef __u64 touch_time_t; | ||
| 35 | |||
| 36 | enum 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 | |||
| 48 | struct touch { | ||
| 49 | int active; | ||
| 50 | int slot; | ||
| 51 | int next; | ||
| 52 | touch_prop_t prop[DIM_TOUCH_PROP]; | ||
| 53 | }; | ||
| 54 | |||
| 55 | struct touch_dev { | ||
| 56 | void (*event)(struct touch_dev *dev, const struct input_event *ev); | ||
| 57 | void (*create)(struct touch_dev *dev, int slot, | ||
| 58 | const touch_prop_mask_t *mask, const touch_prop_t *prop); | ||
| 59 | void (*modify)(struct touch_dev *dev, int slot, | ||
| 60 | const touch_prop_mask_t *mask, const touch_prop_t *prop); | ||
| 61 | void (*destroy)(struct touch_dev *dev, int slot); | ||
| 62 | void (*sync)(struct touch_dev *dev, touch_time_t time); | ||
| 63 | struct touch_dev_impl *impl; | ||
| 64 | void *priv; | ||
| 65 | }; | ||
| 66 | |||
| 67 | struct touch_frame { | ||
| 68 | int ntouch; | ||
| 69 | int slot; | ||
| 70 | struct touch touch[DIM_TOUCHES]; | ||
| 71 | }; | ||
| 72 | |||
| 73 | struct touch_engine { | ||
| 74 | void (*sync)(struct touch_engine *engine, touch_time_t time); | ||
| 75 | struct touch_frame frame; | ||
| 76 | void *priv; | ||
| 77 | }; | ||
| 78 | |||
| 79 | static inline int has_prop(const touch_prop_mask_t *mask, int code) | ||
| 80 | { | ||
| 81 | return (mask[code >> 5] >> (code & 31)) & 1; | ||
| 82 | } | ||
| 83 | |||
| 84 | static inline int next_slot(const struct touch_frame *frame, int slot) | ||
| 85 | { | ||
| 86 | return frame->touch[slot].next; | ||
| 87 | } | ||
| 88 | |||
| 89 | int touch_dev_open(struct touch_dev *dev, int fd); | ||
| 90 | int touch_dev_idle(struct touch_dev *dev, int fd, int ms); | ||
| 91 | int touch_dev_pull(struct touch_dev *dev, int fd); | ||
| 92 | void touch_dev_close(struct touch_dev *dev, int fd); | ||
| 93 | |||
| 94 | void touch_engine_init(struct touch_engine *engine, | ||
| 95 | void (*sync)(struct touch_engine *engine, | ||
| 96 | touch_time_t time), | ||
| 97 | void *priv); | ||
| 98 | void touch_engine_attach(struct touch_engine *engine, struct touch_dev *dev); | ||
| 99 | |||
| 100 | #endif | ||
