← Documents Documentation/input/input.rst GitHub 원문 ↗

Linux 6.18.37 · Input

Linux Input Subsystem Introduction

Input core, device driver, event handler와 evdev·legacy interface의 구조와 사용법입니다.

Source pathDocumentation/input/input.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

input.rst:1-281

Hardware driver가 input core에 event를 보고하고 evdev, keyboard, mousedev, joydev handler가 kernel과 사용자 공간에 배포하는 구조를 설명하며 주요 driver와 시험 도구, `struct input_event` 형식을 정리합니다.

문서 개요
영역대표 구성요소
Device driver`hid-generic`, `psmouse`, `atkbd`, `iforce`
Core`input` module
Generic userspace`evdev`, `/dev/input/eventX`
Legacy mouse`mousedev`, `/dev/input/mice`
Legacy joystick`joydev`, `/dev/input/jsN`
Event record`struct input_event`

Input subsystem의 생산자, core, consumer와 interface입니다.

Subsystem 전체 경로
Bus driver가 hardware 탐지Input device driver가 capability 등록Input core가 handler와 연결Handler가 device node 또는 kernel consumer 제공Application이 표준 event record 해석

장치 탐지부터 application event 처리까지의 공통 경로입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. include:: <isonum.txt>
2
3 ============
4 Introduction
5 ============
6
7 :Copyright: |copy| 1999-2001 Vojtech Pavlik <[email protected]> - Sponsored by SuSE
8
9 Architecture
10 ============
11
12 Input subsystem is a collection of drivers that is designed to support
13 all input devices under Linux. Most of the drivers reside in
14 drivers/input, although quite a few live in drivers/hid and
15 drivers/platform.
16
17 The core of the input subsystem is the input module, which must be
18 loaded before any other of the input modules - it serves as a way of
19 communication between two groups of modules:
20
21 Device drivers
22 --------------
23
24 These modules talk to the hardware (for example via USB), and provide
25 events (keystrokes, mouse movements) to the input module.
26
27 Event handlers
28 --------------
29
30 These modules get events from input core and pass them where needed
31 via various interfaces - keystrokes to the kernel, mouse movements via
32 a simulated PS/2 interface to GPM and X, and so on.
33
34 Simple Usage
35 ============
36
37 For the most usual configuration, with one USB mouse and one USB keyboard,
38 you'll have to load the following modules (or have them built in to the
39 kernel)::
40
41 input
42 mousedev
43 usbcore
44 uhci_hcd or ohci_hcd or ehci_hcd
45 usbhid
46 hid_generic
47
48 After this, the USB keyboard will work straight away, and the USB mouse
49 will be available as a character device on major 13, minor 63::
50
51 crw-r--r-- 1 root root 13, 63 Mar 28 22:45 mice
52
53 This device is usually created automatically by the system. The commands
54 to create it by hand are::
55
56 cd /dev
57 mkdir input
58 mknod input/mice c 13 63
59
60 After that you have to point GPM (the textmode mouse cut&paste tool) and
61 XFree to this device to use it - GPM should be called like::
62
63 gpm -t ps2 -m /dev/input/mice
64
65 And in X::
66
67 Section "Pointer"
68 Protocol "ImPS/2"
69 Device "/dev/input/mice"
70 ZAxisMapping 4 5
71 EndSection
72
73 When you do all of the above, you can use your USB mouse and keyboard.
74
75 Detailed Description
76 ====================
77
78 Event handlers
79 --------------
80
81 Event handlers distribute the events from the devices to userspace and
82 in-kernel consumers, as needed.
83
84 evdev
85 ~~~~~
86
87 ``evdev`` is the generic input event interface. It passes the events
88 generated in the kernel straight to the program, with timestamps. The
89 event codes are the same on all architectures and are hardware
90 independent.
91
92 This is the preferred interface for userspace to consume user
93 input, and all clients are encouraged to use it.
94
95 See :ref:`event-interface` for notes on API.
96
97 The devices are in /dev/input::
98
99 crw-r--r-- 1 root root 13, 64 Apr 1 10:49 event0
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 ...
104
105 There are two ranges of minors: 64 through 95 is the static legacy
106 range. If there are more than 32 input devices in a system, additional
107 evdev nodes are created with minors starting with 256.
108
109 keyboard
110 ~~~~~~~~
111
112 ``keyboard`` is in-kernel input handler and is a part of VT code. It
113 consumes keyboard keystrokes and handles user input for VT consoles.
114
115 mousedev
116 ~~~~~~~~
117
118 ``mousedev`` is a hack to make legacy programs that use mouse input
119 work. It takes events from either mice or digitizers/tablets and makes
120 a PS/2-style (a la /dev/psaux) mouse device available to the
121 userland.
122
123 Mousedev devices in /dev/input (as shown above) are::
124
125 crw-r--r-- 1 root root 13, 32 Mar 28 22:45 mouse0
126 crw-r--r-- 1 root root 13, 33 Mar 29 00:41 mouse1
127 crw-r--r-- 1 root root 13, 34 Mar 29 00:41 mouse2
128 crw-r--r-- 1 root root 13, 35 Apr 1 10:50 mouse3
129 ...
130 ...
131 crw-r--r-- 1 root root 13, 62 Apr 1 10:50 mouse30
132 crw-r--r-- 1 root root 13, 63 Apr 1 10:50 mice
133
134 Each ``mouse`` device is assigned to a single mouse or digitizer, except
135 the last one - ``mice``. This single character device is shared by all
136 mice and digitizers, and even if none are connected, the device is
137 present. This is useful for hotplugging USB mice, so that older programs
138 that do not handle hotplug can open the device even when no mice are
139 present.
140
141 CONFIG_INPUT_MOUSEDEV_SCREEN_[XY] in the kernel configuration are
142 the size of your screen (in pixels) in XFree86. This is needed if you
143 want to use your digitizer in X, because its movement is sent to X
144 via a virtual PS/2 mouse and thus needs to be scaled
145 accordingly. These values won't be used if you use a mouse only.
146
147 Mousedev will generate either PS/2, ImPS/2 (Microsoft IntelliMouse) or
148 ExplorerPS/2 (IntelliMouse Explorer) protocols, depending on what the
149 program reading the data wishes. You can set GPM and X to any of
150 these. You'll need ImPS/2 if you want to make use of a wheel on a USB
151 mouse and ExplorerPS/2 if you want to use extra (up to 5) buttons.
152
153 joydev
154 ~~~~~~
155
156 ``joydev`` implements v0.x and v1.x Linux joystick API. See
157 :ref:`joystick-api` for details.
158
159 As soon as any joystick is connected, it can be accessed in /dev/input on::
160
161 crw-r--r-- 1 root root 13, 0 Apr 1 10:50 js0
162 crw-r--r-- 1 root root 13, 1 Apr 1 10:50 js1
163 crw-r--r-- 1 root root 13, 2 Apr 1 10:50 js2
164 crw-r--r-- 1 root root 13, 3 Apr 1 10:50 js3
165 ...
166
167 And so on up to js31 in legacy range, and additional nodes with minors
168 above 256 if there are more joystick devices.
169
170 Device drivers
171 --------------
172
173 Device drivers are the modules that generate events.
174
175 hid-generic
176 ~~~~~~~~~~~
177
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.
182
183 Currently, it handles USB mice, joysticks, gamepads, steering wheels,
184 keyboards, trackballs and digitizers.
185
186 However, USB uses HID also for monitor controls, speaker controls, UPSs,
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.rst
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.
197
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.
238
239 Verifying if it works
240 =====================
241
242 Typing a couple keys on the keyboard should be enough to check that
243 a keyboard works and is correctly connected to the kernel keyboard
244 driver.
245
246 Doing a ``cat /dev/input/mouse0`` (c, 13, 32) will verify that a mouse
247 is also emulated; characters should appear if you move it.
248
249 You can test the joystick emulation with the ``jstest`` utility,
250 available in the joystick package (see :ref:`joystick-doc`).
251
252 You can test the event devices with the ``evtest`` utility.
253
254 .. _event-interface:
255
256 Event interface
257 ===============
258
259 You can use blocking and nonblocking reads, and also select() on the
260 /dev/input/eventX devices, and you'll always get a whole number of input
261 events on a read. Their layout is::
262
263 struct input_event {
264 struct timeval time;
265 unsigned short type;
266 unsigned short code;
267 int value;
268 };
269
270 ``time`` is the timestamp, it returns the time at which the event happened.
271 Type is for example EV_REL for relative movement, EV_KEY for a keypress or
272 release. More types are defined in include/uapi/linux/input-event-codes.h.
273
274 ``code`` is event code, for example REL_X or KEY_BACKSPACE, again a complete
275 list is in include/uapi/linux/input-event-codes.h.
276
277 ``value`` is the value the event carries. Either a relative change for
278 EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for
279 release, 1 for keypress and 2 for autorepeat.
280
281 See :ref:`input-event-codes` for more information about various even codes.
282

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Input subsystem 구조

1-33

Linux input subsystem은 모든 입력 장치를 지원하도록 설계된 driver 모음입니다. 대부분은 `drivers/input`에 있지만 상당수는 `drivers/hid`와 `drivers/platform`에도 있습니다.

중심인 `input` module은 다른 input module보다 먼저 load되어야 하며 device driver와 event handler 두 module 그룹 사이의 통신 경로 역할을 합니다.

Device driver는 USB 같은 방식으로 hardware와 통신하고 keystroke나 mouse movement event를 input module에 제공합니다. Event handler는 input core에서 event를 받아 kernel keyboard 처리, GPM과 X를 위한 가상 PS/2 mouse interface 등 필요한 대상으로 전달합니다.

Input subsystem 계층
계층역할
Device driversHardware와 통신하고 event 생성USB keyboard, mouse driver
Input coreDriver와 handler 연결`input` module
Event handlersKernel·userspace interface로 배포keyboard, mousedev, evdev

Hardware event가 consumer에 도달하는 세 계층입니다.

Input event 전달
Hardware가 입력 변화 생성Device driver가 변화 읽기Driver가 input core에 event 보고Core가 matching event handler에 배포Handler가 kernel 또는 userspace interface에 전달

장치에서 handler consumer까지의 기본 경로입니다.

.. include:: <isonum.txt>

============
Introduction
============

:Copyright: |copy| 1999-2001 Vojtech Pavlik <[email protected]> - Sponsored by SuSE

Architecture
============

Input subsystem is a collection of drivers that is designed to support
all input devices under Linux. Most of the drivers reside in
drivers/input, although quite a few live in drivers/hid and
drivers/platform.

The core of the input subsystem is the input module, which must be
loaded before any other of the input modules - it serves as a way of
communication between two groups of modules:

Device drivers
--------------

These modules talk to the hardware (for example via USB), and provide
events (keystrokes, mouse movements) to the input module.

Event handlers
--------------

These modules get events from input core and pass them where needed
via various interfaces - keystrokes to the kernel, mouse movements via
a simulated PS/2 interface to GPM and X, and so on.

USB keyboard와 mouse의 기본 구성

34-74

USB mouse 하나와 USB keyboard 하나인 일반 구성에서는 `input`, `mousedev`, `usbcore`, UHCI·OHCI·EHCI 중 해당 host controller driver, `usbhid`, `hid_generic` module을 load하거나 kernel에 내장해야 합니다.

그러면 USB keyboard는 바로 동작하고 USB mouse는 major 13, minor 63인 `/dev/input/mice` character device로 제공됩니다. 보통 system이 자동 생성하지만 수동으로는 `/dev/input`을 만들고 `mknod input/mice c 13 63`을 실행합니다.

GPM은 `gpm -t ps2 -m /dev/input/mice`로 시작하고 XFree의 Pointer section에는 `Protocol "ImPS/2"`, `Device "/dev/input/mice"`, `ZAxisMapping 4 5`를 설정합니다.

기본 USB input module
Module역할
`input`Input subsystem core
`mousedev`Legacy PS/2-style mouse interface
`usbcore`USB core
`uhci_hcd` / `ohci_hcd` / `ehci_hcd`USB host controller
`usbhid`USB HID transport
`hid_generic`Generic HID device handling

일반 USB keyboard·mouse 경로에 필요한 module입니다.

USB mouse 기본 사용
Input·USB·HID module loadUSB keyboard와 mouse 탐지`/dev/input/mice` 확인 또는 생성GPM을 PS/2 protocol로 연결X Pointer section을 ImPS/2로 연결

Module load부터 GPM·X 연결까지의 예전 구성 절차입니다.

Simple Usage
============

For the most usual configuration, with one USB mouse and one USB keyboard,
you'll have to load the following modules (or have them built in to the
kernel)::

        input
        mousedev
        usbcore
        uhci_hcd or ohci_hcd or ehci_hcd
        usbhid
        hid_generic

After this, the USB keyboard will work straight away, and the USB mouse
will be available as a character device on major 13, minor 63::

        crw-r--r--   1 root     root      13,  63 Mar 28 22:45 mice

This device is usually created automatically by the system. The commands
to create it by hand are::

        cd /dev
        mkdir input
        mknod input/mice c 13 63

After that you have to point GPM (the textmode mouse cut&paste tool) and
XFree to this device to use it - GPM should be called like::

        gpm -t ps2 -m /dev/input/mice

And in X::

        Section "Pointer"
            Protocol    "ImPS/2"
            Device      "/dev/input/mice"
            ZAxisMapping 4 5
        EndSection

When you do all of the above, you can use your USB mouse and keyboard.

Event handler와 evdev

75-108

Event handler는 device event를 필요에 따라 사용자 공간과 kernel 내부 consumer에 배포합니다.

`evdev`는 generic input event interface입니다. Kernel에서 생성된 event를 timestamp와 함께 프로그램에 그대로 전달하며 event code는 모든 architecture에서 같고 hardware 독립적입니다. 사용자 공간이 사용자 입력을 소비할 때 권장되는 interface이므로 모든 client가 이를 사용하도록 권장합니다.

Evdev device는 `/dev/input/event0`, `event1`처럼 나타납니다. Minor 64~95는 정적 legacy 범위이며 input device가 32개보다 많으면 minor 256부터 추가 node를 만듭니다.

Evdev node 범위
범위Minor조건
Legacy64~95최대 32개 static event node
Extended256 이상32개를 넘는 input device

Static legacy node와 확장 node의 minor 번호입니다.

Evdev consumer 경로
Device driver가 input core에 event 보고Evdev handler가 matching device와 연결Core event와 timestamp 수신`/dev/input/eventX`에 고정 형식으로 노출사용자 프로그램이 architecture 독립 code로 해석

Hardware 독립 event가 사용자 프로그램에 전달됩니다.

Detailed Description
====================

Event handlers
--------------

Event handlers distribute the events from the devices to userspace and
in-kernel consumers, as needed.

evdev
~~~~~

``evdev`` is the generic input event interface. It passes the events
generated in the kernel straight to the program, with timestamps. The
event codes are the same on all architectures and are hardware
independent.

This is the preferred interface for userspace to consume user
input, and all clients are encouraged to use it.

See :ref:`event-interface` for notes on API.

The devices are in /dev/input::

        crw-r--r--   1 root     root      13,  64 Apr  1 10:49 event0
        crw-r--r--   1 root     root      13,  65 Apr  1 10:50 event1
        crw-r--r--   1 root     root      13,  66 Apr  1 10:50 event2
        crw-r--r--   1 root     root      13,  67 Apr  1 10:50 event3
        ...

There are two ranges of minors: 64 through 95 is the static legacy
range. If there are more than 32 input devices in a system, additional
evdev nodes are created with minors starting with 256.

Keyboard, mousedev와 joydev handler

109-169

`keyboard`는 VT code의 일부인 kernel 내부 input handler로 keyboard keystroke를 소비해 VT console의 사용자 입력을 처리합니다.

`mousedev`는 mouse input을 사용하는 legacy program을 위한 호환 계층입니다. Mouse나 digitizer·tablet event를 받아 `/dev/psaux`와 같은 PS/2-style mouse device로 사용자 공간에 제공합니다.

각 `/dev/input/mouseN`은 한 mouse 또는 digitizer에 대응하지만 마지막 `/dev/input/mice`는 모든 mouse와 digitizer가 공유하며 장치가 없어도 존재합니다. 따라서 hotplug를 모르는 오래된 프로그램도 mouse가 없는 때 미리 열어 둘 수 있습니다.

`CONFIG_INPUT_MOUSEDEV_SCREEN_X/Y`는 digitizer 좌표를 virtual PS/2 mouse movement로 XFree86 화면에 맞춰 scale할 때 쓰는 pixel 크기입니다. Mouse만 사용하면 적용되지 않습니다.

Mousedev는 reader 요청에 따라 PS/2, wheel을 지원하는 ImPS/2, 최대 5개 추가 button을 지원하는 ExplorerPS/2 protocol을 생성합니다. GPM과 X는 이 중 원하는 protocol로 설정할 수 있습니다.

`joydev`는 Linux joystick API v0.x와 v1.x를 구현합니다. Joystick은 `/dev/input/js0`부터 나타나며 legacy 범위는 `js31`까지이고 장치가 더 많으면 minor 256 이상을 사용합니다.

주요 input handler
Handler대상Interface
`keyboard`VT consoleKernel 내부
`mousedev`Legacy mouse program`/dev/input/mouseN`, `/dev/input/mice`
`joydev`Joystick API v0.x·v1.x`/dev/input/jsN`

Handler가 제공하는 consumer와 device node입니다.

Mousedev protocol 선택
Protocol기능
PS/2기본 mouse
ImPS/2USB mouse wheel
ExplorerPS/2Wheel과 최대 5개 추가 button

필요한 mouse 기능에 맞춰 legacy protocol을 선택합니다.

공유 `/dev/input/mice`
개별 mouse·digitizer가 input core에 등록Mousedev가 각 장치 event 수신개별 `/dev/input/mouseN` 제공모든 stream을 `/dev/input/mice`에 병합Legacy program은 장치가 없어도 공유 node를 열어 유지

여러 pointing device를 하나의 hotplug-friendly stream으로 합칩니다.

keyboard
~~~~~~~~

``keyboard`` is in-kernel input handler and is a part of VT code. It
consumes keyboard keystrokes and handles user input for VT consoles.

mousedev
~~~~~~~~

``mousedev`` is a hack to make legacy programs that use mouse input
work. It takes events from either mice or digitizers/tablets and makes
a PS/2-style (a la /dev/psaux) mouse device available to the
userland.

Mousedev devices in /dev/input (as shown above) are::

        crw-r--r--   1 root     root      13,  32 Mar 28 22:45 mouse0
        crw-r--r--   1 root     root      13,  33 Mar 29 00:41 mouse1
        crw-r--r--   1 root     root      13,  34 Mar 29 00:41 mouse2
        crw-r--r--   1 root     root      13,  35 Apr  1 10:50 mouse3
        ...
        ...
        crw-r--r--   1 root     root      13,  62 Apr  1 10:50 mouse30
        crw-r--r--   1 root     root      13,  63 Apr  1 10:50 mice

Each ``mouse`` device is assigned to a single mouse or digitizer, except
the last one - ``mice``. This single character device is shared by all
mice and digitizers, and even if none are connected, the device is
present.  This is useful for hotplugging USB mice, so that older programs
that do not handle hotplug can open the device even when no mice are
present.

CONFIG_INPUT_MOUSEDEV_SCREEN_[XY] in the kernel configuration are
the size of your screen (in pixels) in XFree86. This is needed if you
want to use your digitizer in X, because its movement is sent to X
via a virtual PS/2 mouse and thus needs to be scaled
accordingly. These values won't be used if you use a mouse only.

Mousedev will generate either PS/2, ImPS/2 (Microsoft IntelliMouse) or
ExplorerPS/2 (IntelliMouse Explorer) protocols, depending on what the
program reading the data wishes. You can set GPM and X to any of
these. You'll need ImPS/2 if you want to make use of a wheel on a USB
mouse and ExplorerPS/2 if you want to use extra (up to 5) buttons.

joydev
~~~~~~

``joydev`` implements v0.x and v1.x Linux joystick API. See
:ref:`joystick-api` for details.

As soon as any joystick is connected, it can be accessed in /dev/input on::

        crw-r--r--   1 root     root      13,   0 Apr  1 10:50 js0
        crw-r--r--   1 root     root      13,   1 Apr  1 10:50 js1
        crw-r--r--   1 root     root      13,   2 Apr  1 10:50 js2
        crw-r--r--   1 root     root      13,   3 Apr  1 10:50 js3
        ...

And so on up to js31 in legacy range, and additional nodes with minors
above 256 if there are more joystick devices.

주요 input device driver

170-238

Device driver는 input event를 생성하는 module입니다. `hid-generic`은 HID 장치 종류가 매우 많고 USB HID specification이 복잡해 input suite에서 가장 크고 복잡한 driver 중 하나입니다.

현재 USB mouse, joystick, gamepad, steering wheel, keyboard, trackball과 digitizer를 처리합니다. USB HID는 monitor·speaker control, UPS, LCD 등에도 쓰입니다. Monitor·speaker control은 hid/input에 연결하기 쉽지만 UPS와 LCD에는 적합하지 않아 `hiddev` interface가 마련됐으며 자세한 내용은 `Documentation/hid/hiddev.rst`에 있습니다.

`usbhid`는 parameter 없이 자동 탐지합니다. 장치 편차 때문에 잘 동작하지 않는 경우 문서는 `hid-core.c` 시작 부분의 `DEBUG`를 정의하고 syslog trace를 보내라고 안내합니다.

`usbmouse`는 embedded system, 잘못된 HID descriptor를 가진 mouse, 큰 usbhid가 부적합한 경우를 위한 USB mouse 전용 driver입니다. 단순 HIDBP protocol을 사용하므로 장치가 이를 지원해야 하며 특별한 이유가 없으면 usbhid를 사용합니다.

`usbkbd`도 단순 HIDBP protocol로 keyboard와 통신해 작지만 extra special key를 지원하지 않습니다. 특별한 이유가 없으면 usbhid가 권장됩니다.

`psmouse`는 Synaptics·ALPS touchpad, Intellimouse Explorer, Logitech PS/2 mouse 등 모든 PS/2 pointing device를 처리합니다. `atkbd`는 PS/2(AT) keyboard driver입니다.

`iforce`는 USB와 RS232를 통한 I-Force joystick·wheel driver이며 force feedback도 지원합니다.

Input device driver 역할
Driver지원 대상지침
`hid-generic` / `usbhid`일반 USB HID기본 선택, 자동 탐지
`usbmouse`단순 HIDBP USB mouse특수 사유가 있을 때만
`usbkbd`단순 HIDBP USB keyboardExtra key 미지원
`psmouse`PS/2 pointing deviceTouchpad와 PS/2 mouse 포함
`atkbd`PS/2(AT) keyboardKeyboard 전용
`iforce`USB·RS232 I-Force joystick·wheelForce feedback 포함

지원 bus·protocol과 사용 지침입니다.

USB HID driver 선택
장치가 표준 USB HID인지 확인일반적으로 `usbhid`·`hid-generic` 사용Embedded·깨진 descriptor 등 특별한 제약 확인필요하고 HIDBP 지원 시 `usbmouse` 또는 `usbkbd` 선택특별한 이유가 없으면 generic HID로 복귀

Generic HID와 축소 protocol driver 사이의 선택 기준입니다.

Device drivers
--------------

Device drivers are the modules that generate events.

hid-generic
~~~~~~~~~~~

``hid-generic`` is one of the largest and most complex driver of the
whole suite. It handles all HID devices, and because there is a very
wide variety of them, and because the USB HID specification isn't
simple, it needs to be this big.

Currently, it handles USB mice, joysticks, gamepads, steering wheels,
keyboards, trackballs and digitizers.

However, USB uses HID also for monitor controls, speaker controls, UPSs,
LCDs and many other purposes.

The monitor and speaker controls should be easy to add to the hid/input
interface, but for the UPSs and LCDs it doesn't make much sense. For this,
the hiddev interface was designed. See Documentation/hid/hiddev.rst
for more information about it.

The usage of the usbhid module is very simple, it takes no parameters,
detects everything automatically and when a HID device is inserted, it
detects it appropriately.

However, because the devices vary wildly, you might happen to have a
device that doesn't work well. In that case #define DEBUG at the beginning
of hid-core.c and send me the syslog traces.

usbmouse
~~~~~~~~

For embedded systems, for mice with broken HID descriptors and just any
other use when the big usbhid wouldn't be a good choice, there is the
usbmouse driver. It handles USB mice only. It uses a simpler HIDBP
protocol. This also means the mice must support this simpler protocol. Not
all do. If you don't have any strong reason to use this module, use usbhid
instead.

usbkbd
~~~~~~

Much like usbmouse, this module talks to keyboards with a simplified
HIDBP protocol. It's smaller, but doesn't support any extra special keys.
Use usbhid instead if there isn't any special reason to use this.

psmouse
~~~~~~~

This is driver for all flavors of pointing devices using PS/2
protocol, including Synaptics and ALPS touchpads, Intellimouse
Explorer devices, Logitech PS/2 mice and so on.

atkbd
~~~~~

This is driver for PS/2 (AT) keyboards.

iforce
~~~~~~

A driver for I-Force joysticks and wheels, both over USB and RS232.
It includes Force Feedback support now, even though Immersion
Corp. considers the protocol a trade secret and won't disclose a word
about it.

동작 검증과 `input_event` interface

239-281

Keyboard는 몇 key를 입력해 kernel keyboard driver 연결을 확인합니다. Mouse emulation은 `cat /dev/input/mouse0`에서 mouse를 움직일 때 문자가 나타나는지 봅니다. Joystick emulation은 joystick package의 `jstest`, event device는 `evtest`로 시험합니다.

Input 장치 검증
장치·interface검증 방법
Keyboard몇 key를 입력
Mousedev`cat /dev/input/mouse0` 후 mouse 이동
Joydev`jstest`
Evdev`evtest`

장치 종류별 간단한 확인 방법입니다.

`/dev/input/eventX`에서는 blocking·nonblocking read와 `select()`를 사용할 수 있고 한 번의 read는 항상 `struct input_event`의 정수 개를 반환합니다.

`struct input_event`는 event 발생 시각인 `struct timeval time`, event type인 `unsigned short type`, event code인 `unsigned short code`, 전달값인 `int value`로 구성됩니다.

`type`은 상대 이동 `EV_REL`, key press·release `EV_KEY` 등이며 전체 type은 `include/uapi/linux/input-event-codes.h`에 있습니다. `code`는 `REL_X`, `KEY_BACKSPACE` 같은 세부 code이고 같은 header에 전체 목록이 있습니다.

`value`는 `EV_REL`의 상대 변화량, `EV_ABS`의 절대 새 값, `EV_KEY`의 release 0, press 1, autorepeat 2입니다. 여러 event code의 의미는 `input-event-codes` 문서를 참고합니다.

`struct input_event`
필드형식의미
`time``struct timeval`Event 발생 timestamp
`type``unsigned short``EV_REL`, `EV_KEY` 등 event type
`code``unsigned short``REL_X`, `KEY_BACKSPACE` 등 세부 code
`value``int`상대 변화·절대값·key 상태

Evdev read가 반환하는 architecture-independent event record입니다.

Evdev read
`/dev/input/eventX`를 blocking 또는 nonblocking으로 열기`read()` 또는 `select()`로 event 대기`struct input_event` 정수 개를 수신`time`, `type`, `code`, `value` 해석Event code 규약에 따라 application 상태 갱신

Program이 고정 크기 record를 읽고 의미를 해석합니다.

Verifying if it works
=====================

Typing a couple keys on the keyboard should be enough to check that
a keyboard works and is correctly connected to the kernel keyboard
driver.

Doing a ``cat /dev/input/mouse0`` (c, 13, 32) will verify that a mouse
is also emulated; characters should appear if you move it.

You can test the joystick emulation with the ``jstest`` utility,
available in the joystick package (see :ref:`joystick-doc`).

You can test the event devices with the ``evtest`` utility.

.. _event-interface:

Event interface
===============

You can use blocking and nonblocking reads, and also select() on the
/dev/input/eventX devices, and you'll always get a whole number of input
events on a read. Their layout is::

    struct input_event {
            struct timeval time;
            unsigned short type;
            unsigned short code;
            int value;
    };

``time`` is the timestamp, it returns the time at which the event happened.
Type is for example EV_REL for relative movement, EV_KEY for a keypress or
release. More types are defined in include/uapi/linux/input-event-codes.h.

``code`` is event code, for example REL_X or KEY_BACKSPACE, again a complete
list is in include/uapi/linux/input-event-codes.h.

``value`` is the value the event carries. Either a relative change for
EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for
release, 1 for keypress and 2 for autorepeat.

See :ref:`input-event-codes` for more information about various even codes.