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

Magic Trackpad 2 Improvement #10

Merged
merged 4 commits into from
Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Implement correction.
  • Loading branch information
imbushuo committed Sep 6, 2017
commit 89f1d1a92e8a2a6a22949e76763763d924399a3d
5 changes: 4 additions & 1 deletion src/MagicTrackpad2PtpDevice/AppleDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,12 @@ struct BCM5974_CONFIG {
#define SN_ORIENT 10 /* orientation signal-to-noise ratio */

#define PRESSURE_QUALIFICATION_THRESHOLD 2
#define SIZE_QUALIFICATION_THRESHOLD 7
#define SIZE_QUALIFICATION_THRESHOLD 9
#define SIZE_MU_LOWER_THRESHOLD 5

#define PRESSURE_MU_QUALIFICATION_THRESHOLD_TOTAL 15
#define SIZE_MU_QUALIFICATION_THRESHOLD_TOTAL 25

/* device constants */
static const struct BCM5974_CONFIG Bcm5974ConfigTable[] = {
{
Expand Down
42 changes: 42 additions & 0 deletions src/MagicTrackpad2PtpDevice/InputInterrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ AmtPtpServiceTouchInputInterruptType5(
size_t headerSize = (unsigned int) DeviceContext->DeviceInfo->tp_header;
size_t fingerprintSize = (unsigned int) DeviceContext->DeviceInfo->tp_fsize;
UCHAR actualFingers = 0;
UCHAR muTotalPressure = 0;
UCHAR muTotalSize = 0;

status = WdfIoQueueRetrieveNextRequest(
DeviceContext->InputQueue,
Expand Down Expand Up @@ -257,6 +259,22 @@ AmtPtpServiceTouchInputInterruptType5(
} else {
// Save the information
// Use size to determine confidence in MU scenario
if (raw_n == 2) {
report.Contacts[i].TipSwitch = DeviceContext->ContactRepository[i].Pressure > PRESSURE_QUALIFICATION_THRESHOLD;
report.Contacts[i].Confidence = DeviceContext->ContactRepository[i].Size >= SIZE_MU_LOWER_THRESHOLD;
}
else {
if (DeviceContext->ContactRepository[i].Pressure > PRESSURE_QUALIFICATION_THRESHOLD) {
report.Contacts[i].TipSwitch = 1;
muTotalPressure += DeviceContext->ContactRepository[i].Pressure;
}

if (DeviceContext->ContactRepository[i].Size >= SIZE_MU_LOWER_THRESHOLD) {
report.Contacts[i].Confidence = 1;
muTotalSize += DeviceContext->ContactRepository[i].Size;
}
}

report.Contacts[i].TipSwitch = DeviceContext->ContactRepository[i].Pressure > PRESSURE_QUALIFICATION_THRESHOLD;
report.Contacts[i].Confidence = DeviceContext->ContactRepository[i].Size >= SIZE_MU_LOWER_THRESHOLD;

Expand All @@ -277,6 +295,30 @@ AmtPtpServiceTouchInputInterruptType5(
actualFingers++;
}

if (actualFingers > 2) {
if (muTotalPressure > PRESSURE_MU_QUALIFICATION_THRESHOLD_TOTAL) {
TraceEvents(
TRACE_LEVEL_INFORMATION,
TRACE_INPUT,
"(MU) Perform finger tip switch bit correction."
);
for (i = 0; i < actualFingers; i++) {
report.Contacts[i].TipSwitch = 1;
}

if (muTotalSize > SIZE_MU_QUALIFICATION_THRESHOLD_TOTAL) {
TraceEvents(
TRACE_LEVEL_INFORMATION,
TRACE_INPUT,
"(MU) Perform finger confidence bit correction."
);
for (i = 0; i < actualFingers; i++) {
report.Contacts[i].Confidence = 1;
}
}
}
}

// Set header information
report.ContactCount = actualFingers;

Expand Down