瑞芯微Rockchip开发者社区
直播中

万物死

9年用户 1359经验值
擅长:MEMS/传感技术
私信 关注
[问答]

如何去解决rk3399 USB触摸屏自动旋转的问题呢

经常有客户将触摸和屏的方向装反,又不愿意拆机重装;又或者在设置中将屏幕旋转了90度,而此时触摸方向没变,只能通过代码解决啦。
diff --git a/frameworks/native/services/inputflinger/InputReader.cpp b/frameworks/native/services/inputflinger/InputReader.cpp
index c07c3bb508..f5ef4d91b2 100755
--- a/frameworks/native/services/inputflinger/InputReader.cpp
+++ b/frameworks/native/services/inputflinger/InputReader.cpp
@@ -3511,6 +3511,18 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
     bool viewportChanged = mViewport != newViewport;
     if (viewportChanged) {
         mViewport = newViewport;
+        char tp_orientation[PROPERTY_VALUE_MAX] = {0};
+                               property_get("persist.sys.tp_rotation", tp_orientation, "0");
+                               int mRotation = atoi(tp_orientation);
+                               if ( mRotation == 0 ) {
+                                       mViewport.orientation = mViewport.orientation + DISPLAY_ORIENTATION_0;
+                               } else if ( mRotation == 90 ) {
+                                       mViewport.orientation = mViewport.orientation + DISPLAY_ORIENTATION_90;
+                               } else if ( mRotation == 180 ) {
+                                       mViewport.orientation = mViewport.orientation + DISPLAY_ORIENTATION_180;
+                               } else if ( mRotation == 270 ) {
+                                       mViewport.orientation = mViewport.orientation + DISPLAY_ORIENTATION_270;
+                               }
         if (mDeviceMode == DEVICE_MODE_DIRECT || mDeviceMode == DEVICE_MODE_POINTER) {
persist.sys.tp_rotation设置触摸的初始方向,当然也可以在设置中添加一个触摸屏旋转选项来方便客户操作,只需修改这个值即可。
说明一下:mViewport.orientation本身也是有个值的,比如APP是竖屏,系统是横屏,打开APP的时候系统会自动旋转为竖屏,此时mViewport.orientation也会跟着变化。所以mViewport.orientation最后的值为mViewport.orientation + DISPLAY_ORIENTATION_X.

原作者:空~。

更多回帖

发帖
×
20
完善资料,
赚取积分