I have a Xiaomi Pad 6, which is an Android device with gyroscope, acceleration sensor, etc.
However, this device does not respond to gyroscopes in the game I am developing.
I debugged with VS2022, and found that the breakpoint I set inside Java_com_epicgames_ue4_GameActivity_nativeHandleSensorEvents ( in AndroidJNI.cpp) was never hit. So I guess that’s why the device cannot respond to any sensor change, even though it has some sensors.
I want to know why the function in engine is never called on certain device.
I debugged with Android java code in GameActivity.java, and found that it is because this device doesn’t have magnetometer. So that “onSensorChanged” function returned directly.
Here’s my solution: I use GAME_ROTATION_VECTOR to calculate the rotation matrix instead of getRotationMatrix. Because this vector is a quaternion, which is easy to transform to rotation matrix.