Skip to content

Commit

Permalink
Fix coreOffset detection on MBP model and Macmini8,1 (acidanthera#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhen-zen committed Sep 1, 2020
1 parent f17022f commit dcf11a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Sensors/SMCProcessor/SMCProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,16 +423,16 @@ bool SMCProcessor::start(IOService *provider) {
// Some laptop models start core sensors not with 0, but actually with 1.
size_t coreOffset = 0;
auto model = BaseDeviceInfo::get().modelIdentifier;
auto isdigit = [](auto l) { return l >= '0' && l <= '9'; };
if (!strncmp(model, "MacBook", strlen("MacBook"))) {
auto rmodel = model + strlen("MacBook");
auto isdigit = [](auto l) { return l >= '0' && l <= '9'; };

if (!strncmp(rmodel, "Air", strlen("Air"))) {
// MacBookAir6,1 and above
const char *suffix = rmodel + strlen("Air");
if (isdigit(suffix[0]) && (isdigit(suffix[1]) || suffix[0] >= '6'))
coreOffset = 1;
} else if (!strncmp(model, "Pro", strlen("Pro"))) {
} else if (!strncmp(rmodel, "Pro", strlen("Pro"))) {
const char *suffix = rmodel + strlen("Pro");
if (isdigit(suffix[0]) && isdigit(suffix[1]) && ((suffix[0] == '1' && suffix[1] >= '3') || suffix[0] > '1')) {
// MacBookPro13,1 and above
Expand All @@ -451,6 +451,11 @@ bool SMCProcessor::start(IOService *provider) {
// MacBook8,1 and above
coreOffset = 1;
}
} else if (!strncmp(model, "Macmini", strlen("Macmini"))) {
// Macmini8,1 and above
const char *suffix = model + strlen("Macmini");
if (isdigit(suffix[0]) && suffix[0] >= '8')
coreOffset = 1;
}

setupKeys(coreOffset);
Expand Down

0 comments on commit dcf11a7

Please sign in to comment.