diff options
| author | 2022-12-02 17:13:13 +0000 | |
|---|---|---|
| committer | 2022-12-02 17:13:13 +0000 | |
| commit | b316c34aef60b881f31441a763bed8ce4e00ee78 (patch) | |
| tree | 1d1d7ca2b88a57c7acf2a65b1bc95c042e1ee9b5 /libs/input/Input.cpp | |
| parent | b8280a46f454039efd41825b1e2bdb1ceb6fe0cb (diff) | |
| parent | 635422be3e0e02b7221633b2eb1b112fc18bb65e (diff) | |
Merge "Convert MotionEvent#getSurfaceRotation to ui::Rotation"
Diffstat (limited to 'libs/input/Input.cpp')
| -rw-r--r-- | libs/input/Input.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp index 162b757743..9e8ebf30c5 100644 --- a/libs/input/Input.cpp +++ b/libs/input/Input.cpp @@ -21,6 +21,7 @@ #include <cutils/compiler.h> #include <inttypes.h> #include <string.h> +#include <optional> #include <android-base/file.h> #include <android-base/logging.h> @@ -552,21 +553,21 @@ void MotionEvent::addSample( &pointerCoords[getPointerCount()]); } -int32_t MotionEvent::getSurfaceRotation() const { +std::optional<ui::Rotation> MotionEvent::getSurfaceRotation() const { // The surface rotation is the rotation from the window's coordinate space to that of the // display. Since the event's transform takes display space coordinates to window space, the // returned surface rotation is the inverse of the rotation for the surface. switch (mTransform.getOrientation()) { case ui::Transform::ROT_0: - return static_cast<int32_t>(ui::ROTATION_0); + return ui::ROTATION_0; case ui::Transform::ROT_90: - return static_cast<int32_t>(ui::ROTATION_270); + return ui::ROTATION_270; case ui::Transform::ROT_180: - return static_cast<int32_t>(ui::ROTATION_180); + return ui::ROTATION_180; case ui::Transform::ROT_270: - return static_cast<int32_t>(ui::ROTATION_90); + return ui::ROTATION_90; default: - return -1; + return std::nullopt; } } |