diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2008-11-09 04:20:53 +0100 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2008-11-09 04:20:53 +0100 |
| commit | b8f7fdfe1b8974a6677e73cfe7c83da70a35f4ae (patch) | |
| tree | 544cbe58102898d9eab3c80fc5be1414670810bf /src/gestures.c | |
| parent | 7952ef288f490045a4ab19b510be32512f217324 (diff) | |
Gesture interface in place
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/gestures.c')
| -rw-r--r-- | src/gestures.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/gestures.c b/src/gestures.c new file mode 100644 index 0000000..8dfb939 --- /dev/null +++ b/src/gestures.c | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | #include "gestures.h" | ||
| 2 | |||
| 3 | /******************************************************/ | ||
| 4 | |||
| 5 | void extract_gestures(struct Gestures *gs, struct MTouch* mt) | ||
| 6 | { | ||
| 7 | const struct FingerState *b = mt->ns.finger; | ||
| 8 | const struct FingerState *e = b + mt->ns.nfinger; | ||
| 9 | const struct FingerState *p, *fs; | ||
| 10 | int nof = count_fingers(&mt->os); | ||
| 11 | int nsf = count_fingers(&mt->ns); | ||
| 12 | int dn = 0, i; | ||
| 13 | memset(gs, 0, sizeof(struct Gestures)); | ||
| 14 | if (nof == nsf) { | ||
| 15 | for (p = b; p != e; p++) { | ||
| 16 | if (fs = find_finger(&mt->os, p->id)) { | ||
| 17 | gs->dx += p->hw.position_x - fs->hw.position_x; | ||
| 18 | gs->dy += p->hw.position_y - fs->hw.position_y; | ||
| 19 | dn++; | ||
| 20 | } | ||
| 21 | } | ||
| 22 | } | ||
| 23 | if (gs->dx || gs->dy) { | ||
| 24 | gs->dx /= dn; | ||
| 25 | gs->dy /= dn; | ||
| 26 | if (nsf == 1) | ||
| 27 | SETBIT(gs->type, GS_MOVE); | ||
| 28 | } | ||
| 29 | for (i = 0; i < DIM_BUTTON; i++) { | ||
| 30 | if (GETBIT(mt->ns.button, i) != GETBIT(mt->os.button, i)) { | ||
| 31 | SETBIT(gs->type, GS_BUTTON); | ||
| 32 | gs->btix[gs->nbt] = i + 1; | ||
| 33 | gs->btval[gs->nbt] = GETBIT(mt->ns.button, i); | ||
| 34 | gs->nbt++; | ||
| 35 | } | ||
| 36 | } | ||
| 37 | mt->os = mt->ns; | ||
| 38 | } | ||
| 39 | |||
