diff options
Diffstat (limited to 'src/multitouch.c')
| -rw-r--r-- | src/multitouch.c | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/src/multitouch.c b/src/multitouch.c index cf06f97..8411718 100644 --- a/src/multitouch.c +++ b/src/multitouch.c | |||
| @@ -21,8 +21,7 @@ | |||
| 21 | * | 21 | * |
| 22 | **************************************************************************/ | 22 | **************************************************************************/ |
| 23 | 23 | ||
| 24 | #include "mtouch.h" | 24 | #include "gestures.h" |
| 25 | #include "mipointer.h" | ||
| 26 | 25 | ||
| 27 | //////////////////////////////////////////////////////////////////////////// | 26 | //////////////////////////////////////////////////////////////////////////// |
| 28 | 27 | ||
| @@ -123,40 +122,20 @@ static int device_close(LocalDevicePtr local) | |||
| 123 | 122 | ||
| 124 | //////////////////////////////////////////////////////////////////////////// | 123 | //////////////////////////////////////////////////////////////////////////// |
| 125 | 124 | ||
| 126 | static void handle_state(LocalDevicePtr local, | 125 | static void handle_gestures(LocalDevicePtr local, |
| 127 | const struct State *os, | 126 | const struct Gestures *gs) |
| 128 | const struct State *ns) | ||
| 129 | { | 127 | { |
| 130 | const struct FingerState *fs, *p, *e = ns->finger + ns->nfinger; | 128 | int i; |
| 131 | int dx = 0, dy = 0, dn = 0, n = 0, i; | 129 | if (GETBIT(gs->type, GS_MOVE)) { |
| 132 | if (count_fingers(ns) == count_fingers(os)) { | 130 | xf86PostMotionEvent(local->dev, 0, 0, 2, gs->dx, gs->dy); |
| 133 | for (p = ns->finger; p != e; p++) { | ||
| 134 | if (fs = find_finger(os, p->id)) { | ||
| 135 | dx += p->hw.position_x - fs->hw.position_x; | ||
| 136 | dy += p->hw.position_y - fs->hw.position_y; | ||
| 137 | dn++; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | } | ||
| 141 | if (dx || dy) { | ||
| 142 | dx /= dn; | ||
| 143 | dy /= dn; | ||
| 144 | xf86PostMotionEvent(local->dev, 0, 0, 2, dx, dy); | ||
| 145 | //xf86Msg(X_INFO, "motion: %d %d\n", dx, dy); | 131 | //xf86Msg(X_INFO, "motion: %d %d\n", dx, dy); |
| 146 | n++; | ||
| 147 | } | 132 | } |
| 148 | for (i = 0; i < DIM_BUTTON; i++) { | 133 | if (GETBIT(gs->type, GS_BUTTON)) { |
| 149 | if (GETBIT(ns->button, i) != GETBIT(os->button, i)) { | 134 | for (i = 0; i < gs->nbt; i++) |
| 150 | xf86PostButtonEvent(local->dev, FALSE, | 135 | xf86PostButtonEvent(local->dev, FALSE, |
| 151 | i + 1, GETBIT(ns->button, i), | 136 | gs->btix[i], gs->btval[i], |
| 152 | 0, 0); | 137 | 0, 0); |
| 153 | //xf86Msg(X_INFO, "button: %d -> %d\n", | ||
| 154 | //i, GETBIT(ns->button, i)); | ||
| 155 | n++; | ||
| 156 | } | ||
| 157 | } | 138 | } |
| 158 | //if (n) | ||
| 159 | //output_state(ns); | ||
| 160 | } | 139 | } |
| 161 | 140 | ||
| 162 | //////////////////////////////////////////////////////////////////////////// | 141 | //////////////////////////////////////////////////////////////////////////// |
| @@ -164,11 +143,12 @@ static void handle_state(LocalDevicePtr local, | |||
| 164 | /* called for each full received packet from the touchpad */ | 143 | /* called for each full received packet from the touchpad */ |
| 165 | static void read_input(LocalDevicePtr local) | 144 | static void read_input(LocalDevicePtr local) |
| 166 | { | 145 | { |
| 146 | struct Gestures gs; | ||
| 167 | struct MTouch *mt = local->private; | 147 | struct MTouch *mt = local->private; |
| 168 | while (read_synchronized_event(mt, local->fd)) { | 148 | while (read_synchronized_event(mt, local->fd)) { |
| 169 | modify_state(&mt->ns, &mt->hw, &mt->caps); | 149 | parse_event(mt); |
| 170 | handle_state(local, &mt->os, &mt->ns); | 150 | extract_gestures(&gs, mt); |
| 171 | mt->os = mt->ns; | 151 | handle_gestures(local, &gs); |
| 172 | } | 152 | } |
| 173 | } | 153 | } |
| 174 | 154 | ||
