From a2ef8bcda6cd3864b4c367579defb52ecad19657 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Thu, 13 May 2010 23:21:37 +0200 Subject: 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 --- src/multitouch.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/multitouch.c') 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; static const float hscroll_fraction = 0.05; static const float vswipe_fraction = 0.25; static const float hswipe_fraction = 0.25; +static const float scale_fraction = 0.05; /* flip these to enable event debugging */ #if 1 @@ -81,6 +82,9 @@ static void initButtonLabels(Atom map[DIM_BUTTON]) PROPMAP(map, MT_BUTTON_SWIPE_DOWN, BTN_LABEL_PROP_BTN_1); PROPMAP(map, MT_BUTTON_SWIPE_LEFT, BTN_LABEL_PROP_BTN_2); PROPMAP(map, MT_BUTTON_SWIPE_RIGHT, BTN_LABEL_PROP_BTN_3); + /* how to map scale and rotate? */ + PROPMAP(map, MT_BUTTON_SCALE_DOWN, BTN_LABEL_PROP_BTN_4); + PROPMAP(map, MT_BUTTON_SCALE_UP, BTN_LABEL_PROP_BTN_5); } #endif @@ -88,7 +92,7 @@ static int device_init(DeviceIntPtr dev, LocalDevicePtr local) { struct MTouch *mt = local->private; unsigned char btmap[DIM_BUTTON + 1] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 Atom axes_labels[2], btn_labels[DIM_BUTTON]; @@ -209,11 +213,12 @@ static void handle_gestures(LocalDevicePtr local, const struct Gestures *gs, const struct Capabilities *caps) { - static int vscroll, hscroll, vswipe, hswipe; + static int vscroll, hscroll, vswipe, hswipe, scale; int vscrollstep = 1 + vscroll_fraction * get_cap_ysize(caps); int hscrollstep = 1 + hscroll_fraction * get_cap_xsize(caps); int vswipestep = 1 + vswipe_fraction * get_cap_ysize(caps); int hswipestep = 1 + hswipe_fraction * get_cap_xsize(caps); + int scalestep = 1 + scale_fraction * get_cap_xsize(caps); int i; if (!gs->same_fingers) { vscroll = 0; @@ -249,6 +254,10 @@ static void handle_gestures(LocalDevicePtr local, button_scroll(local, 10, 11, &hswipe, hswipestep, gs->dx); TRACE1("hswipe: %d\n", gs->dx); } + if (GETBIT(gs->type, GS_SCALE)) { + button_scroll(local, 12, 13, &scale, scalestep, gs->scale); + TRACE1("scale: %d\n", gs->scale); + } } /* called for each full received packet from the touchpad */ -- cgit v1.2.3