^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. include:: <isonum.txt>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) Introduction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) :Copyright: |copy| 1999-2001 Vojtech Pavlik <vojtech@ucw.cz> - Sponsored by SuSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) Architecture
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) Input subsystem a collection of drivers that is designed to support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) all input devices under Linux. Most of the drivers reside in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) drivers/input, although quite a few live in drivers/hid and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) drivers/platform.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) The core of the input subsystem is the input module, which must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) loaded before any other of the input modules - it serves as a way of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) communication between two groups of modules:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) Device drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) These modules talk to the hardware (for example via USB), and provide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) events (keystrokes, mouse movements) to the input module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) Event handlers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) These modules get events from input core and pass them where needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) via various interfaces - keystrokes to the kernel, mouse movements via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) a simulated PS/2 interface to GPM and X, and so on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) Simple Usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) For the most usual configuration, with one USB mouse and one USB keyboard,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) you'll have to load the following modules (or have them built in to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) kernel)::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) mousedev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) usbcore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) uhci_hcd or ohci_hcd or ehci_hcd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) usbhid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) hid_generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) After this, the USB keyboard will work straight away, and the USB mouse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) will be available as a character device on major 13, minor 63::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) crw-r--r-- 1 root root 13, 63 Mar 28 22:45 mice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) This device usually created automatically by the system. The commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) to create it by hand are::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) cd /dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) mkdir input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) mknod input/mice c 13 63
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) After that you have to point GPM (the textmode mouse cut&paste tool) and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) XFree to this device to use it - GPM should be called like::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) gpm -t ps2 -m /dev/input/mice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) And in X::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) Section "Pointer"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) Protocol "ImPS/2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) Device "/dev/input/mice"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) ZAxisMapping 4 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) EndSection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) When you do all of the above, you can use your USB mouse and keyboard.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) Detailed Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) Event handlers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) Event handlers distribute the events from the devices to userspace and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) in-kernel consumers, as needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) evdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) ~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ``evdev`` is the generic input event interface. It passes the events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) generated in the kernel straight to the program, with timestamps. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) event codes are the same on all architectures and are hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) independent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) This is the preferred interface for userspace to consume user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) input, and all clients are encouraged to use it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) See :ref:`event-interface` for notes on API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) The devices are in /dev/input::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) crw-r--r-- 1 root root 13, 64 Apr 1 10:49 event0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) crw-r--r-- 1 root root 13, 65 Apr 1 10:50 event1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) crw-r--r-- 1 root root 13, 66 Apr 1 10:50 event2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) crw-r--r-- 1 root root 13, 67 Apr 1 10:50 event3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) There are two ranges of minors: 64 through 95 is the static legacy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) range. If there are more than 32 input devices in a system, additional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) evdev nodes are created with minors starting with 256.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) keyboard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) ``keyboard`` is in-kernel input handler and is a part of VT code. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) consumes keyboard keystrokes and handles user input for VT consoles.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) mousedev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) ~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) ``mousedev`` is a hack to make legacy programs that use mouse input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) work. It takes events from either mice or digitizers/tablets and makes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) a PS/2-style (a la /dev/psaux) mouse device available to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) userland.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) Mousedev devices in /dev/input (as shown above) are::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) crw-r--r-- 1 root root 13, 32 Mar 28 22:45 mouse0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) crw-r--r-- 1 root root 13, 33 Mar 29 00:41 mouse1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) crw-r--r-- 1 root root 13, 34 Mar 29 00:41 mouse2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) crw-r--r-- 1 root root 13, 35 Apr 1 10:50 mouse3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) crw-r--r-- 1 root root 13, 62 Apr 1 10:50 mouse30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) crw-r--r-- 1 root root 13, 63 Apr 1 10:50 mice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) Each ``mouse`` device is assigned to a single mouse or digitizer, except
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) the last one - ``mice``. This single character device is shared by all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) mice and digitizers, and even if none are connected, the device is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) present. This is useful for hotplugging USB mice, so that older programs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) that do not handle hotplug can open the device even when no mice are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) present.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) CONFIG_INPUT_MOUSEDEV_SCREEN_[XY] in the kernel configuration are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) the size of your screen (in pixels) in XFree86. This is needed if you
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) want to use your digitizer in X, because its movement is sent to X
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) via a virtual PS/2 mouse and thus needs to be scaled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) accordingly. These values won't be used if you use a mouse only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) Mousedev will generate either PS/2, ImPS/2 (Microsoft IntelliMouse) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ExplorerPS/2 (IntelliMouse Explorer) protocols, depending on what the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) program reading the data wishes. You can set GPM and X to any of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) these. You'll need ImPS/2 if you want to make use of a wheel on a USB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) mouse and ExplorerPS/2 if you want to use extra (up to 5) buttons.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) joydev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) ~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) ``joydev`` implements v0.x and v1.x Linux joystick API. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) :ref:`joystick-api` for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) As soon as any joystick is connected, it can be accessed in /dev/input on::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) crw-r--r-- 1 root root 13, 0 Apr 1 10:50 js0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) crw-r--r-- 1 root root 13, 1 Apr 1 10:50 js1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) crw-r--r-- 1 root root 13, 2 Apr 1 10:50 js2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) crw-r--r-- 1 root root 13, 3 Apr 1 10:50 js3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) And so on up to js31 in legacy range, and additional nodes with minors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) above 256 if there are more joystick devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) Device drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) Device drivers are the modules that generate events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) hid-generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) ~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ``hid-generic`` is one of the largest and most complex driver of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) whole suite. It handles all HID devices, and because there is a very
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) wide variety of them, and because the USB HID specification isn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) simple, it needs to be this big.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) Currently, it handles USB mice, joysticks, gamepads, steering wheels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) keyboards, trackballs and digitizers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) However, USB uses HID also for monitor controls, speaker controls, UPSs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) LCDs and many other purposes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) The monitor and speaker controls should be easy to add to the hid/input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) interface, but for the UPSs and LCDs it doesn't make much sense. For this,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) the hiddev interface was designed. See Documentation/hid/hiddev.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) for more information about it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) The usage of the usbhid module is very simple, it takes no parameters,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) detects everything automatically and when a HID device is inserted, it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) detects it appropriately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) However, because the devices vary wildly, you might happen to have a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) device that doesn't work well. In that case #define DEBUG at the beginning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) of hid-core.c and send me the syslog traces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) usbmouse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) ~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) For embedded systems, for mice with broken HID descriptors and just any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) other use when the big usbhid wouldn't be a good choice, there is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) usbmouse driver. It handles USB mice only. It uses a simpler HIDBP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) protocol. This also means the mice must support this simpler protocol. Not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) all do. If you don't have any strong reason to use this module, use usbhid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) usbkbd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) ~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) Much like usbmouse, this module talks to keyboards with a simplified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) HIDBP protocol. It's smaller, but doesn't support any extra special keys.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) Use usbhid instead if there isn't any special reason to use this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) psmouse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) ~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) This is driver for all flavors of pointing devices using PS/2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) protocol, including Synaptics and ALPS touchpads, Intellimouse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) Explorer devices, Logitech PS/2 mice and so on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) atkbd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) ~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) This is driver for PS/2 (AT) keyboards.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) iforce
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) ~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) A driver for I-Force joysticks and wheels, both over USB and RS232.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) It includes Force Feedback support now, even though Immersion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) Corp. considers the protocol a trade secret and won't disclose a word
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) about it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) Verifying if it works
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) =====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) Typing a couple keys on the keyboard should be enough to check that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) a keyboard works and is correctly connected to the kernel keyboard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) Doing a ``cat /dev/input/mouse0`` (c, 13, 32) will verify that a mouse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) is also emulated; characters should appear if you move it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) You can test the joystick emulation with the ``jstest`` utility,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) available in the joystick package (see :ref:`joystick-doc`).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) You can test the event devices with the ``evtest`` utility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) .. _event-interface:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) Event interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) You can use blocking and nonblocking reads, and also select() on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) /dev/input/eventX devices, and you'll always get a whole number of input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) events on a read. Their layout is::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct input_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct timeval time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) unsigned short type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) unsigned short code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) unsigned int value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) ``time`` is the timestamp, it returns the time at which the event happened.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) Type is for example EV_REL for relative moment, EV_KEY for a keypress or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) release. More types are defined in include/uapi/linux/input-event-codes.h.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) ``code`` is event code, for example REL_X or KEY_BACKSPACE, again a complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) list is in include/uapi/linux/input-event-codes.h.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) ``value`` is the value the event carries. Either a relative change for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) release, 1 for keypress and 2 for autorepeat.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) See :ref:`input-event-codes` for more information about various even codes.