1STRUCT INPUT_DEV(9) Input Subsystem STRUCT INPUT_DEV(9)
2
3
4
6 struct_input_dev - represents an input device
7
9 struct input_dev {
10 const char * name;
11 const char * phys;
12 const char * uniq;
13 struct input_id id;
14 unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
15 unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
16 unsigned long relbit[BITS_TO_LONGS(REL_CNT)];
17 unsigned long absbit[BITS_TO_LONGS(ABS_CNT)];
18 unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)];
19 unsigned long ledbit[BITS_TO_LONGS(LED_CNT)];
20 unsigned long sndbit[BITS_TO_LONGS(SND_CNT)];
21 unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
22 unsigned long swbit[BITS_TO_LONGS(SW_CNT)];
23 unsigned int keycodemax;
24 unsigned int keycodesize;
25 void * keycode;
26 int (* setkeycode) (struct input_dev *dev,unsigned int scancode, unsigned int keycode);
27 int (* getkeycode) (struct input_dev *dev,unsigned int scancode, unsigned int *keycode);
28 struct ff_device * ff;
29 unsigned int repeat_key;
30 struct timer_list timer;
31 int sync;
32 int abs[ABS_CNT];
33 int rep[REP_MAX + 1];
34 unsigned long key[BITS_TO_LONGS(KEY_CNT)];
35 unsigned long led[BITS_TO_LONGS(LED_CNT)];
36 unsigned long snd[BITS_TO_LONGS(SND_CNT)];
37 unsigned long sw[BITS_TO_LONGS(SW_CNT)];
38 int absmax[ABS_CNT];
39 int absmin[ABS_CNT];
40 int absfuzz[ABS_CNT];
41 int absflat[ABS_CNT];
42 int absres[ABS_CNT];
43 int (* open) (struct input_dev *dev);
44 void (* close) (struct input_dev *dev);
45 int (* flush) (struct input_dev *dev, struct file *file);
46 int (* event) (struct input_dev *dev, unsigned int type, unsigned int code, int value);
47 struct input_handle * grab;
48 spinlock_t event_lock;
49 struct mutex mutex;
50 unsigned int users;
51 bool going_away;
52 struct device dev;
53 struct list_head h_list;
54 struct list_head node;
55 };
56
58 name
59 name of the device
60
61 phys
62 physical path to the device in the system hierarchy
63
64 uniq
65 unique identification code for the device (if device has it)
66
67 id
68 id of the device (struct input_id)
69
70 evbit[BITS_TO_LONGS(EV_CNT)]
71 bitmap of types of events supported by the device (EV_KEY, EV_REL,
72 etc.)
73
74 keybit[BITS_TO_LONGS(KEY_CNT)]
75 bitmap of keys/buttons this device has
76
77 relbit[BITS_TO_LONGS(REL_CNT)]
78 bitmap of relative axes for the device
79
80 absbit[BITS_TO_LONGS(ABS_CNT)]
81 bitmap of absolute axes for the device
82
83 mscbit[BITS_TO_LONGS(MSC_CNT)]
84 bitmap of miscellaneous events supported by the device
85
86 ledbit[BITS_TO_LONGS(LED_CNT)]
87 bitmap of leds present on the device
88
89 sndbit[BITS_TO_LONGS(SND_CNT)]
90 bitmap of sound effects supported by the device
91
92 ffbit[BITS_TO_LONGS(FF_CNT)]
93 bitmap of force feedback effects supported by the device
94
95 swbit[BITS_TO_LONGS(SW_CNT)]
96 bitmap of switches present on the device
97
98 keycodemax
99 size of keycode table
100
101 keycodesize
102 size of elements in keycode table
103
104 keycode
105 map of scancodes to keycodes for this device
106
107 setkeycode
108 optional method to alter current keymap, used to implement sparse
109 keymaps. If not supplied default mechanism will be used. The method
110 is being called while holding event_lock and thus must not sleep
111
112 getkeycode
113 optional method to retrieve current keymap. If not supplied default
114 mechanism will be used. The method is being called while holding
115 event_lock and thus must not sleep
116
117 ff
118 force feedback structure associated with the device if device
119 supports force feedback effects
120
121 repeat_key
122 stores key code of the last key pressed; used to implement software
123 autorepeat
124
125 timer
126 timer for software autorepeat
127
128 sync
129 set to 1 when there were no new events since last EV_SYNC
130
131 abs[ABS_CNT]
132 current values for reports from absolute axes
133
134 rep[REP_MAX + 1]
135 current values for autorepeat parameters (delay, rate)
136
137 key[BITS_TO_LONGS(KEY_CNT)]
138 reflects current state of device's keys/buttons
139
140 led[BITS_TO_LONGS(LED_CNT)]
141 reflects current state of device's LEDs
142
143 snd[BITS_TO_LONGS(SND_CNT)]
144 reflects current state of sound effects
145
146 sw[BITS_TO_LONGS(SW_CNT)]
147 reflects current state of device's switches
148
149 absmax[ABS_CNT]
150 maximum values for events coming from absolute axes
151
152 absmin[ABS_CNT]
153 minimum values for events coming from absolute axes
154
155 absfuzz[ABS_CNT]
156 describes noisiness for axes
157
158 absflat[ABS_CNT]
159 size of the center flat position (used by joydev)
160
161 absres[ABS_CNT]
162 resolution used for events coming form absolute axes
163
164 open
165 this method is called when the very first user calls
166 input_open_device. The driver must prepare the device to start
167 generating events (start polling thread, request an IRQ, submit
168 URB, etc.)
169
170 close
171 this method is called when the very last user calls
172 input_close_device.
173
174 flush
175 purges the device. Most commonly used to get rid of force feedback
176 effects loaded into the device when disconnecting from it
177
178 event
179 event handler for events sent _to_ the device, like EV_LED or
180 EV_SND. The device is expected to carry out the requested action
181 (turn on a LED, play sound, etc.) The call is protected by
182 event_lock and must not sleep
183
184 grab
185 input handle that currently has the device grabbed (via EVIOCGRAB
186 ioctl). When a handle grabs a device it becomes sole recipient for
187 all input events coming from the device
188
189 event_lock
190 this spinlock is is taken when input core receives and processes a
191 new event for the device (in input_event). Code that accesses
192 and/or modifies parameters of a device (such as keymap or absmin,
193 absmax, absfuzz, etc.) after device has been registered with input
194 core must take this lock.
195
196 mutex
197 serializes calls to open, close and flush methods
198
199 users
200 stores number of users (input handlers) that opened this device. It
201 is used by input_open_device and input_close_device to make sure
202 that dev->open is only called when the first user opens device and
203 dev->close is called when the very last user closes the device
204
205 going_away
206 marks devices that are in a middle of unregistering and causes
207 input_open_device*() fail with -ENODEV.
208
209 dev
210 driver model's view of this device
211
212 h_list
213 list of input handles associated with the device. When accessing
214 the list dev->mutex must be held
215
216 node
217 used to place the device onto input_dev_list
218
220Kernel Hackers Manual 2.6. November 2011 STRUCT INPUT_DEV(9)