Add probing for topcase

This commit is contained in:
Jazzzny
2023-06-24 10:22:32 -04:00
parent 138214fd8c
commit 8884897dff
2 changed files with 62 additions and 17 deletions

View File

@@ -36,7 +36,7 @@ class BuildMiscellaneous:
self._feature_unlock_handling()
self._restrict_events_handling()
self._firewire_handling()
self._trackpad_handling()
self._topcase_handling()
self._thunderbolt_handling()
self._webcam_handling()
self._usb_handling()
@@ -170,25 +170,43 @@ class BuildMiscellaneous:
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("IOFireWireFamily.kext/Contents/PlugIns/AppleFWOHCI.kext")["Enabled"] = True
def _trackpad_handling(self) -> None:
def _topcase_handling(self) -> None:
"""
Trackpad Handler
USB Top Case Handler
"""
# Pre-Force Touch trackpad & keyboard support for macOS Ventura
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] < cpu_data.CPUGen.skylake.value:
if self.model.startswith("MacBook"):
# These units got force touch & the new keyboard mapping early, so ignore them
if self.model not in ["MacBookPro11,4", "MacBookPro11,5", "MacBookPro12,1", "MacBook8,1"]:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTopCase.kext", self.constants.topcase_version, self.constants.top_case_path)
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCButtons.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyEventDriver.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBMultitouch.kext", self.constants.multitouch_version, self.constants.multitouch_path)
# Legacy Trackpad & Keyboard support
if self.model in ["MacBook4,1", "MacBook5,2"]:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path)
support.BuildSupport(self.model, self.constants, self.config).enable_kext("LegacyKeyboardInjector.kext", self.constants.legacy_keyboard, self.constants.legacy_keyboard_path) # Inject legacy personalities into AppleUSBTCKeyboard and AppleUSBTCKeyEventDriver
#On-device probing
if not self.constants.custom_model and self.computer.keyboard_type and self.computer.trackpad_type:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTopCase.kext", self.constants.topcase_version, self.constants.top_case_path)
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCButtons.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyEventDriver.kext")["Enabled"] = True
if self.computer.keyboard_type == "Legacy":
support.BuildSupport(self.model, self.constants, self.config).enable_kext("LegacyKeyboardInjector.kext", self.constants.legacy_keyboard, self.constants.legacy_keyboard_path)
if self.computer.trackpad_type == "Legacy":
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path)
elif self.computer.trackpad_type == "Modern":
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBMultitouch.kext", self.constants.multitouch_version, self.constants.multitouch_path)
#Predefined fallback
else:
# Multi Touch Top Case support for macOS Ventura+
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] < cpu_data.CPUGen.skylake.value:
if self.model.startswith("MacBook"):
# These units got the Force Touch top case, so ignore them
if self.model not in ["MacBookPro11,4", "MacBookPro11,5", "MacBookPro12,1", "MacBook8,1"]:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTopCase.kext", self.constants.topcase_version, self.constants.top_case_path)
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCButtons.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyEventDriver.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBMultitouch.kext", self.constants.multitouch_version, self.constants.multitouch_path)
# Two-finger Top Case support for macOS High Sierra+
if self.model in ["MacBook4,1", "MacBook5,2"]:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path) # Also requires AppleUSBTopCase.kext
support.BuildSupport(self.model, self.constants, self.config).enable_kext("LegacyKeyboardInjector.kext", self.constants.legacy_keyboard, self.constants.legacy_keyboard_path) # Inject legacy personalities into AppleUSBTCKeyboard and AppleUSBTCKeyEventDriver
def _thunderbolt_handling(self) -> None:

View File

@@ -595,6 +595,8 @@ class Computer:
opencore_version: Optional[str] = None
opencore_path: Optional[str] = None
bluetooth_chipset: Optional[str] = None
keyboard_type: Optional[str] = None
trackpad_type: Optional[str] = None
ambient_light_sensor: Optional[bool] = False
third_party_sata_ssd: Optional[bool] = False
secure_boot_model: Optional[str] = None
@@ -880,6 +882,31 @@ class Computer:
elif any("Bluetooth" in usb_device.product_name for usb_device in self.usb_devices):
self.bluetooth_chipset = "Generic"
def keyboard_probe(self):
if not self.usb_devices:
return
legacy_ids = ["526","527","528","532","533","534","525","536","537","538","539","540","553","554","555"] # These keyboards were stripped of their personalities after being dropped
modern_ids = ["547","548","549","560","561","562","566","567","568","575","576","577","578","579","580","581","582","583","585","586","587","601","602","603","610","611","612","588","589","590","594","595","596"] #These keyboards remained in AppleUSBTCKeyboard until the kext was removed
if any(value in usb_device.product_name and usb_device.vendor_id == "1452" for value in legacy_ids for usb_device in self.usb_devices):
self.keyboard_type = "Legacy"
elif any(value in usb_device.product_name and usb_device.vendor_id == "1452" for value in modern_ids for usb_device in self.usb_devices):
self.keyboard_type = "Modern"
def trackpad_probe(self):
if not self.usb_devices:
return
legacy_ids = ["526","527","528","778","779","532","533","534","535","536","537","538","539","540","553","554","555"] # Overlap with keyboard IDs as some units have unified USB topcase devices
modern_ids = ["547","548","549","560","561","562","566","567","568","575","576","577","578","579","580","581","582","583","585","586","587","601","602","603","610","611","612","588","589","590","594","595","596"]
if any(value in usb_device.product_name and usb_device.vendor_id == "1452" for value in legacy_ids for usb_device in self.usb_devices):
self.trackpad_type = "Legacy"
elif any(value in usb_device.product_name and usb_device.vendor_id == "1452" for value in modern_ids for usb_device in self.usb_devices):
self.trackpad_type = "Modern"
def sata_disk_probe(self):
# Get all SATA Controllers/Disks from 'system_profiler SPSerialATADataType'
# Determine whether SATA SSD is present and Apple-made