Android触摸屏驱动屏幕翻转

项目中移植了Android触摸屏驱动,后来需要把屏幕翻转180度,此时触摸的坐标是没有适配的,修改以下代码即可:

frameworks/native/services/inputflinger/InputReader.cpp

void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {

    int32_t oldDeviceMode = mDeviceMode;

    ……

    if (viewportChanged) {
        mViewport = newViewport;
            
        char buffer_orientation[PROP_VALUE_MAX];   
        memset(buffer_orientation, 0, sizeof(buffer_orientation));
        property_get("persist.sys.panel.flip", buffer_orientation, "0");    
        int cmpRet = atoi(buffer_orientation);        
        ALOGI("persist.sys.hwrotation~~~~~~~~~~~~~~~~~~~~~~~~~ = %d",cmpRet);    
        if (cmpRet == 0)    
        {        
            mViewport.orientation = DISPLAY_ORIENTATION_0;
        }  
        else if(cmpRet == 90)    
        {
            mViewport.orientation = DISPLAY_ORIENTATION_90;  
        }
        else if(cmpRet == 180)
        {
            mViewport.orientation = DISPLAY_ORIENTATION_180;  
        }
        else if(cmpRet == 270)
        {
            mViewport.orientation = DISPLAY_ORIENTATION_270;  
        }

        if (mDeviceMode == DEVICE_MODE_DIRECT || mDeviceMode == DEVICE_MODE_POINTER) {

……
 

转自: Android触摸屏驱动屏幕翻转

发布了85 篇原创文章 · 获赞 35 · 访问量 17万+

猜你喜欢

转载自blog.csdn.net/WXXGoodJob/article/details/97130004