完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
经常有客户将触摸和屏的方向装反,又不愿意拆机重装;又或者在设置中将屏幕旋转了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. 原作者:空~。 |
|
相关推荐
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
谁有3566+电池+POE充电的方案,有个项目需要用该功能的主板
770 浏览 0 评论
RK3588的GMAC0与PHY的参考时钟电平匹配问题??????
4588 浏览 1 评论
请问各位大佬,如何解决,瑞芯微 RV1126B 使用 mpp 自带工具 调试时,内核直接报错崩溃!
1823 浏览 0 评论
使用rk3568开发板,核0\\1\\3运行linux,核2运行hal,在核0中怎么关闭核2
2378 浏览 0 评论
2381 浏览 0 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 20:36 , Processed in 0.631446 second(s), Total 70, Slave 53 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1978