Skip to content

Commit

Permalink
Merge pull request cl3m#5 from vrwarp/master
Browse files Browse the repository at this point in the history
Added 0.5s time constraint for 3-tap middle click
  • Loading branch information
cl3m committed Aug 11, 2011
2 parents bdb2acc + a0ebd9a commit eefc2ca
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Controller.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit eefc2ca

Please sign in to comment.