OnePlus X (OxygenOS): Screen auto-rotating in wrong direction
I've had the same problem. It was fine again after restoring an old TWRP-backup of "Persist".
Don't know why. Just worked.

If you don't have a Backup of your Persist partition then I think that (re)installing a stock ROM could also be able to fix this. Even if not, it won't hurt to give it a shot.



Edit: I took a short look into /persist and found two interesting files inside it:
/persist/sensors/gyro_sensitity_cal - Containing GyroSens 1.000000 1.000000 1.000000
/persist/sensors/sensors_settings - Containing 1
I guess that explains why it fixed the error and maybe also just checking and correcting these files will do so.