26 #include <QtCore/qsystemdetection.h>
28 #include <CoreFoundation/CoreFoundation.h>
29 #include <IOKit/IOKitLib.h>
31 uint32_t Platform::getIdleTime()
36 static io_service_t service = 0;
38 uint64_t idleTime_ns = 0;
42 IOMasterPort(MACH_PORT_NULL, &master);
43 service = IOServiceGetMatchingService(master, IOServiceMatching(
"IOHIDSystem"));
46 property = IORegistryEntryCreateCFProperty(service, CFSTR(
"HIDIdleTime"), kCFAllocatorDefault, 0);
47 CFNumberGetValue(
static_cast<CFNumberRef
>(property), kCFNumberSInt64Type, &idleTime_ns);
50 return idleTime_ns / 1000000;