<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>struct input_dev</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="Linux Device Drivers" /><link rel="up" href="ch08.html" title="Chapter 8. Input Subsystem" /><link rel="prev" href="re702.html" title="struct ff_effect" /><link rel="next" href="re704.html" title="struct input_handler" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span>struct input_dev</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="re702.html">Prev</a> </td><th width="60%" align="center">Chapter 8. Input Subsystem</th><td width="20%" align="right"> <a accesskey="n" href="re704.html">Next</a></td></tr></table><hr /></div><div class="refentry" title="struct input_dev"><a id="API-struct-input-dev"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct input_dev — represents an input device </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><pre class="programlisting"> struct input_dev { const char * name; const char * phys; const char * uniq; struct input_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)]; 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 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 sync; int abs[ABS_MAX + 1]; int rep[REP_MAX + 1]; 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 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; spinlock_t event_lock; struct mutex mutex; unsigned int users; bool going_away; struct device dev; struct list_head h_list; struct list_head node; }; </pre></div><div class="refsect1" title="Members"><a id="id2698274"></a><h2>Members</h2><div class="variablelist"><dl><dt><span class="term">name</span></dt><dd><p> name of the device </p></dd><dt><span class="term">phys</span></dt><dd><p> physical path to the device in the system hierarchy </p></dd><dt><span class="term">uniq</span></dt><dd><p> unique identification code for the device (if device has it) </p></dd><dt><span class="term">id</span></dt><dd><p> id of the device (struct input_id) </p></dd><dt><span class="term">evbit[BITS_TO_LONGS(EV_CNT)]</span></dt><dd><p> bitmap of types of events supported by the device (EV_KEY, EV_REL, etc.) </p></dd><dt><span class="term">keybit[BITS_TO_LONGS(KEY_CNT)]</span></dt><dd><p> bitmap of keys/buttons this device has </p></dd><dt><span class="term">relbit[BITS_TO_LONGS(REL_CNT)]</span></dt><dd><p> bitmap of relative axes for the device </p></dd><dt><span class="term">absbit[BITS_TO_LONGS(ABS_CNT)]</span></dt><dd><p> bitmap of absolute axes for the device </p></dd><dt><span class="term">mscbit[BITS_TO_LONGS(MSC_CNT)]</span></dt><dd><p> bitmap of miscellaneous events supported by the device </p></dd><dt><span class="term">ledbit[BITS_TO_LONGS(LED_CNT)]</span></dt><dd><p> bitmap of leds present on the device </p></dd><dt><span class="term">sndbit[BITS_TO_LONGS(SND_CNT)]</span></dt><dd><p> bitmap of sound effects supported by the device </p></dd><dt><span class="term">ffbit[BITS_TO_LONGS(FF_CNT)]</span></dt><dd><p> bitmap of force feedback effects supported by the device </p></dd><dt><span class="term">swbit[BITS_TO_LONGS(SW_CNT)]</span></dt><dd><p> bitmap of switches present on the device </p></dd><dt><span class="term">keycodemax</span></dt><dd><p> size of keycode table </p></dd><dt><span class="term">keycodesize</span></dt><dd><p> size of elements in keycode table </p></dd><dt><span class="term">keycode</span></dt><dd><p> map of scancodes to keycodes for this device </p></dd><dt><span class="term">setkeycode</span></dt><dd><p> optional method to alter current keymap, used to implement sparse keymaps. If not supplied default mechanism will be used </p></dd><dt><span class="term">getkeycode</span></dt><dd><p> optional method to retrieve current keymap. If not supplied default mechanism will be used </p></dd><dt><span class="term">ff</span></dt><dd><p> force feedback structure associated with the device if device supports force feedback effects </p></dd><dt><span class="term">repeat_key</span></dt><dd><p> stores key code of the last key pressed; used to implement software autorepeat </p></dd><dt><span class="term">timer</span></dt><dd><p> timer for software autorepeat </p></dd><dt><span class="term">sync</span></dt><dd><p> set to 1 when there were no new events since last EV_SYNC </p></dd><dt><span class="term">abs[ABS_MAX + 1]</span></dt><dd><p> current values for reports from absolute axes </p></dd><dt><span class="term">rep[REP_MAX + 1]</span></dt><dd><p> current values for autorepeat parameters (delay, rate) </p></dd><dt><span class="term">key[BITS_TO_LONGS(KEY_CNT)]</span></dt><dd><p> reflects current state of device's keys/buttons </p></dd><dt><span class="term">led[BITS_TO_LONGS(LED_CNT)]</span></dt><dd><p> reflects current state of device's LEDs </p></dd><dt><span class="term">snd[BITS_TO_LONGS(SND_CNT)]</span></dt><dd><p> reflects current state of sound effects </p></dd><dt><span class="term">sw[BITS_TO_LONGS(SW_CNT)]</span></dt><dd><p> reflects current state of device's switches </p></dd><dt><span class="term">absmax[ABS_MAX + 1]</span></dt><dd><p> maximum values for events coming from absolute axes </p></dd><dt><span class="term">absmin[ABS_MAX + 1]</span></dt><dd><p> minimum values for events coming from absolute axes </p></dd><dt><span class="term">absfuzz[ABS_MAX + 1]</span></dt><dd><p> describes noisiness for axes </p></dd><dt><span class="term">absflat[ABS_MAX + 1]</span></dt><dd><p> size of the center flat position (used by joydev) </p></dd><dt><span class="term">open</span></dt><dd><p> this method is called when the very first user calls <code class="function">input_open_device</code>. The driver must prepare the device to start generating events (start polling thread, request an IRQ, submit URB, etc.) </p></dd><dt><span class="term">close</span></dt><dd><p> this method is called when the very last user calls <code class="function">input_close_device</code>. </p></dd><dt><span class="term">flush</span></dt><dd><p> purges the device. Most commonly used to get rid of force feedback effects loaded into the device when disconnecting from it </p></dd><dt><span class="term">event</span></dt><dd><p> event handler for events sent _to_ the device, like EV_LED or EV_SND. The device is expected to carry out the requested action (turn on a LED, play sound, etc.) The call is protected by <em class="parameter"><code>event_lock</code></em> and must not sleep </p></dd><dt><span class="term">grab</span></dt><dd><p> input handle that currently has the device grabbed (via EVIOCGRAB ioctl). When a handle grabs a device it becomes sole recipient for all input events coming from the device </p></dd><dt><span class="term">event_lock</span></dt><dd><p> this spinlock is is taken when input core receives and processes a new event for the device (in <code class="function">input_event</code>). 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. </p></dd><dt><span class="term">mutex</span></dt><dd><p> serializes calls to <code class="function">open</code>, <code class="function">close</code> and <code class="function">flush</code> methods </p></dd><dt><span class="term">users</span></dt><dd><p> stores number of users (input handlers) that opened this device. It is used by <code class="function">input_open_device</code> and <code class="function">input_close_device</code> to make sure that dev-><code class="function">open</code> is only called when the first user opens device and dev-><code class="function">close</code> is called when the very last user closes the device </p></dd><dt><span class="term">going_away</span></dt><dd><p> marks devices that are in a middle of unregistering and causes input_open_device*() fail with -ENODEV. </p></dd><dt><span class="term">dev</span></dt><dd><p> driver model's view of this device </p></dd><dt><span class="term">h_list</span></dt><dd><p> list of input handles associated with the device. When accessing the list dev->mutex must be held </p></dd><dt><span class="term">node</span></dt><dd><p> used to place the device onto input_dev_list </p></dd></dl></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="re702.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch08.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="re704.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span>struct ff_effect</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span>struct input_handler</span></td></tr></table></div></body></html>