Skip to content

Commit

Permalink
Set the opposite sensor values on android to be consistent with iOS (#…
Browse files Browse the repository at this point in the history
…4368)

<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect. -->

## Summary

The sensors on Android and iOS return opposite values, which cause
inconsistencies. To fix this, I modified the Android sensor listener to
return opposite values.
I didn't modify rotation values, because these are the same.

## Test plan

- Ran each sensor and compared the values returned by both platforms
- Tested an example application to confirm that the behavior of the
sensors is consistent across both platforms.
  • Loading branch information
mstach60161 authored Apr 21, 2023
1 parent bf44b1a commit 1619619
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public void onSensorChanged(SensorEvent event) {
};
setter.sensorSetter(data, orientationDegrees);
} else {
setter.sensorSetter(event.values, orientationDegrees);
// Set the opposite values to be consistent with iOS
float[] data = new float[] {-event.values[0], -event.values[1], -event.values[2]};
setter.sensorSetter(data, orientationDegrees);
}
}

Expand Down

0 comments on commit 1619619

Please sign in to comment.