本文系本站原創,歡迎轉載!
轉載請註明出處:http://blog.csdn.net/android_huber
交流郵箱:[email protected]
-----------------------------------------------------------------------
1.input.c中input_init
註冊input類,初始化proc,註冊設備register_chrdev(INPUT_MAJOR,"input", &input_fops)
2.evdev.c中 evdev_init
input_register_handler(&evdev_handler)註冊handler:將evdev_handler加入到input_handler_list鏈表中,然後遍歷每一個掛在Input_dev_list上的設備調用input_attach_handler
3.inp[ut.c中 input_register_device
device_Add(&dev->dev)→
Kobject_get_path創建sys接口→
list_add_tail(&dev->node.&input_dev_list)將設備加入全局鏈表中→
然後遍歷input_handler_list中的每一個handler,調用input_attach_handler進行attach
4.input.c中 input_attach_handler
調用input_match_device檢測id匹配情況,然後調用handler中的connect函數:
在connect中封裝了handle和evdev->dev結構體
input_register_handle註冊handle,handle可看作handler和device的結合
最終調用device_Add(&evdev->dev)
5.input_event
Input_event-->input_handler_event:對type進行switch查找,對不同事件執行不同處理。對於按鍵和觸摸屏,交由handler->event處理。-->
Input_pass_event→
handler->event-->即evdev_event函數
在evdev_event中封裝了input_event,並將該結構體保存在client->buffer[client->head++]數組中。client中的buffer會處理成環形緩衝區,
處理方式:client->head &= EVDEV_BUFFER_SIZE-1
6.evdev.c中 evdev_read
將client中的input_event結構體提取出來,然後將該結構體copy_to_user到應用層。
下面是我剛畫好的一個流程圖
大家可以參照 下面這篇分析代碼的文章一起看
圖看不全的話,大家可以保存到本地,然後方便放大了看。
需要清晰大圖的請到下面網址去下載
http://download.csdn.net/detail/android_huber/8537241