OSDN Git Service

Changing input flinger to take in account screen rotation (hwrotation) in prop file nougat-x86 android-x86-7.1-r5
authorNicolas Peslerbe <development@peslerbe.com>
Tue, 26 Feb 2019 11:02:10 +0000 (12:02 +0100)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Mon, 21 Sep 2020 23:16:56 +0000 (07:16 +0800)
services/inputflinger/InputReader.cpp

index fd18ce7..ab06a34 100644 (file)
@@ -45,6 +45,7 @@
 #include "InputReader.h"
 
 #include <cutils/log.h>
+#include <cutils/properties.h>
 #include <input/Keyboard.h>
 #include <input/VirtualKeyMap.h>
 
@@ -3371,6 +3372,22 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
     int32_t rawWidth = mRawPointerAxes.x.maxValue - mRawPointerAxes.x.minValue + 1;
     int32_t rawHeight = mRawPointerAxes.y.maxValue - mRawPointerAxes.y.minValue + 1;
 
+    char hwrotBuf[PROPERTY_VALUE_MAX];
+    int32_t hwrotation = DISPLAY_ORIENTATION_0;
+    if (property_get("ro.sf.hwrotation", hwrotBuf, NULL) > 0) {
+        switch (atoi(hwrotBuf)) {
+            case 90:
+                hwrotation = DISPLAY_ORIENTATION_90;
+                break;
+            case 180:
+                hwrotation = DISPLAY_ORIENTATION_180;
+                break;
+            case 270:
+                hwrotation = DISPLAY_ORIENTATION_270;
+                break;
+        }
+    }
+
     // Get associated display dimensions.
     DisplayViewport newViewport;
     if (mParameters.hasAssociatedDisplay) {
@@ -3382,8 +3399,16 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
             mDeviceMode = DEVICE_MODE_DISABLED;
             return;
         }
+        newViewport.orientation = (newViewport.orientation + hwrotation) % 4;
     } else {
+        if ((hwrotation == DISPLAY_ORIENTATION_90 ||
+            hwrotation == DISPLAY_ORIENTATION_270)) {
+            int tmp = rawWidth;
+            rawWidth = rawHeight;
+            rawHeight = tmp;
+        }
         newViewport.setNonDisplayViewport(rawWidth, rawHeight);
+        newViewport.orientation = hwrotation;
     }
     bool viewportChanged = mViewport != newViewport;
     if (viewportChanged) {