input_dev 结构体成员注释


 

 

  1. Name
  2. struct input_dev — represents an input device

  3. Synopsis
  4. struct input_dev {
  5.   const char * name;//name of the device
  6.   const char * phys;//physical path to the device in the system hierarchy
  7.   const char * uniq;//unique identification code for the device (if device has it)
  8.   struct input_id id;//id of the device (struct input_id)
  9.   unsigned long evbit[BITS_TO_LONGS(EV_CNT)]; //bitmap of types of events supported by the device (EV_KEY, EV_REL, etc.)
  10.   unsigned long keybit[BITS_TO_LONGS(KEY_CNT)]; //bitmap of keys/buttons this device has
  11.   unsigned long relbit[BITS_TO_LONGS(REL_CNT)]; //bitmap of relative axes for the device
  12.   unsigned long absbit[BITS_TO_LONGS(ABS_CNT)]; //bitmap of absolute axes for the device
  13.   unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)]; //bitmap of miscellaneous events supported by the device
  14.   unsigned long ledbit[BITS_TO_LONGS(LED_CNT)];//bitmap of leds present on the device
  15.   unsigned long sndbit[BITS_TO_LONGS(SND_CNT)];//bitmap of sound effects supported by the device
  16.   unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];//bitmap of force feedback effects supported by the device
  17.   unsigned long swbit[BITS_TO_LONGS(SW_CNT)];//bitmap of switches present on the device
  18.   unsigned int keycodemax;//size of keycode table
  19.   unsigned int keycodesize;//size of elements in keycode table
  20.   void * keycode;//map of scancodes to keycodes for this device
  21.   /*optional method to alter current keymap, used to implement sparse keymaps.
  22.     If not supplied default mechanism will be used*/
  23.   int (* setkeycode) (struct input_dev *dev, int scancode, int keycode);
  24. /*optional method to retrieve current keymap. If not supplied default mechanism will be used*/
  25.   int (* getkeycode) (struct input_dev *dev, int scancode, int *keycode);
  26.   struct ff_device * ff;//force feedback structure associated with the device if device supports force feedback effects
  27.   unsigned int repeat_key;//stores key code of the last key pressed; used to implement software autorepeat
  28.   struct timer_list timer;//timer for software autorepeat
  29.   int sync;//set to 1 when there were no new events since last EV_SYNC
  30.   int abs[ABS_MAX + 1]; //current values for reports from absolute axes
  31.   int rep[REP_MAX + 1];//current values for autorepeat parameters (delay, rate)
  32.   unsigned long key[BITS_TO_LONGS(KEY_CNT)]; //reflects current state of device's keys/buttons
  33.   unsigned long led[BITS_TO_LONGS(LED_CNT)];//reflects current state of device's LEDs
  34.   unsigned long snd[BITS_TO_LONGS(SND_CNT)];//reflects current state of sound effects
  35.   unsigned long sw[BITS_TO_LONGS(SW_CNT)];//reflects current state of device's switches
  36.   int absmax[ABS_MAX + 1];//maximum values for events coming from absolute axes
  37.   int absmin[ABS_MAX + 1];//minimum values for events coming from absolute axes
  38.   int absfuzz[ABS_MAX + 1];//describes noisiness for axes
  39.   int absflat[ABS_MAX + 1];//size of the center flat position (used by joydev)
  40. /*this method is called when the very first user calls input_open_device.
  41. The driver must prepare the device to start generating events (start polling
  42. thread, request an IRQ, submit URB, etc.) */
  43.   int (* open) (struct input_dev *dev);
  44.   void (* close) (struct input_dev *dev);//this method is called when the very last user calls input_close_device.
  45. /*purges the device. Most commonly used to get rid of force feedback effects
  46.   loaded into the device when disconnecting from it */
  47.   int (* flush) (struct input_dev *dev, struct file *file);
  48. /*event handler for events sent _to_ the device, like EV_LED or EV_SND.
  49.   The device is expected to carry out the requested action (turn on a LED, play sound, etc.)
  50.   The call is protected by event_lock and must not sleep */
  51.   int (* event) (struct input_dev *dev, unsigned int type, unsigned int code, int value);
  52. /*input handle that currently has the device grabbed (via EVIOCGRAB ioctl).
  53. When a handle grabs a device it becomes sole recipient for all input events coming from the device */
  54.   struct input_handle * grab;
  55. /*this spinlock is is taken when input core receives and processes a new event for the device (in input_event). Code that accesses and/or modifies parameters of a device (such as keymap or absmin, absmax, absfuzz, etc.) after device has been  registered with input core must take this lock. */
  56.   spinlock_t event_lock;
  57.   struct mutex mutex; //serializes calls to open, close and flush methods
  58. /*stores number of users (input handlers) that opened this device. It is used by input_open_device and input_close_device to make sure that dev->open is only called when the first user opens device and dev->close is called when the very last user closes the device */
  59.   unsigned int users;
  60.   int going_away; //marks devices that are in a middle of unregistering and causes input_open_device*() fail with -ENODEV.
  61.   struct device dev; //driver model's view of this device

  62.   struct list_head h_list; //list of input handles associated with the device. When accessing the list dev->mutex must be held
  63.   struct list_head node; //used to place the device onto input_dev_list
  64. };


 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值