Is it possible to detect screen rotation? I’m woking on the touch screen driver on mac, so I want to know if the screen is rotated.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
MacBooks (and Thinkpads) have an accelerometer used to detect sudden motion (i.e. being dropped) to prevent the HD head from crashing. The accelerometer data is exposed via webkit APIs.
Native APIs for accelerometer data are only exposed via private Apple-only interfaces, but Amit Singh has published his documentation for the sudden motion sensor API here.
Note that he’s already published a free program that does what you’re trying to do, called SMSRotateD. It’ll rotate the MacBook screen as you flip the device. There’s also a cool sample that has a "gyroscopic" window which will remain top-up as you tilt your device randomly.