| Summary: | Android: Accelerometer values fed to joystick driver are inverted for the X axis and wrong for Z | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Denis Bernard <denis> |
| Component: | joystick | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | denis |
| Version: | HG 2.0 | ||
| Hardware: | All | ||
| OS: | Android (All) | ||
|
Description
Denis Bernard
2013-10-15 18:04:05 UTC
Can you double check this relative to your latest patch?
The code now looks like this:
float x, y;
switch (mDisplay.getRotation()) {
case Surface.ROTATION_90:
x = -event.values[1];
y = event.values[0];
break;
case Surface.ROTATION_270:
x = event.values[1];
y = -event.values[0];
break;
case Surface.ROTATION_180:
x = -event.values[1];
y = -event.values[0];
break;
default:
x = event.values[0];
y = event.values[1];
break;
}
SDLActivity.onNativeAccel(x / SensorManager.GRAVITY_EARTH,
y / SensorManager.GRAVITY_EARTH,
event.values[2] / SensorManager.GRAVITY_EARTH);
(In reply to Sam Lantinga from comment #1) > Can you double check this relative to your latest patch? > SDLActivity.onNativeAccel(x / SensorManager.GRAVITY_EARTH, > y / SensorManager.GRAVITY_EARTH, > event.values[2] / > SensorManager.GRAVITY_EARTH); Yes, this still stands. I didn't want to double patch ;) I'll provide a patch on top of 2155 this evening. In the meantime I'd appreciate if someone else could confirm this (wrong?) behaviour on other devices. Also worth noting, I stumbled upon this bug when playing around with the Accelerometer iOS Demo where the value of the joystick's Y axis is negated: float ax = SDL_JoystickGetAxis(accelerometer, 0); float ay = -SDL_JoystickGetAxis(accelerometer, 1); Is X or Y flipped as well on iOS? Fixed! http://hg.libsdl.org/SDL/rev/fdada7e3b3e7 iOS did indeed have an inverted Y axis, which is now also fixed. Thanks! Closing this bug. |