Skip to content

lightgun-poc / lib/monitors / detectDarwin

Function: detectDarwin()

detectDarwin(ffi): MonitorRect[]

Defined in: lib/monitors.ts:241

Enumerates active displays via CGGetActiveDisplayList + CGDisplayBounds.

Units: CGDisplayBounds returns POINTS in the global display space (top-left origin, y-down — same handedness as Windows), and libnut's darwin moveMouse/getScreenSize live in that same space, so every rect here is consistent with injection with no scaling anywhere. On Retina that means e.g. 1512x982, not the physical 3024x1964 — correct, just surprising in the monitors listing.

CGRect comes back BY VALUE, which needs a registered koffi struct type — the one place the minimal Ffi surface grew (struct, still no callbacks). The ids buffer is a packed uint32[16] (entry i at byte i*4, LE), the count a single uint32 at offset 0 — the test fake writes at exactly these offsets.

Parameters

ffi

Ffi

Returns

MonitorRect[]

Released under the MIT License.