input_dev 结构体成员注释

来源:互联网 发布:网络主播思瑞在线 编辑:程序博客网 时间:2024/04/28 06:57


 

 

  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 pathto the device in the system hierarchy
  7.   const char * uniq;//unique identification codefor 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 axesfor the device
  12.   unsigned long absbit[BITS_TO_LONGS(ABS_CNT)];//bitmap of absolute axesfor 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 elementsin keycode table
  20.   void * keycode;//map of scancodesto keycodes for this device
  21.   /*optional methodto alter current keymap, usedto 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 methodto 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 deviceif device supports force feedback effects
  27.   unsigned int repeat_key;//stores key code of the last key pressed; usedto implement software autorepeat
  28.   struct timer_list timer;//timerfor software autorepeat
  29.   int sync;//setto 1 when there were no new events since last EV_SYNC
  30.   int abs[ABS_MAX+ 1];//current valuesfor reports from absolute axes
  31.   int rep[REP_MAX+ 1];//current valuesfor 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 valuesfor events coming from absolute axes
  37.   int absmin[ABS_MAX+ 1];//minimum valuesfor events coming from absolute axes
  38.   int absfuzz[ABS_MAX+ 1];//describes noisinessfor axes
  39.   int absflat[ABS_MAX+ 1];//size of the center flat position(used by joydev)
  40. /*this methodis 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 methodis called when the very last user calls input_close_device.
  45. /*purges the device. Most commonly usedto 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 handlerfor events sent _to_ the device, like EV_LEDor 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_lockand must not sleep*/
  51.   int (* event)(struct input_dev *dev, unsignedint type, unsignedint 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 spinlockis is taken when input core receivesand processes a new event for the device (in input_event). Code that accessesand/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. Itis used by input_open_device and input_close_device to make sure that dev->openis only called when the first user opens device and dev->closeis called when the very last user closes the device*/
  59.   unsigned int users;
  60.   int going_away;//marks devices that arein 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. };


 

原创粉丝点击