Reputation: 254
I'm developing an Android game that uses the orientation sensor to get the rotation of the device (to roll a ball). I have two devices that I test apps on, one is a Samsung Infuse (phone) and the other is an Asus Eee Pad Transformer TF101 (tablet).
The app runs in landscape on both devices. The problem is that on the Eee Pad, the orientation is measured with the device sideways (landscape mode) while the Infuse measures in upright (portrait) no matter what I do. This makes is so the ball moves left when I tilt my Infuse left, but when I tilt the Eee Pad left, the ball moves up or down.
I can switch the orientation angles, so they move the ball the other way, but it only works for one or the other at a time. Any ideas how I could fix this?
Yes, I am using the deprecated TYPE_ORIENTATION, and not the getOrientation() method. I tried setting it up, but I never got it working correctly and it always spat out really weird values, so I stuck to the deprecated one. Would switching over fix this at all? If so, can someone link me to resources to implement this?
Upvotes: 3
Views: 2256
Reputation: 2804
Google's docs make it clear that the sensor coordinate system is relative to the default orientation of the device. That description mentions the getRotation()
and remapCoordinateSystem()
calls you can use to adjust appropriately.
Upvotes: 4