Permalink
Browse files

Merge pull request #5 from vrwarp/master

Added 0.5s time constraint for 3-tap middle click
  • Loading branch information...
2 parents bdb2acc + a0ebd9a commit eefc2ca701c6764fe11a22aa3d3c2032965d2cde @cl3m committed Aug 11, 2011
Showing with 7 additions and 4 deletions.
  1. +7 −4 Controller.m
View
@@ -101,10 +101,13 @@ int callback(int device, Finger *data, int nFingers, double timestamp, int frame
else
{
if (nFingers==0){
+ NSTimeInterval elapsedTime = -[touchStartTime timeIntervalSinceNow];
touchStartTime = NULL;
- if(middleclickX+middleclickY) {
- float delta = ABS(middleclickX-middleclickX2)+ABS(middleclickY-middleclickY2);
- if (delta < 0.4f) {
+ if (elapsedTime < 0.2f && middleclickX+middleclickY) {
+ float dx = (middleclickX-middleclickX2);
+ float dy = (middleclickY-middleclickY2);
+ float delta = (dx*dx)+(dy*dy);
+ if (delta < 1.0f) {
// Emulate a middle click
// get the current pointer location
@@ -142,7 +145,7 @@ int callback(int device, Finger *data, int nFingers, double timestamp, int frame
} else {
if (maybeMiddleClick==YES){
NSTimeInterval elapsedTime = -[touchStartTime timeIntervalSinceNow];
- if (elapsedTime > 0.5f)
+ if (elapsedTime > 0.2f)
maybeMiddleClick = NO;
}
}

0 comments on commit eefc2ca

Please sign in to comment.