I realize there is not any public documentation about the use of the isight light sensor, however programs such as ShadowBook (shown here) are able to access the the brightness data and I was simply wondering if anyone has been able to achieve a similar result and know how to access this sensor? Thanks!
The sensor is 1/2 inch to the right of the camera. I pointed the display at a bright light and opened the Display system preference. I moved a small object along the top of the screen until they brightness changed.
The ambient light sensor on the newer Unibody MacBook Pro (all models: 13″, 15″, 17″) is located directly next to the iSight camera at the top of the display. You can verify the location by holding your hand over the area to the left of the iSight camera and watch as your screen dims and the keyboard lights brighten.
Roughly 1/2 inch to the right of the camera. You cannot see it because it is covered with a tinted and transparent plate. If you want to experiment and confirm then operate your computer in a bright area and note the screen brightness.
MacBook models over the years are adopting slimmer bezels across the screen to offer a vivid display experience. Under the top narrow bezel of the display panel, Apple houses the HD Web camera, the camera LED and ambient light sensor.
You can access the light sensor with IOService, from the IOKit library. The name for the light sensor is "AppleLMUController". Here's a good example: light sensor.
Simply put, get the service like this: io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("AppleLMUController"));
Then, connect to the service using:
io_connect_t port = 0;
IOServiceOpen(service, mach_task_self(), 0, &port);
Get the light levels using: IOConnectMethodScalarIScalarO(port, 0, 0, 2, &left, &right);
Where left
and right
are integers that now hold the light levels of the sensors.
Note that many IOService methods return a kern_return_t
variable, which will hold KERN_SUCCESS
, unless the method failed. Also be sure to release the service object using IOObjectRelease(service);
EDIT: On second thought, IOConnectMethodScalarIScalarO()
appears to be deprecated.
Instead, use:
uint32_t outputs = 2;
uint64_t values[outputs];
IOConnectCallMethod(port, 0, nil, 0, nil, 0, values , &outputs, nil, 0);
The left and right values will be stored in values[0]
and values[1]
respectively. Be aware that not all MacBooks work this way: on my mid 2010 15'' pro, both values are the same, as the light sensor is in the iSight camera.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With