diff options
| -rw-r--r-- | src/gestures.c | 30 | ||||
| -rw-r--r-- | src/gestures.h | 2 |
2 files changed, 18 insertions, 14 deletions
diff --git a/src/gestures.c b/src/gestures.c index 432f3af..28d0417 100644 --- a/src/gestures.c +++ b/src/gestures.c | |||
| @@ -42,6 +42,15 @@ inline int dyval(const struct FingerState *a, const struct FingerState *b) | |||
| 42 | return a->hw.position_y - b->hw.position_y; | 42 | return a->hw.position_y - b->hw.position_y; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | static void extract_finger_configuration(struct Gestures *gs, struct MTouch* mt) | ||
| 46 | { | ||
| 47 | const struct FingerState *f = mt->state.finger; | ||
| 48 | int i, same = mt->state.nfinger == mt->prev_state.nfinger; | ||
| 49 | for (i = 0; i < mt->state.nfinger; i++) | ||
| 50 | same = same && find_finger(&mt->prev_state, f[i].id); | ||
| 51 | gs->same_fingers = same; | ||
| 52 | } | ||
| 53 | |||
| 45 | static void extract_pointers(struct Gestures *gs, struct MTouch* mt) | 54 | static void extract_pointers(struct Gestures *gs, struct MTouch* mt) |
| 46 | { | 55 | { |
| 47 | const struct FingerState *f = mt->state.finger; | 56 | const struct FingerState *f = mt->state.finger; |
| @@ -54,7 +63,7 @@ static void extract_pointers(struct Gestures *gs, struct MTouch* mt) | |||
| 54 | return; | 63 | return; |
| 55 | } | 64 | } |
| 56 | 65 | ||
| 57 | if (mt->state.nfinger == mt->prev_state.nfinger) { | 66 | if (gs->same_fingers) { |
| 58 | for (i = 0; i < mt->state.nfinger; i++) { | 67 | for (i = 0; i < mt->state.nfinger; i++) { |
| 59 | if (GETBIT(mt->mem.pointing, i)) | 68 | if (GETBIT(mt->mem.pointing, i)) |
| 60 | continue; | 69 | continue; |
| @@ -83,9 +92,8 @@ static void extract_pointers(struct Gestures *gs, struct MTouch* mt) | |||
| 83 | 92 | ||
| 84 | static void extract_movement(struct Gestures *gs, struct MTouch* mt) | 93 | static void extract_movement(struct Gestures *gs, struct MTouch* mt) |
| 85 | { | 94 | { |
| 86 | const struct FingerState *prev[DIM_FINGER]; | 95 | const struct FingerState *prev, *f = mt->state.finger; |
| 87 | const struct FingerState *f = mt->state.finger; | 96 | int i, x = 0, y = 0; |
| 88 | int same_fingers, i, x = 0, y = 0; | ||
| 89 | int dx, dy, xcut, ycut, xmax = 0, ymax = 0; | 97 | int dx, dy, xcut, ycut, xmax = 0, ymax = 0; |
| 90 | 98 | ||
| 91 | mt->mem.moving = 0; | 99 | mt->mem.moving = 0; |
| @@ -94,13 +102,7 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt) | |||
| 94 | if (mt->state.nfinger == 0) | 102 | if (mt->state.nfinger == 0) |
| 95 | return; | 103 | return; |
| 96 | 104 | ||
| 97 | same_fingers = mt->state.nfinger == mt->prev_state.nfinger; | 105 | if (!gs->same_fingers) { |
| 98 | for (i = 0; i < mt->state.nfinger; i++) { | ||
| 99 | prev[i] = find_finger(&mt->prev_state, mt->state.finger[i].id); | ||
| 100 | same_fingers = same_fingers && prev[i]; | ||
| 101 | } | ||
| 102 | |||
| 103 | if (!same_fingers) { | ||
| 104 | mt->mem.move_time = mt->state.evtime; | 106 | mt->mem.move_time = mt->state.evtime; |
| 105 | if (mt->state.nfinger > mt->prev_state.nfinger) | 107 | if (mt->state.nfinger > mt->prev_state.nfinger) |
| 106 | mt->mem.move_time += FINGER_ATTACK_MS; | 108 | mt->mem.move_time += FINGER_ATTACK_MS; |
| @@ -112,8 +114,9 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt) | |||
| 112 | for (i = 0; i < mt->state.nfinger; i++) { | 114 | for (i = 0; i < mt->state.nfinger; i++) { |
| 113 | if (!GETBIT(mt->mem.pointing, i)) | 115 | if (!GETBIT(mt->mem.pointing, i)) |
| 114 | continue; | 116 | continue; |
| 115 | dx = dxval(&f[i], prev[i]); | 117 | prev = find_finger(&mt->prev_state, f[i].id); |
| 116 | dy = dyval(&f[i], prev[i]); | 118 | dx = dxval(&f[i], prev); |
| 119 | dy = dyval(&f[i], prev); | ||
| 117 | mt->mem.dx[i] += dx; | 120 | mt->mem.dx[i] += dx; |
| 118 | mt->mem.dy[i] += dy; | 121 | mt->mem.dy[i] += dy; |
| 119 | xmax = maxval(xmax, abs(mt->mem.dx[i])); | 122 | xmax = maxval(xmax, abs(mt->mem.dx[i])); |
| @@ -186,6 +189,7 @@ static void extract_type(struct Gestures *gs, struct MTouch* mt) | |||
| 186 | void extract_gestures(struct Gestures *gs, struct MTouch* mt) | 189 | void extract_gestures(struct Gestures *gs, struct MTouch* mt) |
| 187 | { | 190 | { |
| 188 | memset(gs, 0, sizeof(struct Gestures)); | 191 | memset(gs, 0, sizeof(struct Gestures)); |
| 192 | extract_finger_configuration(gs, mt); | ||
| 189 | extract_pointers(gs, mt); | 193 | extract_pointers(gs, mt); |
| 190 | extract_movement(gs, mt); | 194 | extract_movement(gs, mt); |
| 191 | extract_buttons(gs, mt); | 195 | extract_buttons(gs, mt); |
diff --git a/src/gestures.h b/src/gestures.h index e99bc3d..5630d4c 100644 --- a/src/gestures.h +++ b/src/gestures.h | |||
| @@ -33,7 +33,7 @@ | |||
| 33 | 33 | ||
| 34 | struct Gestures { | 34 | struct Gestures { |
| 35 | unsigned type, btmask, btdata; | 35 | unsigned type, btmask, btdata; |
| 36 | int dx, dy; | 36 | int same_fingers, dx, dy; |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | void extract_gestures(struct Gestures *gs, struct MTouch* mt); | 39 | void extract_gestures(struct Gestures *gs, struct MTouch* mt); |
