Android: Inform that sensors must be enabled in ProjectSettings

This commit is contained in:
Anish Mishra 2025-02-21 22:05:26 +05:30
parent 394508d26d
commit 93bababb8c
2 changed files with 8 additions and 4 deletions

View file

@ -614,7 +614,7 @@ void Input::joy_connection_changed(int p_idx, bool p_connected, const String &p_
Vector3 Input::get_gravity() const { Vector3 Input::get_gravity() const {
_THREAD_SAFE_METHOD_ _THREAD_SAFE_METHOD_
#ifdef DEBUG_ENABLED #if defined(DEBUG_ENABLED) && defined(ANDROID_ENABLED)
if (!gravity_enabled) { if (!gravity_enabled) {
WARN_PRINT_ONCE("`input_devices/sensors/enable_gravity` is not enabled in project settings."); WARN_PRINT_ONCE("`input_devices/sensors/enable_gravity` is not enabled in project settings.");
} }
@ -626,7 +626,7 @@ Vector3 Input::get_gravity() const {
Vector3 Input::get_accelerometer() const { Vector3 Input::get_accelerometer() const {
_THREAD_SAFE_METHOD_ _THREAD_SAFE_METHOD_
#ifdef DEBUG_ENABLED #if defined(DEBUG_ENABLED) && defined(ANDROID_ENABLED)
if (!accelerometer_enabled) { if (!accelerometer_enabled) {
WARN_PRINT_ONCE("`input_devices/sensors/enable_accelerometer` is not enabled in project settings."); WARN_PRINT_ONCE("`input_devices/sensors/enable_accelerometer` is not enabled in project settings.");
} }
@ -638,7 +638,7 @@ Vector3 Input::get_accelerometer() const {
Vector3 Input::get_magnetometer() const { Vector3 Input::get_magnetometer() const {
_THREAD_SAFE_METHOD_ _THREAD_SAFE_METHOD_
#ifdef DEBUG_ENABLED #if defined(DEBUG_ENABLED) && defined(ANDROID_ENABLED)
if (!magnetometer_enabled) { if (!magnetometer_enabled) {
WARN_PRINT_ONCE("`input_devices/sensors/enable_magnetometer` is not enabled in project settings."); WARN_PRINT_ONCE("`input_devices/sensors/enable_magnetometer` is not enabled in project settings.");
} }
@ -650,7 +650,7 @@ Vector3 Input::get_magnetometer() const {
Vector3 Input::get_gyroscope() const { Vector3 Input::get_gyroscope() const {
_THREAD_SAFE_METHOD_ _THREAD_SAFE_METHOD_
#ifdef DEBUG_ENABLED #if defined(DEBUG_ENABLED) && defined(ANDROID_ENABLED)
if (!gyroscope_enabled) { if (!gyroscope_enabled) {
WARN_PRINT_ONCE("`input_devices/sensors/enable_gyroscope` is not enabled in project settings."); WARN_PRINT_ONCE("`input_devices/sensors/enable_gyroscope` is not enabled in project settings.");
} }

View file

@ -51,6 +51,7 @@
Returns the acceleration in m/s² of the device's accelerometer sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO]. Returns the acceleration in m/s² of the device's accelerometer sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO].
Note this method returns an empty [Vector3] when running from the editor even when your device has an accelerometer. You must export your project to a supported device to read values from the accelerometer. Note this method returns an empty [Vector3] when running from the editor even when your device has an accelerometer. You must export your project to a supported device to read values from the accelerometer.
[b]Note:[/b] This method only works on Android and iOS. On other platforms, it always returns [constant Vector3.ZERO]. [b]Note:[/b] This method only works on Android and iOS. On other platforms, it always returns [constant Vector3.ZERO].
[b]Note:[/b] For Android, [member ProjectSettings.input_devices/sensors/enable_accelerometer] must be enabled.
</description> </description>
</method> </method>
<method name="get_action_raw_strength" qualifiers="const"> <method name="get_action_raw_strength" qualifiers="const">
@ -97,6 +98,7 @@
<description> <description>
Returns the gravity in m/s² of the device's accelerometer sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO]. Returns the gravity in m/s² of the device's accelerometer sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO].
[b]Note:[/b] This method only works on Android and iOS. On other platforms, it always returns [constant Vector3.ZERO]. [b]Note:[/b] This method only works on Android and iOS. On other platforms, it always returns [constant Vector3.ZERO].
[b]Note:[/b] For Android, [member ProjectSettings.input_devices/sensors/enable_gravity] must be enabled.
</description> </description>
</method> </method>
<method name="get_gyroscope" qualifiers="const"> <method name="get_gyroscope" qualifiers="const">
@ -104,6 +106,7 @@
<description> <description>
Returns the rotation rate in rad/s around a device's X, Y, and Z axes of the gyroscope sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO]. Returns the rotation rate in rad/s around a device's X, Y, and Z axes of the gyroscope sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO].
[b]Note:[/b] This method only works on Android and iOS. On other platforms, it always returns [constant Vector3.ZERO]. [b]Note:[/b] This method only works on Android and iOS. On other platforms, it always returns [constant Vector3.ZERO].
[b]Note:[/b] For Android, [member ProjectSettings.input_devices/sensors/enable_gyroscope] must be enabled.
</description> </description>
</method> </method>
<method name="get_joy_axis" qualifiers="const"> <method name="get_joy_axis" qualifiers="const">
@ -177,6 +180,7 @@
<description> <description>
Returns the magnetic field strength in micro-Tesla for all axes of the device's magnetometer sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO]. Returns the magnetic field strength in micro-Tesla for all axes of the device's magnetometer sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO].
[b]Note:[/b] This method only works on Android and iOS. On other platforms, it always returns [constant Vector3.ZERO]. [b]Note:[/b] This method only works on Android and iOS. On other platforms, it always returns [constant Vector3.ZERO].
[b]Note:[/b] For Android, [member ProjectSettings.input_devices/sensors/enable_magnetometer] must be enabled.
</description> </description>
</method> </method>
<method name="get_mouse_button_mask" qualifiers="const"> <method name="get_mouse_button_mask" qualifiers="const">