Input_输入子系统

应用          open()   read()   write()   close()        (type,code,value)


(创建设备节点,实现FOPS)|------------->event------->                       ↑    struct_input_eveent

input_handler层       |                                1.创建设备节点     >event_client (口—口—口) 数组队列        

(evdev.c)      (input_handler)-->connect-->2.分配event对象-->input_handle{*handler , *dev } 


(创建个类,申请编号)               ↓                         input_handler_list

       

input_core层                  恒匹配

       

(input.c)                       ↑              input_device_list


              (input_dev)------->input_event;input_sync

input_device层

(自己写) --->(1.分配对象 2.初始对象 3.注册对象 4.初始迎检)


硬件         EV_ABS    EV_KEY    EV_REL   

<结构体>

  struct input_dev {
    const char *name;
    const char *phys;
    const char *uniq;
    struct input_id id;

    //位表
    unsigned long evbit[BITS_TO_LONGS(EV_CNT)]; //表示能够产生哪种类型的数据:EV_KEY,EV_ABS
    unsigned long keybit[BITS_TO_LONGS(KEY_CNT)]; //表示能够产生哪些按键数据
    unsigned long relbit[BITS_TO_LONGS(REL_CNT)]; //表示能够产生哪些相对坐标数据
    unsigned long absbit[BITS_TO_LONGS(ABS_CNT)]; //表示能够产生哪些绝对坐标数据
    unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)];
    unsigned long ledbit[BITS_TO_LONGS(LED_CNT)];
    unsigned long sndbit[BITS_TO_LONGS(SND_CNT)];
    unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
    unsigned long swbit[BITS_TO_LONGS(SW_CNT)];

    struct device dev; //父类

    struct list_head h_list;
    struct list_head node; //链表的节点
  };

  struct input_event {   //上报给用户的输入设备的数据包的类型
    struct timeval time; //时间戳
    __u16 type; //读到的数据类型:EV_KEY,EV_ABS,EV_REL
    __u16 code; //编码值
    __s32 value; //状态
  };

 <笔记>

1.input handler    用户交互,不知数据,只知上传

2.input_core   维护了两个链表,为上下层提供接口,他不是总线!!

3.input device      硬件交互,知道数据,不知上传

4.编程:

  1,分配一个 input device对象
  2,初始化input device对象
  3,注册input device对象
  4,硬件初始化,获取到硬件的数据,上报给input handler

5.代码:

   key:https://www.cnblogs.com/panda-w/p/10943249.html

    ts  :https://www.cnblogs.com/panda-w/p/10949993.html

6.input_core层也实现了一个fops,但只实现了open,就回到了input_handler层,所以他第一个打开 

7.一个设备对应一个connect方法,对应一个设备节点,对应一个event对象,对应一个input_handle,对应一个event_client缓冲队列,所以数据上报不会混乱

8.应用程序会根据设备号找到对应的缓冲队列

             

猜你喜欢

转载自www.cnblogs.com/panda-w/p/10922744.html