summaryrefslogtreecommitdiff
path: root/libs/input/Input.cpp
diff options
context:
space:
mode:
author Prabir Pradhan <prabirmsp@google.com> 2021-07-28 17:30:18 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2021-07-28 17:30:18 +0000
commit921daeb4bc6208ec608d1d14a9a1c3a07de2f029 (patch)
tree24c86eb9a4fad83d7653620f51f4737f1cd15837 /libs/input/Input.cpp
parenta62ca85c60b1705cd6044f94a9cfed71dc16c75b (diff)
parent15c1c683fd5a19c63fc6a74973d67839f4687523 (diff)
Merge "MotionEvent: Guard getRawX/Y compatibility logic using feature flag" into sc-dev am: 15c1c683fd
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/15371962 Change-Id: Iabba246d11b32d38f1b3d75ff7d09809b76555d5
Diffstat (limited to 'libs/input/Input.cpp')
-rw-r--r--libs/input/Input.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index 2860aa303f..35209f7a07 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -23,6 +23,7 @@
#include <limits.h>
#include <string.h>
+#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <gui/constants.h>
#include <input/Input.h>
@@ -42,6 +43,15 @@ namespace android {
namespace {
+// When per-window-input-rotation is enabled, InputFlinger works in the un-rotated display
+// coordinates and SurfaceFlinger includes the display rotation in the input window transforms.
+bool isPerWindowInputRotationEnabled() {
+ static const bool PER_WINDOW_INPUT_ROTATION =
+ base::GetBoolProperty("persist.debug.per_window_input_rotation", false);
+
+ return PER_WINDOW_INPUT_ROTATION;
+}
+
float transformAngle(const ui::Transform& transform, float angleRadians) {
// Construct and transform a vector oriented at the specified clockwise angle from vertical.
// Coordinate system: down is increasing Y, right is increasing X.
@@ -530,6 +540,8 @@ float MotionEvent::getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex,
size_t historicalIndex) const {
const PointerCoords* coords = getHistoricalRawPointerCoords(pointerIndex, historicalIndex);
+ if (!isPerWindowInputRotationEnabled()) return coords->getAxisValue(axis);
+
if (axis == AMOTION_EVENT_AXIS_X || axis == AMOTION_EVENT_AXIS_Y) {
// For compatibility, convert raw coordinates into "oriented screen space". Once app
// developers are educated about getRaw, we can consider removing this.