Skip to content

Commit

Permalink
Always inject USB power properties
Browse files Browse the repository at this point in the history
  • Loading branch information
benbaker76 committed Mar 27, 2020
1 parent c102e01 commit 9226c65
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Hackintool.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0331;
CURRENT_PROJECT_VERSION = 0332;
DEVELOPMENT_TEAM = 5LGHPJM9ZR;
ENABLE_HARDENED_RUNTIME = NO;
ENABLE_STRICT_OBJC_MSGSEND = NO;
Expand All @@ -728,7 +728,7 @@
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2";
INFOPLIST_FILE = "Hackintool/Hackintool-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @executable_path/../Frameworks";
MARKETING_VERSION = 3.3.1;
MARKETING_VERSION = 3.3.2;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.Hackintool;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -748,7 +748,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0331;
CURRENT_PROJECT_VERSION = 0332;
DEVELOPMENT_TEAM = 5LGHPJM9ZR;
ENABLE_HARDENED_RUNTIME = NO;
ENABLE_STRICT_OBJC_MSGSEND = NO;
Expand All @@ -762,7 +762,7 @@
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2";
INFOPLIST_FILE = "Hackintool/Hackintool-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @executable_path/../Frameworks";
MARKETING_VERSION = 3.3.1;
MARKETING_VERSION = 3.3.2;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.Hackintool;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Binary file not shown.
23 changes: 16 additions & 7 deletions Hackintool/USB.m
Original file line number Diff line number Diff line change
Expand Up @@ -272,25 +272,31 @@ void injectDefaultUSBPowerProperties(NSMutableDictionary *ioProviderMergePropert
[ioProviderMergePropertiesDictionary setObject:@(5100) forKey:@"kUSBWakePowerSupply"];
}

void injectUSBPowerProperties(AppDelegate *appDelegate, NSMutableDictionary *ioProviderMergePropertiesDictionary)
bool injectUSBPowerProperties(AppDelegate *appDelegate, NSMutableDictionary *ioProviderMergePropertiesDictionary)
{
NSFileManager *fileManager = [NSFileManager defaultManager];
/* NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *ioUSBHostPath = @"/System/Library/Extensions/IOUSBHostFamily.kext/Contents/Info.plist";
if (![fileManager fileExistsAtPath:ioUSBHostPath])
return;
return false; */

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

NSDictionary *ioUSBHostInfoDictionary = [NSDictionary dictionaryWithContentsOfFile:ioUSBHostPath];
if (!(filePath = [mainBundle pathForResource:@"config_patches" ofType:@"plist" inDirectory:@"Clover"]))
return false;

NSDictionary *ioUSBHostInfoDictionary = [NSDictionary dictionaryWithContentsOfFile:filePath];
NSDictionary *ioUSBHostIOKitPersonalities = [ioUSBHostInfoDictionary objectForKey:@"IOKitPersonalities"];
NSString *nearestModelIdentifier = nil;

// If we already have an entry leave it out
if ([[ioUSBHostIOKitPersonalities allKeys] containsObject:appDelegate.modelIdentifier])
return;
return false;

// Get the closest model and use the power entries for it
if (![appDelegate tryGetNearestModel:[ioUSBHostIOKitPersonalities allKeys] modelIdentifier:appDelegate.modelIdentifier nearestModelIdentifier:&nearestModelIdentifier])
return;
return false;

//NSLog(@"nearestModelIdentifier: %@", nearestModelIdentifier);

Expand All @@ -306,6 +312,8 @@ void injectUSBPowerProperties(AppDelegate *appDelegate, NSMutableDictionary *ioP
[ioProviderMergePropertiesDictionary setObject:sleepPowerSupply forKey:@"kUSBSleepPowerSupply"];
[ioProviderMergePropertiesDictionary setObject:wakePortCurrentLimit forKey:@"kUSBWakePortCurrentLimit"];
[ioProviderMergePropertiesDictionary setObject:wakePowerSupply forKey:@"kUSBWakePowerSupply"];

return true;
}

void injectUSBControllerProperties(AppDelegate *appDelegate, NSMutableDictionary *ioKitPersonalities, uint32_t usbControllerID)
Expand Down Expand Up @@ -600,7 +608,8 @@ void addUSBDictionary(AppDelegate *appDelegate, NSMutableDictionary *ioKitPerson
}
else
{
injectUSBPowerProperties(appDelegate, ioProviderMergePropertiesDictionary);
if (!injectUSBPowerProperties(appDelegate, ioProviderMergePropertiesDictionary))
injectDefaultUSBPowerProperties(ioProviderMergePropertiesDictionary);

[modelEntryDictionary setObject:@"com.apple.driver.AppleUSBMergeNub" forKey:@"CFBundleIdentifier"];
[modelEntryDictionary setObject:@"AppleUSBMergeNub" forKey:@"IOClass"];
Expand Down

0 comments on commit 9226c65

Please sign in to comment.