Android accelerometer

Hey all, I’ve been toying around with porting an old game i wrote to sdl2 and android. Now I’m not sure about the java code in the sdl accelerometer, but it seems buggy. The code below

switch (mDisplay.getRotation()) {
case Surface.ROTATION_90:
x = -event.values[1];
y = event.values[0];
case Surface.ROTATION_270:
x = event.values[1];
y = -event.values[0];
case Surface.ROTATION_180:
x = -event.values[1]; // everything math seems to tell me this should [0]
y = -event.values[0]; // should be [1] ???
x = event.values[0];
y = event.values[1];
SDLActivity.onNativeAccel(-x / SensorManager.GRAVITY_EARTH,
y / SensorManager.GRAVITY_EARTH,
event.values[2] / SensorManager.GRAVITY_EARTH - 1);

in the last line you subtract 1 from the z-axis. I figure you want to get rid of gravity. But under normal usage and the logic above the gravity axis is in the y direction. The way it now makes both the y-axis close to -1 and the z-axis. With the z-axis overflowing and thus flipping between -2^15 to +2^15 with small movements