Skip to content

Commit aba9cd5

Browse files
MHShettythestinger
authored andcommitted
Support landscape orientation for gyroscope
(for latest changes made to sensor code)
1 parent 1beb7fb commit aba9cd5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/src/main/java/app/grapheneos/camera/notifier/SensorOrientationChangeNotifier.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class SensorOrientationChangeNotifier private constructor(
9595
filteredValues[2] = ALPHA * filteredValues[2] + (1 - ALPHA) * event.values[2]
9696

9797
var x : Float = filteredValues[0]
98-
val y : Float = filteredValues[1]
98+
var y : Float = filteredValues[1]
9999
var z : Float = filteredValues[2]
100100

101101
var newOrientation = mOrientation
@@ -114,6 +114,12 @@ class SensorOrientationChangeNotifier private constructor(
114114
return
115115
}
116116

117+
if (newOrientation == 90 || newOrientation == 270) {
118+
val t = x
119+
x = y
120+
y = t
121+
}
122+
117123
x = ((180 / Math.PI) * atan(x / sqrt(y * y + z * z))).toFloat()
118124
z = ((180 / Math.PI) * atan(z / sqrt(y * y + x * x))).toFloat()
119125

0 commit comments

Comments
 (0)