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: Inform that sensors must be enabled in ProjectSettings #103132

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

@syntaxerror247
Copy link
Member Author

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

@bruvzg
Copy link
Member

bruvzg commented Feb 21, 2025

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
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
Copy link
Member

bruvzg commented Feb 21, 2025

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
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Feb 24, 2025

Thanks!

@syntaxerror247 syntaxerror247 deleted the docs-sensors branch February 24, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants