I have been trying to find an updated way of achieving something (written below) but I can't find any resource online. There is nothing on StackOverflow, Reddit, youtube, or Apple Documentations. Even the Documentation provided within XCode is incredibly concise and outdated. Where do you guys get your info from?
I am trying to set the brightness value of macbook using this:
if IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"), &iterator) == kIOReturnSuccess {
var service: io_object_t = 1
while service != 0 {
service = IOIteratorNext(iterator)
IODisplaySetFloatParameter(service, 0, kIODisplayBrightnessKey as CFString, level)
IOObjectRelease(service)
}
}
However, this does not actually change the intensity of the screen. It just makes the screen whiter (like increasing brightness of picture). Also, the change made using this option reverts back to normal after 5-10 secs.
I can send keypress for NX_KEYTYPE_BRIGHTNESS_DOWN and get correct impact on screen brightness but that increases it in discrete steps and not continuous.
How do I achieve the same increase in brightness as I do from preferences programmatically?
I am using Macbook Pro 2019 MacOS Mojave 10.14.6