Godot Version
4.4.1 Godot Stable
Question
`How can I return value of orientation of device and make resolution change based on it ?
print(ProjectSettings.get_setting("display/window/handheld/orientation"))
I tried this but this is only setting for sensor , I have used 6 (ScreenOrientation SCREEN_SENSOR = 6) , but how to check if device is landscape or orientation is there method to return value, so we can make adjustments based on it ?
Have tried also use in global
func _process(delta: float) -> void:
print(DisplayServer.screen_get_orientation())
`
So looking at the source code of Godot it use p_screen to identify orientation of Apple mobile devices
DisplayServer::ScreenOrientation DisplayServerAppleEmbedded::screen_get_orientation(int p_screen) const {
p_screen = _get_screen_index(p_screen);
int screen_count = get_screen_count();
ERR_FAIL_INDEX_V(p_screen, screen_count, SCREEN_LANDSCAPE);
return screen_orientation;
}
void DisplayServerAppleEmbedded::screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) {
p_screen = _get_screen_index(p_screen);
int screen_count = get_screen_count();
ERR_FAIL_INDEX(p_screen, screen_count);
screen_orientation = p_orientation;
if (@available(iOS 16.0, *)) {
[GDTAppDelegateService.viewController setNeedsUpdateOfSupportedInterfaceOrientations];
}
#if !defined(VISIONOS_ENABLED)
else {
[UIViewController attemptRotationToDeviceOrientation];
}
#endif
}
so can I call this variable to make grid , resolution decision instead of calling get_viewport().size ?
Another method could be use one of those built in features to identify on Android and iOS position of device
Vector3 get_gravity() const;
Vector3 get_accelerometer() const;
Vector3 get_magnetometer() const;
Vector3 get_gyroscope() const;
mrcdk
August 29, 2025, 7:32am
4
What’s your issue? As you said, if you use DisplayServer.screen_get_orientation() it should return the current device ScreenOrientation
3 Likes
Well it return setting for orientation from project setting not orientation of device which loosing a purpose for tiles flip with viewport new size .
I tried to export it to iOS and in Xcode all I see is 6 which is always unless I change project setting for other .
mrcdk
August 29, 2025, 10:47am
6
Ah, I see. It seems it’s not really implemented then. You should open an issue in the issue tracker then.
Maybe getting the size of the screen with DisplayServer.screen_get_size() and checking which side is bigger or connecting to the Viewport.size_changed signal may work.
1 Like
Yeah it easier then gravity , gyroscopes , acceleration to get to bottom of it but it get confusing unless I only make assumptions of x and y out out Vector3 and with assign of negative and positive number to identify landscape right , left , portrait , upside down portrait position .
system
Closed
September 28, 2025, 11:05am
8
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.