ISight Ambient Air Sensor

I understand that there is no public documentation on the use of the isight light sensor, however, programs like ShadowBook ​​( shown here) can access the brightness data, and I just wondered if anyone was able to achieve a similar result and find out How to access this sensor? Thanks!

+6
source share
1 answer

You can access the photosensitive sensor using IOService, from the IOKit library. The name of the light sensor is "AppleLMUController". Here is a good example: a light sensor . Simply put, get the service as follows: 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 that will contain KERN_SUCCESS if the method does not work. Also, do not forget to free the service object using IOObjectRelease(service);

EDIT: On the other hand, IOConnectMethodScalarIScalarO() seems deprecated. Use instead:

 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. Keep in mind that not all MacBooks work this way: in my mid-15th year of 2010, both values ​​are the same, since the light sensor is in the iSight camera.

+7
source

Source: https://habr.com/ru/post/912675/


All Articles