conclusion inputmanager

触屏按键:

kernel/arch/arm/boot/dts/xxx/xxx-qrd-skua.dtsi:66:                        compatible = "mstar,msg28xx";
    i2c@78b9000 { /* BLSP1 QUP5 */
      mstar@26 {
                        compatible = "mstar,msg28xx";
            reg = <0x26>;
                        interrupt-parent = <&msm_gpio>;
                        interrupts = <13 0x2008>;
                        mstar,irq-gpio = <&msm_gpio 13 0x00000001>;
                        mstar,reset-gpio = <&msm_gpio 12 0x0>;
                        vdd-supply = <&xxx_l17>;
                        vcc_i2c-supply = <&xxx_l6>;  
                        pinctrl-names = "pmx_ts_active","pmx_ts_suspend","pmx_ts_release";
                        pinctrl-0 = <&ts_int_active &ts_reset_active>;
                        pinctrl-1 = <&ts_int_suspend &ts_reset_suspend>;
                        pinctrl-2 = <&ts_release>;
                        };

    };

ARM Linux 3.x的设备树(Device Tree)

http://blog.csdn.net/21cnbao/article/details/8457546

 

kernel/drivers/input/touchscreen/msg2835/ilitek_drv_qcom.c:144:    { .compatible = "mstar,msg28xx",},

static struct i2c_driver touch_device_driver =
{
    .driver = {
        .name = MSG_TP_IC_NAME,
        .owner = THIS_MODULE,
        .of_match_table = touch_match_table,   //"mstar,msg28xx"
    },
    .probe = touch_driver_probe,
    .remove = touch_driver_remove,
    .id_table = touch_device_id,
};
 

匹配后调用:

/* probe function is used for matching and initializing input device */

static int /*__devinit*/ touch_driver_probe(struct i2c_client *client,
        const struct i2c_device_id *id)

{}

 

触摸屏,虚拟键:

设备文件:

add device 8: /dev/input/event0

  name:     "msg28xx"

 

实体键,power等

add device 3: /dev/input/event4
  name:     "qpnp_pon"

 

InputManager.cpp

void InputManager::initialize() {
    mReaderThread = new InputReaderThread(mReader);
    mDispatcherThread = new InputDispatcherThread(mDispatcher);
}
 

InputReader 通过loopOnce , EventHub 轮询"/dev/input"

openDeviceLocked (    // Configure virtual keys.

    if ((device->classes & INPUT_DEVICE_CLASS_TOUCH)) {
        // Load the virtual keys for the touch screen, if any.
        // We do this now so that we can make sure to load the keymap if necessary.
        status_t status = loadVirtualKeyMapLocked(device); //("/sys/board_properties/virtualkeys.goodix-ts");
        if (!status) {
            device->classes |= INPUT_DEVICE_CLASS_KEYBOARD;
        }

    }

// Load the key map.

loadKeyMapLocked //根据 virtualkeys.goodix-ts中的虚拟值匹配ft5x06_ts.kl中的键值,得到keycode

)打开其中某个字符文件event0,addDeviceLocked

 

kernel/drivers/input/touchscreen/gt1xx/gt1x.c:29:static const char *gt1x_ts_name = "goodix-ts";

 

其中调用

 mEventHub->getEvents(timeoutMillis, mEventBuffer, EVENT_BUFFER_SIZE);//得到events

   // Flush queued events out to the listener.

    // This must happen outside of the lock because the listener could potentially call
    // back into the InputReader's methods, such as getScanCodeState, or become blocked
    // on another thread similarly waiting to acquire the InputReader lock thereby
    // resulting in a deadlock.  This situation is actually quite plausible because the
    // listener is actually the input dispatcher, which calls into the window manager,
    // which occasionally calls into the input reader.
    mQueuedListener->flush(); //class QueuedInputListener : public InputListenerInterface

 

InputDispatcher 从哪里获取数据,再通过looper分发(InputChannel)到上层(viewimpl)

class InputDispatcher : public InputDispatcherInterface

根据event类型可分为:

notifyConfigurationChanged

notifyKey

notifyMotion

notifySwitch

notifyDeviceReset

 

notifyKey

mPolicy->interceptKeyBeforeQueueing(&event, /*byref*/ policyFlags);

shouldSendKeyToInputFilterLocked(args)

enqueueInboundEventLocked(newEntry);

 

 

threadLoop --> dispatchOnce --> dispatchOnceInnerLocked(pokeUserActivityLocked(mPendingEvent);//点亮按键背光) --> dispatchKeyLocked(// Give the policy a chance to intercept the key.//interceptKeyBeforeDispatching) --> dispatchEventLocked-->prepareDispatchCycleLocked-->startDispatchCycleLocked-->(//Publish the key event.)connection->inputPublisher.publishKeyEvent -->mChannel->sendMessage(&msg);

 

(可参考 http://blog.csdn.net/u011630458/article/details/22314243

这一次进入dispatchKeyLocked函数之后,如果键值是home,则entry->interceptKeyResult的属性为:KeyEntry::INTERCEPT_KEY_RESULT_SKIP,之后就会在setInjectionResultLocked中做表示键值处理完成的操作,拦截键值,不往上层发送;如果属性为KeyEntry::INTERCEPT_KEY_RESULT_CONTINUE,则接着通过findFocusedWindowTargetsLocked找到目前焦点所在的activity,然后dispatchEventLocked来上报键值:)

 

ViewRootImpl  WindowInputEventReceiver(WindowInputEventReceiver(mInputChannel,Looper.myLooper());)

        public void onInputEvent(InputEvent event) {
            enqueueInputEvent(event, this, 0, true);

        }

InputStage 这里进行一系列有关输入法等的判断,不管,先分析触摸事件ViewPostImeInputStage

            mView.dispatchPointerEvent(event); -->dispatchTouchEvent

DecorView  dispatchTouchEvent--> cb.dispatchTouchEvent(Activity.java)-->dispatchTouchEvent(//You can override this to intercept all touch screen events before they are dispatched to the window.) -->getWindow().superDispatchTouchEvent(ev)-->mDecor.superDispatchTouchEvent(event);-->ViewGroup.dispatchTouchEvent(//分发到子view中)

 

可参考http://blog.csdn.net/qq_23547831/article/details/51530671

 

修改按键的kl映射文件:   device\xxx\xxx\ft5x06_ts.kl

 

配置长按home键的反应行为:默认为0,不做设置

    // These need to match the documentation/constant in
    // core/res/res/values/config.xml
    static final int LONG_PRESS_HOME_NOTHING = 0;
    static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 1;
    static final int LONG_PRESS_HOME_ASSIST = 2;
    static final int LAST_LONG_PRESS_HOME_BEHAVIOR = LONG_PRESS_HOME_ASSIST;

 

    <!-- Control the behavior when the user long presses the home button.
            0 - Nothing
            1 - Recent apps view in SystemUI
            2 - Launch assist intent
         This needs to match the constants in
         policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
    -->
    <integer name="config_longPressOnHomeBehavior">0</integer>

 

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值