diff --git a/.gitignore b/.gitignore index c6f0a8a..cdf0b04 100644 --- a/.gitignore +++ b/.gitignore @@ -172,4 +172,7 @@ usb.json USBMap.kext UTBMap.kext *USBMap.json -settings.json \ No newline at end of file +settings.json + +.vscode +samples/ \ No newline at end of file diff --git a/README.md b/README.md index 634aec5..e357ef1 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Simply download the latest `Windows.exe` from releases. If Windows Defender/othe ### From Windows PE -Yes this works lol. Some device names may not be as descriptive but if you really don't want to install Windows, you can create a Windows PE USB and hit Shift + F10 to open `cmd,` then run the program. +Yes this works lol. Some device names may not be as descriptive but if you really don't want to install Windows, you can create a Windows PE USB and hit Shift + F10 to open `cmd`, then run the program. ### From macOS diff --git a/Scripts/usbdump.py b/Scripts/usbdump.py index 48b57f6..1dc5924 100644 --- a/Scripts/usbdump.py +++ b/Scripts/usbdump.py @@ -66,11 +66,7 @@ def get_device_name(port): if not port["DeviceInfoNode"]: port["DeviceInfoNode"] = {} - if ( - not port["ConnectionInfo"]["DeviceDescriptor"]["iProduct"] - or (port["UsbDeviceProperties"].get("DeviceDesc") or port["DeviceInfoNode"].get("DeviceDescName")) - and (port["UsbDeviceProperties"].get("DeviceDesc") or port["DeviceInfoNode"].get("DeviceDescName")) != "USB Composite Device" - ): + if not port["ConnectionInfo"]["DeviceDescriptor"]["iProduct"]: return port["UsbDeviceProperties"].get("DeviceDesc") or port["DeviceInfoNode"].get("DeviceDescName") for string_desc in port["StringDescs"] or []: if string_desc["DescriptorIndex"] == port["ConnectionInfo"]["DeviceDescriptor"]["iProduct"]: @@ -207,7 +203,7 @@ def get_controllers(): usbdump_path = Path(sys._MEIPASS) / usbdump_path info = json.loads(subprocess.run(usbdump_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.decode()) - # info = json.load(Path("/Users/dhinak/Downloads/obummer.txt").open()) + # info = json.load(Path("samples/alfa147.json").open())["usbdump"] for controller in info: # root controller_info = { diff --git a/base.py b/base.py index e738cd5..93ef618 100644 --- a/base.py +++ b/base.py @@ -187,12 +187,12 @@ def print_controllers(self, controllers, colored=False): if not colored: print(" " + self.port_to_str(port)) elif port["devices"]: - print(" " + color(self.port_to_str(port)).cyan.bold) + print(" " + color(self.port_to_str(port)).green.bold) elif ( self.get_controller_from_list(controller, self.controllers_historical) and [i for i in self.get_controller_from_list(controller, self.controllers_historical)["ports"] if i["index"] == port["index"]][0]["devices"] ): - print(" " + color(self.port_to_str(port)).green.bold) + print(" " + color(self.port_to_str(port)).cyan.bold) else: print(" " + self.port_to_str(port)) @@ -315,23 +315,29 @@ def select_ports(self): port_count_str = color(port_count_str).red if controller["selected_count"] > 15 else color(port_count_str).green print(self.controller_to_str(controller) + f" | {port_count_str} ports") for port in controller["ports"]: - port_info = f"[{'#' if port['selected'] else ' '}] {port['selection_index']}. " + self.port_to_str(port) + port_info = f"[{'#' if port['selected'] else ' '}] {port['selection_index']}.{(len(str(selection_index)) - len(str(port['selection_index'])) + 1) * ' ' }" + self.port_to_str(port) companion = self.get_companion_port(port) if companion: port_info += f" | Companion to {companion['selection_index']}" - print(port_info) + if port["selected"]: + print(color(port_info).green.bold) + else: + print(port_info) if port["comment"]: - print(len(f"[{'#' if port['selected'] else ' '}] {port['selection_index']}. ") * " " + port["comment"]) + print( + len(f"[{'#' if port['selected'] else ' '}] {port['selection_index']}.{(len(str(selection_index)) - len(str(port['selection_index'])) + 1) * ' ' }") * " " + + color(port["comment"]).blue.bold + ) for device in port["devices"]: - self.print_devices(device, indentation=" ") + self.print_devices(device, indentation=" " + len(str(selection_index)) * " " * 2) print() print(f"Binding companions is currently {color('on').green if self.settings['auto_bind_companions'] else color('off').red}.\n") print( textwrap.dedent( - """\ - K. Build UTBMap.kext + f"""\ + K. Build {'USBMap' if self.settings['use_native'] else 'UTBMap'}.kext A. Select All N. Select None P. Enable All Populated Ports @@ -607,7 +613,7 @@ def build_kext(self): if not self.settings["use_native"]: template["OSBundleLibraries"] = {"com.dhinakg.USBToolBox.kext": "1.0.0"} - write_path = shared.current_dir / Path("UTBMap.kext") + write_path = shared.current_dir / (Path("USBMap.kext") if self.settings["use_native"] else Path("UTBMap.kext")) if write_path.exists(): print("Removing existing kext...")