一. 輸入設備結構體
1. input_dev 輸入設備
struct input_dev {
const char *name; //設備名
const char *phys; //設備系統層的物理路徑
const char *uniq; //
struct input_id id; //輸入設備id 總線類型;廠商編號,產品id,產品版本
unsigned long evbit[BITS_TO_LONGS(EV_CNT)]; //事件類型標志位
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)]; //led指示燈標志位
unsigned long sndbit[BITS_TO_LONGS(SND_CNT)]; //聲音事件
unsigned long ffbit[BITS_TO_LONGS(FF_CNT)]; //強制反饋事件
unsigned long swbit[BITS_TO_LONGS(SW_CNT)]; //開關事件標志位
unsigned int hint_events_per_packet;
unsigned int keycodemax; //鍵盤碼表大小
unsigned int keycodesize; //鍵盤碼大小
void *keycode; //鍵盤碼表指針
int (*setkeycode)(struct input_dev *dev,unsigned int scancode, unsigned int keycode); //設置鍵盤碼
int (*getkeycode)(struct input_dev *dev,unsigned int scancode, unsigned int *keycode); //獲取鍵盤碼
int (*setkeycode_new)(struct input_dev *dev,const struct input_keymap_entry *ke,unsigned int *old_keycode);
int (*getkeycode_new)(struct input_dev *dev,struct input_keymap_entry *ke);
struct ff_device *ff; //強制反饋設備
unsigned int repeat_key; //重復按鍵標志位
struct timer_list timer; //定時器
int rep[REP_CNT]; //重復次數
struct input_mt_slot *mt;
int mtsize;
int slot;
struct input_absinfo *absinfo;
unsigned long key[BITS_TO_LONGS(KEY_CNT)]; //
unsigned long led[BITS_TO_LONGS(LED_CNT)]; //
unsigned long snd[BITS_TO_LONGS(SND_CNT)]; //
unsigned long sw[BITS_TO_LONGS(SW_CNT)]; //
int (*open)(struct input_dev *dev); //open方法
void (*close)(struct input_dev *dev); //close方法
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 __rcu *grab;
spinlock_t event_lock;
struct mutex mutex;
unsigned int users;
bool going_away;
bool sync;
struct device dev; //設備文件
struct list_head h_list; //input_handler處理器鏈表頭
struct list_head node; //input_device設備鏈表頭
};
2. input_handler 輸入處理器
struct input_handler {
void *private; //私有數據
void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); //事件處理
bool (*filter)(struct input_handle *handle, unsigned int type, unsigned int code, int value); //過濾器
bool (*match)(struct input_handler *handler, struct input_dev *dev); //設備匹配
int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id); //設備連接
void (*disconnect)(struct input_handle *handle); //設備斷開連接
void (*start)(struct input_handle *handle);
const struct file_operations *fops; //輸入操作函數集
int minor; //次設備號
const char *name; //設備名
const struct input_device_id *id_table; //輸入設備 id表
struct list_head h_list; //input_handler處理器鏈表頭
struct list_head node; //input_device設備鏈表頭
};