summaryrefslogtreecommitdiff
path: root/src/multitouch.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-05-13 23:21:37 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-05-14 01:41:39 +0200
commita2ef8bcda6cd3864b4c367579defb52ecad19657 (patch)
tree902391874bd1982f99854c33728abdee77913004 /src/multitouch.c
parent32dea71a85ac1b46c35bf85f456f3c4772b30e76 (diff)
Add scale gesture
Moving two fingers apart or closer together will trigger the gesture. This patch computes the scaling gesture and maps it to mouse buttons 12 and 13. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/multitouch.c')
-rw-r--r--src/multitouch.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/multitouch.c b/src/multitouch.c
index a11b8da..6281a5b 100644
--- a/src/multitouch.c
+++ b/src/multitouch.c
@@ -31,6 +31,7 @@ static const float vscroll_fraction = 0.05;
31static const float hscroll_fraction = 0.05; 31static const float hscroll_fraction = 0.05;
32static const float vswipe_fraction = 0.25; 32static const float vswipe_fraction = 0.25;
33static const float hswipe_fraction = 0.25; 33static const float hswipe_fraction = 0.25;
34static const float scale_fraction = 0.05;
34 35
35/* flip these to enable event debugging */ 36/* flip these to enable event debugging */
36#if 1 37#if 1
@@ -81,6 +82,9 @@ static void initButtonLabels(Atom map[DIM_BUTTON])
81 PROPMAP(map, MT_BUTTON_SWIPE_DOWN, BTN_LABEL_PROP_BTN_1); 82 PROPMAP(map, MT_BUTTON_SWIPE_DOWN, BTN_LABEL_PROP_BTN_1);
82 PROPMAP(map, MT_BUTTON_SWIPE_LEFT, BTN_LABEL_PROP_BTN_2); 83 PROPMAP(map, MT_BUTTON_SWIPE_LEFT, BTN_LABEL_PROP_BTN_2);
83 PROPMAP(map, MT_BUTTON_SWIPE_RIGHT, BTN_LABEL_PROP_BTN_3); 84 PROPMAP(map, MT_BUTTON_SWIPE_RIGHT, BTN_LABEL_PROP_BTN_3);
85 /* how to map scale and rotate? */
86 PROPMAP(map, MT_BUTTON_SCALE_DOWN, BTN_LABEL_PROP_BTN_4);
87 PROPMAP(map, MT_BUTTON_SCALE_UP, BTN_LABEL_PROP_BTN_5);
84} 88}
85#endif 89#endif
86 90
@@ -88,7 +92,7 @@ static int device_init(DeviceIntPtr dev, LocalDevicePtr local)
88{ 92{
89 struct MTouch *mt = local->private; 93 struct MTouch *mt = local->private;
90 unsigned char btmap[DIM_BUTTON + 1] = { 94 unsigned char btmap[DIM_BUTTON + 1] = {
91 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 95 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
92 }; 96 };
93#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 97#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
94 Atom axes_labels[2], btn_labels[DIM_BUTTON]; 98 Atom axes_labels[2], btn_labels[DIM_BUTTON];
@@ -209,11 +213,12 @@ static void handle_gestures(LocalDevicePtr local,
209 const struct Gestures *gs, 213 const struct Gestures *gs,
210 const struct Capabilities *caps) 214 const struct Capabilities *caps)
211{ 215{
212 static int vscroll, hscroll, vswipe, hswipe; 216 static int vscroll, hscroll, vswipe, hswipe, scale;
213 int vscrollstep = 1 + vscroll_fraction * get_cap_ysize(caps); 217 int vscrollstep = 1 + vscroll_fraction * get_cap_ysize(caps);
214 int hscrollstep = 1 + hscroll_fraction * get_cap_xsize(caps); 218 int hscrollstep = 1 + hscroll_fraction * get_cap_xsize(caps);
215 int vswipestep = 1 + vswipe_fraction * get_cap_ysize(caps); 219 int vswipestep = 1 + vswipe_fraction * get_cap_ysize(caps);
216 int hswipestep = 1 + hswipe_fraction * get_cap_xsize(caps); 220 int hswipestep = 1 + hswipe_fraction * get_cap_xsize(caps);
221 int scalestep = 1 + scale_fraction * get_cap_xsize(caps);
217 int i; 222 int i;
218 if (!gs->same_fingers) { 223 if (!gs->same_fingers) {
219 vscroll = 0; 224 vscroll = 0;
@@ -249,6 +254,10 @@ static void handle_gestures(LocalDevicePtr local,
249 button_scroll(local, 10, 11, &hswipe, hswipestep, gs->dx); 254 button_scroll(local, 10, 11, &hswipe, hswipestep, gs->dx);
250 TRACE1("hswipe: %d\n", gs->dx); 255 TRACE1("hswipe: %d\n", gs->dx);
251 } 256 }
257 if (GETBIT(gs->type, GS_SCALE)) {
258 button_scroll(local, 12, 13, &scale, scalestep, gs->scale);
259 TRACE1("scale: %d\n", gs->scale);
260 }
252} 261}
253 262
254/* called for each full received packet from the touchpad */ 263/* called for each full received packet from the touchpad */