diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/gestures.c | 10 | ||||
| -rw-r--r-- | src/mtstate.c | 19 | ||||
| -rw-r--r-- | src/mtstate.h | 9 |
3 files changed, 27 insertions, 11 deletions
diff --git a/src/gestures.c b/src/gestures.c index a0ef5d4..9426226 100644 --- a/src/gestures.c +++ b/src/gestures.c | |||
| @@ -31,18 +31,18 @@ | |||
| 31 | static const int FINGER_ATTACK_MS = 70; | 31 | static const int FINGER_ATTACK_MS = 70; |
| 32 | static const int FINGER_DECAY_MS = 120; | 32 | static const int FINGER_DECAY_MS = 120; |
| 33 | 33 | ||
| 34 | inline int dxval(const struct FingerState *a, const struct FingerState *b) | 34 | inline int dxval(const struct MTFinger *a, const struct MTFinger *b) |
| 35 | { | 35 | { |
| 36 | return a->hw.position_x - b->hw.position_x; | 36 | return a->hw.position_x - b->hw.position_x; |
| 37 | } | 37 | } |
| 38 | inline int dyval(const struct FingerState *a, const struct FingerState *b) | 38 | inline int dyval(const struct MTFinger *a, const struct MTFinger *b) |
| 39 | { | 39 | { |
| 40 | return a->hw.position_y - b->hw.position_y; | 40 | return a->hw.position_y - b->hw.position_y; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | static void extract_finger_configuration(struct Gestures *gs, struct MTouch* mt) | 43 | static void extract_finger_configuration(struct Gestures *gs, struct MTouch* mt) |
| 44 | { | 44 | { |
| 45 | const struct FingerState *f = mt->state.finger; | 45 | const struct MTFinger *f = mt->state.finger; |
| 46 | int i, same = mt->state.nfinger == mt->prev_state.nfinger; | 46 | int i, same = mt->state.nfinger == mt->prev_state.nfinger; |
| 47 | for (i = 0; i < mt->state.nfinger; i++) | 47 | for (i = 0; i < mt->state.nfinger; i++) |
| 48 | same = same && find_finger(&mt->prev_state, f[i].id); | 48 | same = same && find_finger(&mt->prev_state, f[i].id); |
| @@ -51,7 +51,7 @@ static void extract_finger_configuration(struct Gestures *gs, struct MTouch* mt) | |||
| 51 | 51 | ||
| 52 | static void extract_pointers(struct Gestures *gs, struct MTouch* mt) | 52 | static void extract_pointers(struct Gestures *gs, struct MTouch* mt) |
| 53 | { | 53 | { |
| 54 | const struct FingerState *f = mt->state.finger; | 54 | const struct MTFinger *f = mt->state.finger; |
| 55 | int i; | 55 | int i; |
| 56 | 56 | ||
| 57 | if (mt->state.nfinger < 2) { | 57 | if (mt->state.nfinger < 2) { |
| @@ -86,7 +86,7 @@ static void extract_pointers(struct Gestures *gs, struct MTouch* mt) | |||
| 86 | 86 | ||
| 87 | static void extract_movement(struct Gestures *gs, struct MTouch* mt) | 87 | static void extract_movement(struct Gestures *gs, struct MTouch* mt) |
| 88 | { | 88 | { |
| 89 | const struct FingerState *prev, *f = mt->state.finger; | 89 | const struct MTFinger *prev, *f = mt->state.finger; |
| 90 | int i, x = 0, y = 0; | 90 | int i, x = 0, y = 0; |
| 91 | int dx, dy, xcut, ycut, xmax = 0, ymax = 0; | 91 | int dx, dy, xcut, ycut, xmax = 0, ymax = 0; |
| 92 | 92 | ||
diff --git a/src/mtstate.c b/src/mtstate.c index a8541dc..c3bcc78 100644 --- a/src/mtstate.c +++ b/src/mtstate.c | |||
| @@ -39,6 +39,14 @@ static int touching_finger(const struct FingerData *hw, | |||
| 39 | return 1; | 39 | return 1; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | static int set_finger(struct MTFinger *f, | ||
| 43 | const struct FingerState *fs, | ||
| 44 | const struct Capabilities *caps) | ||
| 45 | { | ||
| 46 | f->hw = fs->hw; | ||
| 47 | f->id = fs->id; | ||
| 48 | } | ||
| 49 | |||
| 42 | void extract_mtstate(struct MTState *s, | 50 | void extract_mtstate(struct MTState *s, |
| 43 | const struct HWState *hs, | 51 | const struct HWState *hs, |
| 44 | const struct Capabilities *caps) | 52 | const struct Capabilities *caps) |
| @@ -46,15 +54,18 @@ void extract_mtstate(struct MTState *s, | |||
| 46 | int i; | 54 | int i; |
| 47 | 55 | ||
| 48 | s->nfinger = 0; | 56 | s->nfinger = 0; |
| 49 | for (i = 0; i < hs->nfinger; i++) | 57 | for (i = 0; i < hs->nfinger; i++) { |
| 50 | if (touching_finger(&hs->finger[i].hw, caps)) | 58 | if (!touching_finger(&hs->finger[i].hw, caps)) |
| 51 | s->finger[s->nfinger++] = hs->finger[i]; | 59 | continue; |
| 60 | set_finger(&s->finger[s->nfinger], &hs->finger[i], caps); | ||
| 61 | s->nfinger++; | ||
| 62 | } | ||
| 52 | 63 | ||
| 53 | s->button = hs->button; | 64 | s->button = hs->button; |
| 54 | s->evtime = hs->evtime; | 65 | s->evtime = hs->evtime; |
| 55 | } | 66 | } |
| 56 | 67 | ||
| 57 | const struct FingerState *find_finger(const struct MTState *s, int id) | 68 | const struct MTFinger *find_finger(const struct MTState *s, int id) |
| 58 | { | 69 | { |
| 59 | int i; | 70 | int i; |
| 60 | 71 | ||
diff --git a/src/mtstate.h b/src/mtstate.h index f8790dd..fa297cd 100644 --- a/src/mtstate.h +++ b/src/mtstate.h | |||
| @@ -24,8 +24,13 @@ | |||
| 24 | 24 | ||
| 25 | #include "hwstate.h" | 25 | #include "hwstate.h" |
| 26 | 26 | ||
| 27 | struct MTFinger { | ||
| 28 | struct FingerData hw; | ||
| 29 | int id; | ||
| 30 | }; | ||
| 31 | |||
| 27 | struct MTState { | 32 | struct MTState { |
| 28 | struct FingerState finger[DIM_FINGER]; | 33 | struct MTFinger finger[DIM_FINGER]; |
| 29 | int nfinger; | 34 | int nfinger; |
| 30 | unsigned button; | 35 | unsigned button; |
| 31 | mstime_t evtime; | 36 | mstime_t evtime; |
| @@ -37,7 +42,7 @@ void extract_mtstate(struct MTState *s, | |||
| 37 | const struct Capabilities *caps); | 42 | const struct Capabilities *caps); |
| 38 | void output_mtstate(const struct MTState *s); | 43 | void output_mtstate(const struct MTState *s); |
| 39 | 44 | ||
| 40 | const struct FingerState *find_finger(const struct MTState *s, int id); | 45 | const struct MTFinger *find_finger(const struct MTState *s, int id); |
| 41 | 46 | ||
| 42 | #endif | 47 | #endif |
| 43 | 48 | ||
