Ignoring global rotation in gyroscope controller

I’d really appreciate some advice from you guys. I am trying to process a gyroscope input and map it to my game, i.e. player tilts their device and the character on screen moves left and right.

Essentially, I have it working. The following two scenarios occur in my game, as desired. You can see that the player is standing still, facing one direction. When they yaw their device (blue rectangle) around its local y-axis (going from the top of the screen down towards gravity), I am able to correctly process the input and move the character on-screen. Great!

9344144--1307135--Screenshot 2023-09-19 at 20.09.47.png

BUT! I have a problem. Let’s consider Scenario 3 below:
9344144--1307141--Screenshot 2023-09-19 at 20.12.56.png 9344144--1307180--Screenshot 2023-09-19 at 20.46.39.png
Here, the player is technically not yawing their device. They are moving their physical body position in world space. You can see that whilst the device has moved 45° globally, it is still facing the player face-on. This should not be registered in the game and it should be ignored by the character. I am really struggling to achieve this.

Right now, I see no way of distinguishing the global rotation from the local rotation, and then ignoring it. The result is unpredictable and undesirable movement. Let’s say if the player was sat in a rotating chair and turning their body slightly whilst playing, the game misinterprets this and turns the character. I need to prevent this from happening. Does anyone have any advice on how to achieve this?

Notes: I am using Unity 2020.3 and the standard UnityEngine.Input class (not the new Input Manager). I also have deliberately avoided showing code, because the code to get this far is extensive. I am using the Gyro exclusively so far and nothing from the accelerometer. I can show code if needed, but first I thought it might be better to just hear advice.

9344144--1307144--upload_2023-9-19_20-14-44.png

Can nobody really help with this? I can attach my code as a package if it helps. I’d really appreciate some help as I have been struggling with this issue for months.