diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2010-05-13 23:21:37 +0200 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2010-05-14 01:41:39 +0200 |
commit | 2f23f280d5bff3d5aa3f6115ecc05fa73b1cc2bb (patch) | |
tree | 3b6c98868b0d663c24ebfd6706922a6e99c23404 /src/gestures.c | |
parent | a2ef8bcda6cd3864b4c367579defb52ecad19657 (diff) | |
download | xorg-input-kobomultitouch-2f23f280d5bff3d5aa3f6115ecc05fa73b1cc2bb.tar.gz xorg-input-kobomultitouch-2f23f280d5bff3d5aa3f6115ecc05fa73b1cc2bb.tar.bz2 xorg-input-kobomultitouch-2f23f280d5bff3d5aa3f6115ecc05fa73b1cc2bb.zip |
Add rotation gesture
Moving two fingers around a center point will trigger the gesture.
This patch computes the rotation gesture and maps it to mouse buttons
14 and 15.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/gestures.c')
-rw-r--r-- | src/gestures.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/gestures.c b/src/gestures.c index 03ec96d..2dafe79 100644 --- a/src/gestures.c +++ b/src/gestures.c @@ -74,7 +74,8 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt) float xm[DIM_FINGER], ym[DIM_FINGER]; float xpos = 0, ypos = 0; float move, xmove = 0, ymove = 0; - float rad, rad2 = 0, scale = 0; + float rad, rad2 = 0, scale = 0, rot = 0; + if (!nmove || nmove != npoint) return; @@ -116,13 +117,23 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt) rad2 += yp[i] * yp[i]; scale += xp[i] * xm[i]; scale += yp[i] * ym[i]; + rot += xp[i] * ym[i]; + rot -= yp[i] * xm[i]; } rad2 /= nmove; scale /= nmove; + rot /= nmove; rad = sqrt(rad2); scale /= rad; + rot /= rad; - if (abs(scale) > move) { + if (abs(rot) > move && abs(rot) > abs(scale)) { + gs->rot = rot; + if (gs->rot) { + if (nmove == 2) + SETBIT(gs->type, GS_ROTATE); + } + } else if (abs(scale) > move) { gs->scale = scale; if (gs->scale) { if (nmove == 2) |