android: fix getRotationMode() to return canonical DEVICE_ROTATED_* values - #2393
Open
chofuhoyu wants to merge 5 commits into
Open
android: fix getRotationMode() to return canonical DEVICE_ROTATED_* values#2393chofuhoyu wants to merge 5 commits into
chofuhoyu wants to merge 5 commits into
Conversation
…alues Add a mapping from Android's SCREEN_ORIENTATION_* constants to KOReader's canonical DEVICE_ROTATED_* values. Previously, getRotationMode() returned raw Android orientation values (e.g., PORTRAIT=1, LANDSCAPE=0) which don't match the DEVICE_ROTATED_* encoding (0=UPRIGHT, 1=CLOCKWISE, etc.) used throughout the rest of the codebase. Also ensure setRotationMode() updates cur_rotation_mode to keep the internal state in sync.
Frenzie
reviewed
Jun 11, 2026
As suggested by Frenzie in PR review.
android.orientation.get() already returns LinuxFB constants (which are identical to DEVICE_ROTATED_* encoding) via getOrientationCompat(), which has used Display.getRotation() since 2021. The mapping table was designed for Android SCREEN_ORIENTATION_* constants but received LinuxFB values, inverting the mapping for orientations 0 and 1. Restore the pre-PR koreader#2393 behavior of returning android.orientation.get() directly, now with the understanding that it already provides the correct 4-way orientation value.
Author
|
However, I seem to have come across a bug related to this I'm trying to fix that. |
Android's SurfaceFlinger handles display rotation and delivers touch events in display coordinates. The BB is never rotated by the Android setRotationMode override (it only calls android.orientation.set), so touch coordinates must not be transformed. Return 0 (UR) to skip the coordinate translation in the gesture detector and input handler.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a mapping from Android's SCREEN_ORIENTATION_* constants to KOReader's canonical DEVICE_ROTATED_* values. Required by koreader/koreader#15507.
Changes:
This change is