A game about forced loneliness, made by TACStudios
1using System.ComponentModel;
2using UnityEngine.InputSystem.LowLevel;
3
4namespace UnityEngine.InputSystem.Processors
5{
6 [DesignTimeVisible(false)]
7 internal class CompensateRotationProcessor : InputProcessor<Quaternion>
8 {
9 public override Quaternion Process(Quaternion value, InputControl control)
10 {
11 if (!InputSystem.settings.compensateForScreenOrientation)
12 return value;
13
14 const float kSqrtOfTwo = 1.4142135623731f;
15 var q = Quaternion.identity;
16
17 switch (InputRuntime.s_Instance.screenOrientation)
18 {
19 case ScreenOrientation.PortraitUpsideDown: q = new Quaternion(0.0f, 0.0f, 1.0f /*sin(pi/2)*/, 0.0f /*cos(pi/2)*/); break;
20 case ScreenOrientation.LandscapeLeft: q = new Quaternion(0.0f, 0.0f, kSqrtOfTwo * 0.5f /*sin(pi/4)*/, -kSqrtOfTwo * 0.5f /*cos(pi/4)*/); break;
21 case ScreenOrientation.LandscapeRight: q = new Quaternion(0.0f, 0.0f, -kSqrtOfTwo * 0.5f /*sin(3pi/4)*/, -kSqrtOfTwo * 0.5f /*cos(3pi/4)*/); break;
22 }
23
24 return value * q;
25 }
26
27 public override string ToString()
28 {
29 return "CompensateRotation()";
30 }
31
32 public override CachingPolicy cachingPolicy => CachingPolicy.EvaluateOnEveryRead;
33 }
34}