Skip to content

Commit

Permalink
Use usb.ids for BT device lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
benbaker76 committed Nov 20, 2021
1 parent db87731 commit 786e8b8
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 1,721 deletions.
12 changes: 4 additions & 8 deletions Hackintool.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
E28286C221FC508300A0CB2D /* DiskUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = E28286C021FC508300A0CB2D /* DiskUtilities.m */; };
E28286C821FC943700A0CB2D /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E28286C721FC943700A0CB2D /* Security.framework */; };
E28341E622346A880022713F /* libxml2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = E28341E522346A880022713F /* libxml2.tbd */; };
E28652CE22B55A3C00D42BFB /* BT in Resources */ = {isa = PBXBuildFile; fileRef = E28652CD22B55A3C00D42BFB /* BT */; };
E29361D321FFF3DC00ED0105 /* ACPI in Resources */ = {isa = PBXBuildFile; fileRef = E29361D221FFF3DC00ED0105 /* ACPI */; };
E29361D521FFF3E300ED0105 /* Utilities in Resources */ = {isa = PBXBuildFile; fileRef = E29361D421FFF3E200ED0105 /* Utilities */; };
E29436BF21FBC5D30029FA2D /* DiskArbitration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E29436BE21FBC5D20029FA2D /* DiskArbitration.framework */; };
Expand Down Expand Up @@ -145,7 +144,6 @@
E28286C321FC913800A0CB2D /* LocalAuthentication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalAuthentication.framework; path = System/Library/Frameworks/LocalAuthentication.framework; sourceTree = SDKROOT; };
E28286C721FC943700A0CB2D /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
E28341E522346A880022713F /* libxml2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxml2.tbd; path = usr/lib/libxml2.tbd; sourceTree = SDKROOT; };
E28652CD22B55A3C00D42BFB /* BT */ = {isa = PBXFileReference; lastKnownFileType = folder; path = BT; sourceTree = "<group>"; };
E29361D221FFF3DC00ED0105 /* ACPI */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ACPI; sourceTree = "<group>"; };
E29361D421FFF3E200ED0105 /* Utilities */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Utilities; sourceTree = "<group>"; };
E29436BE21FBC5D20029FA2D /* DiskArbitration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DiskArbitration.framework; path = System/Library/Frameworks/DiskArbitration.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -377,7 +375,6 @@
children = (
E29361D221FFF3DC00ED0105 /* ACPI */,
E248A34E211B03CE00A48C84 /* Audio */,
E28652CD22B55A3C00D42BFB /* BT */,
E2D20D4C223184DF00BAC721 /* Clover */,
E2A5A6B022A03BCA00CE02D1 /* DisplayMergeNub */,
E2AB61FB227A44B100724F32 /* EveryMac */,
Expand Down Expand Up @@ -507,7 +504,6 @@
E2804A77220484F900B40C25 /* Localizable.strings in Resources */,
E2ABF70820D7369000652F83 /* Media.xcassets in Resources */,
E248A34F211B03CE00A48C84 /* Audio in Resources */,
E28652CE22B55A3C00D42BFB /* BT in Resources */,
E2D20D4D223184DF00BAC721 /* Clover in Resources */,
E27BFB91211BCEE300C75CDB /* Intel in Resources */,
E29361D521FFF3E300ED0105 /* Utilities in Resources */,
Expand Down Expand Up @@ -719,7 +715,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0367;
CURRENT_PROJECT_VERSION = 0368;
DEVELOPMENT_TEAM = 5LGHPJM9ZR;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_STRICT_OBJC_MSGSEND = NO;
Expand All @@ -734,7 +730,7 @@
INFOPLIST_FILE = "Hackintool/Hackintool-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 3.6.7;
MARKETING_VERSION = 3.6.8;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.Hackintool;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -755,7 +751,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0367;
CURRENT_PROJECT_VERSION = 0368;
DEVELOPMENT_TEAM = 5LGHPJM9ZR;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_STRICT_OBJC_MSGSEND = NO;
Expand All @@ -770,7 +766,7 @@
INFOPLIST_FILE = "Hackintool/Hackintool-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 3.6.7;
MARKETING_VERSION = 3.6.8;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.Hackintool;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Binary file not shown.
117 changes: 11 additions & 106 deletions Hackintool/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -1535,9 +1535,10 @@ - (void)parseUSBIDs

- (bool)getUSBDeviceInfo:(NSNumber *)vendorID deviceID:(NSNumber *)deviceID vendorName:(NSString **)vendorName deviceName:(NSString **)deviceName
{
bool result = NO;
NSMutableDictionary *vendorDictionary = [_usbVendorsDictionary objectForKey:vendorID];

if (vendorDictionary != nil)
if (vendorDictionary == nil)
{
NSString *vendorNameTemp = [vendorDictionary objectForKey:@"VendorName"];
NSMutableDictionary *deviceDictionary = [vendorDictionary objectForKey:@"Devices"];
Expand All @@ -1548,10 +1549,10 @@ - (bool)getUSBDeviceInfo:(NSNumber *)vendorID deviceID:(NSNumber *)deviceID vend

if (deviceNameTemp != nil)
*deviceName = deviceNameTemp;

result = (vendorNameTemp != nil && deviceNameTemp != nil);
}

bool result = (*deviceName != nil);


if (*vendorName == nil)
*vendorName = @"???";

Expand Down Expand Up @@ -2014,6 +2015,7 @@ - (void)getBluetoothDeviceInfo:(NSDictionary *)deviceDictionary bluetoothDeviceD
{
NSString *productName = [deviceDictionary objectForKey:@kUSBProductString];
NSString *vendorName = [deviceDictionary objectForKey:@kUSBVendorString];
NSString *productNameTemp = nil, *vendorNameTemp = nil;
NSNumber *productID = [deviceDictionary objectForKey:@"idProduct"];
NSNumber *vendorID = [deviceDictionary objectForKey:@"idVendor"];
NSNumber *fwLoaded = [deviceDictionary objectForKey:@"FirmwareLoaded"];
Expand All @@ -2030,8 +2032,11 @@ - (void)getBluetoothDeviceInfo:(NSDictionary *)deviceDictionary bluetoothDeviceD
if (fwLoaded == nil)
fwLoaded = [deviceDictionary objectForKey:@"RM,FirmwareLoaded"];

if (productName == nil || vendorName == nil)
[self getUSBDeviceInfo:vendorID deviceID:productID vendorName:&vendorName deviceName:&productName];
if ([self getUSBDeviceInfo:vendorID deviceID:productID vendorName:&vendorNameTemp deviceName:&productNameTemp])
{
vendorName = vendorNameTemp;
productName = productNameTemp;
}

[bluetoothDeviceDictionary setObject:productID forKey:@"DeviceID"];
[bluetoothDeviceDictionary setObject:vendorID forKey:@"VendorID"];
Expand Down Expand Up @@ -2070,106 +2075,6 @@ - (void)updateBluetoothDevices
}
}

NSBundle *mainBundle = [NSBundle mainBundle];
NSString *filePath = nil;

NSArray *brcmDeviceArray = nil;
NSArray *atherosDeviceArray = nil;
NSArray *intelDeviceArray = nil;

if ((filePath = [mainBundle pathForResource:@"BRCMDevice" ofType:@"plist" inDirectory:@"BT"]))
brcmDeviceArray = [NSArray arrayWithContentsOfFile:filePath];

if ((filePath = [mainBundle pathForResource:@"AtherosDevice" ofType:@"plist" inDirectory:@"BT"]))
atherosDeviceArray = [NSArray arrayWithContentsOfFile:filePath];

if ((filePath = [mainBundle pathForResource:@"IntelDevice" ofType:@"plist" inDirectory:@"BT"]))
intelDeviceArray = [NSArray arrayWithContentsOfFile:filePath];

NSMutableArray *usbPropertyDictionaryArray = nil;

if (!getIORegPropertyDictionaryArrayWithChild(@"AppleUSBHostPort", @kIOUSBDeviceClassName, &usbPropertyDictionaryArray))
return;

for (NSMutableDictionary *deviceDictionary in usbPropertyDictionaryArray)
{
NSMutableDictionary *bluetoothDeviceDictionary = [NSMutableDictionary dictionary];

[self getBluetoothDeviceInfo:deviceDictionary bluetoothDeviceDictionary:bluetoothDeviceDictionary];

NSNumber *productID = [bluetoothDeviceDictionary objectForKey:@"DeviceID"];
NSNumber *vendorID = [bluetoothDeviceDictionary objectForKey:@"VendorID"];

bool foundMatch = NO;

for (NSMutableDictionary *btDictionary in _bluetoothDevicesArray)
{
NSNumber *btPID = [btDictionary objectForKey:@"DeviceID"];
NSNumber *btVID = [btDictionary objectForKey:@"VendorID"];

if ([productID isEqualToNumber:btPID] && [vendorID isEqualToNumber:btVID])
{
foundMatch = YES;

break;
}
}

if (foundMatch)
continue;

for (NSDictionary *brcmDeviceDictionary in brcmDeviceArray)
{
NSString *name = [brcmDeviceDictionary objectForKey:@"Name"];
NSNumber *brcmPID = [brcmDeviceDictionary objectForKey:@"ProductID"];
NSNumber *brcmVID = [brcmDeviceDictionary objectForKey:@"VendorID"];

if ([productID isEqualToNumber:brcmPID] && [vendorID isEqualToNumber:brcmVID])
{
[bluetoothDeviceDictionary setObject:name forKey:@"DeviceName"];
[bluetoothDeviceDictionary setObject:@"Broadcom Corp." forKey:@"VendorName"];

[_bluetoothDevicesArray addObject:bluetoothDeviceDictionary];

break;
}
}

for (NSDictionary *atherosDeviceDictionary in atherosDeviceArray)
{
NSString *name = [atherosDeviceDictionary objectForKey:@"Name"];
NSNumber *atherosPID = [atherosDeviceDictionary objectForKey:@"ProductID"];
NSNumber *atherosVID = [atherosDeviceDictionary objectForKey:@"VendorID"];

if ([productID isEqualToNumber:atherosPID] && [vendorID isEqualToNumber:atherosVID])
{
[bluetoothDeviceDictionary setObject:name forKey:@"DeviceName"];
[bluetoothDeviceDictionary setObject:@"Lite-On Technology Corp." forKey:@"VendorName"];

[_bluetoothDevicesArray addObject:bluetoothDeviceDictionary];

break;
}
}

for (NSDictionary *intelDeviceDictionary in intelDeviceArray)
{
NSString *name = [intelDeviceDictionary objectForKey:@"Name"];
NSNumber *intelPID = [intelDeviceDictionary objectForKey:@"ProductID"];
NSNumber *intelVID = [intelDeviceDictionary objectForKey:@"VendorID"];

if ([productID isEqualToNumber:intelPID] && [vendorID isEqualToNumber:intelVID])
{
[bluetoothDeviceDictionary setObject:name forKey:@"DeviceName"];
[bluetoothDeviceDictionary setObject:@"Intel Corp." forKey:@"VendorName"];

[_bluetoothDevicesArray addObject:bluetoothDeviceDictionary];

break;
}
}
}

[_bluetoothDevicesTableView reloadData];
}

Expand Down
Loading

0 comments on commit 786e8b8

Please sign in to comment.