Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android rotation lock setting is not respected #1737

Open
Oxdeception opened this issue Dec 29, 2023 · 1 comment · Fixed by VsFreyaDevs/lime2#11 · May be fixed by #1835
Open

Android rotation lock setting is not respected #1737

Oxdeception opened this issue Dec 29, 2023 · 1 comment · Fixed by VsFreyaDevs/lime2#11 · May be fixed by #1835

Comments

@Oxdeception
Copy link

Steps to Reproduce

  1. Create Lime project using SimpleImage template
  2. Set Auto-rotate screen to off on Android device
  3. lime test android
  4. Rotate device

Expected Behavior
Starting orientation is maintained

Actual Behavior
Orientation changes

@player-03
Copy link
Contributor

The documentation for ACCELEROMETER_ROTATION makes it sound like apps get to override the system setting, so maybe Lime is doing that somewhere.

Or maybe Lime uses Display.getRotation() without regard to the accelerometer setting. Though since that value comes from Android, it ought to work correctly.

public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
// Since we may have an orientation set, we won't receive onConfigurationChanged events.
// We thus should check here.
int newOrientation = SDLActivity.SDL_ORIENTATION_UNKNOWN;
float x, y;
switch (mDisplay.getRotation()) {
case Surface.ROTATION_90:
x = -event.values[1];
y = event.values[0];
newOrientation = SDLActivity.SDL_ORIENTATION_LANDSCAPE;
break;
case Surface.ROTATION_270:
x = event.values[1];
y = -event.values[0];
newOrientation = SDLActivity.SDL_ORIENTATION_LANDSCAPE_FLIPPED;
break;
case Surface.ROTATION_180:
x = -event.values[0];
y = -event.values[1];
newOrientation = SDLActivity.SDL_ORIENTATION_PORTRAIT_FLIPPED;
break;
default:
x = event.values[0];
y = event.values[1];
newOrientation = SDLActivity.SDL_ORIENTATION_PORTRAIT;
break;
}
if (newOrientation != SDLActivity.mCurrentOrientation) {
SDLActivity.mCurrentOrientation = newOrientation;
SDLActivity.onNativeOrientationChanged(newOrientation);
}
SDLActivity.onNativeAccel(-x / SensorManager.GRAVITY_EARTH,
y / SensorManager.GRAVITY_EARTH,
event.values[2] / SensorManager.GRAVITY_EARTH);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants