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) | |
Add rotation gesturev1.0-alpha3
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) | |||
| 74 | float xm[DIM_FINGER], ym[DIM_FINGER]; | 74 | float xm[DIM_FINGER], ym[DIM_FINGER]; |
| 75 | float xpos = 0, ypos = 0; | 75 | float xpos = 0, ypos = 0; |
| 76 | float move, xmove = 0, ymove = 0; | 76 | float move, xmove = 0, ymove = 0; |
| 77 | float rad, rad2 = 0, scale = 0; | 77 | float rad, rad2 = 0, scale = 0, rot = 0; |
| 78 | |||
| 78 | 79 | ||
| 79 | if (!nmove || nmove != npoint) | 80 | if (!nmove || nmove != npoint) |
| 80 | return; | 81 | return; |
| @@ -116,13 +117,23 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt) | |||
| 116 | rad2 += yp[i] * yp[i]; | 117 | rad2 += yp[i] * yp[i]; |
| 117 | scale += xp[i] * xm[i]; | 118 | scale += xp[i] * xm[i]; |
| 118 | scale += yp[i] * ym[i]; | 119 | scale += yp[i] * ym[i]; |
| 120 | rot += xp[i] * ym[i]; | ||
| 121 | rot -= yp[i] * xm[i]; | ||
| 119 | } | 122 | } |
| 120 | rad2 /= nmove; | 123 | rad2 /= nmove; |
| 121 | scale /= nmove; | 124 | scale /= nmove; |
| 125 | rot /= nmove; | ||
| 122 | rad = sqrt(rad2); | 126 | rad = sqrt(rad2); |
| 123 | scale /= rad; | 127 | scale /= rad; |
| 128 | rot /= rad; | ||
| 124 | 129 | ||
| 125 | if (abs(scale) > move) { | 130 | if (abs(rot) > move && abs(rot) > abs(scale)) { |
| 131 | gs->rot = rot; | ||
| 132 | if (gs->rot) { | ||
| 133 | if (nmove == 2) | ||
| 134 | SETBIT(gs->type, GS_ROTATE); | ||
| 135 | } | ||
| 136 | } else if (abs(scale) > move) { | ||
| 126 | gs->scale = scale; | 137 | gs->scale = scale; |
| 127 | if (gs->scale) { | 138 | if (gs->scale) { |
| 128 | if (nmove == 2) | 139 | if (nmove == 2) |
