Skip to content

Commit ce7514b

Browse files
committed
Some more colors, revert USB Composite Device handling
1 parent 34edd05 commit ce7514b

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,7 @@ usb.json
172172
USBMap.kext
173173
UTBMap.kext
174174
*USBMap.json
175-
settings.json
175+
settings.json
176+
177+
.vscode
178+
samples/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Simply download the latest `Windows.exe` from releases. If Windows Defender/othe
2222

2323
### From Windows PE
2424

25-
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.
25+
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.
2626

2727
### From macOS
2828

Scripts/usbdump.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ def get_device_name(port):
6666
if not port["DeviceInfoNode"]:
6767
port["DeviceInfoNode"] = {}
6868

69-
if (
70-
not port["ConnectionInfo"]["DeviceDescriptor"]["iProduct"]
71-
or (port["UsbDeviceProperties"].get("DeviceDesc") or port["DeviceInfoNode"].get("DeviceDescName"))
72-
and (port["UsbDeviceProperties"].get("DeviceDesc") or port["DeviceInfoNode"].get("DeviceDescName")) != "USB Composite Device"
73-
):
69+
if not port["ConnectionInfo"]["DeviceDescriptor"]["iProduct"]:
7470
return port["UsbDeviceProperties"].get("DeviceDesc") or port["DeviceInfoNode"].get("DeviceDescName")
7571
for string_desc in port["StringDescs"] or []:
7672
if string_desc["DescriptorIndex"] == port["ConnectionInfo"]["DeviceDescriptor"]["iProduct"]:
@@ -207,7 +203,7 @@ def get_controllers():
207203
usbdump_path = Path(sys._MEIPASS) / usbdump_path
208204

209205
info = json.loads(subprocess.run(usbdump_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.decode())
210-
# info = json.load(Path("/Users/dhinak/Downloads/obummer.txt").open())
206+
# info = json.load(Path("samples/alfa147.json").open())["usbdump"]
211207
for controller in info:
212208
# root
213209
controller_info = {

base.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ def print_controllers(self, controllers, colored=False):
187187
if not colored:
188188
print(" " + self.port_to_str(port))
189189
elif port["devices"]:
190-
print(" " + color(self.port_to_str(port)).cyan.bold)
190+
print(" " + color(self.port_to_str(port)).green.bold)
191191
elif (
192192
self.get_controller_from_list(controller, self.controllers_historical)
193193
and [i for i in self.get_controller_from_list(controller, self.controllers_historical)["ports"] if i["index"] == port["index"]][0]["devices"]
194194
):
195-
print(" " + color(self.port_to_str(port)).green.bold)
195+
print(" " + color(self.port_to_str(port)).cyan.bold)
196196
else:
197197
print(" " + self.port_to_str(port))
198198

@@ -315,23 +315,29 @@ def select_ports(self):
315315
port_count_str = color(port_count_str).red if controller["selected_count"] > 15 else color(port_count_str).green
316316
print(self.controller_to_str(controller) + f" | {port_count_str} ports")
317317
for port in controller["ports"]:
318-
port_info = f"[{'#' if port['selected'] else ' '}] {port['selection_index']}. " + self.port_to_str(port)
318+
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)
319319
companion = self.get_companion_port(port)
320320
if companion:
321321
port_info += f" | Companion to {companion['selection_index']}"
322-
print(port_info)
322+
if port["selected"]:
323+
print(color(port_info).green.bold)
324+
else:
325+
print(port_info)
323326
if port["comment"]:
324-
print(len(f"[{'#' if port['selected'] else ' '}] {port['selection_index']}. ") * " " + port["comment"])
327+
print(
328+
len(f"[{'#' if port['selected'] else ' '}] {port['selection_index']}.{(len(str(selection_index)) - len(str(port['selection_index'])) + 1) * ' ' }") * " "
329+
+ color(port["comment"]).blue.bold
330+
)
325331
for device in port["devices"]:
326-
self.print_devices(device, indentation=" ")
332+
self.print_devices(device, indentation=" " + len(str(selection_index)) * " " * 2)
327333
print()
328334

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

331337
print(
332338
textwrap.dedent(
333-
"""\
334-
K. Build UTBMap.kext
339+
f"""\
340+
K. Build {'USBMap' if self.settings['use_native'] else 'UTBMap'}.kext
335341
A. Select All
336342
N. Select None
337343
P. Enable All Populated Ports
@@ -607,7 +613,7 @@ def build_kext(self):
607613
if not self.settings["use_native"]:
608614
template["OSBundleLibraries"] = {"com.dhinakg.USBToolBox.kext": "1.0.0"}
609615

610-
write_path = shared.current_dir / Path("UTBMap.kext")
616+
write_path = shared.current_dir / (Path("USBMap.kext") if self.settings["use_native"] else Path("UTBMap.kext"))
611617

612618
if write_path.exists():
613619
print("Removing existing kext...")

0 commit comments

Comments
 (0)