Skip to content

Commit 784eec6

Browse files
committed
Add AppleUSBMergeNub support
1 parent af348dd commit 784eec6

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

Scripts/shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def debug(str):
127127
if False:
128128
input(f"DEBUG: {str}\nPress enter to continue")
129129

130-
test_mode = True
130+
test_mode = False
131131
if test_mode:
132132
debug_dump_path = Path(input("Debug dump path: ").strip().replace("'", "").replace('"', ""))
133133
else:

base.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self):
4242
self.settings_path = shared.current_dir / Path("settings.json")
4343

4444
self.settings = (
45-
json.load(self.settings_path.open()) if self.settings_path.exists() else {"show_friendly_types": True, "use_native": False, "add_comments_to_map": True, "auto_bind_companions": True}
45+
json.load(self.settings_path.open()) if self.settings_path.exists() else {"show_friendly_types": True, "use_native": False, "use_legacy_native": False, "add_comments_to_map": True, "auto_bind_companions": True}
4646
)
4747
self.controllers_historical = json.load(self.json_path.open("r")) if self.json_path.exists() else None
4848

@@ -333,10 +333,18 @@ def select_ports(self):
333333

334334
print(f"Binding companions is currently {color('on').green if self.settings['auto_bind_companions'] else color('off').red}.\n")
335335

336+
output_kext = None
337+
if self.settings["use_native"] and self.settings["use_legacy_native"]:
338+
output_kext = "USBMapLegacy.kext"
339+
elif self.settings["use_native"]:
340+
output_kext = "USBMap.kext"
341+
else:
342+
output_kext = "UTBMap.kext (requires USBToolBox.kext)"
343+
336344
print(
337345
textwrap.dedent(
338346
f"""\
339-
K. Build {'USBMap' if self.settings['use_native'] else 'UTBMap'}.kext{' (requires USBToolBox.kext)' if self.settings['use_native'] else ''}
347+
K. Build {output_kext}
340348
A. Select All
341349
N. Select None
342350
P. Enable All Populated Ports
@@ -527,7 +535,7 @@ def build_kext(self):
527535
"Enter Model Identifier",
528536
"Enter the model identifier: ",
529537
[
530-
"You are seeing this as you have selected to use AppleUSBHostController. Model identifier autodetection is unavailable as you are not on macOS.",
538+
"You are seeing this as you have selected to use native classes. Model identifier autodetection is unavailable as you are not on macOS.",
531539
"Please enter the model identifier of the target system below. You can find it in System Information or with 'system_profiler -detailLevel mini SPHardwareDataType'.",
532540
],
533541
).start()
@@ -557,8 +565,8 @@ def build_kext(self):
557565

558566
if self.settings["use_native"]:
559567
personality = {
560-
"CFBundleIdentifier": "com.apple.driver.AppleUSBHostMergeProperties",
561-
"IOClass": "AppleUSBHostMergeProperties",
568+
"CFBundleIdentifier": "com.apple.driver." + ("AppleUSBMergeNub" if self.settings["use_legacy_native"] else "AppleUSBHostMergeProperties"),
569+
"IOClass": ("AppleUSBMergeNub" if self.settings["use_legacy_native"] else "AppleUSBHostMergeProperties"),
562570
"IOProviderClass": "AppleUSBHostController",
563571
"IOParentMatch": self.choose_matching_key(controller),
564572
"model": model_identifier,
@@ -612,7 +620,15 @@ def build_kext(self):
612620
if not self.settings["use_native"]:
613621
template["OSBundleLibraries"] = {"com.dhinakg.USBToolBox.kext": "1.0.0"}
614622

615-
write_path = shared.current_dir / (Path("USBMap.kext") if self.settings["use_native"] else Path("UTBMap.kext"))
623+
output_kext = None
624+
if self.settings["use_native"] and self.settings["use_legacy_native"]:
625+
output_kext = "USBMapLegacy.kext"
626+
elif self.settings["use_native"]:
627+
output_kext = "USBMap.kext"
628+
else:
629+
output_kext = "UTBMap.kext"
630+
631+
write_path = shared.current_dir / Path(output_kext)
616632

617633
if write_path.exists():
618634
print("Removing existing kext...")
@@ -646,6 +662,7 @@ def combination(name, variable):
646662
for i in [
647663
["T", *combination("Show Friendly Types", "show_friendly_types"), ["Show friendly types (ie. 'USB 3 Type A') instead of numbers."]],
648664
["N", *combination("Use Native Classes", "use_native"), ["Use native Apple classes (AppleUSBHostMergeProperties) instead of the USBToolBox kext."]],
665+
["L", *combination("Use Legacy Native Classes (requires Use Native Classes)", "use_legacy_native"), ["Use AppleUSBMergeNub instead of AppleUSBHostMergeProperties, for legacy macOS."]],
649666
["A", *combination("Add Comments to Map", "add_comments_to_map"), ["Add port comments inside the map."]],
650667
[
651668
"C",

0 commit comments

Comments
 (0)