如何检测 Mac 上的屏幕旋转?
是否可以检测屏幕旋转?我正在使用Mac上的触摸屏驱动程序,所以我想知道屏幕是否旋转。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MacBook(和 Thinkpad)有一个加速度计,用于检测突然运动(即跌落),以防止 HD 磁头崩溃。加速度计数据通过 webkit API 公开。
加速度计数据的本机 API 仅通过专用于 Apple 的专用接口公开,但 Amit Singh 已发布了有关突然运动传感器 API 的文档 此处。
请注意,他已经发布了一个名为 SMSrotateD 的免费程序,可以完成您想要做的事情。当您翻转设备时,它会旋转 MacBook 屏幕。还有一个很酷的示例,它有一个“陀螺仪”窗口,当您随机倾斜设备时,该窗口将保持顶部向上。
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.
希望这个 HTML 会有帮助(下面是工作版本 http://jsfiddle.net/b7Efq/)
另外,您可以检查SeisMac。他们还提供了一个工作库
Hope this HTML will be helpful (below and working version http://jsfiddle.net/b7Efq/)
Also, you can check SeisMac. They also provide a working library