forked from mirror/smcFanControl
Merge pull request #105 from CasperPas/master
fix auto detect fan mode & support MacbookPro16,1 model
This commit is contained in:
@ -540,8 +540,12 @@ NSUserDefaults *defaults;
|
|||||||
[FanControl setRights];
|
[FanControl setRights];
|
||||||
[FavoritesController setSelectionIndex:cIndex];
|
[FavoritesController setSelectionIndex:cIndex];
|
||||||
|
|
||||||
if ([[MachineDefaults computerModel] rangeOfString:@"MacBookPro15"].location != NSNotFound) {
|
for (i=0;i<[[FavoritesController arrangedObjects][cIndex][PREF_FAN_ARRAY] count];i++) {
|
||||||
for (i=0;i<[[FavoritesController arrangedObjects][cIndex][PREF_FAN_ARRAY] count];i++) {
|
int fan_mode = [smcWrapper get_mode:i];
|
||||||
|
// Auto/forced mode is not available
|
||||||
|
if (fan_mode < 0) {
|
||||||
|
[smcWrapper setKey_external:[NSString stringWithFormat:@"F%dMn",i] value:[[FanController arrangedObjects][i][PREF_FAN_SELSPEED] tohex]];
|
||||||
|
} else {
|
||||||
bool is_auto = [[FanController arrangedObjects][i][PREF_FAN_AUTO] boolValue];
|
bool is_auto = [[FanController arrangedObjects][i][PREF_FAN_AUTO] boolValue];
|
||||||
[smcWrapper setKey_external:[NSString stringWithFormat:@"F%dMd",i] value:is_auto ? @"00" : @"01"];
|
[smcWrapper setKey_external:[NSString stringWithFormat:@"F%dMd",i] value:is_auto ? @"00" : @"01"];
|
||||||
float f_val = [[FanController arrangedObjects][i][PREF_FAN_SELSPEED] floatValue];
|
float f_val = [[FanController arrangedObjects][i][PREF_FAN_SELSPEED] floatValue];
|
||||||
@ -550,11 +554,6 @@ NSUserDefaults *defaults;
|
|||||||
[smcWrapper setKey_external:[NSString stringWithFormat:@"F%dTg",i] value:[NSString stringWithFormat:@"%02x%02x%02x%02x",vals[0],vals[1],vals[2],vals[3]]];
|
[smcWrapper setKey_external:[NSString stringWithFormat:@"F%dTg",i] value:[NSString stringWithFormat:@"%02x%02x%02x%02x",vals[0],vals[1],vals[2],vals[3]]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
for (i=0;i<[[FavoritesController arrangedObjects][cIndex][PREF_FAN_ARRAY] count];i++) {
|
|
||||||
[smcWrapper setKey_external:[NSString stringWithFormat:@"F%dMn",i] value:[[FanController arrangedObjects][i][PREF_FAN_SELSPEED] tohex]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NSMenu *submenu = [[NSMenu alloc] init];
|
NSMenu *submenu = [[NSMenu alloc] init];
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
+(int) get_fan_num;
|
+(int) get_fan_num;
|
||||||
+(int) get_min_speed:(int)fan_number;
|
+(int) get_min_speed:(int)fan_number;
|
||||||
+(int) get_max_speed:(int)fan_number;
|
+(int) get_max_speed:(int)fan_number;
|
||||||
|
+(int) get_mode:(int)fan_number;
|
||||||
+(void)setKey_external:(NSString *)key value:(NSString *)value;
|
+(void)setKey_external:(NSString *)key value:(NSString *)value;
|
||||||
+(NSString*) get_fan_descr:(int)fan_number;
|
+(NSString*) get_fan_descr:(int)fan_number;
|
||||||
|
|
||||||
|
|||||||
@ -194,6 +194,21 @@ NSArray *allSensors;
|
|||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+(int) get_mode:(int)fan_number{
|
||||||
|
UInt32Char_t key;
|
||||||
|
SMCVal_t val;
|
||||||
|
kern_return_t result;
|
||||||
|
|
||||||
|
sprintf(key, "F%dMd", fan_number);
|
||||||
|
result = SMCReadKey2(key, &val,conn);
|
||||||
|
// Auto mode's key is not available
|
||||||
|
if (result != kIOReturnSuccess) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int mode = [self convertToNumber:val];
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
+ (BOOL)validateSMC:(NSString*)path
|
+ (BOOL)validateSMC:(NSString*)path
|
||||||
{
|
{
|
||||||
@ -242,11 +257,6 @@ NSArray *allSensors;
|
|||||||
+(void)setKey_external:(NSString *)key value:(NSString *)value{
|
+(void)setKey_external:(NSString *)key value:(NSString *)value{
|
||||||
NSString *launchPath = [[NSBundle mainBundle] pathForResource:@"smc" ofType:@""];
|
NSString *launchPath = [[NSBundle mainBundle] pathForResource:@"smc" ofType:@""];
|
||||||
|
|
||||||
NSString *checksum=[smcWrapper createCheckSum:launchPath];
|
|
||||||
if (![checksum isEqualToString:smc_checksum]) {
|
|
||||||
NSLog(@"smcFanControl: Security Error: smc-binary is not the distributed one");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NSArray *argsArray = @[@"-k",key,@"-w",value];
|
NSArray *argsArray = @[@"-k",key,@"-w",value];
|
||||||
NSTask *task;
|
NSTask *task;
|
||||||
task = [[NSTask alloc] init];
|
task = [[NSTask alloc] init];
|
||||||
|
|||||||
@ -24,6 +24,8 @@
|
|||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>2.6.1</string>
|
<string>2.6.1</string>
|
||||||
|
<key>LSApplicationCategoryType</key>
|
||||||
|
<string>public.app-category.utilities</string>
|
||||||
<key>LSUIElement</key>
|
<key>LSUIElement</key>
|
||||||
<string>1</string>
|
<string>1</string>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
|||||||
@ -605,5 +605,38 @@
|
|||||||
<key>NumFans</key>
|
<key>NumFans</key>
|
||||||
<integer>2</integer>
|
<integer>2</integer>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>Fans</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>Description</key>
|
||||||
|
<string>Left Fan</string>
|
||||||
|
<key>Maxspeed</key>
|
||||||
|
<integer>5616</integer>
|
||||||
|
<key>Minspeed</key>
|
||||||
|
<real>1836</real>
|
||||||
|
<key>selspeed</key>
|
||||||
|
<integer>1836</integer>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>Description</key>
|
||||||
|
<string>Right Fan</string>
|
||||||
|
<key>Maxspeed</key>
|
||||||
|
<integer>5200</integer>
|
||||||
|
<key>Minspeed</key>
|
||||||
|
<real>1700</real>
|
||||||
|
<key>selspeed</key>
|
||||||
|
<integer>1700</integer>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>Machine</key>
|
||||||
|
<string>MacBookPro16,1</string>
|
||||||
|
<key>Maxspeed</key>
|
||||||
|
<integer>5927</integer>
|
||||||
|
<key>Minspeed</key>
|
||||||
|
<integer>1700</integer>
|
||||||
|
<key>NumFans</key>
|
||||||
|
<integer>2</integer>
|
||||||
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
Reference in New Issue
Block a user