Loading

linux-2.6内核驱动学习——jz2440之输入子系统

  如果按照上一篇记录的那样,只有本公司的人或者自己才能使用驱动。想写出一个通用的驱动程序,让其他应用程序来无缝移植,需要使用现成的驱动——输入子系统。

/drivers/input/input.c


#define EV_SYN 0x00  //同步类
#define EV_KEY 0x01  //按键类
#define EV_REL 0x02  //相对位移类
#define EV_ABS 0x03  //绝对位移 



struct
input_dev { void *private; const char *name; const char *phys; const char *uniq; struct input_id id; unsigned long evbit[NBITS(EV_MAX)]; //表示能产生哪类时间 unsigned long keybit[NBITS(KEY_MAX)];    //表示能产生哪些按键 unsigned long relbit[NBITS(REL_MAX)];    //表示能产生哪些相对位移事件 unsigned long absbit[NBITS(ABS_MAX)];    //表示能产生哪些绝对位移事件 unsigned long mscbit[NBITS(MSC_MAX)]; unsigned long ledbit[NBITS(LED_MAX)]; unsigned long sndbit[NBITS(SND_MAX)]; unsigned long ffbit[NBITS(FF_MAX)]; unsigned long swbit[NBITS(SW_MAX)]; unsigned int keycodemax; unsigned int keycodesize; void *keycode; int (*setkeycode)(struct input_dev *dev, int scancode, int keycode); int (*getkeycode)(struct input_dev *dev, int scancode, int *keycode); struct ff_device *ff; unsigned int repeat_key; struct timer_list timer; int state; int sync; int abs[ABS_MAX + 1]; int rep[REP_MAX + 1]; unsigned long key[NBITS(KEY_MAX)]; unsigned long led[NBITS(LED_MAX)]; unsigned long snd[NBITS(SND_MAX)]; unsigned long sw[NBITS(SW_MAX)]; int absmax[ABS_MAX + 1]; int absmin[ABS_MAX + 1]; int absfuzz[ABS_MAX + 1]; int absflat[ABS_MAX + 1]; int (*open)(struct input_dev *dev); void (*close)(struct input_dev *dev); int (*flush)(struct input_dev *dev, struct file *file); int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); struct input_handle *grab; struct mutex mutex; /* serializes open and close operations */ unsigned int users; struct class_device cdev; union { /* temporarily so while we switching to struct device */ struct device *parent; } dev; struct list_head h_list; struct list_head node; };

 

posted @ 2019-01-17 14:28  dinosaur-  阅读(400)  评论(0编辑  收藏  举报