zoukankan      html  css  js  c++  java
  • RK Android7.1 禁用 USB触摸

     Android输入系统(6)——多点触摸处理

    一.

    二.禁用触摸

    2.1.frameworks ativeservicesinputflingerEventHub.h 

     EventHub->getEvents(),获取输入事件和设备增删事件

    /*
     * Input device classes.
     */
    enum {
        /* The input device is a keyboard or has buttons. */
        INPUT_DEVICE_CLASS_KEYBOARD      = 0x00000001,
    
        /* The input device is an alpha-numeric keyboard (not just a dial pad). */
        INPUT_DEVICE_CLASS_ALPHAKEY      = 0x00000002,
    
        /* The input device is a touchscreen or a touchpad (either single-touch or multi-touch). */
        INPUT_DEVICE_CLASS_TOUCH         = 0x00000004,
    
        /* The input device is a cursor device such as a trackball or mouse. */
        INPUT_DEVICE_CLASS_CURSOR        = 0x00000008,
    
        /* The input device is a multi-touch touchscreen. */
        INPUT_DEVICE_CLASS_TOUCH_MT      = 0x00000010,
    
        /* The input device is a directional pad (implies keyboard, has DPAD keys). */
        INPUT_DEVICE_CLASS_DPAD          = 0x00000020,
    
        /* The input device is a gamepad (implies keyboard, has BUTTON keys). */
        INPUT_DEVICE_CLASS_GAMEPAD       = 0x00000040,
    
        /* The input device has switches. */
        INPUT_DEVICE_CLASS_SWITCH        = 0x00000080,
    
        /* The input device is a joystick (implies gamepad, has joystick absolute axes). */
        INPUT_DEVICE_CLASS_JOYSTICK      = 0x00000100,
    
        /* The input device has a vibrator (supports FF_RUMBLE). */
        INPUT_DEVICE_CLASS_VIBRATOR      = 0x00000200,
        /* The input device has a mouse. */
        INPUT_DEVICE_CLASS_KEYMOUSE      = 0x00000400,
    
        /* The input device has a microphone. */
        INPUT_DEVICE_CLASS_MIC           = 0x00000400,
    
        /* The input device is an external stylus (has data we want to fuse with touch data). */
        INPUT_DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800,
    
        /* The input device has a rotary encoder */
        INPUT_DEVICE_CLASS_ROTARY_ENCODER = 0x00001000,
    
        /* The input device is virtual (not a real device, not part of UI configuration). */
        INPUT_DEVICE_CLASS_VIRTUAL       = 0x40000000,
    
        /* The input device is external (not built-in). */
        INPUT_DEVICE_CLASS_EXTERNAL      = 0x80000000,
    };
    

    2.2.frameworks ativeservicesinputflingerEventHub.cpp  Mapper只处理一次 不能根据属性同步

    触摸

    --- a/frameworks/native/services/inputflinger/EventHub.cpp
    +++ b/frameworks/native/services/inputflinger/EventHub.cpp
    @@ -1199,7 +1199,10 @@ status_t EventHub::openDeviceLocked(const char *devicePath) {
                     device->classes |= INPUT_DEVICE_CLASS_ROTARY_ENCODER;
                 }
         }
    -
    +	char  usb_touch [PROPERTY_VALUE_MAX];
    +	int usb_touch_flag = 0;
    +	property_get("persist.sys.UsbTouch", usb_touch, "0");
    +	usb_touch_flag = strtol(usb_touch,0,0);
         // See if this is a touch pad.
         // Is this a new modern multi-touch driver?
         if (test_bit(ABS_MT_POSITION_X, device->absBitmask)
    @@ -1208,13 +1211,21 @@ status_t EventHub::openDeviceLocked(const char *devicePath) {
             // with the ABS_MT range.  Try to confirm that the device really is
             // a touch screen.
             if (test_bit(BTN_TOUCH, device->keyBitmask) || !haveGamepadButtons) {
    -            device->classes |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT;
    +            device->classes |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT;	
    +			if(usb_touch_flag){
    +				ALOGD("gatsby INPUT_DEVICE_CLASS_TOUCH  INPUT_DEVICE_CLASS_TOUCH_MT");
    +				return -1;
    +			}			
             }
         // Is this an old style single-touch driver?
         } else if (test_bit(BTN_TOUCH, device->keyBitmask)
                 && test_bit(ABS_X, device->absBitmask)
                 && test_bit(ABS_Y, device->absBitmask)) {
    -        device->classes |= INPUT_DEVICE_CLASS_TOUCH;
    +        device->classes |= INPUT_DEVICE_CLASS_TOUCH;		
    +		if(usb_touch_flag){
    +			ALOGD("gatsby INPUT_DEVICE_CLASS_TOUCH");
    +		    return -1;
    +		}	
         // Is this a BT stylus?
         } else if ((test_bit(ABS_PRESSURE, device->absBitmask) ||
                     test_bit(BTN_TOUCH, device->keyBitmask))
    

     键盘

    device->classes |= INPUT_DEVICE_CLASS_KEYBOARD | INPUT_DEVICE_CLASS_KEYMOUSE;

    鼠标

    device->classes |= INPUT_DEVICE_CLASS_CURSOR;  

    2.3.frameworks ativeservicesinputflingerInputReader.cpp 多点触摸屏处理函数 处理数据上报 

    输入系统 InputReader

    • 键盘类设备:KeyboardInputMapper
    • 触摸屏设备:MultiTouchInputMapper或SingleTouchInputMapper
    • 鼠标类设备:CursorInputMapper
    --- a/frameworks/native/services/inputflinger/InputReader.cpp
    +++ b/frameworks/native/services/inputflinger/InputReader.cpp
    @@ -85,6 +85,9 @@ static const nsecs_t STYLUS_DATA_LATENCY = ms2ns(10);
     static const int KEYCODE_ENTER = 28;
     static const int KEYCODE_DPAD_CENTER = 232;
     
    +static	char  usb_touch [PROPERTY_VALUE_MAX];
    +static	int usb_touch_flag = 0;
    +
     // --- Static Functions ---
     
     template<typename T>
    @@ -1739,6 +1742,10 @@ void MultiTouchMotionAccumulator::clearSlots(int32_t initialSlot) {
     }
     
     void MultiTouchMotionAccumulator::process(const RawEvent* rawEvent) {
    +	//ALOGD("gatsby MultiTouchMotionAccumulator");
    +	property_get("persist.sys.UsbTouch", usb_touch, "0");
    +	usb_touch_flag = strtol(usb_touch,0,0);
    +if(usb_touch_flag){
         if (rawEvent->type == EV_ABS) {
             bool newSlot = false;
             if (mUsingSlotsProtocol) {
    @@ -1821,6 +1828,7 @@ void MultiTouchMotionAccumulator::process(const RawEvent* rawEvent) {
             // MultiTouch Sync: The driver has returned all data for *one* of the pointers.
             mCurrentSlot += 1;
         }
    +}	
     }
    

     三.禁用鼠标

    3.1.鼠标、触摸休眠唤醒

    mCursorButtonAccumulator.process(rawEvent);//按键
    mCursorMotionAccumulator.process(rawEvent);//移动
    mCursorScrollAccumulator.process(rawEvent);//滚动

    --- a/frameworks/native/services/inputflinger/InputReader.cpp
    +++ b/frameworks/native/services/inputflinger/InputReader.cpp
    @@ -85,6 +85,9 @@ static const nsecs_t STYLUS_DATA_LATENCY = ms2ns(10);
     static const int KEYCODE_ENTER = 28;
     static const int KEYCODE_DPAD_CENTER = 232;
     
    +static	char  usb_mouse [PROPERTY_VALUE_MAX];
    +static	int   usb_mouse_flag = 0;
    +
     // --- Static Functions ---
     
     template<typename T>
    @@ -2622,6 +2625,11 @@ void CursorInputMapper::reset(nsecs_t when) {
     }
     
     void CursorInputMapper::process(const RawEvent* rawEvent) {
    +	property_get("persist.sys.UsbMouse", usb_mouse, "0");
    +	usb_mouse_flag = strtol(usb_mouse,0,0);
    +	//ALOGD("gatsby CursorInputMapper %d",usb_mouse_flag);
    +	if(!usb_mouse_flag){
    +	//ALOGD("gatsby CursorInputMapperxxxxx %d",usb_mouse_flag);
         mCursorButtonAccumulator.process(rawEvent);
         mCursorMotionAccumulator.process(rawEvent);
         mCursorScrollAccumulator.process(rawEvent);
    @@ -2629,6 +2637,7 @@ void CursorInputMapper::process(const RawEvent* rawEvent) {
         if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) {
             sync(rawEvent->when);
         }
    +	}
     }
     
     void CursorInputMapper::sync(nsecs_t when) {
    @@ -3372,7 +3381,8 @@ void TouchInputMapper::configureParameters() {
         // Initial downs on external touch devices should wake the device.
         // Normally we don't do this for internal touch screens to prevent them from waking
         // up in your pocket but you can enable it using the input device configuration.
    -    mParameters.wake = getDevice()->isExternal();
    +    //mParameters.wake = getDevice()->isExternal();
    +	mParameters.wake = 0;
         getDevice()->getConfiguration().tryGetProperty(String8("touch.wake"),
                 mParameters.wake);
     }  

    3.2.异常  init.rc里面的服务老是重启 

    [ 3.434014] init: Service 'inputflinger' (pid 226) killed by signal 6
    [ 3.434052] init: Service 'inputflinger' (pid 226) killing any children in process group

    [    2.837536] init: Starting service 'inputflinger'...
    [    2.838752] init: Starting service 'installd'...
    [    2.839252] init: Starting service 'keystore'...
    [    2.845439] init: Starting service 'mediacodec'...
    [    2.845861] init: Starting service 'mediadrm'...
    [    2.848736] init: Starting service 'mediaextractor'...
    [    2.851013] init: Starting service 'media'...
    [    2.855864] init: Starting service 'netd'...
    [    2.856386] init: Service 'rootservice' (pid 217) exited with status 0
    [    2.856576] init: Starting service 'gatekeeperd'...
    [    2.864264] logd.daemon: reinit
    [    2.871770] rk_gmac-dwmac ff290000.ethernet: rk_get_eth_addr: mac address: 3e:6e:85:07:a7:0e
    [    2.871786] eth0: device MAC address 3e:6e:85:07:a7:0e
    [    2.872398] init: Starting service 'perfprofd'...
    [    2.872895] init: Service 'logd-reinit' (pid 202) exited with status 0
    [    2.873057] init: Service 'akmd' (pid 221) exited with status 254
    [    2.910133] ret = ffffffff
    [    2.910574] init: Service 'up_eth0' (pid 220) exited with status 0
    [    2.914185] init: Service 'drmservice' (pid 219) exited with status 0
    [    2.945194] capability: warning: `daemonsu' uses 32-bit capabilities (legacy support in use)
    [    2.946996] init: Untracked pid 233 exited with status 0
    [    3.034081] read descriptors
    [    3.034182] read strings
    [    3.034962] pcd_pullup, is_on 1
    [    3.226907] EXT4-fs (mmcblk2p10): re-mounted. Opts: (null)
    [    3.231591] random: nonblocking pool is initialized
    [    3.434014] init: Service 'inputflinger' (pid 226) killed by signal 6
    [    3.434052] init: Service 'inputflinger' (pid 226) killing any children in process group
    

     3.3.优化

    --- a/frameworks/native/services/inputflinger/InputReader.cpp
    +++ b/frameworks/native/services/inputflinger/InputReader.cpp
    @@ -85,6 +85,9 @@ static const nsecs_t STYLUS_DATA_LATENCY = ms2ns(10);
     static const int KEYCODE_ENTER = 28;
     static const int KEYCODE_DPAD_CENTER = 232;
     
    +static	char  usb_mouse [PROPERTY_VALUE_MAX];
    +static	int   usb_mouse_flag = 0;
    +
     // --- Static Functions ---
     
     template<typename T>
    @@ -1260,6 +1263,7 @@ void CursorButtonAccumulator::clearButtons() {
     }
     
     void CursorButtonAccumulator::process(const RawEvent* rawEvent) {
    +	if(!usb_mouse_flag){
         if (rawEvent->type == EV_KEY) {
             switch (rawEvent->code) {
             case BTN_LEFT:
    @@ -1292,6 +1296,7 @@ void CursorButtonAccumulator::process(const RawEvent* rawEvent) {
                 break;
             }
         }
    +	}
     }
     
     uint32_t CursorButtonAccumulator::getButtonState() const {
    @@ -1334,6 +1339,7 @@ void CursorMotionAccumulator::clearRelativeAxes() {
     }
     
     void CursorMotionAccumulator::process(const RawEvent* rawEvent) {
    +	if(!usb_mouse_flag){
         if (rawEvent->type == EV_REL) {
             switch (rawEvent->code) {
             case REL_X:
    @@ -1344,6 +1350,7 @@ void CursorMotionAccumulator::process(const RawEvent* rawEvent) {
                 break;
             }
         }
    +	}
     }
     
     void CursorMotionAccumulator::finishSync() {
    @@ -1373,6 +1380,7 @@ void CursorScrollAccumulator::clearRelativeAxes() {
     }
     
     void CursorScrollAccumulator::process(const RawEvent* rawEvent) {
    +	if(!usb_mouse_flag){
         if (rawEvent->type == EV_REL) {
             switch (rawEvent->code) {
             case REL_WHEEL:
    @@ -1383,6 +1391,7 @@ void CursorScrollAccumulator::process(const RawEvent* rawEvent) {
                 break;
             }
         }
    +	}
     }
     
     void CursorScrollAccumulator::finishSync() {
    @@ -2622,6 +2631,9 @@ void CursorInputMapper::reset(nsecs_t when) {
     }
     
     void CursorInputMapper::process(const RawEvent* rawEvent) {
    +	property_get("persist.sys.UsbMouse", usb_mouse, "0");
    +	usb_mouse_flag = strtol(usb_mouse,0,0);
    +	//ALOGD("gatsby CursorInputMapper %d",usb_mouse_flag);
         mCursorButtonAccumulator.process(rawEvent);
         mCursorMotionAccumulator.process(rawEvent);
         mCursorScrollAccumulator.process(rawEvent);
    @@ -3372,7 +3384,8 @@ void TouchInputMapper::configureParameters() {
         // Initial downs on external touch devices should wake the device.
         // Normally we don't do this for internal touch screens to prevent them from waking
         // up in your pocket but you can enable it using the input device configuration.
    -    mParameters.wake = getDevice()->isExternal();
    +    //mParameters.wake = getDevice()->isExternal();
    +	mParameters.wake = 0;
         getDevice()->getConfiguration().tryGetProperty(String8("touch.wake"),
                 mParameters.wake);
     }
    

      

      

      

  • 相关阅读:
    Python编码规范12-访问控制--访问控制
    Python编码规范11-命名规范--命名约定
    Python编码规范10-命名规范--命名规范
    Python编码规范09-注释--文档注释
    Python编码规范08-注释--代码注释
    Python编码规范07-基础规范--文件和sockets
    Python编码规范06-基础规范--字符串
    Python编码规范05-基础规范--文档字符串(docstring)
    Python编码规范04-基础规范--空格
    Python编码规范03-基础规范--import语句
  • 原文地址:https://www.cnblogs.com/crushgirl/p/15200388.html
Copyright © 2011-2022 走看看