Chinaunix首页 | 论坛 | 博客
  • 博客访问: 669524
  • 博文数量: 103
  • 博客积分: 2532
  • 博客等级: 大尉
  • 技术积分: 2039
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-26 16:07
文章分类

全部博文(103)

文章存档

2012年(38)

2011年(28)

2010年(16)

2009年(16)

2008年(5)

分类: LINUX

2012-05-17 15:17:29


点击(此处)折叠或打开

  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. };

阅读(3584) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~