Skip to content

Commit

Permalink
Magic Trackpad 2: use standard Microsoft processing spec
Browse files Browse the repository at this point in the history
This is defined in https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/touchpad-windows-precision-touchpad-collection, and I slightly modified it for MT2. Should partially mitigate issue #212, #170, #166, #163, #161, #94, #38, #37 and #83.
  • Loading branch information
Bingxing Wang committed Aug 28, 2019
1 parent 1dab122 commit 539b442
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 624 deletions.
Binary file modified src/AmtPtpDeviceUsbUm/AmtPtpDeviceUsbUm.inf
Binary file not shown.
59 changes: 0 additions & 59 deletions src/AmtPtpDeviceUsbUm/Device.c
Expand Up @@ -117,7 +117,6 @@ AmtPtpCreateDevice(
return status;
}

_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
AmtPtpEvtDevicePrepareHardware(
_In_ WDFDEVICE Device,
Expand Down Expand Up @@ -189,61 +188,6 @@ AmtPtpEvtDevicePrepareHardware(
);
return status;
}

// Set fuzz information
pDeviceContext->HorizonalFuzz = pDeviceContext->DeviceInfo->x.snratio ?
(pDeviceContext->DeviceInfo->x.max - pDeviceContext->DeviceInfo->x.min) / pDeviceContext->DeviceInfo->x.snratio :
0.0;

pDeviceContext->VerticalFuzz = pDeviceContext->DeviceInfo->y.snratio ?
(pDeviceContext->DeviceInfo->y.max - pDeviceContext->DeviceInfo->y.min) / pDeviceContext->DeviceInfo->y.snratio :
0.0;

pDeviceContext->PressureFuzz = pDeviceContext->DeviceInfo->p.snratio ?
(pDeviceContext->DeviceInfo->p.max - pDeviceContext->DeviceInfo->p.min) / pDeviceContext->DeviceInfo->p.snratio :
0.0;

pDeviceContext->WidthFuzz = pDeviceContext->DeviceInfo->w.snratio ?
(pDeviceContext->DeviceInfo->w.max - pDeviceContext->DeviceInfo->w.min) / pDeviceContext->DeviceInfo->w.snratio :
0.0;

pDeviceContext->OrientationFuzz = pDeviceContext->DeviceInfo->o.snratio ?
(pDeviceContext->DeviceInfo->o.max - pDeviceContext->DeviceInfo->o.min) / pDeviceContext->DeviceInfo->o.snratio :
0.0;

pDeviceContext->SgContactSizeQualLevel = SIZE_QUALIFICATION_THRESHOLD;
pDeviceContext->MuContactSizeQualLevel = SIZE_MU_LOWER_THRESHOLD;
pDeviceContext->PressureQualLevel = PRESSURE_QUALIFICATION_THRESHOLD;

pDeviceContext->TouchStateMachineInfo.HorizonalFuzz = pDeviceContext->HorizonalFuzz;
pDeviceContext->TouchStateMachineInfo.VerticalFuzz = pDeviceContext->VerticalFuzz;
pDeviceContext->TouchStateMachineInfo.WidthFuzz = pDeviceContext->WidthFuzz;
pDeviceContext->TouchStateMachineInfo.OrientationFuzz = pDeviceContext->OrientationFuzz;
pDeviceContext->TouchStateMachineInfo.PressureFuzz = pDeviceContext->PressureFuzz;

status = SmResetState(&pDeviceContext->TouchStateMachineInfo);
if (!NT_SUCCESS(status)) {

TraceEvents(
TRACE_LEVEL_ERROR,
TRACE_DEVICE,
"%!FUNC! SmResetState failed with %!STATUS!",
status
);
return status;

}

TraceEvents(
TRACE_LEVEL_INFORMATION,
TRACE_DEVICE,
"%!FUNC! fuzz information: h = %f, v = %f, p = %f, w = %f, o = %f",
pDeviceContext->HorizonalFuzz,
pDeviceContext->VerticalFuzz,
pDeviceContext->PressureFuzz,
pDeviceContext->WidthFuzz,
pDeviceContext->OrientationFuzz
);
}

//
Expand Down Expand Up @@ -551,8 +495,6 @@ AmtPtpSetWellspringMode(

}

// D0 Entry & Exit
_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
AmtPtpEvtDeviceD0Entry(
_In_ WDFDEVICE Device,
Expand Down Expand Up @@ -642,7 +584,6 @@ AmtPtpEvtDeviceD0Entry(
return status;
}

_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
AmtPtpEvtDeviceD0Exit(
_In_ WDFDEVICE Device,
Expand Down
23 changes: 2 additions & 21 deletions src/AmtPtpDeviceUsbUm/Device.h
Expand Up @@ -24,14 +24,7 @@ typedef struct _DEVICE_CONTEXT
BOOL IsSurfaceReportOn;
BOOL IsButtonReportOn;

double HorizonalFuzz;
double VerticalFuzz;
double PressureFuzz;
double WidthFuzz;
double OrientationFuzz;

PTP_CONTACT_RAW ContactRepository[5];
SM_RUNTIME_INFORMATION TouchStateMachineInfo;

LARGE_INTEGER PerfCounter;

Expand Down Expand Up @@ -63,6 +56,8 @@ AmtPtpCreateDevice(
// handle
//
EVT_WDF_DEVICE_PREPARE_HARDWARE AmtPtpEvtDevicePrepareHardware;
EVT_WDF_DEVICE_D0_ENTRY AmtPtpEvtDeviceD0Entry;
EVT_WDF_DEVICE_D0_EXIT AmtPtpEvtDeviceD0Exit;

_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
Expand Down Expand Up @@ -96,20 +91,6 @@ DbgDevicePowerString(
_In_ WDF_POWER_DEVICE_STATE Type
);

_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
AmtPtpEvtDeviceD0Entry(
_In_ WDFDEVICE Device,
_In_ WDF_POWER_DEVICE_STATE PreviousState
);

_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
AmtPtpEvtDeviceD0Exit(
_In_ WDFDEVICE Device,
_In_ WDF_POWER_DEVICE_STATE TargetState
);

_IRQL_requires_(PASSIVE_LEVEL)
VOID
AmtPtpEvtUsbInterruptPipeReadComplete(
Expand Down
1 change: 0 additions & 1 deletion src/AmtPtpDeviceUsbUm/Driver.h
Expand Up @@ -14,7 +14,6 @@

#include "AppleDefinition.h"
#include "Hid.h"
#include "InputStateMachine.h"
#include "Device.h"
#include "Queue.h"

Expand Down

0 comments on commit 539b442

Please sign in to comment.