Skip to content

Commit

Permalink
Input: Determine tipswitch value from pressure input for Magic Trackp…
Browse files Browse the repository at this point in the history
…ad 2 (#436)

* Determine tipswitch value from pressure input
* Fix invalid references to pressure value

Co-authored-by: Jordan Craven <[email protected]>
  • Loading branch information
b0undl3ss and Jordan Craven authored Oct 2, 2021
1 parent 9d006db commit 133c629
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/AmtPtpDeviceUsbKm/Interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ AmtPtpEvtUsbInterruptPipeReadComplete(
PtpReport.Contacts[i].ContactID = (UCHAR) i;
PtpReport.Contacts[i].X = x;
PtpReport.Contacts[i].Y = y;
PtpReport.Contacts[i].TipSwitch = (AmtRawToInteger(f->touch_major) << 1) >= 200 || (AmtRawToInteger(f->touch_minor) << 1) >= 150;
PtpReport.Contacts[i].TipSwitch = f->pressure != 0;
PtpReport.Contacts[i].Confidence = (AmtRawToInteger(f->touch_minor) << 1) > 0;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/AmtPtpDeviceUsbUm/InputInterrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ AmtPtpServiceTouchInputInterrupt(
PtpReport.Contacts[i].ContactID = (UCHAR) i;
PtpReport.Contacts[i].X = x;
PtpReport.Contacts[i].Y = y;
PtpReport.Contacts[i].TipSwitch = (AmtRawToInteger(f->touch_major) << 1) >= 200;
PtpReport.Contacts[i].TipSwitch = f->pressure != 0;
PtpReport.Contacts[i].Confidence = (AmtRawToInteger(f->touch_minor) << 1) > 0;

#ifdef INPUT_CONTENT_TRACE
Expand Down Expand Up @@ -515,7 +515,7 @@ AmtPtpServiceTouchInputInterruptType5(
PtpReport.Contacts[i].ContactID = f_type5->ContactIdentifier.Id;
PtpReport.Contacts[i].X = (USHORT) x;
PtpReport.Contacts[i].Y = (USHORT) y;
PtpReport.Contacts[i].TipSwitch = (AmtRawToInteger(f_type5->TouchMajor) << 1) > 0;
PtpReport.Contacts[i].TipSwitch = f_type5->Pressure != 0;

// The Microsoft spec says reject any input larger than 25mm. This is not ideal
// for Magic Trackpad 2 - so we raised the threshold a bit higher.
Expand Down
2 changes: 1 addition & 1 deletion src/AmtPtpHidFilter/Input.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ PtpFilterInputRequestCompletionCallback(
ptpOutputReport.Contacts[i].ContactID = f_type5->OrientationAndOrigin.ContactIdentifier.Id;
ptpOutputReport.Contacts[i].X = (USHORT)x;
ptpOutputReport.Contacts[i].Y = (USHORT)y;
ptpOutputReport.Contacts[i].TipSwitch = ((signed short) (f_type5->TouchMajor) << 1) > 0;
ptpOutputReport.Contacts[i].TipSwitch = f_type5->Pressure != 0;
// The Microsoft spec says reject any input larger than 25mm. This is not ideal
// for Magic Trackpad 2 - so we raised the threshold a bit higher.
// Or maybe I used the wrong unit? IDK
Expand Down

0 comments on commit 133c629

Please sign in to comment.