Repository navigation
Motion: the phone's sensors turned by Android's display rotation - a foldable's landscape inner screen turned them a quarter too far - #284
Conversation
… SDL's orientation - a foldable's landscape inner screen SDL 3.4.16 counts a quarter turn more on a display whose natural orientation is landscape (SDL_android.c onNativeRotationChanged), so on an unfolded Galaxy Z Fold 8 (4:3 inner screen) rotation 0 read as SDL_ORIENTATION_LANDSCAPE and to_screen() turned the axes 90 degrees too far: turning the phone tilted the aim. SDL also takes the natural orientation only in SDLActivity.onCreate, and the activity lives through folding (configChanges), so it stayed that of the screen the app started on. to_screen() now asks Android's Display.getRotation() through JNI (at most every 250 ms) - the turn from the display's natural orientation, which the sensor axes follow - and without JNI takes SDL's orientation less its natural one. On portrait phones rotation 90 / 270 maps as LANDSCAPE / LANDSCAPE_FLIPPED did. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Tested on a Galaxy Z Fold 8, unfolded (4:3 inner screen, natural orientation landscape): with this change the phone's motion controls aim the right way - turning the phone left/right moves the aim left/right again, instead of up/down as with 0.3.1-beta. How it was built: this branch (0.3.1-beta + this commit) with the app's Gradle build, Driver: Ready for review from my side. |
Summary
On a Galaxy Z Fold 8, unfolded, the phone's motion controls are turned a quarter: turning the phone left/right moves
the aim up/down. Folded (cover screen) they are right. The inner screen is 4:3 and its natural orientation is
landscape (as on the Pixel Fold or a tablet), and two things in SDL 3.4.16 meet
to_screen()'s portrait assumption:The sensor axes follow the display's natural orientation, so what
to_screen()needs is the rotation from thenatural orientation - Android's
Display.getRotation().The change (
runtime/hle/motion.conly)screen_turns():Display.getRotation()of the activity's display through JNI (SDL_GetAndroidJNIEnv/SDL_GetAndroidActivity, inside a local frame, exceptions cleared), asked at most every 250 ms since folding sendsno event here. Without JNI: SDL's orientation less its natural orientation.
to_screen()turns by that: 1 ->(-y, x), 3 ->(y, -x), 2 ->(-x, -y), 0 -> as is.LANDSCAPE/LANDSCAPE_FLIPPEDdid, so nothing changes there.[motion] the screen is turned N degrees from its natural orientation.Testing
aarch64-linux-android30) against the SDL 3.4.16 headers (the tarball's sha256matches
android/deps/build_deps.sh), with the app's flags plus-Wall -Wextra: no warnings.Display.getRotation()) was checked on an API 37 emulator with a 2400x1800landscape-natural display, against injected gyroscope readings: a yaw moved the screen point sideways with it,
while the portrait-assuming mapping moved it vertically - the reported symptom.
comment below). Not checked here: a regular portrait phone (rotation 90 / 270 maps exactly as before).
🤖 Generated with Claude Code