My game uses the accelerometer, everything works fine but I noticed there is going to be a slight issue with some phones. The game forces the orientation to be landscape however some phones have a default screen orientation of landscape…
Right now I was always assuming the user was going to have to tilt their phone to see the game correctly, this would mean the accelerometer reading for the X axis would move the player in the Y and the Y reading would move the player in the X. With the phones that have a default landscape screen the X will correspond to the X in game and the Y for the Y in game (as they wont need to tilt their phones.)
My question is how do I handle this? I can adapt the code to invert the X and Y directions based on the phones orientation, so how would I get the current orientation of the phone programmatically? If there is a better way that would be great
Hope that makes sense
EDIT:
Actually would it be safe to assume that if the devices length is greater than its height the screen would be defaulted to landscape?
from http://developer.android.com/reference/android/view/Display.html:
You’ll have to experiment with the devices to make sure android knows the “natural” orientation correctly. If so, then just check for ROTATION_90 (or ROTATION_270) to see if the device is on it’s side or not. If so, then switch x and y axis.