I'm trying to write a small Objective-C command line tool that adjusts the rotation of a given display.
Sadly, I can not find any reference in Apple's documentation that tells how to change the rotation (aside from getting it). I think it has to be done with using CGDisplayModeRef
but I can't find out how. Any help would be appreciated!
Extracted from https://github.com/CdLbB/fb-rotate - it seems IOKit
can do the job although the behavior seems a bit odd to me. In a nutshell:
io_service_t service = CGDisplayIOServicePort(myDisplayID); //IOKit Handle (get myDisplayID yourself)
IOOptionBits options = (0x00000400 | (kIOScaleRotate90) << 16) //Some undocumented hex'ing
IOServiceRequestProbe(service, options); //Set rotation to display
Don't forget to link against IOKit
.
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