diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2011-01-02 11:00:52 +0100 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2011-01-02 12:39:07 +0100 |
| commit | c0666a895e7fe8e488332263fd106ced0ed7cab7 (patch) | |
| tree | fca88fbee4aaed6e1eed050a749ce6246a7f1966 /src/grail-event.c | |
| parent | 1e07054fbeab6e90f104c279d3246097dd838a17 (diff) | |
Replace touch logic with utouch frame engine
The original grail uses an internal touch framework and exports some
touch information as extended attributes to gesture events. This was
never quite the intention, but rather to expose gestures and touches
on a similar footing, such that grail can be input agnostic. This
patch starts off by replacing the internal touch framework with the
utouch-frame engine.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/grail-event.c')
| -rw-r--r-- | src/grail-event.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/grail-event.c b/src/grail-event.c index 23fdbb3..9c0e437 100644 --- a/src/grail-event.c +++ b/src/grail-event.c | |||
| @@ -28,17 +28,17 @@ | |||
| 28 | #include <math.h> | 28 | #include <math.h> |
| 29 | 29 | ||
| 30 | static void compute_bbox(struct grail_coord *min, struct grail_coord *max, | 30 | static void compute_bbox(struct grail_coord *min, struct grail_coord *max, |
| 31 | const struct touch_frame *frame) | 31 | const struct utouch_frame *frame) |
| 32 | { | 32 | { |
| 33 | float x, y; | 33 | float x, y; |
| 34 | int i; | 34 | int i; |
| 35 | if (frame->nactive < 1) | 35 | if (frame->num_active < 1) |
| 36 | return; | 36 | return; |
| 37 | x = frame->active[0]->x; | 37 | x = frame->active[0]->x; |
| 38 | y = frame->active[0]->y; | 38 | y = frame->active[0]->y; |
| 39 | min->x = max->x = x; | 39 | min->x = max->x = x; |
| 40 | min->y = max->y = y; | 40 | min->y = max->y = y; |
| 41 | for (i = 1; i < frame->nactive; i++) { | 41 | for (i = 1; i < frame->num_active; i++) { |
| 42 | x = frame->active[i]->x; | 42 | x = frame->active[i]->x; |
| 43 | y = frame->active[i]->y; | 43 | y = frame->active[i]->y; |
| 44 | if (x < min->x) | 44 | if (x < min->x) |
| @@ -53,10 +53,10 @@ static void compute_bbox(struct grail_coord *min, struct grail_coord *max, | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | int gin_add_contact_props(const struct gesture_inserter *gin, | 55 | int gin_add_contact_props(const struct gesture_inserter *gin, |
| 56 | grail_prop_t *prop, const struct touch_frame *frame) | 56 | grail_prop_t *prop, const struct utouch_frame *frame) |
| 57 | { | 57 | { |
| 58 | struct grail_coord min, max; | 58 | struct grail_coord min, max; |
| 59 | int i, n = 0, ntouch = frame->nactive; | 59 | int i, n = 0, ntouch = frame->num_active; |
| 60 | if (!ntouch) | 60 | if (!ntouch) |
| 61 | return n; | 61 | return n; |
| 62 | if (ntouch > 5) | 62 | if (ntouch > 5) |
| @@ -67,7 +67,7 @@ int gin_add_contact_props(const struct gesture_inserter *gin, | |||
| 67 | prop[n++] = gin_prop_x(gin, max.x); | 67 | prop[n++] = gin_prop_x(gin, max.x); |
| 68 | prop[n++] = gin_prop_y(gin, max.y); | 68 | prop[n++] = gin_prop_y(gin, max.y); |
| 69 | for (i = 0; i < ntouch; i++) { | 69 | for (i = 0; i < ntouch; i++) { |
| 70 | const struct touch *ct = frame->active[i]; | 70 | const struct utouch_contact *ct = frame->active[i]; |
| 71 | prop[n++] = ct->id; | 71 | prop[n++] = ct->id; |
| 72 | prop[n++] = gin_prop_x(gin, ct->x); | 72 | prop[n++] = gin_prop_x(gin, ct->x); |
| 73 | prop[n++] = gin_prop_y(gin, ct->y); | 73 | prop[n++] = gin_prop_y(gin, ct->y); |
| @@ -79,15 +79,15 @@ int gin_get_clients(struct grail *ge, | |||
| 79 | struct grail_client_info *info, int maxinfo, | 79 | struct grail_client_info *info, int maxinfo, |
| 80 | const grail_mask_t* types, int btypes, | 80 | const grail_mask_t* types, int btypes, |
| 81 | const grail_mask_t* span, int bspan, | 81 | const grail_mask_t* span, int bspan, |
| 82 | const struct touch_frame *frame) | 82 | const struct utouch_frame *frame) |
| 83 | { | 83 | { |
| 84 | struct grail_coord pos[DIM_TOUCH]; | 84 | struct grail_coord pos[DIM_TOUCH]; |
| 85 | int i, npos = 0; | 85 | int i, npos = 0; |
| 86 | if (!ge->get_clients) | 86 | if (!ge->get_clients) |
| 87 | return 0; | 87 | return 0; |
| 88 | grail_mask_foreach(i, span, bspan) { | 88 | grail_mask_foreach(i, span, bspan) { |
| 89 | pos[npos].x = gin_prop_x(ge->gin, frame->touch[i].x); | 89 | pos[npos].x = gin_prop_x(ge->gin, frame->slots[i]->x); |
| 90 | pos[npos].y = gin_prop_y(ge->gin, frame->touch[i].y); | 90 | pos[npos].y = gin_prop_y(ge->gin, frame->slots[i]->y); |
| 91 | npos++; | 91 | npos++; |
| 92 | } | 92 | } |
| 93 | return ge->get_clients(ge, info, maxinfo, pos, npos, types, btypes); | 93 | return ge->get_clients(ge, info, maxinfo, pos, npos, types, btypes); |
| @@ -95,7 +95,7 @@ int gin_get_clients(struct grail *ge, | |||
| 95 | 95 | ||
| 96 | void gin_send_event(struct grail *ge, struct slot_state *s, | 96 | void gin_send_event(struct grail *ge, struct slot_state *s, |
| 97 | const struct gesture_event *ev, | 97 | const struct gesture_event *ev, |
| 98 | const struct touch_frame *frame) | 98 | const struct utouch_frame *frame) |
| 99 | { | 99 | { |
| 100 | struct grail_impl *impl = ge->impl; | 100 | struct grail_impl *impl = ge->impl; |
| 101 | const struct gesture_inserter *gin = ge->gin; | 101 | const struct gesture_inserter *gin = ge->gin; |
| @@ -121,15 +121,14 @@ void gin_send_event(struct grail *ge, struct slot_state *s, | |||
| 121 | int grail_get_contacts(const struct grail *ge, | 121 | int grail_get_contacts(const struct grail *ge, |
| 122 | struct grail_contact *touch, int max_touch) | 122 | struct grail_contact *touch, int max_touch) |
| 123 | { | 123 | { |
| 124 | const struct touch_dev *dev = &ge->impl->dev; | ||
| 125 | const struct gesture_inserter *gin = ge->gin; | 124 | const struct gesture_inserter *gin = ge->gin; |
| 126 | const struct touch_frame *frame = &dev->frame; | 125 | const struct utouch_frame *frame = ge->impl->frame; |
| 127 | int i; | 126 | int i; |
| 128 | if (frame->nactive < max_touch) | 127 | if (frame->num_active < max_touch) |
| 129 | max_touch = frame->nactive; | 128 | max_touch = frame->num_active; |
| 130 | for (i = 0; i < max_touch; i++) { | 129 | for (i = 0; i < max_touch; i++) { |
| 131 | struct grail_contact *t = &touch[i]; | 130 | struct grail_contact *t = &touch[i]; |
| 132 | const struct touch *ct = frame->active[i]; | 131 | const struct utouch_contact *ct = frame->active[i]; |
| 133 | t->id = ct->id; | 132 | t->id = ct->id; |
| 134 | t->tool_type = ct->tool_type; | 133 | t->tool_type = ct->tool_type; |
| 135 | t->pos.x = gin_prop_x(gin, ct->x); | 134 | t->pos.x = gin_prop_x(gin, ct->x); |
| @@ -138,8 +137,8 @@ int grail_get_contacts(const struct grail *ge, | |||
| 138 | t->touch_minor = gin->scale_r * ct->touch_minor; | 137 | t->touch_minor = gin->scale_r * ct->touch_minor; |
| 139 | t->width_major = gin->scale_r * ct->width_major; | 138 | t->width_major = gin->scale_r * ct->width_major; |
| 140 | t->width_minor = gin->scale_r * ct->width_minor; | 139 | t->width_minor = gin->scale_r * ct->width_minor; |
| 141 | t->angle = touch_angle(dev, ct->orientation); | 140 | t->angle = ct->orientation; |
| 142 | t->pressure = touch_pressure(dev, ct->pressure); | 141 | t->pressure = ct->pressure; |
| 143 | } | 142 | } |
| 144 | return max_touch; | 143 | return max_touch; |
| 145 | } | 144 | } |
