Skip to content

Android: Inform that sensors must be enabled in ProjectSettings - #103132

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
syntaxerror247:docs-sensors
Feb 24, 2025
Merged

Android: Inform that sensors must be enabled in ProjectSettings#103132
Repiteo merged 1 commit into
godotengine:masterfrom
syntaxerror247:docs-sensors

Conversation

@syntaxerror247

@syntaxerror247 syntaxerror247 commented Feb 21, 2025

Copy link
Copy Markdown
Member

@syntaxerror247

Copy link
Copy Markdown
Member Author

@bruvzg Do these settings work for iOS? I checked the code, and it looks like they're only implemented on Android.

@bruvzg

bruvzg commented Feb 21, 2025

Copy link
Copy Markdown
Member

These should not have any effect on iOS, but seems like Input still printing warning if it's not set.

godot/core/input/input.cpp

Lines 614 to 660 in 394508d

Vector3 Input::get_gravity() const {
_THREAD_SAFE_METHOD_
#ifdef DEBUG_ENABLED
if (!gravity_enabled) {
WARN_PRINT_ONCE("`input_devices/sensors/enable_gravity` is not enabled in project settings.");
}
#endif
return gravity;
}
Vector3 Input::get_accelerometer() const {
_THREAD_SAFE_METHOD_
#ifdef DEBUG_ENABLED
if (!accelerometer_enabled) {
WARN_PRINT_ONCE("`input_devices/sensors/enable_accelerometer` is not enabled in project settings.");
}
#endif
return accelerometer;
}
Vector3 Input::get_magnetometer() const {
_THREAD_SAFE_METHOD_
#ifdef DEBUG_ENABLED
if (!magnetometer_enabled) {
WARN_PRINT_ONCE("`input_devices/sensors/enable_magnetometer` is not enabled in project settings.");
}
#endif
return magnetometer;
}
Vector3 Input::get_gyroscope() const {
_THREAD_SAFE_METHOD_
#ifdef DEBUG_ENABLED
if (!gyroscope_enabled) {
WARN_PRINT_ONCE("`input_devices/sensors/enable_gyroscope` is not enabled in project settings.");
}
#endif
return gyroscope;
}

@syntaxerror247

Copy link
Copy Markdown
Member Author

The warning will now only print for Android.

@bruvzg We should also implement this for iOS if possible, as it would reduce battery usage.

@bruvzg

bruvzg commented Feb 21, 2025

Copy link
Copy Markdown
Member

We should also implement this for iOS if possible, as it would reduce battery usage.

Should be possible, but not sure if there will be any effect on the battery.

Sensors are polled here, but it probably requires calling CMMotionManager stopDeviceMotionUpdates to have any effect (it will disable updates for all sensors, I do not think OS will ever disable actual sensors):

- (void)handleMotion {

Edit: it should be possible to config individual sensors, but code should be changed a bit.

@Repiteo
Repiteo merged commit f931a65 into godotengine:master Feb 24, 2025
@Repiteo

Repiteo commented Feb 24, 2025

Copy link
Copy Markdown
Contributor

Thanks!

@syntaxerror247
syntaxerror247 deleted the docs-sensors branch February 24, 2025 15:23
@Calinou Calinou mentioned this pull request Jul 23, 2025
BendyLand pushed a commit to BendyLand/voltaire that referenced this pull request Aug 2, 2026
Android: Inform that sensors must be enabled in ProjectSettings
BendyLand pushed a commit to BendyLand/voltaire that referenced this pull request Aug 2, 2026
Android: Inform that sensors must be enabled in ProjectSettings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

5 participants