diff options
Diffstat (limited to 'src/memory.c')
| -rw-r--r-- | src/memory.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/memory.c b/src/memory.c index 4cfb7da..748aa07 100644 --- a/src/memory.c +++ b/src/memory.c | |||
| @@ -32,13 +32,15 @@ static const int FINGER_ATTACK_MS = 40; | |||
| 32 | static const int FINGER_DECAY_MS = 120; | 32 | static const int FINGER_DECAY_MS = 120; |
| 33 | static const int FINGER_CORNER_MS = 150; | 33 | static const int FINGER_CORNER_MS = 150; |
| 34 | 34 | ||
| 35 | static inline int dxval(const struct MTFinger *a, const struct MTFinger *b) | 35 | static inline int dxval(const struct FingerState *a, |
| 36 | const struct FingerState *b) | ||
| 36 | { | 37 | { |
| 37 | return a->hw.position_x - b->hw.position_x; | 38 | return a->position_x - b->position_x; |
| 38 | } | 39 | } |
| 39 | static inline int dyval(const struct MTFinger *a, const struct MTFinger *b) | 40 | static inline int dyval(const struct FingerState *a, |
| 41 | const struct FingerState *b) | ||
| 40 | { | 42 | { |
| 41 | return a->hw.position_y - b->hw.position_y; | 43 | return a->position_y - b->position_y; |
| 42 | } | 44 | } |
| 43 | 45 | ||
| 44 | void init_memory(struct Memory *mem) | 46 | void init_memory(struct Memory *mem) |
| @@ -60,20 +62,18 @@ static void update_configuration(struct Memory *m, | |||
| 60 | const struct MTState *prev_state, | 62 | const struct MTState *prev_state, |
| 61 | const struct MTState *state) | 63 | const struct MTState *state) |
| 62 | { | 64 | { |
| 63 | const struct MTFinger *f = state->finger; | 65 | const struct FingerState *f = state->finger; |
| 64 | bitmask_t fingers = BITONES(state->nfinger); | 66 | bitmask_t fingers = BITONES(state->nfinger); |
| 65 | int i; | 67 | int i; |
| 66 | m->added = 0; | 68 | m->added = 0; |
| 67 | foreach_bit(i, fingers) | 69 | foreach_bit(i, fingers) |
| 68 | if (!find_finger(prev_state, f[i].id)) | 70 | if (!find_finger(prev_state, f[i].tracking_id)) |
| 69 | SETBIT(m->added, i); | 71 | SETBIT(m->added, i); |
| 70 | m->same = m->fingers == fingers && m->added == 0; | 72 | m->same = m->fingers == fingers && m->added == 0; |
| 71 | m->fingers = fingers; | 73 | m->fingers = fingers; |
| 72 | if (!m->same) | 74 | if (!m->same) |
| 73 | m->thumb = 0; | 75 | m->thumb = 0; |
| 74 | foreach_bit(i, fingers) | 76 | m->thumb |= state->thumb; |
| 75 | if (f[i].thumb) | ||
| 76 | SETBIT(m->thumb, i); | ||
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | /** | 79 | /** |
| @@ -90,8 +90,9 @@ static void update_pointers(struct Memory *m, | |||
| 90 | const struct MTState *state, | 90 | const struct MTState *state, |
| 91 | const struct Capabilities *caps) | 91 | const struct Capabilities *caps) |
| 92 | { | 92 | { |
| 93 | const struct MTFinger *f = state->finger; | 93 | const struct FingerState *f = state->finger; |
| 94 | int yclick = caps->abs[BIT_POSITION_Y].maximum - CLICK_AREA(caps); | 94 | int yclick = caps->abs[BIT_POSITION_Y].maximum - CLICK_AREA(caps); |
| 95 | |||
| 95 | int i; | 96 | int i; |
| 96 | 97 | ||
| 97 | if (state->nfinger < 2) { | 98 | if (state->nfinger < 2) { |
| @@ -102,7 +103,7 @@ static void update_pointers(struct Memory *m, | |||
| 102 | 103 | ||
| 103 | if (m->same) { | 104 | if (m->same) { |
| 104 | foreach_bit(i, m->fingers & ~m->pointing) { | 105 | foreach_bit(i, m->fingers & ~m->pointing) { |
| 105 | if (f[i].hw.position_y <= m->ybar) { | 106 | if (f[i].position_y <= m->ybar) { |
| 106 | m->pointing = m->fingers; | 107 | m->pointing = m->fingers; |
| 107 | return; | 108 | return; |
| 108 | } | 109 | } |
| @@ -113,10 +114,10 @@ static void update_pointers(struct Memory *m, | |||
| 113 | m->pointing = 0; | 114 | m->pointing = 0; |
| 114 | m->ybar = yclick; | 115 | m->ybar = yclick; |
| 115 | foreach_bit(i, m->fingers) { | 116 | foreach_bit(i, m->fingers) { |
| 116 | if (f[i].hw.position_y > yclick) | 117 | if (f[i].position_y > yclick) |
| 117 | continue; | 118 | continue; |
| 118 | if (!m->pointing || f[i].hw.position_y > m->ybar) | 119 | if (!m->pointing || f[i].position_y > m->ybar) |
| 119 | m->ybar = f[i].hw.position_y; | 120 | m->ybar = f[i].position_y; |
| 120 | SETBIT(m->pointing, i); | 121 | SETBIT(m->pointing, i); |
| 121 | } | 122 | } |
| 122 | 123 | ||
| @@ -140,7 +141,7 @@ static void update_movement(struct Memory *m, | |||
| 140 | const struct MTState *state, | 141 | const struct MTState *state, |
| 141 | const struct Capabilities *caps) | 142 | const struct Capabilities *caps) |
| 142 | { | 143 | { |
| 143 | const struct MTFinger *prev, *f = state->finger; | 144 | const struct FingerState *prev, *f = state->finger; |
| 144 | int i, xcut, ycut, xmax = 0, ymax = 0; | 145 | int i, xcut, ycut, xmax = 0, ymax = 0; |
| 145 | 146 | ||
| 146 | m->moving = 0; | 147 | m->moving = 0; |
| @@ -167,7 +168,7 @@ static void update_movement(struct Memory *m, | |||
| 167 | 168 | ||
| 168 | foreach_bit(i, m->pointing) { | 169 | foreach_bit(i, m->pointing) { |
| 169 | int dx, dy; | 170 | int dx, dy; |
| 170 | prev = find_finger(prev_state, f[i].id); | 171 | prev = find_finger(prev_state, f[i].tracking_id); |
| 171 | dx = dxval(&f[i], prev); | 172 | dx = dxval(&f[i], prev); |
| 172 | dy = dyval(&f[i], prev); | 173 | dy = dyval(&f[i], prev); |
| 173 | m->dx[i] += dx; | 174 | m->dx[i] += dx; |
