mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-14 12:48:18 +10:00
Merge pull request #1078 from Jazzzny/topcase-probe
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
- device_probe.py:
|
||||
- Add USB device parsing via `IOUSBDevice` class
|
||||
- Streamline Bluetooth device detection
|
||||
- Add Probing for Top Case hardware (Jazzzny)
|
||||
- Improves handling for altered hardware scenarios (i.e. MacBookPro4,1 with MacBookPro3,1 topcase)
|
||||
- Increment Binaries:
|
||||
- PatcherSupportPkg 1.1.4 - release
|
||||
|
||||
|
||||
111
data/usb_data.py
Normal file
111
data/usb_data.py
Normal file
@@ -0,0 +1,111 @@
|
||||
class AppleIDs:
|
||||
# All top case devices use Vendor ID 05ac
|
||||
Modern_AppleUSBTCKeyboard = [
|
||||
0x223,
|
||||
0x224,
|
||||
0x225,
|
||||
0x230,
|
||||
0x231,
|
||||
0x232,
|
||||
0x236,
|
||||
0x237,
|
||||
0x238,
|
||||
0x23f,
|
||||
0x240,
|
||||
0x241,
|
||||
0x242,
|
||||
0x243,
|
||||
0x244,
|
||||
0x245,
|
||||
0x246,
|
||||
0x247,
|
||||
0x249,
|
||||
0x24a,
|
||||
0x24b,
|
||||
0x259,
|
||||
0x25a,
|
||||
0x25b,
|
||||
0x262,
|
||||
0x263,
|
||||
0x264,
|
||||
0x24c,
|
||||
0x24d,
|
||||
0x24e,
|
||||
0x252,
|
||||
0x253,
|
||||
0x254
|
||||
]
|
||||
|
||||
Legacy_AppleUSBTCKeyboard = [
|
||||
0x20e,
|
||||
0x20f,
|
||||
0x210,
|
||||
0x214,
|
||||
0x215,
|
||||
0x216,
|
||||
0x20d,
|
||||
0x218,
|
||||
0x219,
|
||||
0x21a,
|
||||
0x21b,
|
||||
0x21c,
|
||||
0x229,
|
||||
0x22a,
|
||||
0x22b
|
||||
]
|
||||
|
||||
AppleUSBTrackpad = [
|
||||
0x20e,
|
||||
0x20f,
|
||||
0x210,
|
||||
0x30a,
|
||||
0x30b,
|
||||
0x214,
|
||||
0x215,
|
||||
0x216,
|
||||
0x217,
|
||||
0x218,
|
||||
0x219,
|
||||
0x21a,
|
||||
0x21b,
|
||||
0x21c,
|
||||
0x229,
|
||||
0x22a,
|
||||
0x22b
|
||||
]
|
||||
|
||||
AppleUSBMultiTouch = [
|
||||
0x223,
|
||||
0x224,
|
||||
0x225,
|
||||
0x230,
|
||||
0x231,
|
||||
0x232,
|
||||
0x236,
|
||||
0x237,
|
||||
0x238,
|
||||
0x23f,
|
||||
0x240,
|
||||
0x241,
|
||||
0x242,
|
||||
0x243,
|
||||
0x244,
|
||||
0x245,
|
||||
0x246,
|
||||
0x247,
|
||||
0x249,
|
||||
0x24a,
|
||||
0x24b,
|
||||
0x259,
|
||||
0x25a,
|
||||
0x25b,
|
||||
0x262,
|
||||
0x263,
|
||||
0x264,
|
||||
0x24c,
|
||||
0x24d,
|
||||
0x24e,
|
||||
0x252,
|
||||
0x253,
|
||||
0x254
|
||||
]
|
||||
@@ -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.internal_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.internal_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:
|
||||
|
||||
@@ -12,7 +12,7 @@ from dataclasses import dataclass, field
|
||||
from typing import Any, ClassVar, Optional, Type, Union
|
||||
|
||||
from resources import utilities, ioreg
|
||||
from data import pci_data
|
||||
from data import pci_data, usb_data
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -595,6 +595,8 @@ class Computer:
|
||||
opencore_version: Optional[str] = None
|
||||
opencore_path: Optional[str] = None
|
||||
bluetooth_chipset: Optional[str] = None
|
||||
internal_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
|
||||
@@ -620,6 +622,7 @@ class Computer:
|
||||
computer.usb_device_probe()
|
||||
computer.cpu_probe()
|
||||
computer.bluetooth_probe()
|
||||
computer.topcase_probe()
|
||||
computer.ambient_light_sensor_probe()
|
||||
computer.sata_disk_probe()
|
||||
computer.oclp_sys_patch_probe()
|
||||
@@ -880,6 +883,26 @@ class Computer:
|
||||
elif any("Bluetooth" in usb_device.product_name for usb_device in self.usb_devices):
|
||||
self.bluetooth_chipset = "Generic"
|
||||
|
||||
def topcase_probe(self):
|
||||
if not self.usb_devices:
|
||||
return
|
||||
|
||||
for usb_device in self.usb_devices:
|
||||
if self.internal_keyboard_type and self.trackpad_type:
|
||||
break
|
||||
if usb_device.vendor_id != 0x5ac:
|
||||
continue
|
||||
|
||||
if usb_device.device_id in usb_data.AppleIDs.Legacy_AppleUSBTCKeyboard:
|
||||
self.internal_keyboard_type = "Legacy"
|
||||
elif usb_device.device_id in usb_data.AppleIDs.Modern_AppleUSBTCKeyboard:
|
||||
self.internal_keyboard_type = "Modern"
|
||||
|
||||
if usb_device.device_id in usb_data.AppleIDs.AppleUSBTrackpad:
|
||||
self.trackpad_type = "Legacy"
|
||||
elif usb_device.device_id in usb_data.AppleIDs.AppleUSBMultiTouch:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user