Skip to content

Commit

Permalink
Add generic T2 fallback for all T2 devices.
Browse files Browse the repository at this point in the history
Experience might not be optimal for a few devices due to the lack of region data.

Resolved #142.
  • Loading branch information
Bingxing Wang committed Oct 9, 2019
1 parent b1e9ec0 commit d665981
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ There is a bring-up issue for certain MacBook Pro and MacBook Air. I am looking
- [x] Apple Magic Trackpad 2 (Not stable)
- [x] MacBook Pro with Retina Display (2013, 2014, 2015, 13-inch & 15-inch)
- [x] New MacBook (12-inch)
- [x] MacBook Pro 2015, 2016, 2017
- [ ] _(Work in progress)_ T2-based devices: MacBook Air 2018, MacBook Pro 2017/2018/2019: a few is supported as of now
- [x] MacBook Pro 2015, 2016, 2017 (a few SPI devices are in work-in-progress state)
- [x] T2-based devices: MacBook Air 2018, MacBook Pro 2017/2018/2019: Use default fallback, experience might not be optimal. Open a issue if you encountered dead touch regions.

## Roadmap

Expand Down
14 changes: 9 additions & 5 deletions src/AmtPtpDeviceUsbKm/AmtPtpDeviceUsbKm.inf
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1 ; make sure the number matches with
%ManufacturerName%=Standard,NT$ARCH$

[Standard.NT$ARCH$]
; T2 trackpad
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_027a&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_027b&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_027c&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_027d&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_0273&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_0274&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_0277&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_027A&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_027B&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_027C&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_027D&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_0290&MI_02
%AmtPtpDeviceUsbKm.DeviceDesc%=AmtPtpDeviceUsbKm_Device, USB\Vid_05ac&Pid_0291&MI_02

[AmtPtpDeviceUsbKm_Device.NT]
CopyFiles=Drivers_Dir
Expand Down
9 changes: 8 additions & 1 deletion src/AmtPtpDeviceUsbKm/Device.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ AmtPtpGetDeviceConfig(
}
}

return NULL;
// Generic fallback
TraceEvents(
TRACE_LEVEL_WARNING,
TRACE_DRIVER,
"%!FUNC! Selected a generic fallback configuration"
);

return &Bcm5974ConfigTable[0];
}

NTSTATUS
Expand Down
54 changes: 50 additions & 4 deletions src/AmtPtpDeviceUsbKm/Hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,27 @@ AmtPtpGetHidDescriptor(
{
TraceEvents(
TRACE_LEVEL_WARNING, TRACE_DRIVER,
"%!FUNC! Device HID registry is not found"
"%!FUNC! Device HID registry is not found, use a generic fallback"
);

status = STATUS_INVALID_DEVICE_STATE;
szCopy = AmtPtpT2DefaultHidDescriptor.bLength;
status = WdfMemoryCopyFromBuffer(
requestMemory,
0,
(PVOID)&AmtPtpT2DefaultHidDescriptor,
szCopy
);

if (!NT_SUCCESS(status)) {
TraceEvents(
TRACE_LEVEL_ERROR, TRACE_DRIVER,
"%!FUNC! WdfMemoryCopyFromBuffer failed with %!STATUS!",
status
);
goto exit;
}

WdfRequestSetInformation(Request, szCopy);
break;
}
};
Expand Down Expand Up @@ -222,9 +239,38 @@ AmtPtpGetReportDescriptor(
{
TraceEvents(
TRACE_LEVEL_WARNING, TRACE_DRIVER,
"%!FUNC! Device HID registry is not found"
"%!FUNC! Device HID registry is not found, use a generic fallback"
);
status = STATUS_INVALID_DEVICE_STATE;

szCopy = AmtPtpT2DefaultHidDescriptor.DescriptorList[0].wReportLength;
if (szCopy == 0) {

status = STATUS_INVALID_DEVICE_STATE;
TraceEvents(
TRACE_LEVEL_ERROR, TRACE_DRIVER,
"%!FUNC! Device HID report length is zero"
);
goto exit;
}

status = WdfMemoryCopyFromBuffer(
requestMemory,
0,
(PVOID)&AmtPtpT2ReportDescriptor,
szCopy
);

if (!NT_SUCCESS(status)) {

TraceEvents(
TRACE_LEVEL_ERROR, TRACE_DRIVER,
"%!FUNC! WdfMemoryCopyFromBuffer failed with %!STATUS!",
status
);
goto exit;
}

WdfRequestSetInformation(Request, szCopy);
break;
}
}
Expand Down

0 comments on commit d665981

Please sign in to comment.