Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed two-finger tap not working #36

Merged
merged 1 commit into from
Aug 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions MiddleClick/Controller.m
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,25 @@ int touchCallback(int device, Finger* data, int nFingers, double timestamp,
}

if (nFingers == fingersQua) {
Finger* f1 = &data[0];
Finger* f2 = &data[1];
Finger* f3 = &data[2];

if (maybeMiddleClick == YES) {
middleclickX = (f1->normalized.pos.x + f2->normalized.pos.x + f3->normalized.pos.x);
middleclickY = (f1->normalized.pos.y + f2->normalized.pos.y + f3->normalized.pos.y);
for (int i = 0; i < fingersQua; i++)
{
mtPoint pos = ((Finger *)&data[i])->normalized.pos;
middleclickX += pos.x;
Copy link
Author

@ASHIJANKEN ASHIJANKEN Jan 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to explicitly set middleclickX and middleclickY to 0 here since they are set to 0 at l.249~250.

middleclickY += pos.y;
}
middleclickX2 = middleclickX;
middleclickY2 = middleclickY;
maybeMiddleClick = NO;
} else {
middleclickX2 = (f1->normalized.pos.x + f2->normalized.pos.x + f3->normalized.pos.x);
middleclickY2 = (f1->normalized.pos.y + f2->normalized.pos.y + f3->normalized.pos.y);
middleclickX2 = 0.0f;
middleclickY2 = 0.0f;
for (int i = 0; i < fingersQua; i++)
{
mtPoint pos = ((Finger *)&data[i])->normalized.pos;
middleclickX2 += pos.x;
middleclickY2 += pos.y;
}
}
}
}
Expand Down