1<html><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.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="input_subsystem.html#idp1114168316" title="Input core"><link rel="prev" href="API-struct-input-value.html" title="struct input_value"><link rel="next" href="API-struct-input-handler.html" title="struct input_handler"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">struct input_dev</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-struct-input-value.html">Prev</a>&#160;</td><th width="60%" align="center">Input core</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-struct-input-handler.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-input-dev"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct input_dev &#8212; 
2     represents an input device
3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting">
4struct input_dev {
5  const char * name;
6  const char * phys;
7  const char * uniq;
8  struct input_id id;
9  unsigned long propbit[BITS_TO_LONGS(INPUT_PROP_CNT)];
10  unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
11  unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
12  unsigned long relbit[BITS_TO_LONGS(REL_CNT)];
13  unsigned long absbit[BITS_TO_LONGS(ABS_CNT)];
14  unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)];
15  unsigned long ledbit[BITS_TO_LONGS(LED_CNT)];
16  unsigned long sndbit[BITS_TO_LONGS(SND_CNT)];
17  unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
18  unsigned long swbit[BITS_TO_LONGS(SW_CNT)];
19  unsigned int hint_events_per_packet;
20  unsigned int keycodemax;
21  unsigned int keycodesize;
22  void * keycode;
23  int (* setkeycode) (struct input_dev *dev,const struct input_keymap_entry *ke,unsigned int *old_keycode);
24  int (* getkeycode) (struct input_dev *dev,struct input_keymap_entry *ke);
25  struct ff_device * ff;
26  unsigned int repeat_key;
27  struct timer_list timer;
28  int rep[REP_CNT];
29  struct input_mt * mt;
30  struct input_absinfo * absinfo;
31  unsigned long key[BITS_TO_LONGS(KEY_CNT)];
32  unsigned long led[BITS_TO_LONGS(LED_CNT)];
33  unsigned long snd[BITS_TO_LONGS(SND_CNT)];
34  unsigned long sw[BITS_TO_LONGS(SW_CNT)];
35  int (* open) (struct input_dev *dev);
36  void (* close) (struct input_dev *dev);
37  int (* flush) (struct input_dev *dev, struct file *file);
38  int (* event) (struct input_dev *dev, unsigned int type, unsigned int code, int value);
39  struct input_handle __rcu * grab;
40  spinlock_t event_lock;
41  struct mutex mutex;
42  unsigned int users;
43  bool going_away;
44  struct device dev;
45  struct list_head h_list;
46  struct list_head node;
47  unsigned int num_vals;
48  unsigned int max_vals;
49  struct input_value * vals;
50  bool devres_managed;
51};  </pre></div><div class="refsect1"><a name="idp1114180812"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">name</span></dt><dd><p>
52   name of the device
53      </p></dd><dt><span class="term">phys</span></dt><dd><p>
54   physical path to the device in the system hierarchy
55      </p></dd><dt><span class="term">uniq</span></dt><dd><p>
56   unique identification code for the device (if device has it)
57      </p></dd><dt><span class="term">id</span></dt><dd><p>
58   id of the device (struct input_id)
59      </p></dd><dt><span class="term">propbit[BITS_TO_LONGS(INPUT_PROP_CNT)]</span></dt><dd><p>
60   bitmap of device properties and quirks
61      </p></dd><dt><span class="term">evbit[BITS_TO_LONGS(EV_CNT)]</span></dt><dd><p>
62   bitmap of types of events supported by the device (EV_KEY,
63   EV_REL, etc.)
64      </p></dd><dt><span class="term">keybit[BITS_TO_LONGS(KEY_CNT)]</span></dt><dd><p>
65   bitmap of keys/buttons this device has
66      </p></dd><dt><span class="term">relbit[BITS_TO_LONGS(REL_CNT)]</span></dt><dd><p>
67   bitmap of relative axes for the device
68      </p></dd><dt><span class="term">absbit[BITS_TO_LONGS(ABS_CNT)]</span></dt><dd><p>
69   bitmap of absolute axes for the device
70      </p></dd><dt><span class="term">mscbit[BITS_TO_LONGS(MSC_CNT)]</span></dt><dd><p>
71   bitmap of miscellaneous events supported by the device
72      </p></dd><dt><span class="term">ledbit[BITS_TO_LONGS(LED_CNT)]</span></dt><dd><p>
73   bitmap of leds present on the device
74      </p></dd><dt><span class="term">sndbit[BITS_TO_LONGS(SND_CNT)]</span></dt><dd><p>
75   bitmap of sound effects supported by the device
76      </p></dd><dt><span class="term">ffbit[BITS_TO_LONGS(FF_CNT)]</span></dt><dd><p>
77   bitmap of force feedback effects supported by the device
78      </p></dd><dt><span class="term">swbit[BITS_TO_LONGS(SW_CNT)]</span></dt><dd><p>
79   bitmap of switches present on the device
80      </p></dd><dt><span class="term">hint_events_per_packet</span></dt><dd><p>
81   average number of events generated by the
82   device in a packet (between EV_SYN/SYN_REPORT events). Used by
83   event handlers to estimate size of the buffer needed to hold
84   events.
85      </p></dd><dt><span class="term">keycodemax</span></dt><dd><p>
86   size of keycode table
87      </p></dd><dt><span class="term">keycodesize</span></dt><dd><p>
88   size of elements in keycode table
89      </p></dd><dt><span class="term">keycode</span></dt><dd><p>
90   map of scancodes to keycodes for this device
91      </p></dd><dt><span class="term">setkeycode</span></dt><dd><p>
92   optional method to alter current keymap, used to implement
93   sparse keymaps. If not supplied default mechanism will be used.
94   The method is being called while holding event_lock and thus must
95   not sleep
96      </p></dd><dt><span class="term">getkeycode</span></dt><dd><p>
97   optional legacy method to retrieve current keymap.
98      </p></dd><dt><span class="term">ff</span></dt><dd><p>
99   force feedback structure associated with the device if device
100   supports force feedback effects
101      </p></dd><dt><span class="term">repeat_key</span></dt><dd><p>
102   stores key code of the last key pressed; used to implement
103   software autorepeat
104      </p></dd><dt><span class="term">timer</span></dt><dd><p>
105   timer for software autorepeat
106      </p></dd><dt><span class="term">rep[REP_CNT]</span></dt><dd><p>
107   current values for autorepeat parameters (delay, rate)
108      </p></dd><dt><span class="term">mt</span></dt><dd><p>
109   pointer to multitouch state
110      </p></dd><dt><span class="term">absinfo</span></dt><dd><p>
111   array of <span class="structname">struct input_absinfo</span> elements holding information
112   about absolute axes (current value, min, max, flat, fuzz,
113   resolution)
114      </p></dd><dt><span class="term">key[BITS_TO_LONGS(KEY_CNT)]</span></dt><dd><p>
115   reflects current state of device's keys/buttons
116      </p></dd><dt><span class="term">led[BITS_TO_LONGS(LED_CNT)]</span></dt><dd><p>
117   reflects current state of device's LEDs
118      </p></dd><dt><span class="term">snd[BITS_TO_LONGS(SND_CNT)]</span></dt><dd><p>
119   reflects current state of sound effects
120      </p></dd><dt><span class="term">sw[BITS_TO_LONGS(SW_CNT)]</span></dt><dd><p>
121   reflects current state of device's switches
122      </p></dd><dt><span class="term">open</span></dt><dd><p>
123   this method is called when the very first user calls
124   <code class="function">input_open_device</code>. The driver must prepare the device
125   to start generating events (start polling thread,
126   request an IRQ, submit URB, etc.)
127      </p></dd><dt><span class="term">close</span></dt><dd><p>
128   this method is called when the very last user calls
129   <code class="function">input_close_device</code>.
130      </p></dd><dt><span class="term">flush</span></dt><dd><p>
131   purges the device. Most commonly used to get rid of force
132   feedback effects loaded into the device when disconnecting
133   from it
134      </p></dd><dt><span class="term">event</span></dt><dd><p>
135   event handler for events sent _to_ the device, like EV_LED
136   or EV_SND. The device is expected to carry out the requested
137   action (turn on a LED, play sound, etc.) The call is protected
138   by <em class="parameter"><code>event_lock</code></em> and must not sleep
139      </p></dd><dt><span class="term">grab</span></dt><dd><p>
140   input handle that currently has the device grabbed (via
141   EVIOCGRAB ioctl). When a handle grabs a device it becomes sole
142   recipient for all input events coming from the device
143      </p></dd><dt><span class="term">event_lock</span></dt><dd><p>
144   this spinlock is is taken when input core receives
145   and processes a new event for the device (in <code class="function">input_event</code>).
146   Code that accesses and/or modifies parameters of a device
147   (such as keymap or absmin, absmax, absfuzz, etc.) after device
148   has been registered with input core must take this lock.
149      </p></dd><dt><span class="term">mutex</span></dt><dd><p>
150   serializes calls to <code class="function">open</code>, <code class="function">close</code> and <code class="function">flush</code> methods
151      </p></dd><dt><span class="term">users</span></dt><dd><p>
152   stores number of users (input handlers) that opened this
153   device. It is used by <code class="function">input_open_device</code> and <code class="function">input_close_device</code>
154   to make sure that dev-&gt;<code class="function">open</code> is only called when the first
155   user opens device and dev-&gt;<code class="function">close</code> is called when the very
156   last user closes the device
157      </p></dd><dt><span class="term">going_away</span></dt><dd><p>
158   marks devices that are in a middle of unregistering and
159   causes input_open_device*() fail with -ENODEV.
160      </p></dd><dt><span class="term">dev</span></dt><dd><p>
161   driver model's view of this device
162      </p></dd><dt><span class="term">h_list</span></dt><dd><p>
163   list of input handles associated with the device. When
164   accessing the list dev-&gt;mutex must be held
165      </p></dd><dt><span class="term">node</span></dt><dd><p>
166   used to place the device onto input_dev_list
167      </p></dd><dt><span class="term">num_vals</span></dt><dd><p>
168   number of values queued in the current frame
169      </p></dd><dt><span class="term">max_vals</span></dt><dd><p>
170   maximum number of values queued in a frame
171      </p></dd><dt><span class="term">vals</span></dt><dd><p>
172   array of values queued in the current frame
173      </p></dd><dt><span class="term">devres_managed</span></dt><dd><p>
174   indicates that devices is managed with devres framework
175   and needs not be explicitly unregistered or freed.
176      </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="API-struct-input-value.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="input_subsystem.html#idp1114168316">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-struct-input-handler.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">struct input_value</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">struct input_handler</span></td></tr></table></div></body></html>
177