Created
August 29, 2016 08:54
-
-
Save edwardean/d5fe31c5fedea5ecb7a43f3b3cdf905e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //CGDisplayIOServicePort is depreciated in OS 10.9 – so you have to use IOServiceGetMatchingServices to get the service parameter for IODisplaySetFloatParameter. | |
| - (void) setBrightnessTo: (float) level | |
| { | |
| io_iterator_t iterator; | |
| kern_return_t result = IOServiceGetMatchingServices(kIOMasterPortDefault, | |
| IOServiceMatching("IODisplayConnect"), | |
| &iterator); | |
| // If we were successful | |
| if (result == kIOReturnSuccess) | |
| { | |
| io_object_t service; | |
| while ((service = IOIteratorNext(iterator))) { | |
| IODisplaySetFloatParameter(service, kNilOptions, CFSTR(kIODisplayBrightnessKey), level); | |
| // Let the object go | |
| IOObjectRelease(service); | |
| return; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment