diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-04-15 18:16:50 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-04-17 23:19:34 -0400 |
commit | ad6493800b08791bd7ea1a578b8c8b14dfecec0d (patch) | |
tree | 2b3bdd8fc77a71e8796eee7b68624aa632ac4bfe | |
parent | b08c118cde9dfd92f1f3c90544a682ee8b2ea740 (diff) |
Input: docs - freshen up introduction
Stop saying that API is experimental and that only USB is supported,
acknowledge that evdev is the preferred interface, and remove paragraph
encouraging people sending snail mail to Vojtech :) along with his email.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | Documentation/input/event-codes.rst | 2 | ||||
-rw-r--r-- | Documentation/input/input.rst | 253 | ||||
-rw-r--r-- | Documentation/input/joydev/joystick-api.rst | 2 | ||||
-rw-r--r-- | Documentation/input/joydev/joystick.rst | 2 |
4 files changed, 127 insertions, 132 deletions
diff --git a/Documentation/input/event-codes.rst b/Documentation/input/event-codes.rst index 92db50954169..00b88f113bda 100644 --- a/Documentation/input/event-codes.rst +++ b/Documentation/input/event-codes.rst | |||
@@ -1,3 +1,5 @@ | |||
1 | .. _input-event-codes: | ||
2 | |||
1 | ================= | 3 | ================= |
2 | Input event codes | 4 | Input event codes |
3 | ================= | 5 | ================= |
diff --git a/Documentation/input/input.rst b/Documentation/input/input.rst index ac7669ad3e76..3b3a22975106 100644 --- a/Documentation/input/input.rst +++ b/Documentation/input/input.rst | |||
@@ -1,25 +1,20 @@ | |||
1 | .. include:: <isonum.txt> | 1 | .. include:: <isonum.txt> |
2 | 2 | ||
3 | =================== | 3 | ============ |
4 | Linux Input drivers | 4 | Introduction |
5 | =================== | 5 | ============ |
6 | 6 | ||
7 | :Copyright: |copy| 1999-2001 Vojtech Pavlik <vojtech@ucw.cz> - Sponsored by SuSE | 7 | :Copyright: |copy| 1999-2001 Vojtech Pavlik <vojtech@ucw.cz> - Sponsored by SuSE |
8 | 8 | ||
9 | Should you need to contact me, the author, you can do so either by e-mail | 9 | Architecture |
10 | - mail your message to <vojtech@ucw.cz>, or by paper mail: Vojtech Pavlik, | ||
11 | Simunkova 1594, Prague 8, 182 00 Czech Republic | ||
12 | |||
13 | Introduction | ||
14 | ============ | 10 | ============ |
15 | 11 | ||
16 | This is a collection of drivers that is designed to support all input | 12 | Input subsystem a collection of drivers that is designed to support |
17 | devices under Linux. While it is currently used only on for USB input | 13 | all input devices under Linux. Most of the drivers reside in |
18 | devices, future use (say 2.5/2.6) is expected to expand to replace | 14 | drivers/input, although quite a few live in drivers/hid and |
19 | most of the existing input system, which is why it lives in | 15 | drivers/platform. |
20 | drivers/input/ instead of drivers/usb/. | ||
21 | 16 | ||
22 | The centre of the input drivers is the input module, which must be | 17 | The core of the input subsystem is the input module, which must be |
23 | loaded before any other of the input modules - it serves as a way of | 18 | loaded before any other of the input modules - it serves as a way of |
24 | communication between two groups of modules: | 19 | communication between two groups of modules: |
25 | 20 | ||
@@ -32,9 +27,9 @@ events (keystrokes, mouse movements) to the input module. | |||
32 | Event handlers | 27 | Event handlers |
33 | -------------- | 28 | -------------- |
34 | 29 | ||
35 | These modules get events from input and pass them where needed via | 30 | These modules get events from input core and pass them where needed |
36 | various interfaces - keystrokes to the kernel, mouse movements via a | 31 | via various interfaces - keystrokes to the kernel, mouse movements via |
37 | simulated PS/2 interface to GPM and X and so on. | 32 | a simulated PS/2 interface to GPM and X, and so on. |
38 | 33 | ||
39 | Simple Usage | 34 | Simple Usage |
40 | ============ | 35 | ============ |
@@ -45,19 +40,18 @@ kernel):: | |||
45 | 40 | ||
46 | input | 41 | input |
47 | mousedev | 42 | mousedev |
48 | keybdev | ||
49 | usbcore | 43 | usbcore |
50 | uhci_hcd or ohci_hcd or ehci_hcd | 44 | uhci_hcd or ohci_hcd or ehci_hcd |
51 | usbhid | 45 | usbhid |
46 | hid_generic | ||
52 | 47 | ||
53 | After this, the USB keyboard will work straight away, and the USB mouse | 48 | After this, the USB keyboard will work straight away, and the USB mouse |
54 | will be available as a character device on major 13, minor 63:: | 49 | will be available as a character device on major 13, minor 63:: |
55 | 50 | ||
56 | crw-r--r-- 1 root root 13, 63 Mar 28 22:45 mice | 51 | crw-r--r-- 1 root root 13, 63 Mar 28 22:45 mice |
57 | 52 | ||
58 | This device has to be created. | 53 | This device usually created automatically by the system. The commands |
59 | 54 | to create it by hand are:: | |
60 | The commands to create it by hand are:: | ||
61 | 55 | ||
62 | cd /dev | 56 | cd /dev |
63 | mkdir input | 57 | mkdir input |
@@ -81,100 +75,50 @@ When you do all of the above, you can use your USB mouse and keyboard. | |||
81 | Detailed Description | 75 | Detailed Description |
82 | ==================== | 76 | ==================== |
83 | 77 | ||
84 | Device drivers | 78 | Event handlers |
85 | -------------- | 79 | -------------- |
86 | 80 | ||
87 | Device drivers are the modules that generate events. The events are | 81 | Event handlers distribute the events from the devices to userspace and |
88 | however not useful without being handled, so you also will need to use some | 82 | in-kernel consumers, as needed. |
89 | of the modules from section 3.2. | ||
90 | |||
91 | usbhid | ||
92 | ~~~~~~ | ||
93 | |||
94 | usbhid is the largest and most complex driver of the whole suite. It | ||
95 | handles all HID devices, and because there is a very wide variety of them, | ||
96 | and because the USB HID specification isn't simple, it needs to be this big. | ||
97 | |||
98 | Currently, it handles USB mice, joysticks, gamepads, steering wheels | ||
99 | keyboards, trackballs and digitizers. | ||
100 | |||
101 | However, USB uses HID also for monitor controls, speaker controls, UPSs, | ||
102 | LCDs and many other purposes. | ||
103 | |||
104 | The monitor and speaker controls should be easy to add to the hid/input | ||
105 | interface, but for the UPSs and LCDs it doesn't make much sense. For this, | ||
106 | the hiddev interface was designed. See Documentation/hid/hiddev.txt | ||
107 | for more information about it. | ||
108 | |||
109 | The usage of the usbhid module is very simple, it takes no parameters, | ||
110 | detects everything automatically and when a HID device is inserted, it | ||
111 | detects it appropriately. | ||
112 | |||
113 | However, because the devices vary wildly, you might happen to have a | ||
114 | device that doesn't work well. In that case #define DEBUG at the beginning | ||
115 | of hid-core.c and send me the syslog traces. | ||
116 | 83 | ||
117 | usbmouse | 84 | evdev |
118 | ~~~~~~~~ | ||
119 | |||
120 | For embedded systems, for mice with broken HID descriptors and just any | ||
121 | other use when the big usbhid wouldn't be a good choice, there is the | ||
122 | usbmouse driver. It handles USB mice only. It uses a simpler HIDBP | ||
123 | protocol. This also means the mice must support this simpler protocol. Not | ||
124 | all do. If you don't have any strong reason to use this module, use usbhid | ||
125 | instead. | ||
126 | |||
127 | usbkbd | ||
128 | ~~~~~~ | ||
129 | |||
130 | Much like usbmouse, this module talks to keyboards with a simplified | ||
131 | HIDBP protocol. It's smaller, but doesn't support any extra special keys. | ||
132 | Use usbhid instead if there isn't any special reason to use this. | ||
133 | |||
134 | wacom | ||
135 | ~~~~~ | 85 | ~~~~~ |
136 | 86 | ||
137 | This is a driver for Wacom Graphire and Intuos tablets. Not for Wacom | 87 | ``evdev`` is the generic input event interface. It passes the events |
138 | PenPartner, that one is handled by the HID driver. Although the Intuos and | 88 | generated in the kernel straight to the program, with timestamps. The |
139 | Graphire tablets claim that they are HID tablets as well, they are not and | 89 | event codes are the same on all architectures and are hardware |
140 | thus need this specific driver. | 90 | independent. |
141 | 91 | ||
142 | iforce | 92 | This is the preferred interface for userspace to consume user |
143 | ~~~~~~ | 93 | input, and all clients are encouraged to use it. |
144 | 94 | ||
145 | A driver for I-Force joysticks and wheels, both over USB and RS232. | 95 | See :ref:`event-interface` for notes on API. |
146 | It includes ForceFeedback support now, even though Immersion | ||
147 | Corp. considers the protocol a trade secret and won't disclose a word | ||
148 | about it. | ||
149 | 96 | ||
150 | Event handlers | 97 | The devices are in /dev/input:: |
151 | -------------- | ||
152 | 98 | ||
153 | Event handlers distribute the events from the devices to userland and | 99 | crw-r--r-- 1 root root 13, 64 Apr 1 10:49 event0 |
154 | kernel, as needed. | 100 | crw-r--r-- 1 root root 13, 65 Apr 1 10:50 event1 |
101 | crw-r--r-- 1 root root 13, 66 Apr 1 10:50 event2 | ||
102 | crw-r--r-- 1 root root 13, 67 Apr 1 10:50 event3 | ||
103 | ... | ||
155 | 104 | ||
156 | keybdev | 105 | There are two ranges of minors: 64 through 95 is the static legacy |
157 | ~~~~~~~ | 106 | range. If there are more than 32 input devices in a system, additional |
107 | evdev nodes are created with minors starting with 256. | ||
158 | 108 | ||
159 | keybdev is currently a rather ugly hack that translates the input | 109 | keyboard |
160 | events into architecture-specific keyboard raw mode (Xlated AT Set2 on | 110 | ~~~~~~~~ |
161 | x86), and passes them into the handle_scancode function of the | ||
162 | keyboard.c module. This works well enough on all architectures that | ||
163 | keybdev can generate rawmode on, other architectures can be added to | ||
164 | it. | ||
165 | 111 | ||
166 | The right way would be to pass the events to keyboard.c directly, | 112 | ``keyboard`` is in-kernel input handler ad is a part of VT code. It |
167 | best if keyboard.c would itself be an event handler. This is done in | 113 | consumes keyboard keystrokes and handles user input for VT consoles. |
168 | the input patch, available on the webpage mentioned below. | ||
169 | 114 | ||
170 | mousedev | 115 | mousedev |
171 | ~~~~~~~~ | 116 | ~~~~~~~~ |
172 | 117 | ||
173 | mousedev is also a hack to make programs that use mouse input | 118 | ``mousedev`` is a hack to make legacy programs that use mouse input |
174 | work. It takes events from either mice or digitizers/tablets and makes | 119 | work. It takes events from either mice or digitizers/tablets and makes |
175 | a PS/2-style (a la /dev/psaux) mouse device available to the | 120 | a PS/2-style (a la /dev/psaux) mouse device available to the |
176 | userland. Ideally, the programs could use a more reasonable interface, | 121 | userland. |
177 | for example evdev | ||
178 | 122 | ||
179 | Mousedev devices in /dev/input (as shown above) are:: | 123 | Mousedev devices in /dev/input (as shown above) are:: |
180 | 124 | ||
@@ -190,8 +134,9 @@ Mousedev devices in /dev/input (as shown above) are:: | |||
190 | Each ``mouse`` device is assigned to a single mouse or digitizer, except | 134 | Each ``mouse`` device is assigned to a single mouse or digitizer, except |
191 | the last one - ``mice``. This single character device is shared by all | 135 | the last one - ``mice``. This single character device is shared by all |
192 | mice and digitizers, and even if none are connected, the device is | 136 | mice and digitizers, and even if none are connected, the device is |
193 | present. This is useful for hotplugging USB mice, so that programs | 137 | present. This is useful for hotplugging USB mice, so that older programs |
194 | can open the device even when no mice are present. | 138 | that do not handle hotplug can open the device even when no mice are |
139 | present. | ||
195 | 140 | ||
196 | CONFIG_INPUT_MOUSEDEV_SCREEN_[XY] in the kernel configuration are | 141 | CONFIG_INPUT_MOUSEDEV_SCREEN_[XY] in the kernel configuration are |
197 | the size of your screen (in pixels) in XFree86. This is needed if you | 142 | the size of your screen (in pixels) in XFree86. This is needed if you |
@@ -208,11 +153,10 @@ mouse and ExplorerPS/2 if you want to use extra (up to 5) buttons. | |||
208 | joydev | 153 | joydev |
209 | ~~~~~~ | 154 | ~~~~~~ |
210 | 155 | ||
211 | Joydev implements v0.x and v1.x Linux joystick api, much like | 156 | ``joydev`` implements v0.x and v1.x Linux joystick API. See |
212 | drivers/char/joystick/joystick.c used to in earlier versions. See | 157 | :ref:`joystick-api` for details. |
213 | joystick-api.txt in the Documentation subdirectory for details. As | 158 | |
214 | soon as any joystick is connected, it can be accessed in /dev/input | 159 | As soon as any joystick is connected, it can be accessed in /dev/input on:: |
215 | on:: | ||
216 | 160 | ||
217 | crw-r--r-- 1 root root 13, 0 Apr 1 10:50 js0 | 161 | crw-r--r-- 1 root root 13, 0 Apr 1 10:50 js0 |
218 | crw-r--r-- 1 root root 13, 1 Apr 1 10:50 js1 | 162 | crw-r--r-- 1 root root 13, 1 Apr 1 10:50 js1 |
@@ -220,56 +164,99 @@ on:: | |||
220 | crw-r--r-- 1 root root 13, 3 Apr 1 10:50 js3 | 164 | crw-r--r-- 1 root root 13, 3 Apr 1 10:50 js3 |
221 | ... | 165 | ... |
222 | 166 | ||
223 | And so on up to js31. | 167 | And so on up to js31 in legacy range, and additional nodes with minors |
168 | above 256 if there are more joystick devices. | ||
224 | 169 | ||
225 | evdev | 170 | Device drivers |
226 | ~~~~~ | 171 | -------------- |
227 | 172 | ||
228 | evdev is the generic input event interface. It passes the events | 173 | Device drivers are the modules that generate events. |
229 | generated in the kernel straight to the program, with timestamps. The | ||
230 | API is still evolving, but should be usable now. It's described in | ||
231 | section 5. | ||
232 | 174 | ||
233 | This should be the way for GPM and X to get keyboard and mouse | 175 | hid-generic |
234 | events. It allows for multihead in X without any specific multihead | 176 | ~~~~~~~~~~~ |
235 | kernel support. The event codes are the same on all architectures and | ||
236 | are hardware independent. | ||
237 | 177 | ||
238 | The devices are in /dev/input:: | 178 | ``hid-generic`` is one of the largest and most complex driver of the |
179 | whole suite. It handles all HID devices, and because there is a very | ||
180 | wide variety of them, and because the USB HID specification isn't | ||
181 | simple, it needs to be this big. | ||
239 | 182 | ||
240 | crw-r--r-- 1 root root 13, 64 Apr 1 10:49 event0 | 183 | Currently, it handles USB mice, joysticks, gamepads, steering wheels |
241 | crw-r--r-- 1 root root 13, 65 Apr 1 10:50 event1 | 184 | keyboards, trackballs and digitizers. |
242 | crw-r--r-- 1 root root 13, 66 Apr 1 10:50 event2 | 185 | |
243 | crw-r--r-- 1 root root 13, 67 Apr 1 10:50 event3 | 186 | However, USB uses HID also for monitor controls, speaker controls, UPSs, |
244 | ... | 187 | LCDs and many other purposes. |
188 | |||
189 | The monitor and speaker controls should be easy to add to the hid/input | ||
190 | interface, but for the UPSs and LCDs it doesn't make much sense. For this, | ||
191 | the hiddev interface was designed. See Documentation/hid/hiddev.txt | ||
192 | for more information about it. | ||
193 | |||
194 | The usage of the usbhid module is very simple, it takes no parameters, | ||
195 | detects everything automatically and when a HID device is inserted, it | ||
196 | detects it appropriately. | ||
245 | 197 | ||
246 | And so on up to event31. | 198 | However, because the devices vary wildly, you might happen to have a |
199 | device that doesn't work well. In that case #define DEBUG at the beginning | ||
200 | of hid-core.c and send me the syslog traces. | ||
201 | |||
202 | usbmouse | ||
203 | ~~~~~~~~ | ||
204 | |||
205 | For embedded systems, for mice with broken HID descriptors and just any | ||
206 | other use when the big usbhid wouldn't be a good choice, there is the | ||
207 | usbmouse driver. It handles USB mice only. It uses a simpler HIDBP | ||
208 | protocol. This also means the mice must support this simpler protocol. Not | ||
209 | all do. If you don't have any strong reason to use this module, use usbhid | ||
210 | instead. | ||
211 | |||
212 | usbkbd | ||
213 | ~~~~~~ | ||
214 | |||
215 | Much like usbmouse, this module talks to keyboards with a simplified | ||
216 | HIDBP protocol. It's smaller, but doesn't support any extra special keys. | ||
217 | Use usbhid instead if there isn't any special reason to use this. | ||
218 | |||
219 | psmouse | ||
220 | ~~~~~~~ | ||
221 | |||
222 | This is driver for all flavors of pointing devices using PS/2 | ||
223 | protocol, including Synaptics and ALPS touchpads, Intellimouse | ||
224 | Explorer devices, Logitech PS/2 mice and so on. | ||
225 | |||
226 | atkbd | ||
227 | ~~~~~ | ||
228 | |||
229 | This is driver for PS/2 (AT) keyboards. | ||
230 | |||
231 | iforce | ||
232 | ~~~~~~ | ||
233 | |||
234 | A driver for I-Force joysticks and wheels, both over USB and RS232. | ||
235 | It includes Force Feedback support now, even though Immersion | ||
236 | Corp. considers the protocol a trade secret and won't disclose a word | ||
237 | about it. | ||
247 | 238 | ||
248 | Verifying if it works | 239 | Verifying if it works |
249 | ===================== | 240 | ===================== |
250 | 241 | ||
251 | Typing a couple keys on the keyboard should be enough to check that | 242 | Typing a couple keys on the keyboard should be enough to check that |
252 | a USB keyboard works and is correctly connected to the kernel keyboard | 243 | a keyboard works and is correctly connected to the kernel keyboard |
253 | driver. | 244 | driver. |
254 | 245 | ||
255 | Doing a ``cat /dev/input/mouse0`` (c, 13, 32) will verify that a mouse | 246 | Doing a ``cat /dev/input/mouse0`` (c, 13, 32) will verify that a mouse |
256 | is also emulated; characters should appear if you move it. | 247 | is also emulated; characters should appear if you move it. |
257 | 248 | ||
258 | You can test the joystick emulation with the ``jstest`` utility, | 249 | You can test the joystick emulation with the ``jstest`` utility, |
259 | available in the joystick package (see Documentation/input/joystick.txt). | 250 | available in the joystick package (see :ref:`joystick-doc`). |
260 | 251 | ||
261 | You can test the event devices with the ``evtest`` utility available | 252 | You can test the event devices with the ``evtest`` utility. |
262 | in the LinuxConsole project CVS archive (see the URL below). | 253 | |
254 | .. _event-interface: | ||
263 | 255 | ||
264 | Event interface | 256 | Event interface |
265 | =============== | 257 | =============== |
266 | 258 | ||
267 | Should you want to add event device support into any application (X, gpm, | 259 | You can use blocking and nonblocking reads, and also select() on the |
268 | svgalib ...) I <vojtech@ucw.cz> will be happy to provide you any help I | ||
269 | can. Here goes a description of the current state of things, which is going | ||
270 | to be extended, but not changed incompatibly as time goes: | ||
271 | |||
272 | You can use blocking and nonblocking reads, also select() on the | ||
273 | /dev/input/eventX devices, and you'll always get a whole number of input | 260 | /dev/input/eventX devices, and you'll always get a whole number of input |
274 | events on a read. Their layout is:: | 261 | events on a read. Their layout is:: |
275 | 262 | ||
@@ -290,3 +277,5 @@ list is in include/uapi/linux/input-event-codes.h. | |||
290 | ``value`` is the value the event carries. Either a relative change for | 277 | ``value`` is the value the event carries. Either a relative change for |
291 | EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for | 278 | EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for |
292 | release, 1 for keypress and 2 for autorepeat. | 279 | release, 1 for keypress and 2 for autorepeat. |
280 | |||
281 | See :ref:`input-event-codes` for more information about various even codes. | ||
diff --git a/Documentation/input/joydev/joystick-api.rst b/Documentation/input/joydev/joystick-api.rst index 42edcfc6e8af..95803e2e8cd0 100644 --- a/Documentation/input/joydev/joystick-api.rst +++ b/Documentation/input/joydev/joystick-api.rst | |||
@@ -1,3 +1,5 @@ | |||
1 | .. _joystick-api: | ||
2 | |||
1 | ===================== | 3 | ===================== |
2 | Programming Interface | 4 | Programming Interface |
3 | ===================== | 5 | ===================== |
diff --git a/Documentation/input/joydev/joystick.rst b/Documentation/input/joydev/joystick.rst index b90705eb69b1..9746fd76cc58 100644 --- a/Documentation/input/joydev/joystick.rst +++ b/Documentation/input/joydev/joystick.rst | |||
@@ -1,5 +1,7 @@ | |||
1 | .. include:: <isonum.txt> | 1 | .. include:: <isonum.txt> |
2 | 2 | ||
3 | .. _joystick-doc: | ||
4 | |||
3 | Introduction | 5 | Introduction |
4 | ============ | 6 | ============ |
5 | 7 | ||