From ec08964fa2ae88285364d1735206e2f6efc0cb7d Mon Sep 17 00:00:00 2001 From: Jordan Craven Date: Sat, 25 Sep 2021 15:53:11 -0700 Subject: [PATCH 1/2] Determine tipswitch value from pressure input --- src/AmtPtpDeviceUsbKm/Interrupt.c | 2 +- src/AmtPtpDeviceUsbUm/InputInterrupt.c | 4 ++-- src/AmtPtpHidFilter/Input.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AmtPtpDeviceUsbKm/Interrupt.c b/src/AmtPtpDeviceUsbKm/Interrupt.c index 95407bb..43d1c3d 100644 --- a/src/AmtPtpDeviceUsbKm/Interrupt.c +++ b/src/AmtPtpDeviceUsbKm/Interrupt.c @@ -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; } } diff --git a/src/AmtPtpDeviceUsbUm/InputInterrupt.c b/src/AmtPtpDeviceUsbUm/InputInterrupt.c index 3ece692..20f20d4 100644 --- a/src/AmtPtpDeviceUsbUm/InputInterrupt.c +++ b/src/AmtPtpDeviceUsbUm/InputInterrupt.c @@ -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 @@ -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. diff --git a/src/AmtPtpHidFilter/Input.c b/src/AmtPtpHidFilter/Input.c index 1d5265e..caecc93 100644 --- a/src/AmtPtpHidFilter/Input.c +++ b/src/AmtPtpHidFilter/Input.c @@ -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; + 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. // Or maybe I used the wrong unit? IDK From 76045216236178160e22c9630a982f4d885c3e1e Mon Sep 17 00:00:00 2001 From: Jordan Craven Date: Sun, 26 Sep 2021 11:48:05 -0700 Subject: [PATCH 2/2] Fix invalid references to pressure value --- src/AmtPtpDeviceUsbKm/Interrupt.c | 2 +- src/AmtPtpDeviceUsbUm/InputInterrupt.c | 2 +- src/AmtPtpHidFilter/Input.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AmtPtpDeviceUsbKm/Interrupt.c b/src/AmtPtpDeviceUsbKm/Interrupt.c index 43d1c3d..27ae01d 100644 --- a/src/AmtPtpDeviceUsbKm/Interrupt.c +++ b/src/AmtPtpDeviceUsbKm/Interrupt.c @@ -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 = f->Pressure != 0; + PtpReport.Contacts[i].TipSwitch = f->pressure != 0; PtpReport.Contacts[i].Confidence = (AmtRawToInteger(f->touch_minor) << 1) > 0; } } diff --git a/src/AmtPtpDeviceUsbUm/InputInterrupt.c b/src/AmtPtpDeviceUsbUm/InputInterrupt.c index 20f20d4..24d1df9 100644 --- a/src/AmtPtpDeviceUsbUm/InputInterrupt.c +++ b/src/AmtPtpDeviceUsbUm/InputInterrupt.c @@ -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 = f->Pressure != 0; + PtpReport.Contacts[i].TipSwitch = f->pressure != 0; PtpReport.Contacts[i].Confidence = (AmtRawToInteger(f->touch_minor) << 1) > 0; #ifdef INPUT_CONTENT_TRACE diff --git a/src/AmtPtpHidFilter/Input.c b/src/AmtPtpHidFilter/Input.c index caecc93..9cbc4c0 100644 --- a/src/AmtPtpHidFilter/Input.c +++ b/src/AmtPtpHidFilter/Input.c @@ -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; - PtpReport.Contacts[i].TipSwitch = f_type5->Pressure != 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