diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /Documentation/input |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'Documentation/input')
-rw-r--r-- | Documentation/input/amijoy.txt | 184 | ||||
-rw-r--r-- | Documentation/input/atarikbd.txt | 709 | ||||
-rw-r--r-- | Documentation/input/cd32.txt | 19 | ||||
-rw-r--r-- | Documentation/input/cs461x.txt | 45 | ||||
-rw-r--r-- | Documentation/input/ff.txt | 227 | ||||
-rw-r--r-- | Documentation/input/gameport-programming.txt | 189 | ||||
-rw-r--r-- | Documentation/input/iforce-protocol.txt | 254 | ||||
-rw-r--r-- | Documentation/input/input-programming.txt | 281 | ||||
-rw-r--r-- | Documentation/input/input.txt | 312 | ||||
-rw-r--r-- | Documentation/input/interactive.fig | 42 | ||||
-rw-r--r-- | Documentation/input/joystick-api.txt | 316 | ||||
-rw-r--r-- | Documentation/input/joystick-parport.txt | 542 | ||||
-rw-r--r-- | Documentation/input/joystick.txt | 588 | ||||
-rw-r--r-- | Documentation/input/shape.fig | 65 | ||||
-rw-r--r-- | Documentation/input/xpad.txt | 116 |
15 files changed, 3889 insertions, 0 deletions
diff --git a/Documentation/input/amijoy.txt b/Documentation/input/amijoy.txt new file mode 100644 index 000000000000..3b8b2d43a68e --- /dev/null +++ b/Documentation/input/amijoy.txt | |||
@@ -0,0 +1,184 @@ | |||
1 | Amiga 4-joystick parport extension | ||
2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
3 | Parallel port pins: | ||
4 | |||
5 | (2) - Up1 (6) - Up2 | ||
6 | (3) - Down1 (7) - Down2 | ||
7 | (4) - Left1 (8) - Left2 | ||
8 | (5) - Right1 (9) - Right2 | ||
9 | (13) - Fire1 (11) - Fire2 | ||
10 | (18) - Gnd1 (18) - Gnd2 | ||
11 | |||
12 | Amiga digital joystick pinout | ||
13 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
14 | (1) - Up | ||
15 | (2) - Down | ||
16 | (3) - Left | ||
17 | (4) - Right | ||
18 | (5) - n/c | ||
19 | (6) - Fire button | ||
20 | (7) - +5V (50mA) | ||
21 | (8) - Gnd | ||
22 | (9) - Thumb button | ||
23 | |||
24 | Amiga mouse pinout | ||
25 | ~~~~~~~~~~~~~~~~~~ | ||
26 | (1) - V-pulse | ||
27 | (2) - H-pulse | ||
28 | (3) - VQ-pulse | ||
29 | (4) - HQ-pulse | ||
30 | (5) - Middle button | ||
31 | (6) - Left button | ||
32 | (7) - +5V (50mA) | ||
33 | (8) - Gnd | ||
34 | (9) - Right button | ||
35 | |||
36 | Amiga analog joystick pinout | ||
37 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
38 | (1) - Top button | ||
39 | (2) - Top2 button | ||
40 | (3) - Trigger button | ||
41 | (4) - Thumb button | ||
42 | (5) - Analog X | ||
43 | (6) - n/c | ||
44 | (7) - +5V (50mA) | ||
45 | (8) - Gnd | ||
46 | (9) - Analog Y | ||
47 | |||
48 | Amiga lightpen pinout | ||
49 | ~~~~~~~~~~~~~~~~~~~~~ | ||
50 | (1) - n/c | ||
51 | (2) - n/c | ||
52 | (3) - n/c | ||
53 | (4) - n/c | ||
54 | (5) - Touch button | ||
55 | (6) - /Beamtrigger | ||
56 | (7) - +5V (50mA) | ||
57 | (8) - Gnd | ||
58 | (9) - Stylus button | ||
59 | |||
60 | ------------------------------------------------------------------------------- | ||
61 | |||
62 | NAME rev ADDR type chip Description | ||
63 | JOY0DAT 00A R Denise Joystick-mouse 0 data (left vert, horiz) | ||
64 | JOY1DAT 00C R Denise Joystick-mouse 1 data (right vert,horiz) | ||
65 | |||
66 | These addresses each read a 16 bit register. These in turn | ||
67 | are loaded from the MDAT serial stream and are clocked in on | ||
68 | the rising edge of SCLK. MLD output is used to parallel load | ||
69 | the external parallel-to-serial converter.This in turn is | ||
70 | loaded with the 4 quadrature inputs from each of two game | ||
71 | controller ports (8 total) plus 8 miscellaneous control bits | ||
72 | which are new for LISA and can be read in upper 8 bits of | ||
73 | LISAID. | ||
74 | Register bits are as follows: | ||
75 | Mouse counter usage (pins 1,3 =Yclock, pins 2,4 =Xclock) | ||
76 | |||
77 | BIT# 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 | ||
78 | JOY0DAT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0 | ||
79 | JOY1DAT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0 | ||
80 | |||
81 | 0=LEFT CONTROLLER PAIR, 1=RIGHT CONTROLLER PAIR. | ||
82 | (4 counters total).The bit usage for both left and right | ||
83 | addresses is shown below. Each 6 bit counter (Y7-Y2,X7-X2) is | ||
84 | clocked by 2 of the signals input from the mouse serial | ||
85 | stream. Starting with first bit recived: | ||
86 | |||
87 | +-------------------+-----------------------------------------+ | ||
88 | | Serial | Bit Name | Description | | ||
89 | +--------+----------+-----------------------------------------+ | ||
90 | | 0 | M0H | JOY0DAT Horizontal Clock | | ||
91 | | 1 | M0HQ | JOY0DAT Horizontal Clock (quadrature) | | ||
92 | | 2 | M0V | JOY0DAT Vertical Clock | | ||
93 | | 3 | M0VQ | JOY0DAT Vertical Clock (quadrature) | | ||
94 | | 4 | M1V | JOY1DAT Horizontall Clock | | ||
95 | | 5 | M1VQ | JOY1DAT Horizontall Clock (quadrature) | | ||
96 | | 6 | M1V | JOY1DAT Vertical Clock | | ||
97 | | 7 | M1VQ | JOY1DAT Vertical Clock (quadrature) | | ||
98 | +--------+----------+-----------------------------------------+ | ||
99 | |||
100 | Bits 1 and 0 of each counter (Y1-Y0,X1-X0) may be | ||
101 | read to determine the state of the related input signal pair. | ||
102 | This allows these pins to double as joystick switch inputs. | ||
103 | Joystick switch closures can be deciphered as follows: | ||
104 | |||
105 | +------------+------+---------------------------------+ | ||
106 | | Directions | Pin# | Counter bits | | ||
107 | +------------+------+---------------------------------+ | ||
108 | | Forward | 1 | Y1 xor Y0 (BIT#09 xor BIT#08) | | ||
109 | | Left | 3 | Y1 | | ||
110 | | Back | 2 | X1 xor X0 (BIT#01 xor BIT#00) | | ||
111 | | Right | 4 | X1 | | ||
112 | +------------+------+---------------------------------+ | ||
113 | |||
114 | ------------------------------------------------------------------------------- | ||
115 | |||
116 | NAME rev ADDR type chip Description | ||
117 | JOYTEST 036 W Denise Write to all 4 joystick-mouse counters at once. | ||
118 | |||
119 | Mouse counter write test data: | ||
120 | BIT# 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 | ||
121 | JOYxDAT Y7 Y6 Y5 Y4 Y3 Y2 xx xx X7 X6 X5 X4 X3 X2 xx xx | ||
122 | JOYxDAT Y7 Y6 Y5 Y4 Y3 Y2 xx xx X7 X6 X5 X4 X3 X2 xx xx | ||
123 | |||
124 | ------------------------------------------------------------------------------- | ||
125 | |||
126 | NAME rev ADDR type chip Description | ||
127 | POT0DAT h 012 R Paula Pot counter data left pair (vert, horiz) | ||
128 | POT1DAT h 014 R Paula Pot counter data right pair (vert,horiz) | ||
129 | |||
130 | These addresses each read a pair of 8 bit pot counters. | ||
131 | (4 counters total). The bit assignment for both | ||
132 | addresses is shown below. The counters are stopped by signals | ||
133 | from 2 controller connectors (left-right) with 2 pins each. | ||
134 | |||
135 | BIT# 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 | ||
136 | RIGHT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0 | ||
137 | LEFT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0 | ||
138 | |||
139 | +--------------------------+-------+ | ||
140 | | CONNECTORS | PAULA | | ||
141 | +-------+------+-----+-----+-------+ | ||
142 | | Loc. | Dir. | Sym | pin | pin | | ||
143 | +-------+------+-----+-----+-------+ | ||
144 | | RIGHT | Y | RX | 9 | 33 | | ||
145 | | RIGHT | X | RX | 5 | 32 | | ||
146 | | LEFT | Y | LY | 9 | 36 | | ||
147 | | LEFT | X | LX | 5 | 35 | | ||
148 | +-------+------+-----+-----+-------+ | ||
149 | |||
150 | With normal (NTSC or PAL) horiz. line rate, the pots will | ||
151 | give a full scale (FF) reading with about 500kohms in one | ||
152 | frame time. With proportionally faster horiz line times, | ||
153 | the counters will count proportionally faster. | ||
154 | This should be noted when doing variable beam displays. | ||
155 | |||
156 | ------------------------------------------------------------------------------- | ||
157 | |||
158 | NAME rev ADDR type chip Description | ||
159 | POTGO 034 W Paula Pot port (4 bit) bi-direction and data, and pot counter start. | ||
160 | |||
161 | ------------------------------------------------------------------------------- | ||
162 | |||
163 | NAME rev ADDR type chip Description | ||
164 | POTINP 016 R Paula Pot pin data read | ||
165 | |||
166 | This register controls a 4 bit bi-direction I/O port | ||
167 | that shares the same 4 pins as the 4 pot counters above. | ||
168 | |||
169 | +-------+----------+---------------------------------------------+ | ||
170 | | BIT# | FUNCTION | DESCRIPTION | | ||
171 | +-------+----------+---------------------------------------------+ | ||
172 | | 15 | OUTRY | Output enable for Paula pin 33 | | ||
173 | | 14 | DATRY | I/O data Paula pin 33 | | ||
174 | | 13 | OUTRX | Output enable for Paula pin 32 | | ||
175 | | 12 | DATRX | I/O data Paula pin 32 | | ||
176 | | 11 | OUTLY | Out put enable for Paula pin 36 | | ||
177 | | 10 | DATLY | I/O data Paula pin 36 | | ||
178 | | 09 | OUTLX | Output enable for Paula pin 35 | | ||
179 | | 08 | DATLX | I/O data Paula pin 35 | | ||
180 | | 07-01 | X | Not used | | ||
181 | | 00 | START | Start pots (dump capacitors,start counters) | | ||
182 | +-------+----------+---------------------------------------------+ | ||
183 | |||
184 | ------------------------------------------------------------------------------- | ||
diff --git a/Documentation/input/atarikbd.txt b/Documentation/input/atarikbd.txt new file mode 100644 index 000000000000..8fb896c74114 --- /dev/null +++ b/Documentation/input/atarikbd.txt | |||
@@ -0,0 +1,709 @@ | |||
1 | Intelligent Keyboard (ikbd) Protocol | ||
2 | |||
3 | |||
4 | 1. Introduction | ||
5 | |||
6 | The Atari Corp. Intelligent Keyboard (ikbd) is a general purpose keyboard | ||
7 | controller that is flexible enough that it can be used in a variety of | ||
8 | products without modification. The keyboard, with its microcontroller, | ||
9 | provides a convenient connection point for a mouse and switch-type joysticks. | ||
10 | The ikbd processor also maintains a time-of-day clock with one second | ||
11 | resolution. | ||
12 | The ikbd has been designed to be general enough that it can be used with a | ||
13 | ariety of new computer products. Product variations in a number of | ||
14 | keyswitches, mouse resolution, etc. can be accommodated. | ||
15 | The ikbd communicates with the main processor over a high speed bi-directional | ||
16 | serial interface. It can function in a variety of modes to facilitate | ||
17 | different applications of the keyboard, joysticks, or mouse. Limited use of | ||
18 | the controller is possible in applications in which only a unidirectional | ||
19 | communications medium is available by carefully designing the default modes. | ||
20 | |||
21 | 3. Keyboard | ||
22 | |||
23 | The keyboard always returns key make/break scan codes. The ikbd generates | ||
24 | keyboard scan codes for each key press and release. The key scan make (key | ||
25 | closure) codes start at 1, and are defined in Appendix A. For example, the | ||
26 | ISO key position in the scan code table should exist even if no keyswitch | ||
27 | exists in that position on a particular keyboard. The break code for each key | ||
28 | is obtained by ORing 0x80 with the make code. | ||
29 | |||
30 | The special codes 0xF6 through 0xFF are reserved for use as follows: | ||
31 | 0xF6 status report | ||
32 | 0xF7 absolute mouse position record | ||
33 | 0xF8-0xFB relative mouse position records(lsbs determind by | ||
34 | mouse button states) | ||
35 | 0xFC time-of-day | ||
36 | 0xFD joystick report (both sticks) | ||
37 | 0xFE joystick 0 event | ||
38 | 0xFF joystick 1 event | ||
39 | |||
40 | The two shift keys return different scan codes in this mode. The ENTER key | ||
41 | and the RETurn key are also distinct. | ||
42 | |||
43 | 4. Mouse | ||
44 | |||
45 | The mouse port should be capable of supporting a mouse with resolution of | ||
46 | approximately 200 counts (phase changes or 'clicks') per inch of travel. The | ||
47 | mouse should be scanned at a rate that will permit accurate tracking at | ||
48 | velocities up to 10 inches per second. | ||
49 | The ikbd can report mouse motion in three distinctly different ways. It can | ||
50 | report relative motion, absolute motion in a coordinate system maintained | ||
51 | within the ikbd, or by converting mouse motion into keyboard cursor control | ||
52 | key equivalents. | ||
53 | The mouse buttons can be treated as part of the mouse or as additional | ||
54 | keyboard keys. | ||
55 | |||
56 | 4.1 Relative Position Reporting | ||
57 | |||
58 | In relative position mode, the ikbd will return relative mouse position | ||
59 | records whenever a mouse event occurs. A mouse event consists of a mouse | ||
60 | button being pressed or released, or motion in either axis exceeding a | ||
61 | settable threshold of motion. Regardless of the threshold, all bits of | ||
62 | resolution are returned to the host computer. | ||
63 | Note that the ikbd may return mouse relative position reports with | ||
64 | significantly more than the threshold delta x or y. This may happen since no | ||
65 | relative mouse motion events will be generated: (a) while the keyboard has | ||
66 | been 'paused' ( the event will be stored until keyboard communications is | ||
67 | resumed) (b) while any event is being transmitted. | ||
68 | |||
69 | The relative mouse position record is a three byte record of the form | ||
70 | (regardless of keyboard mode): | ||
71 | %111110xy ; mouse position record flag | ||
72 | ; where y is the right button state | ||
73 | ; and x is the left button state | ||
74 | X ; delta x as twos complement integer | ||
75 | Y ; delta y as twos complement integer | ||
76 | |||
77 | Note that the value of the button state bits should be valid even if the | ||
78 | MOUSE BUTTON ACTION has set the buttons to act like part of the keyboard. | ||
79 | If the accumulated motion before the report packet is generated exceeds the | ||
80 | +127...-128 range, the motion is broken into multiple packets. | ||
81 | Note that the sign of the delta y reported is a function of the Y origin | ||
82 | selected. | ||
83 | |||
84 | 4.2 Absolute Position reporting | ||
85 | |||
86 | The ikbd can also maintain absolute mouse position. Commands exist for | ||
87 | reseting the mouse position, setting X/Y scaling, and interrogating the | ||
88 | current mouse position. | ||
89 | |||
90 | 4.3 Mouse Cursor Key Mode | ||
91 | |||
92 | The ikbd can translate mouse motion into the equivalent cursor keystrokes. | ||
93 | The number of mouse clicks per keystroke is independently programmable in | ||
94 | each axis. The ikbd internally maintains mouse motion information to the | ||
95 | highest resolution available, and merely generates a pair of cursor key events | ||
96 | for each multiple of the scale factor. | ||
97 | Mouse motion produces the cursor key make code immediately followed by the | ||
98 | break code for the appropriate cursor key. The mouse buttons produce scan | ||
99 | codes above those normally assigned for the largest envisioned keyboard (i.e. | ||
100 | LEFT=0x74 & RIGHT=0x75). | ||
101 | |||
102 | 5. Joystick | ||
103 | |||
104 | 5.1 Joystick Event Reporting | ||
105 | |||
106 | In this mode, the ikbd generates a record whever the joystick position is | ||
107 | changed (i.e. for each opening or closing of a joystick switch or trigger). | ||
108 | |||
109 | The joystick event record is two bytes of the form: | ||
110 | %1111111x ; Joystick event marker | ||
111 | ; where x is Joystick 0 or 1 | ||
112 | %x000yyyy ; where yyyy is the stick position | ||
113 | ; and x is the trigger | ||
114 | |||
115 | 5.2 Joystick Interrogation | ||
116 | |||
117 | The current state of the joystick ports may be interrogated at any time in | ||
118 | this mode by sending an 'Interrogate Joystick' command to the ikbd. | ||
119 | |||
120 | The ikbd response to joystick interrogation is a three byte report of the form | ||
121 | 0xFD ; joystick report header | ||
122 | %x000yyyy ; Joystick 0 | ||
123 | %x000yyyy ; Joystick 1 | ||
124 | ; where x is the trigger | ||
125 | ; and yyy is the stick position | ||
126 | |||
127 | 5.3 Joystick Monitoring | ||
128 | |||
129 | A mode is available that devotes nearly all of the keyboard communications | ||
130 | time to reporting the state of the joystick ports at a user specifiable rate. | ||
131 | It remains in this mode until reset or commanded into another mode. The PAUSE | ||
132 | command in this mode not only stop the output but also temporarily stops | ||
133 | scanning the joysticks (samples are not queued). | ||
134 | |||
135 | 5.4 Fire Button Monitoring | ||
136 | |||
137 | A mode is provided to permit monitoring a single input bit at a high rate. In | ||
138 | this mode the ikbd monitors the state of the Joystick 1 fire button at the | ||
139 | maximum rate permitted by the serial communication channel. The data is packed | ||
140 | 8 bits per byte for transmission to the host. The ikbd remains in this mode | ||
141 | until reset or commanded into another mode. The PAUSE command in this mode not | ||
142 | only stops the output but also temporarily stops scanning the button (samples | ||
143 | are not queued). | ||
144 | |||
145 | 5.5 Joystick Key Code Mode | ||
146 | |||
147 | The ikbd may be commanded to translate the use of either joystick into the | ||
148 | equivalent cursor control keystroke(s). The ikbd provides a single breakpoint | ||
149 | velocity joystick cursor. | ||
150 | Joystick events produce the make code, immediately followed by the break code | ||
151 | for the appropriate cursor motion keys. The trigger or fire buttons of the | ||
152 | joysticks produce pseudo key scan codes above those used by the largest key | ||
153 | matrix envisioned (i.e. JOYSTICK0=0x74, JOYSTICK1=0x75). | ||
154 | |||
155 | 6. Time-of-Day Clock | ||
156 | |||
157 | The ikbd also maintains a time-of-day clock for the system. Commands are | ||
158 | available to set and interrogate the timer-of-day clock. Time-keeping is | ||
159 | maintained down to a resolution of one second. | ||
160 | |||
161 | 7. Status Inquiries | ||
162 | |||
163 | The current state of ikbd modes and parameters may be found by sending status | ||
164 | inquiry commands that correspond to the ikbd set commands. | ||
165 | |||
166 | 8. Power-Up Mode | ||
167 | |||
168 | The keyboard controller will perform a simple self-test on power-up to detect | ||
169 | major controller faults (ROM checksum and RAM test) and such things as stuck | ||
170 | keys. Any keys down at power-up are presumed to be stuck, and their BREAK | ||
171 | (sic) code is returned (which without the preceding MAKE code is a flag for a | ||
172 | keyboard error). If the controller self-test completes without error, the code | ||
173 | 0xF0 is returned. (This code will be used to indicate the version/rlease of | ||
174 | the ikbd controller. The first release of the ikbd is version 0xF0, should | ||
175 | there be a second release it will be 0xF1, and so on.) | ||
176 | The ikbd defaults to a mouse position reporting with threshold of 1 unit in | ||
177 | either axis and the Y=0 origin at the top of the screen, and joystick event | ||
178 | reporting mode for joystick 1, with both buttons being logically assigned to | ||
179 | the mouse. After any joystick command, the ikbd assumes that joysticks are | ||
180 | connected to both Joystick0 and Joystick1. Any mouse command (except MOUSE | ||
181 | DISABLE) then causes port 0 to again be scanned as if it were a mouse, and | ||
182 | both buttons are logically connected to it. If a mouse diable command is | ||
183 | received while port 0 is presumed to be a mouse, the button is logically | ||
184 | assigned to Joystick1 ( until the mouse is reenabled by another mouse command). | ||
185 | |||
186 | 9. ikbd Command Set | ||
187 | |||
188 | This section contains a list of commands that can be sent to the ikbd. Command | ||
189 | codes (such as 0x00) which are not specified should perform no operation | ||
190 | (NOPs). | ||
191 | |||
192 | 9.1 RESET | ||
193 | |||
194 | 0x80 | ||
195 | 0x01 | ||
196 | |||
197 | N.B. The RESET command is the only two byte command understood by the ikbd. | ||
198 | Any byte following an 0x80 command byte other than 0x01 is ignored (and causes | ||
199 | the 0x80 to be ignored). | ||
200 | A reset may also be caused by sending a break lasting at least 200mS to the | ||
201 | ikbd. | ||
202 | Executing the RESET command returns the keyboard to its default (power-up) | ||
203 | mode and parameter settings. It does not affect the time-of-day clock. | ||
204 | The RESET command or function causes the ikbd to perform a simple self-test. | ||
205 | If the test is successful, the ikbd will send the code of 0xF0 within 300mS | ||
206 | of receipt of the RESET command (or the end of the break, or power-up). The | ||
207 | ikbd will then scan the key matrix for any stuck (closed) keys. Any keys found | ||
208 | closed will cause the break scan code to be generated (the break code arriving | ||
209 | without being preceded by the make code is a flag for a key matrix error). | ||
210 | |||
211 | 9.2. SET MOUSE BUTTON ACTION | ||
212 | |||
213 | 0x07 | ||
214 | %00000mss ; mouse button action | ||
215 | ; (m is presumed = 1 when in MOUSE KEYCODE mode) | ||
216 | ; mss=0xy, mouse button press or release causes mouse | ||
217 | ; position report | ||
218 | ; where y=1, mouse key press causes absolute report | ||
219 | ; and x=1, mouse key release causes absolute report | ||
220 | ; mss=100, mouse buttons act like keys | ||
221 | |||
222 | This command sets how the ikbd should treat the buttons on the mouse. The | ||
223 | default mouse button action mode is %00000000, the buttons are treated as part | ||
224 | of the mouse logically. | ||
225 | When buttons act like keys, LEFT=0x74 & RIGHT=0x75. | ||
226 | |||
227 | 9.3 SET RELATIVE MOUSE POSITION REPORTING | ||
228 | |||
229 | 0x08 | ||
230 | |||
231 | Set relative mouse position reporting. (DEFAULT) Mouse position packets are | ||
232 | generated asynchronously by the ikbd whenever motion exceeds the setable | ||
233 | threshold in either axis (see SET MOUSE THRESHOLD). Depending upon the mouse | ||
234 | key mode, mouse position reports may also be generated when either mouse | ||
235 | button is pressed or released. Otherwise the mouse buttons behave as if they | ||
236 | were keyboard keys. | ||
237 | |||
238 | 9.4 SET ABSOLUTE MOUSE POSITIONING | ||
239 | |||
240 | 0x09 | ||
241 | XMSB ; X maximum (in scaled mouse clicks) | ||
242 | XLSB | ||
243 | YMSB ; Y maximum (in scaled mouse clicks) | ||
244 | YLSB | ||
245 | |||
246 | Set absolute mouse position maintenance. Resets the ikbd maintained X and Y | ||
247 | coordinates. | ||
248 | In this mode, the value of the internally maintained coordinates does NOT wrap | ||
249 | between 0 and large positive numbers. Excess motion below 0 is ignored. The | ||
250 | command sets the maximum positive value that can be attained in the scaled | ||
251 | coordinate system. Motion beyond that value is also ignored. | ||
252 | |||
253 | 9.5 SET MOUSE KEYCODE MOSE | ||
254 | |||
255 | 0x0A | ||
256 | deltax ; distance in X clicks to return (LEFT) or (RIGHT) | ||
257 | deltay ; distance in Y clicks to return (UP) or (DOWN) | ||
258 | |||
259 | Set mouse monitoring routines to return cursor motion keycodes instead of | ||
260 | either RELATIVE or ABSOLUTE motion records. The ikbd returns the appropriate | ||
261 | cursor keycode after mouse travel exceeding the user specified deltas in | ||
262 | either axis. When the keyboard is in key scan code mode, mouse motion will | ||
263 | cause the make code immediately followed by the break code. Note that this | ||
264 | command is not affected by the mouse motion origin. | ||
265 | |||
266 | 9..6 SET MOUSE THRESHOLD | ||
267 | |||
268 | 0x0B | ||
269 | X ; x threshold in mouse ticks (positive integers) | ||
270 | Y ; y threshold in mouse ticks (positive integers) | ||
271 | |||
272 | This command sets the threshold before a mouse event is generated. Note that | ||
273 | it does NOT affect the resolution of the data returned to the host. This | ||
274 | command is valid only in RELATIVE MOUSE POSITIONING mode. The thresholds | ||
275 | default to 1 at RESET (or power-up). | ||
276 | |||
277 | 9.7 SET MOUSE SCALE | ||
278 | |||
279 | 0x0C | ||
280 | X ; horizontal mouse ticks per internel X | ||
281 | Y ; vertical mouse ticks per internel Y | ||
282 | |||
283 | This command sets the scale factor for the ABSOLUTE MOUSE POSITIONING mode. | ||
284 | In this mode, the specified number of mouse phase changes ('clicks') must | ||
285 | occur before the internally maintained coordinate is changed by one | ||
286 | (independently scaled for each axis). Remember that the mouse position | ||
287 | information is available only by interrogating the ikbd in the ABSOLUTE MOUSE | ||
288 | POSITIONING mode unless the ikbd has been commanded to report on button press | ||
289 | or release (see SET MOSE BUTTON ACTION). | ||
290 | |||
291 | 9.8 INTERROGATE MOUSE POSITION | ||
292 | |||
293 | 0x0D | ||
294 | Returns: | ||
295 | 0xF7 ; absolute mouse position header | ||
296 | BUTTONS | ||
297 | 0000dcba ; where a is right button down since last interrogation | ||
298 | ; b is right button up since last | ||
299 | ; c is left button down since last | ||
300 | ; d is left button up since last | ||
301 | XMSB ; X coordinate | ||
302 | XLSB | ||
303 | YMSB ; Y coordinate | ||
304 | YLSB | ||
305 | |||
306 | The INTERROGATE MOUSE POSITION command is valid when in the ABSOLUTE MOUSE | ||
307 | POSITIONING mode, regardless of the setting of the MOUSE BUTTON ACTION. | ||
308 | |||
309 | 9.9 LOAD MOUSE POSITION | ||
310 | |||
311 | 0x0E | ||
312 | 0x00 ; filler | ||
313 | XMSB ; X coordinate | ||
314 | XLSB ; (in scaled coordinate system) | ||
315 | YMSB ; Y coordinate | ||
316 | YLSB | ||
317 | |||
318 | This command allows the user to preset the internally maintained absolute | ||
319 | mouse position. | ||
320 | |||
321 | 9.10 SET Y=0 AT BOTTOM | ||
322 | |||
323 | 0x0F | ||
324 | |||
325 | This command makes the origin of the Y axis to be at the bottom of the | ||
326 | logical coordinate system internel to the ikbd for all relative or absolute | ||
327 | mouse motion. This causes mouse motion toward the user to be negative in sign | ||
328 | and away from the user to be positive. | ||
329 | |||
330 | 9.11 SET Y=0 AT TOP | ||
331 | |||
332 | 0x10 | ||
333 | |||
334 | Makes the origin of the Y axis to be at the top of the logical coordinate | ||
335 | system within the ikbd for all relative or absolute mouse motion. (DEFAULT) | ||
336 | This causes mouse motion toward the user to be positive in sign and away from | ||
337 | the user to be negative. | ||
338 | |||
339 | 9.12 RESUME | ||
340 | |||
341 | 0x11 | ||
342 | |||
343 | Resume sending data to the host. Since any command received by the ikbd after | ||
344 | its output has been paused also causes an implicit RESUME this command can be | ||
345 | thought of as a NO OPERATION command. If this command is received by the ikbd | ||
346 | and it is not PAUSED, it is simply ignored. | ||
347 | |||
348 | 9.13 DISABLE MOUSE | ||
349 | |||
350 | 0x12 | ||
351 | |||
352 | All mouse event reporting is disabled (and scanning may be internally | ||
353 | disabled). Any valid mouse mode command resumes mouse motion monitoring. (The | ||
354 | valid mouse mode commands are SET RELATIVE MOUSE POSITION REPORTING, SET | ||
355 | ABSOLUTE MOUSE POSITIONING, and SET MOUSE KEYCODE MODE. ) | ||
356 | N.B. If the mouse buttons have been commanded to act like keyboard keys, this | ||
357 | command DOES affect their actions. | ||
358 | |||
359 | 9.14 PAUSE OUTPUT | ||
360 | |||
361 | 0x13 | ||
362 | |||
363 | Stop sending data to the host until another valid command is received. Key | ||
364 | matrix activity is still monitored and scan codes or ASCII characters enqueued | ||
365 | (up to the maximum supported by the microcontroller) to be sent when the host | ||
366 | allows the output to be resumed. If in the JOYSTICK EVENT REPORTING mode, | ||
367 | joystick events are also queued. | ||
368 | Mouse motion should be accumulated while the output is paused. If the ikbd is | ||
369 | in RELATIVE MOUSE POSITIONING REPORTING mode, motion is accumulated beyond the | ||
370 | normal threshold limits to produce the minimum number of packets necessary for | ||
371 | transmission when output is resumed. Pressing or releasing either mouse button | ||
372 | causes any accumulated motion to be immediately queued as packets, if the | ||
373 | mouse is in RELATIVE MOUSE POSITION REPORTING mode. | ||
374 | Because of the limitations of the microcontroller memory this command should | ||
375 | be used sparingly, and the output should not be shut of for more than <tbd> | ||
376 | milliseconds at a time. | ||
377 | The output is stopped only at the end of the current 'even'. If the PAUSE | ||
378 | OUTPUT command is received in the middle of a multiple byte report, the packet | ||
379 | will still be transmitted to conclusion and then the PAUSE will take effect. | ||
380 | When the ikbd is in either the JOYSTICK MONITORING mode or the FIRE BUTTON | ||
381 | MONITORING mode, the PAUSE OUTPUT command also temporarily stops the | ||
382 | monitoring process (i.e. the samples are not enqueued for transmission). | ||
383 | |||
384 | 0.15 SET JOYSTICK EVENT REPORTING | ||
385 | |||
386 | 0x14 | ||
387 | |||
388 | Enter JOYSTICK EVENT REPORTING mode (DEFAULT). Each opening or closure of a | ||
389 | joystick switch or trigger causes a joystick event record to be generated. | ||
390 | |||
391 | 9.16 SET JOYSTICK INTERROGATION MODE | ||
392 | |||
393 | 0x15 | ||
394 | |||
395 | Disables JOYSTICK EVENT REPORTING. Host must send individual JOYSTICK | ||
396 | INTERROGATE commands to sense joystick state. | ||
397 | |||
398 | 9.17 JOYSTICK INTERROGATE | ||
399 | |||
400 | 0x16 | ||
401 | |||
402 | Return a record indicating the current state of the joysticks. This command | ||
403 | is valid in either the JOYSTICK EVENT REPORTING mode or the JOYSTICK | ||
404 | INTERROGATION MODE. | ||
405 | |||
406 | 9.18 SET JOYSTICK MONITORING | ||
407 | |||
408 | 0x17 | ||
409 | rate ; time between samples in hundreths of a second | ||
410 | Returns: (in packets of two as long as in mode) | ||
411 | %000000xy ; where y is JOYSTICK1 Fire button | ||
412 | ; and x is JOYSTICK0 Fire button | ||
413 | %nnnnmmmm ; where m is JOYSTICK1 state | ||
414 | ; and n is JOYSTICK0 state | ||
415 | |||
416 | Sets the ikbd to do nothing but monitor the serial command lne, maintain the | ||
417 | time-of-day clock, and monitor the joystick. The rate sets the interval | ||
418 | between joystick samples. | ||
419 | N.B. The user should not set the rate higher than the serial communications | ||
420 | channel will allow the 2 bytes packets to be transmitted. | ||
421 | |||
422 | 9.19 SET FIRE BUTTON MONITORING | ||
423 | |||
424 | 0x18 | ||
425 | Returns: (as long as in mode) | ||
426 | %bbbbbbbb ; state of the JOYSTICK1 fire button packed | ||
427 | ; 8 bits per byte, the first sample if the MSB | ||
428 | |||
429 | Set the ikbd to do nothing but monitor the serial command line, maintain the | ||
430 | time-of-day clock, and monitor the fire button on Joystick 1. The fire button | ||
431 | is scanned at a rate that causes 8 samples to be made in the time it takes for | ||
432 | the previous byte to be sent to the host (i.e. scan rate = 8/10 * baud rate). | ||
433 | The sample interval should be as constant as possible. | ||
434 | |||
435 | 9.20 SET JOYSTICK KEYCODE MODE | ||
436 | |||
437 | 0x19 | ||
438 | RX ; length of time (in tenths of seconds) until | ||
439 | ; horizontal velocity breakpoint is reached | ||
440 | RY ; length of time (in tenths of seconds) until | ||
441 | ; vertical velocity breakpoint is reached | ||
442 | TX ; length (in tenths of seconds) of joystick closure | ||
443 | ; until horizontal cursor key is generated before RX | ||
444 | ; has elapsed | ||
445 | TY ; length (in tenths of seconds) of joystick closure | ||
446 | ; until vertical cursor key is generated before RY | ||
447 | ; has elapsed | ||
448 | VX ; length (in tenths of seconds) of joystick closure | ||
449 | ; until horizontal cursor keystokes are generated | ||
450 | ; after RX has elapsed | ||
451 | VY ; length (in tenths of seconds) of joystick closure | ||
452 | ; until vertical cursor keystokes are generated | ||
453 | ; after RY has elapsed | ||
454 | |||
455 | In this mode, joystick 0 is scanned in a way that simulates cursor keystrokes. | ||
456 | On initial closure, a keystroke pair (make/break) is generated. Then up to Rn | ||
457 | tenths of seconds later, keystroke pairs are generated every Tn tenths of | ||
458 | seconds. After the Rn breakpoint is reached, keystroke pairs are generated | ||
459 | every Vn tenths of seconds. This provides a velocity (auto-repeat) breakpoint | ||
460 | feature. | ||
461 | Note that by setting RX and/or Ry to zero, the velocity feature can be | ||
462 | disabled. The values of TX and TY then become meaningless, and the generation | ||
463 | of cursor 'keystrokes' is set by VX and VY. | ||
464 | |||
465 | 9.21 DISABLE JOYSTICKS | ||
466 | |||
467 | 0x1A | ||
468 | |||
469 | Disable the generation of any joystick events (and scanning may be internally | ||
470 | disabled). Any valid joystick mode command resumes joystick monitoring. (The | ||
471 | joystick mode commands are SET JOYSTICK EVENT REPORTING, SET JOYSTICK | ||
472 | INTERROGATION MODE, SET JOYSTICK MONITORING, SET FIRE BUTTON MONITORING, and | ||
473 | SET JOYSTICK KEYCODE MODE.) | ||
474 | |||
475 | 9.22 TIME-OF-DAY CLOCK SET | ||
476 | |||
477 | 0x1B | ||
478 | YY ; year (2 least significant digits) | ||
479 | MM ; month | ||
480 | DD ; day | ||
481 | hh ; hour | ||
482 | mm ; minute | ||
483 | ss ; second | ||
484 | |||
485 | All time-of-day data should be sent to the ikbd in packed BCD format. | ||
486 | Any digit that is not a valid BCD digit should be treated as a 'don't care' | ||
487 | and not alter that particular field of the date or time. This permits setting | ||
488 | only some subfields of the time-of-day clock. | ||
489 | |||
490 | 9.23 INTERROGATE TIME-OF-DAT CLOCK | ||
491 | |||
492 | 0x1C | ||
493 | Returns: | ||
494 | 0xFC ; time-of-day event header | ||
495 | YY ; year (2 least significant digits) | ||
496 | MM ; month | ||
497 | DD ; day | ||
498 | hh ; hour | ||
499 | mm ; minute | ||
500 | ss ; second | ||
501 | |||
502 | All time-of-day is sent in packed BCD format. | ||
503 | |||
504 | 9.24 MEMORY LOAD | ||
505 | |||
506 | 0x20 | ||
507 | ADRMSB ; address in controller | ||
508 | ADRLSB ; memory to be loaded | ||
509 | NUM ; number of bytes (0-128) | ||
510 | { data } | ||
511 | |||
512 | This command permits the host to load arbitrary values into the ikbd | ||
513 | controller memory. The time between data bytes must be less than 20ms. | ||
514 | |||
515 | 9.25 MEMORY READ | ||
516 | |||
517 | 0x21 | ||
518 | ADRMSB ; address in controller | ||
519 | ADRLSB ; memory to be read | ||
520 | Returns: | ||
521 | 0xF6 ; status header | ||
522 | 0x20 ; memory access | ||
523 | { data } ; 6 data bytes starting at ADR | ||
524 | |||
525 | This comand permits the host to read from the ikbd controller memory. | ||
526 | |||
527 | 9.26 CONTROLLER EXECUTE | ||
528 | |||
529 | 0x22 | ||
530 | ADRMSB ; address of subroutine in | ||
531 | ADRLSB ; controller memory to be called | ||
532 | |||
533 | This command allows the host to command the execution of a subroutine in the | ||
534 | ikbd controller memory. | ||
535 | |||
536 | 9.27 STATUS INQUIRIES | ||
537 | |||
538 | Status commands are formed by inclusively ORing 0x80 with the | ||
539 | relevant SET command. | ||
540 | |||
541 | Example: | ||
542 | 0x88 (or 0x89 or 0x8A) ; request mouse mode | ||
543 | Returns: | ||
544 | 0xF6 ; status response header | ||
545 | mode ; 0x08 is RELATIVE | ||
546 | ; 0x09 is ABSOLUTE | ||
547 | ; 0x0A is KEYCODE | ||
548 | param1 ; 0 is RELATIVE | ||
549 | ; XMSB maximum if ABSOLUTE | ||
550 | ; DELTA X is KEYCODE | ||
551 | param2 ; 0 is RELATIVE | ||
552 | ; YMSB maximum if ABSOLUTE | ||
553 | ; DELTA Y is KEYCODE | ||
554 | param3 ; 0 if RELATIVE | ||
555 | ; or KEYCODE | ||
556 | ; YMSB is ABSOLUTE | ||
557 | param4 ; 0 if RELATIVE | ||
558 | ; or KEYCODE | ||
559 | ; YLSB is ABSOLUTE | ||
560 | 0 ; pad | ||
561 | 0 | ||
562 | |||
563 | The STATUS INQUIRY commands request the ikbd to return either the current mode | ||
564 | or the parameters associated with a given command. All status reports are | ||
565 | padded to form 8 byte long return packets. The responses to the status | ||
566 | requests are designed so that the host may store them away (after stripping | ||
567 | off the status report header byte) and later send them back as commands to | ||
568 | ikbd to restore its state. The 0 pad bytes will be treated as NOPs by the | ||
569 | ikbd. | ||
570 | |||
571 | Valid STATUS INQUIRY commands are: | ||
572 | |||
573 | 0x87 mouse button action | ||
574 | 0x88 mouse mode | ||
575 | 0x89 | ||
576 | 0x8A | ||
577 | 0x8B mnouse threshold | ||
578 | 0x8C mouse scale | ||
579 | 0x8F mouse vertical coordinates | ||
580 | 0x90 ( returns 0x0F Y=0 at bottom | ||
581 | 0x10 Y=0 at top ) | ||
582 | 0x92 mouse enable/disable | ||
583 | ( returns 0x00 enabled) | ||
584 | 0x12 disabled ) | ||
585 | 0x94 joystick mode | ||
586 | 0x95 | ||
587 | 0x96 | ||
588 | 0x9A joystick enable/disable | ||
589 | ( returns 0x00 enabled | ||
590 | 0x1A disabled ) | ||
591 | |||
592 | It is the (host) programmer's responsibility to have only one unanswered | ||
593 | inquiry in process at a time. | ||
594 | STATUS INQUIRY commands are not valid if the ikbd is in JOYSTICK MONITORING | ||
595 | mode or FIRE BUTTON MONITORING mode. | ||
596 | |||
597 | |||
598 | 10. SCAN CODES | ||
599 | |||
600 | The key scan codes return by the ikbd are chosen to simplify the | ||
601 | implementaion of GSX. | ||
602 | |||
603 | GSX Standard Keyboard Mapping. | ||
604 | |||
605 | Hex Keytop | ||
606 | 01 Esc | ||
607 | 02 1 | ||
608 | 03 2 | ||
609 | 04 3 | ||
610 | 05 4 | ||
611 | 06 5 | ||
612 | 07 6 | ||
613 | 08 7 | ||
614 | 09 8 | ||
615 | 0A 9 | ||
616 | 0B 0 | ||
617 | 0C - | ||
618 | 0D == | ||
619 | 0E BS | ||
620 | 0F TAB | ||
621 | 10 Q | ||
622 | 11 W | ||
623 | 12 E | ||
624 | 13 R | ||
625 | 14 T | ||
626 | 15 Y | ||
627 | 16 U | ||
628 | 17 I | ||
629 | 18 O | ||
630 | 19 P | ||
631 | 1A [ | ||
632 | 1B ] | ||
633 | 1C RET | ||
634 | 1D CTRL | ||
635 | 1E A | ||
636 | 1F S | ||
637 | 20 D | ||
638 | 21 F | ||
639 | 22 G | ||
640 | 23 H | ||
641 | 24 J | ||
642 | 25 K | ||
643 | 26 L | ||
644 | 27 ; | ||
645 | 28 ' | ||
646 | 29 ` | ||
647 | 2A (LEFT) SHIFT | ||
648 | 2B \ | ||
649 | 2C Z | ||
650 | 2D X | ||
651 | 2E C | ||
652 | 2F V | ||
653 | 30 B | ||
654 | 31 N | ||
655 | 32 M | ||
656 | 33 , | ||
657 | 34 . | ||
658 | 35 / | ||
659 | 36 (RIGHT) SHIFT | ||
660 | 37 { NOT USED } | ||
661 | 38 ALT | ||
662 | 39 SPACE BAR | ||
663 | 3A CAPS LOCK | ||
664 | 3B F1 | ||
665 | 3C F2 | ||
666 | 3D F3 | ||
667 | 3E F4 | ||
668 | 3F F5 | ||
669 | 40 F6 | ||
670 | 41 F7 | ||
671 | 42 F8 | ||
672 | 43 F9 | ||
673 | 44 F10 | ||
674 | 45 { NOT USED } | ||
675 | 46 { NOT USED } | ||
676 | 47 HOME | ||
677 | 48 UP ARROW | ||
678 | 49 { NOT USED } | ||
679 | 4A KEYPAD - | ||
680 | 4B LEFT ARROW | ||
681 | 4C { NOT USED } | ||
682 | 4D RIGHT ARROW | ||
683 | 4E KEYPAD + | ||
684 | 4F { NOT USED } | ||
685 | 50 DOWN ARROW | ||
686 | 51 { NOT USED } | ||
687 | 52 INSERT | ||
688 | 53 DEL | ||
689 | 54 { NOT USED } | ||
690 | 5F { NOT USED } | ||
691 | 60 ISO KEY | ||
692 | 61 UNDO | ||
693 | 62 HELP | ||
694 | 63 KEYPAD ( | ||
695 | 64 KEYPAD / | ||
696 | 65 KEYPAD * | ||
697 | 66 KEYPAD * | ||
698 | 67 KEYPAD 7 | ||
699 | 68 KEYPAD 8 | ||
700 | 69 KEYPAD 9 | ||
701 | 6A KEYPAD 4 | ||
702 | 6B KEYPAD 5 | ||
703 | 6C KEYPAD 6 | ||
704 | 6D KEYPAD 1 | ||
705 | 6E KEYPAD 2 | ||
706 | 6F KEYPAD 3 | ||
707 | 70 KEYPAD 0 | ||
708 | 71 KEYPAD . | ||
709 | 72 KEYPAD ENTER | ||
diff --git a/Documentation/input/cd32.txt b/Documentation/input/cd32.txt new file mode 100644 index 000000000000..a003d9b41eca --- /dev/null +++ b/Documentation/input/cd32.txt | |||
@@ -0,0 +1,19 @@ | |||
1 | I have written a small patch that let's me use my Amiga CD32 | ||
2 | joypad connected to the parallel port. Thought I'd share it with you so | ||
3 | you can add it to the list of supported joysticks (hopefully someone will | ||
4 | find it useful). | ||
5 | |||
6 | It needs the following wiring: | ||
7 | |||
8 | CD32 pad | Parallel port | ||
9 | ---------------------------- | ||
10 | 1 (Up) | 2 (D0) | ||
11 | 2 (Down) | 3 (D1) | ||
12 | 3 (Left) | 4 (D2) | ||
13 | 4 (Right) | 5 (D3) | ||
14 | 5 (Fire3) | 14 (AUTOFD) | ||
15 | 6 (Fire1) | 17 (SELIN) | ||
16 | 7 (+5V) | 1 (STROBE) | ||
17 | 8 (Gnd) | 18 (Gnd) | ||
18 | 9 (Fire2) | 7 (D5) | ||
19 | |||
diff --git a/Documentation/input/cs461x.txt b/Documentation/input/cs461x.txt new file mode 100644 index 000000000000..6181747a14d8 --- /dev/null +++ b/Documentation/input/cs461x.txt | |||
@@ -0,0 +1,45 @@ | |||
1 | Preface. | ||
2 | |||
3 | This is a new low-level driver to support analog joystick attached to | ||
4 | Crystal SoundFusion CS4610/CS4612/CS4615. This code is based upon | ||
5 | Vortex/Solo drivers as an example of decoration style, and ALSA | ||
6 | 0.5.8a kernel drivers as an chipset documentation and samples. | ||
7 | |||
8 | This version does not have cooked mode support; the basic code | ||
9 | is present here, but have not tested completely. The button analysis | ||
10 | is completed in this mode, but the axis movement is not. | ||
11 | |||
12 | Raw mode works fine with analog joystick front-end driver and cs461x | ||
13 | driver as a backend. I've tested this driver with CS4610, 4-axis and | ||
14 | 4-button joystick; I mean the jstest utility. Also I've tried to | ||
15 | play in xracer game using joystick, and the result is better than | ||
16 | keyboard only mode. | ||
17 | |||
18 | The sensitivity and calibrate quality have not been tested; the two | ||
19 | reasons are performed: the same hardware cannot work under Win95 (blue | ||
20 | screen in VJOYD); I have no documentation on my chip; and the existing | ||
21 | behavior in my case was not raised the requirement of joystick calibration. | ||
22 | So the driver have no code to perform hardware related calibration. | ||
23 | |||
24 | The patch contains minor changes of Config.in and Makefile files. All | ||
25 | needed code have been moved to one separate file cs461x.c like ns558.c | ||
26 | This driver have the basic support for PCI devices only; there is no | ||
27 | ISA or PnP ISA cards supported. AFAIK the ns558 have support for Crystal | ||
28 | ISA and PnP ISA series. | ||
29 | |||
30 | The driver works witn ALSA drivers simultaneously. For exmple, the xracer | ||
31 | uses joystick as input device and PCM device as sound output in one time. | ||
32 | There are no sound or input collisions detected. The source code have | ||
33 | comments about them; but I've found the joystick can be initialized | ||
34 | separately of ALSA modules. So, you canm use only one joystick driver | ||
35 | without ALSA drivers. The ALSA drivers are not needed to compile or | ||
36 | run this driver. | ||
37 | |||
38 | There are no debug information print have been placed in source, and no | ||
39 | specific options required to work this driver. The found chipset parameters | ||
40 | are printed via printk(KERN_INFO "..."), see the /var/log/messages to | ||
41 | inspect cs461x: prefixed messages to determine possible card detection | ||
42 | errors. | ||
43 | |||
44 | Regards, | ||
45 | Viktor | ||
diff --git a/Documentation/input/ff.txt b/Documentation/input/ff.txt new file mode 100644 index 000000000000..efa7dd6751f3 --- /dev/null +++ b/Documentation/input/ff.txt | |||
@@ -0,0 +1,227 @@ | |||
1 | Force feedback for Linux. | ||
2 | By Johann Deneux <deneux@ifrance.com> on 2001/04/22. | ||
3 | You may redistribute this file. Please remember to include shape.fig and | ||
4 | interactive.fig as well. | ||
5 | ---------------------------------------------------------------------------- | ||
6 | |||
7 | 0. Introduction | ||
8 | ~~~~~~~~~~~~~~~ | ||
9 | This document describes how to use force feedback devices under Linux. The | ||
10 | goal is not to support these devices as if they were simple input-only devices | ||
11 | (as it is already the case), but to really enable the rendering of force | ||
12 | effects. | ||
13 | At the moment, only I-Force devices are supported, and not officially. That | ||
14 | means I had to find out how the protocol works on my own. Of course, the | ||
15 | information I managed to grasp is far from being complete, and I can not | ||
16 | guarranty that this driver will work for you. | ||
17 | This document only describes the force feedback part of the driver for I-Force | ||
18 | devices. Please read joystick.txt before reading further this document. | ||
19 | |||
20 | 2. Instructions to the user | ||
21 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
22 | Here are instructions on how to compile and use the driver. In fact, this | ||
23 | driver is the normal iforce, input and evdev drivers written by Vojtech | ||
24 | Pavlik, plus additions to support force feedback. | ||
25 | |||
26 | Before you start, let me WARN you that some devices shake violently during the | ||
27 | initialisation phase. This happens for example with my "AVB Top Shot Pegasus". | ||
28 | To stop this annoying behaviour, move you joystick to its limits. Anyway, you | ||
29 | should keep a hand on your device, in order to avoid it to brake down if | ||
30 | something goes wrong. | ||
31 | |||
32 | At the kernel's compilation: | ||
33 | - Enable IForce/Serial | ||
34 | - Enable Event interface | ||
35 | |||
36 | Compile the modules, install them. | ||
37 | |||
38 | You also need inputattach. | ||
39 | |||
40 | You then need to insert the modules into the following order: | ||
41 | % modprobe joydev | ||
42 | % modprobe serport # Only for serial | ||
43 | % modprobe iforce | ||
44 | % modprobe evdev | ||
45 | % ./inputattach -ifor $2 & # Only for serial | ||
46 | If you are using USB, you don't need the inputattach step. | ||
47 | |||
48 | Please check that you have all the /dev/input entries needed: | ||
49 | cd /dev | ||
50 | rm js* | ||
51 | mkdir input | ||
52 | mknod input/js0 c 13 0 | ||
53 | mknod input/js1 c 13 1 | ||
54 | mknod input/js2 c 13 2 | ||
55 | mknod input/js3 c 13 3 | ||
56 | ln -s input/js0 js0 | ||
57 | ln -s input/js1 js1 | ||
58 | ln -s input/js2 js2 | ||
59 | ln -s input/js3 js3 | ||
60 | |||
61 | mknod input/event0 c 13 64 | ||
62 | mknod input/event1 c 13 65 | ||
63 | mknod input/event2 c 13 66 | ||
64 | mknod input/event3 c 13 67 | ||
65 | |||
66 | 2.1 Does it work ? | ||
67 | ~~~~~~~~~~~~~~~~~~ | ||
68 | There is an utility called fftest that will allow you to test the driver. | ||
69 | % fftest /dev/input/eventXX | ||
70 | |||
71 | 3. Instructions to the developper | ||
72 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
73 | All interactions are done using the event API. That is, you can use ioctl() | ||
74 | and write() on /dev/input/eventXX. | ||
75 | This information is subject to change. | ||
76 | |||
77 | 3.1 Querying device capabilities | ||
78 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
79 | #include <linux/input.h> | ||
80 | #include <sys/ioctl.h> | ||
81 | |||
82 | unsigned long features[1 + FF_MAX/sizeof(unsigned long)]; | ||
83 | int ioctl(int file_descriptor, int request, unsigned long *features); | ||
84 | |||
85 | "request" must be EVIOCGBIT(EV_FF, size of features array in bytes ) | ||
86 | |||
87 | Returns the features supported by the device. features is a bitfield with the | ||
88 | following bits: | ||
89 | - FF_X has an X axis (usually joysticks) | ||
90 | - FF_Y has an Y axis (usually joysticks) | ||
91 | - FF_WHEEL has a wheel (usually sterring wheels) | ||
92 | - FF_CONSTANT can render constant force effects | ||
93 | - FF_PERIODIC can render periodic effects (sine, triangle, square...) | ||
94 | - FF_RAMP can render ramp effects | ||
95 | - FF_SPRING can simulate the presence of a spring | ||
96 | - FF_FRICTION can simulate friction | ||
97 | - FF_DAMPER can simulate damper effects | ||
98 | - FF_RUMBLE rumble effects (normally the only effect supported by rumble | ||
99 | pads) | ||
100 | - FF_INERTIA can simulate inertia | ||
101 | |||
102 | |||
103 | int ioctl(int fd, EVIOCGEFFECTS, int *n); | ||
104 | |||
105 | Returns the number of effects the device can keep in its memory. | ||
106 | |||
107 | 3.2 Uploading effects to the device | ||
108 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
109 | #include <linux/input.h> | ||
110 | #include <sys/ioctl.h> | ||
111 | |||
112 | int ioctl(int file_descriptor, int request, struct ff_effect *effect); | ||
113 | |||
114 | "request" must be EVIOCSFF. | ||
115 | |||
116 | "effect" points to a structure describing the effect to upload. The effect is | ||
117 | uploaded, but not played. | ||
118 | The content of effect may be modified. In particular, its field "id" is set | ||
119 | to the unique id assigned by the driver. This data is required for performing | ||
120 | some operations (removing an effect, controlling the playback). | ||
121 | This if field must be set to -1 by the user in order to tell the driver to | ||
122 | allocate a new effect. | ||
123 | See <linux/input.h> for a description of the ff_effect stuct. You should also | ||
124 | find help in a few sketches, contained in files shape.fig and interactive.fig. | ||
125 | You need xfig to visualize these files. | ||
126 | |||
127 | 3.3 Removing an effect from the device | ||
128 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
129 | int ioctl(int fd, EVIOCRMFF, effect.id); | ||
130 | |||
131 | This makes room for new effects in the device's memory. Please note this won't | ||
132 | stop the effect if it was playing. | ||
133 | |||
134 | 3.4 Controlling the playback of effects | ||
135 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
136 | Control of playing is done with write(). Below is an example: | ||
137 | |||
138 | #include <linux/input.h> | ||
139 | #include <unistd.h> | ||
140 | |||
141 | struct input_event play; | ||
142 | struct input_event stop; | ||
143 | struct ff_effect effect; | ||
144 | int fd; | ||
145 | ... | ||
146 | fd = open("/dev/input/eventXX", O_RDWR); | ||
147 | ... | ||
148 | /* Play three times */ | ||
149 | play.type = EV_FF; | ||
150 | play.code = effect.id; | ||
151 | play.value = 3; | ||
152 | |||
153 | write(fd, (const void*) &play, sizeof(play)); | ||
154 | ... | ||
155 | /* Stop an effect */ | ||
156 | stop.type = EV_FF; | ||
157 | stop.code = effect.id; | ||
158 | stop.value = 0; | ||
159 | |||
160 | write(fd, (const void*) &play, sizeof(stop)); | ||
161 | |||
162 | 3.5 Setting the gain | ||
163 | ~~~~~~~~~~~~~~~~~~~~ | ||
164 | Not all devices have the same strength. Therefore, users should set a gain | ||
165 | factor depending on how strong they want effects to be. This setting is | ||
166 | persistent across access to the driver, so you should not care about it if | ||
167 | you are writing games, as another utility probably already set this for you. | ||
168 | |||
169 | /* Set the gain of the device | ||
170 | int gain; /* between 0 and 100 */ | ||
171 | struct input_event ie; /* structure used to communicate with the driver */ | ||
172 | |||
173 | ie.type = EV_FF; | ||
174 | ie.code = FF_GAIN; | ||
175 | ie.value = 0xFFFFUL * gain / 100; | ||
176 | |||
177 | if (write(fd, &ie, sizeof(ie)) == -1) | ||
178 | perror("set gain"); | ||
179 | |||
180 | 3.6 Enabling/Disabling autocenter | ||
181 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
182 | The autocenter feature quite disturbs the rendering of effects in my opinion, | ||
183 | and I think it should be an effect, which computation depends on the game | ||
184 | type. But you can enable it if you want. | ||
185 | |||
186 | int autocenter; /* between 0 and 100 */ | ||
187 | struct input_event ie; | ||
188 | |||
189 | ie.type = EV_FF; | ||
190 | ie.code = FF_AUTOCENTER; | ||
191 | ie.value = 0xFFFFUL * autocenter / 100; | ||
192 | |||
193 | if (write(fd, &ie, sizeof(ie)) == -1) | ||
194 | perror("set auto-center"); | ||
195 | |||
196 | A value of 0 means "no auto-center". | ||
197 | |||
198 | 3.7 Dynamic update of an effect | ||
199 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
200 | Proceed as if you wanted to upload a new effect, except that instead of | ||
201 | setting the id field to -1, you set it to the wanted effect id. | ||
202 | Normally, the effect is not stopped and restarted. However, depending on the | ||
203 | type of device, not all parameters can be dynamically updated. For example, | ||
204 | the direction of an effect cannot be updated with iforce devices. In this | ||
205 | case, the driver stops the effect, up-load it, and restart it. | ||
206 | |||
207 | |||
208 | 3.8 Information about the status of effects | ||
209 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
210 | Every time the status of an effect is changed, an event is sent. The values | ||
211 | and meanings of the fields of the event are as follows: | ||
212 | struct input_event { | ||
213 | /* When the status of the effect changed */ | ||
214 | struct timeval time; | ||
215 | |||
216 | /* Set to EV_FF_STATUS */ | ||
217 | unsigned short type; | ||
218 | |||
219 | /* Contains the id of the effect */ | ||
220 | unsigned short code; | ||
221 | |||
222 | /* Indicates the status */ | ||
223 | unsigned int value; | ||
224 | }; | ||
225 | |||
226 | FF_STATUS_STOPPED The effect stopped playing | ||
227 | FF_STATUS_PLAYING The effect started to play | ||
diff --git a/Documentation/input/gameport-programming.txt b/Documentation/input/gameport-programming.txt new file mode 100644 index 000000000000..1ba3d322e0ac --- /dev/null +++ b/Documentation/input/gameport-programming.txt | |||
@@ -0,0 +1,189 @@ | |||
1 | $Id: gameport-programming.txt,v 1.3 2001/04/24 13:51:37 vojtech Exp $ | ||
2 | |||
3 | Programming gameport drivers | ||
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
5 | |||
6 | 1. A basic classic gameport | ||
7 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
8 | |||
9 | If the gameport doesn't provide more than the inb()/outb() functionality, | ||
10 | the code needed to register it with the joystick drivers is simple: | ||
11 | |||
12 | struct gameport gameport; | ||
13 | |||
14 | gameport.io = MY_IO_ADDRESS; | ||
15 | gameport_register_port(&gameport); | ||
16 | |||
17 | Make sure struct gameport is initialized to 0 in all other fields. The | ||
18 | gameport generic code will take care of the rest. | ||
19 | |||
20 | If your hardware supports more than one io address, and your driver can | ||
21 | choose which one program the hardware to, starting from the more exotic | ||
22 | addresses is preferred, because the likelyhood of clashing with the standard | ||
23 | 0x201 address is smaller. | ||
24 | |||
25 | Eg. if your driver supports addresses 0x200, 0x208, 0x210 and 0x218, then | ||
26 | 0x218 would be the address of first choice. | ||
27 | |||
28 | If your hardware supports a gameport address that is not mapped to ISA io | ||
29 | space (is above 0x1000), use that one, and don't map the ISA mirror. | ||
30 | |||
31 | Also, always request_region() on the whole io space occupied by the | ||
32 | gameport. Although only one ioport is really used, the gameport usually | ||
33 | occupies from one to sixteen addresses in the io space. | ||
34 | |||
35 | Please also consider enabling the gameport on the card in the ->open() | ||
36 | callback if the io is mapped to ISA space - this way it'll occupy the io | ||
37 | space only when something really is using it. Disable it again in the | ||
38 | ->close() callback. You also can select the io address in the ->open() | ||
39 | callback, so that it doesn't fail if some of the possible addresses are | ||
40 | already occupied by other gameports. | ||
41 | |||
42 | 2. Memory mapped gameport | ||
43 | ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
44 | |||
45 | When a gameport can be accessed through MMIO, this way is preferred, because | ||
46 | it is faster, allowing more reads per second. Registering such a gameport | ||
47 | isn't as easy as a basic IO one, but not so much complex: | ||
48 | |||
49 | struct gameport gameport; | ||
50 | |||
51 | void my_trigger(struct gameport *gameport) | ||
52 | { | ||
53 | my_mmio = 0xff; | ||
54 | } | ||
55 | |||
56 | unsigned char my_read(struct gameport *gameport) | ||
57 | { | ||
58 | return my_mmio; | ||
59 | } | ||
60 | |||
61 | gameport.read = my_read; | ||
62 | gameport.trigger = my_trigger; | ||
63 | gameport_register_port(&gameport); | ||
64 | |||
65 | 3. Cooked mode gameport | ||
66 | ~~~~~~~~~~~~~~~~~~~~~~~ | ||
67 | |||
68 | There are gameports that can report the axis values as numbers, that means | ||
69 | the driver doesn't have to measure them the old way - an ADC is built into | ||
70 | the gameport. To register a cooked gameport: | ||
71 | |||
72 | struct gameport gameport; | ||
73 | |||
74 | int my_cooked_read(struct gameport *gameport, int *axes, int *buttons) | ||
75 | { | ||
76 | int i; | ||
77 | |||
78 | for (i = 0; i < 4; i++) | ||
79 | axes[i] = my_mmio[i]; | ||
80 | buttons[i] = my_mmio[4]; | ||
81 | } | ||
82 | |||
83 | int my_open(struct gameport *gameport, int mode) | ||
84 | { | ||
85 | return -(mode != GAMEPORT_MODE_COOKED); | ||
86 | } | ||
87 | |||
88 | gameport.cooked_read = my_cooked_read; | ||
89 | gameport.open = my_open; | ||
90 | gameport.fuzz = 8; | ||
91 | gameport_register_port(&gameport); | ||
92 | |||
93 | The only confusing thing here is the fuzz value. Best determined by | ||
94 | experimentation, it is the amount of noise in the ADC data. Perfect | ||
95 | gameports can set this to zero, most common have fuzz between 8 and 32. | ||
96 | See analog.c and input.c for handling of fuzz - the fuzz value determines | ||
97 | the size of a gaussian filter window that is used to eliminate the noise | ||
98 | in the data. | ||
99 | |||
100 | 4. More complex gameports | ||
101 | ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
102 | |||
103 | Gameports can support both raw and cooked modes. In that case combine either | ||
104 | examples 1+2 or 1+3. Gameports can support internal calibration - see below, | ||
105 | and also lightning.c and analog.c on how that works. If your driver supports | ||
106 | more than one gameport instance simultaneously, use the ->private member of | ||
107 | the gameport struct to point to your data. | ||
108 | |||
109 | 5. Unregistering a gameport | ||
110 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
111 | |||
112 | Simple: | ||
113 | |||
114 | gameport_unregister_port(&gameport); | ||
115 | |||
116 | 6. The gameport structure | ||
117 | ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
118 | |||
119 | struct gameport { | ||
120 | |||
121 | void *private; | ||
122 | |||
123 | A private pointer for free use in the gameport driver. (Not the joystick | ||
124 | driver!) | ||
125 | |||
126 | int number; | ||
127 | |||
128 | Number assigned to the gameport when registered. Informational purpose only. | ||
129 | |||
130 | int io; | ||
131 | |||
132 | I/O address for use with raw mode. You have to either set this, or ->read() | ||
133 | to some value if your gameport supports raw mode. | ||
134 | |||
135 | int speed; | ||
136 | |||
137 | Raw mode speed of the gameport reads in thousands of reads per second. | ||
138 | |||
139 | int fuzz; | ||
140 | |||
141 | If the gameport supports cooked mode, this should be set to a value that | ||
142 | represents the amount of noise in the data. See section 3. | ||
143 | |||
144 | void (*trigger)(struct gameport *); | ||
145 | |||
146 | Trigger. This function should trigger the ns558 oneshots. If set to NULL, | ||
147 | outb(0xff, io) will be used. | ||
148 | |||
149 | unsigned char (*read)(struct gameport *); | ||
150 | |||
151 | Read the buttons and ns558 oneshot bits. If set to NULL, inb(io) will be | ||
152 | used instead. | ||
153 | |||
154 | int (*cooked_read)(struct gameport *, int *axes, int *buttons); | ||
155 | |||
156 | If the gameport supports cooked mode, it should point this to its cooked | ||
157 | read function. It should fill axes[0..3] with four values of the joystick axes | ||
158 | and buttons[0] with four bits representing the buttons. | ||
159 | |||
160 | int (*calibrate)(struct gameport *, int *axes, int *max); | ||
161 | |||
162 | Function for calibrating the ADC hardware. When called, axes[0..3] should be | ||
163 | pre-filled by cooked data by the caller, max[0..3] should be pre-filled with | ||
164 | expected maximums for each axis. The calibrate() function should set the | ||
165 | sensitivity of the ADC hardware so that the maximums fit in its range and | ||
166 | recompute the axes[] values to match the new sensitivity or re-read them from | ||
167 | the hardware so that they give valid values. | ||
168 | |||
169 | int (*open)(struct gameport *, int mode); | ||
170 | |||
171 | Open() serves two purposes. First a driver either opens the port in raw or | ||
172 | in cooked mode, the open() callback can decide which modes are supported. | ||
173 | Second, resource allocation can happen here. The port can also be enabled | ||
174 | here. Prior to this call, other fields of the gameport struct (namely the io | ||
175 | member) need not to be valid. | ||
176 | |||
177 | void (*close)(struct gameport *); | ||
178 | |||
179 | Close() should free the resources allocated by open, possibly disabling the | ||
180 | gameport. | ||
181 | |||
182 | struct gameport_dev *dev; | ||
183 | struct gameport *next; | ||
184 | |||
185 | For internal use by the gameport layer. | ||
186 | |||
187 | }; | ||
188 | |||
189 | Enjoy! | ||
diff --git a/Documentation/input/iforce-protocol.txt b/Documentation/input/iforce-protocol.txt new file mode 100644 index 000000000000..95df4ca70e71 --- /dev/null +++ b/Documentation/input/iforce-protocol.txt | |||
@@ -0,0 +1,254 @@ | |||
1 | ** Introduction | ||
2 | This document describes what I managed to discover about the protocol used to | ||
3 | specify force effects to I-Force 2.0 devices. None of this information comes | ||
4 | from Immerse. That's why you should not trust what is written in this | ||
5 | document. This document is intended to help understanding the protocol. | ||
6 | This is not a reference. Comments and corrections are welcome. To contact me, | ||
7 | send an email to: deneux@ifrance.com | ||
8 | |||
9 | ** WARNING ** | ||
10 | I may not be held responsible for any dammage or harm caused if you try to | ||
11 | send data to your I-Force device based on what you read in this document. | ||
12 | |||
13 | ** Preliminary Notes: | ||
14 | All values are hexadecimal with big-endian encoding (msb on the left). Beware, | ||
15 | values inside packets are encoded using little-endian. Bytes whose roles are | ||
16 | unknown are marked ??? Information that needs deeper inspection is marked (?) | ||
17 | |||
18 | ** General form of a packet ** | ||
19 | This is how packets look when the device uses the rs232 to communicate. | ||
20 | 2B OP LEN DATA CS | ||
21 | CS is the checksum. It is equal to the exclusive or of all bytes. | ||
22 | |||
23 | When using USB: | ||
24 | OP DATA | ||
25 | The 2B, LEN and CS fields have disappeared, probably because USB handles frames and | ||
26 | data corruption is handled or unsignificant. | ||
27 | |||
28 | First, I describe effects that are sent by the device to the computer | ||
29 | |||
30 | ** Device input state | ||
31 | This packet is used to indicate the state of each button and the value of each | ||
32 | axis | ||
33 | OP= 01 for a joystick, 03 for a wheel | ||
34 | LEN= Varies from device to device | ||
35 | 00 X-Axis lsb | ||
36 | 01 X-Axis msb | ||
37 | 02 Y-Axis lsb, or gas pedal for a wheel | ||
38 | 03 Y-Axis msb, or brake pedal for a wheel | ||
39 | 04 Throttle | ||
40 | 05 Buttons | ||
41 | 06 Lower 4 bits: Buttons | ||
42 | Upper 4 bits: Hat | ||
43 | 07 Rudder | ||
44 | |||
45 | ** Device effects states | ||
46 | OP= 02 | ||
47 | LEN= Varies | ||
48 | 00 ? Bit 1 (Value 2) is the value of the deadman switch | ||
49 | 01 Bit 8 is set if the effect is playing. Bits 0 to 7 are the effect id. | ||
50 | 02 ?? | ||
51 | 03 Address of parameter block changed (lsb) | ||
52 | 04 Address of parameter block changed (msb) | ||
53 | 05 Address of second parameter block changed (lsb) | ||
54 | ... depending on the number of parameter blocks updated | ||
55 | |||
56 | ** Force effect ** | ||
57 | OP= 01 | ||
58 | LEN= 0e | ||
59 | 00 Channel (when playing several effects at the same time, each must be assigned a channel) | ||
60 | 01 Wave form | ||
61 | Val 00 Constant | ||
62 | Val 20 Square | ||
63 | Val 21 Triangle | ||
64 | Val 22 Sine | ||
65 | Val 23 Sawtooth up | ||
66 | Val 24 Sawtooth down | ||
67 | Val 40 Spring (Force = f(pos)) | ||
68 | Val 41 Friction (Force = f(velocity)) and Inertia (Force = f(acceleration)) | ||
69 | |||
70 | |||
71 | 02 Axes affected and trigger | ||
72 | Bits 4-7: Val 2 = effect along one axis. Byte 05 indicates direction | ||
73 | Val 4 = X axis only. Byte 05 must contain 5a | ||
74 | Val 8 = Y axis only. Byte 05 must contain b4 | ||
75 | Val c = X and Y axes. Bytes 05 must contain 60 | ||
76 | Bits 0-3: Val 0 = No trigger | ||
77 | Val x+1 = Button x triggers the effect | ||
78 | When the whole byte is 0, cancel the previously set trigger | ||
79 | |||
80 | 03-04 Duration of effect (little endian encoding, in ms) | ||
81 | |||
82 | 05 Direction of effect, if applicable. Else, see 02 for value to assign. | ||
83 | |||
84 | 06-07 Minimum time between triggering. | ||
85 | |||
86 | 08-09 Address of periodicity or magnitude parameters | ||
87 | 0a-0b Address of attack and fade parameters, or ffff if none. | ||
88 | *or* | ||
89 | 08-09 Address of interactive parameters for X-axis, or ffff if not applicable | ||
90 | 0a-0b Address of interactive parameters for Y-axis, or ffff if not applicable | ||
91 | |||
92 | 0c-0d Delay before execution of effect (little endian encoding, in ms) | ||
93 | |||
94 | |||
95 | ** Time based parameters ** | ||
96 | |||
97 | *** Attack and fade *** | ||
98 | OP= 02 | ||
99 | LEN= 08 | ||
100 | 00-01 Address where to store the parameteres | ||
101 | 02-03 Duration of attack (little endian encoding, in ms) | ||
102 | 04 Level at end of attack. Signed byte. | ||
103 | 05-06 Duration of fade. | ||
104 | 07 Level at end of fade. | ||
105 | |||
106 | *** Magnitude *** | ||
107 | OP= 03 | ||
108 | LEN= 03 | ||
109 | 00-01 Address | ||
110 | 02 Level. Signed byte. | ||
111 | |||
112 | *** Periodicity *** | ||
113 | OP= 04 | ||
114 | LEN= 07 | ||
115 | 00-01 Address | ||
116 | 02 Magnitude. Signed byte. | ||
117 | 03 Offset. Signed byte. | ||
118 | 04 Phase. Val 00 = 0 deg, Val 40 = 90 degs. | ||
119 | 05-06 Period (little endian encoding, in ms) | ||
120 | |||
121 | ** Interactive parameters ** | ||
122 | OP= 05 | ||
123 | LEN= 0a | ||
124 | 00-01 Address | ||
125 | 02 Positive Coeff | ||
126 | 03 Negative Coeff | ||
127 | 04+05 Offset (center) | ||
128 | 06+07 Dead band (Val 01F4 = 5000 (decimal)) | ||
129 | 08 Positive saturation (Val 0a = 1000 (decimal) Val 64 = 10000 (decimal)) | ||
130 | 09 Negative saturation | ||
131 | |||
132 | The encoding is a bit funny here: For coeffs, these are signed values. The | ||
133 | maximum value is 64 (100 decimal), the min is 9c. | ||
134 | For the offset, the minimum value is FE0C, the maximum value is 01F4. | ||
135 | For the deadband, the minimum value is 0, the max is 03E8. | ||
136 | |||
137 | ** Controls ** | ||
138 | OP= 41 | ||
139 | LEN= 03 | ||
140 | 00 Channel | ||
141 | 01 Start/Stop | ||
142 | Val 00: Stop | ||
143 | Val 01: Start and play once. | ||
144 | Val 41: Start and play n times (See byte 02 below) | ||
145 | 02 Number of iterations n. | ||
146 | |||
147 | ** Init ** | ||
148 | |||
149 | *** Querying features *** | ||
150 | OP= ff | ||
151 | Query command. Length varies according to the query type. | ||
152 | The general format of this packet is: | ||
153 | ff 01 QUERY [INDEX] CHECKSUM | ||
154 | reponses are of the same form: | ||
155 | FF LEN QUERY VALUE_QUERIED CHECKSUM2 | ||
156 | where LEN = 1 + length(VALUE_QUERIED) | ||
157 | |||
158 | **** Query ram size **** | ||
159 | QUERY = 42 ('B'uffer size) | ||
160 | The device should reply with the same packet plus two additionnal bytes | ||
161 | containing the size of the memory: | ||
162 | ff 03 42 03 e8 CS would mean that the device has 1000 bytes of ram available. | ||
163 | |||
164 | **** Query number of effects **** | ||
165 | QUERY = 4e ('N'umber of effects) | ||
166 | The device should respond by sending the number of effects that can be played | ||
167 | at the same time (one byte) | ||
168 | ff 02 4e 14 CS would stand for 20 effects. | ||
169 | |||
170 | **** Vendor's id **** | ||
171 | QUERY = 4d ('M'anufacturer) | ||
172 | Query the vendors'id (2 bytes) | ||
173 | |||
174 | **** Product id ***** | ||
175 | QUERY = 50 ('P'roduct) | ||
176 | Query the product id (2 bytes) | ||
177 | |||
178 | **** Open device **** | ||
179 | QUERY = 4f ('O'pen) | ||
180 | No data returned. | ||
181 | |||
182 | **** Close device ***** | ||
183 | QUERY = 43 ('C')lose | ||
184 | No data returned. | ||
185 | |||
186 | **** Query effect **** | ||
187 | QUERY = 45 ('E') | ||
188 | Send effect type. | ||
189 | Returns nonzero if supported (2 bytes) | ||
190 | |||
191 | **** Firmware Version **** | ||
192 | QUERY = 56 ('V'ersion) | ||
193 | Sends back 3 bytes - major, minor, subminor | ||
194 | |||
195 | *** Initialisation of the device *** | ||
196 | |||
197 | **** Set Control **** | ||
198 | !!! Device dependent, can be different on different models !!! | ||
199 | OP= 40 <idx> <val> [<val>] | ||
200 | LEN= 2 or 3 | ||
201 | 00 Idx | ||
202 | Idx 00 Set dead zone (0..2048) | ||
203 | Idx 01 Ignore Deadman sensor (0..1) | ||
204 | Idx 02 Enable comm watchdog (0..1) | ||
205 | Idx 03 Set the strength of the spring (0..100) | ||
206 | Idx 04 Enable or disable the spring (0/1) | ||
207 | Idx 05 Set axis saturation threshold (0..2048) | ||
208 | |||
209 | **** Set Effect State **** | ||
210 | OP= 42 <val> | ||
211 | LEN= 1 | ||
212 | 00 State | ||
213 | Bit 3 Pause force feedback | ||
214 | Bit 2 Enable force feedback | ||
215 | Bit 0 Stop all effects | ||
216 | |||
217 | **** Set overall gain **** | ||
218 | OP= 43 <val> | ||
219 | LEN= 1 | ||
220 | 00 Gain | ||
221 | Val 00 = 0% | ||
222 | Val 40 = 50% | ||
223 | Val 80 = 100% | ||
224 | |||
225 | ** Parameter memory ** | ||
226 | |||
227 | Each device has a certain amount of memory to store parameters of effects. | ||
228 | The amount of RAM may vary, I encountered values from 200 to 1000 bytes. Below | ||
229 | is the amount of memory apparently needed for every set of parameters: | ||
230 | - period : 0c | ||
231 | - magnitude : 02 | ||
232 | - attack and fade : 0e | ||
233 | - interactive : 08 | ||
234 | |||
235 | ** Appendix: How to study the protocol ? ** | ||
236 | |||
237 | 1. Generate effects using the force editor provided with the DirectX SDK, or use Immersion Studio (freely available at their web site in the developer section: www.immersion.com) | ||
238 | 2. Start a soft spying RS232 or USB (depending on where you connected your joystick/wheel). I used ComPortSpy from fCoder (alpha version!) | ||
239 | 3. Play the effect, and watch what happens on the spy screen. | ||
240 | |||
241 | A few words about ComPortSpy: | ||
242 | At first glance, this soft seems, hum, well... buggy. In fact, data appear with a few seconds latency. Personnaly, I restart it every time I play an effect. | ||
243 | Remember it's free (as in free beer) and alpha! | ||
244 | |||
245 | ** URLS ** | ||
246 | Check www.immerse.com for Immersion Studio, and www.fcoder.com for ComPortSpy. | ||
247 | |||
248 | ** Author of this document ** | ||
249 | Johann Deneux <deneux@ifrance.com> | ||
250 | Home page at http://www.esil.univ-mrs.fr/~jdeneux/projects/ff/ | ||
251 | |||
252 | Additions by Vojtech Pavlik. | ||
253 | |||
254 | I-Force is trademark of Immersion Corp. | ||
diff --git a/Documentation/input/input-programming.txt b/Documentation/input/input-programming.txt new file mode 100644 index 000000000000..180e0689676c --- /dev/null +++ b/Documentation/input/input-programming.txt | |||
@@ -0,0 +1,281 @@ | |||
1 | $Id: input-programming.txt,v 1.4 2001/05/04 09:47:14 vojtech Exp $ | ||
2 | |||
3 | Programming input drivers | ||
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
5 | |||
6 | 1. Creating an input device driver | ||
7 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
8 | |||
9 | 1.0 The simplest example | ||
10 | ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
11 | |||
12 | Here comes a very simple example of an input device driver. The device has | ||
13 | just one button and the button is accessible at i/o port BUTTON_PORT. When | ||
14 | pressed or released a BUTTON_IRQ happens. The driver could look like: | ||
15 | |||
16 | #include <linux/input.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/init.h> | ||
19 | |||
20 | #include <asm/irq.h> | ||
21 | #include <asm/io.h> | ||
22 | |||
23 | static void button_interrupt(int irq, void *dummy, struct pt_regs *fp) | ||
24 | { | ||
25 | input_report_key(&button_dev, BTN_1, inb(BUTTON_PORT) & 1); | ||
26 | input_sync(&button_dev); | ||
27 | } | ||
28 | |||
29 | static int __init button_init(void) | ||
30 | { | ||
31 | if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) { | ||
32 | printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq); | ||
33 | return -EBUSY; | ||
34 | } | ||
35 | |||
36 | button_dev.evbit[0] = BIT(EV_KEY); | ||
37 | button_dev.keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
38 | |||
39 | input_register_device(&button_dev); | ||
40 | } | ||
41 | |||
42 | static void __exit button_exit(void) | ||
43 | { | ||
44 | input_unregister_device(&button_dev); | ||
45 | free_irq(BUTTON_IRQ, button_interrupt); | ||
46 | } | ||
47 | |||
48 | module_init(button_init); | ||
49 | module_exit(button_exit); | ||
50 | |||
51 | 1.1 What the example does | ||
52 | ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
53 | |||
54 | First it has to include the <linux/input.h> file, which interfaces to the | ||
55 | input subsystem. This provides all the definitions needed. | ||
56 | |||
57 | In the _init function, which is called either upon module load or when | ||
58 | booting the kernel, it grabs the required resources (it should also check | ||
59 | for the presence of the device). | ||
60 | |||
61 | Then it sets the input bitfields. This way the device driver tells the other | ||
62 | parts of the input systems what it is - what events can be generated or | ||
63 | accepted by this input device. Our example device can only generate EV_KEY type | ||
64 | events, and from those only BTN_0 event code. Thus we only set these two | ||
65 | bits. We could have used | ||
66 | |||
67 | set_bit(EV_KEY, button_dev.evbit); | ||
68 | set_bit(BTN_0, button_dev.keybit); | ||
69 | |||
70 | as well, but with more than single bits the first approach tends to be | ||
71 | shorter. | ||
72 | |||
73 | Then the example driver registers the input device structure by calling | ||
74 | |||
75 | input_register_device(&button_dev); | ||
76 | |||
77 | This adds the button_dev structure to linked lists of the input driver and | ||
78 | calls device handler modules _connect functions to tell them a new input | ||
79 | device has appeared. Because the _connect functions may call kmalloc(, | ||
80 | GFP_KERNEL), which can sleep, input_register_device() must not be called | ||
81 | from an interrupt or with a spinlock held. | ||
82 | |||
83 | While in use, the only used function of the driver is | ||
84 | |||
85 | button_interrupt() | ||
86 | |||
87 | which upon every interrupt from the button checks its state and reports it | ||
88 | via the | ||
89 | |||
90 | input_report_key() | ||
91 | |||
92 | call to the input system. There is no need to check whether the interrupt | ||
93 | routine isn't reporting two same value events (press, press for example) to | ||
94 | the input system, because the input_report_* functions check that | ||
95 | themselves. | ||
96 | |||
97 | Then there is the | ||
98 | |||
99 | input_sync() | ||
100 | |||
101 | call to tell those who receive the events that we've sent a complete report. | ||
102 | This doesn't seem important in the one button case, but is quite important | ||
103 | for for example mouse movement, where you don't want the X and Y values | ||
104 | to be interpreted separately, because that'd result in a different movement. | ||
105 | |||
106 | 1.2 dev->open() and dev->close() | ||
107 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
108 | |||
109 | In case the driver has to repeatedly poll the device, because it doesn't | ||
110 | have an interrupt coming from it and the polling is too expensive to be done | ||
111 | all the time, or if the device uses a valuable resource (eg. interrupt), it | ||
112 | can use the open and close callback to know when it can stop polling or | ||
113 | release the interrupt and when it must resume polling or grab the interrupt | ||
114 | again. To do that, we would add this to our example driver: | ||
115 | |||
116 | int button_used = 0; | ||
117 | |||
118 | static int button_open(struct input_dev *dev) | ||
119 | { | ||
120 | if (button_used++) | ||
121 | return 0; | ||
122 | |||
123 | if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) { | ||
124 | printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq); | ||
125 | button_used--; | ||
126 | return -EBUSY; | ||
127 | } | ||
128 | |||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | static void button_close(struct input_dev *dev) | ||
133 | { | ||
134 | if (!--button_used) | ||
135 | free_irq(IRQ_AMIGA_VERTB, button_interrupt); | ||
136 | } | ||
137 | |||
138 | static int __init button_init(void) | ||
139 | { | ||
140 | ... | ||
141 | button_dev.open = button_open; | ||
142 | button_dev.close = button_close; | ||
143 | ... | ||
144 | } | ||
145 | |||
146 | Note the button_used variable - we have to track how many times the open | ||
147 | function was called to know when exactly our device stops being used. | ||
148 | |||
149 | The open() callback should return a 0 in case of success or any nonzero value | ||
150 | in case of failure. The close() callback (which is void) must always succeed. | ||
151 | |||
152 | 1.3 Basic event types | ||
153 | ~~~~~~~~~~~~~~~~~~~~~ | ||
154 | |||
155 | The most simple event type is EV_KEY, which is used for keys and buttons. | ||
156 | It's reported to the input system via: | ||
157 | |||
158 | input_report_key(struct input_dev *dev, int code, int value) | ||
159 | |||
160 | See linux/input.h for the allowable values of code (from 0 to KEY_MAX). | ||
161 | Value is interpreted as a truth value, ie any nonzero value means key | ||
162 | pressed, zero value means key released. The input code generates events only | ||
163 | in case the value is different from before. | ||
164 | |||
165 | In addition to EV_KEY, there are two more basic event types: EV_REL and | ||
166 | EV_ABS. They are used for relative and absolute values supplied by the | ||
167 | device. A relative value may be for example a mouse movement in the X axis. | ||
168 | The mouse reports it as a relative difference from the last position, | ||
169 | because it doesn't have any absolute coordinate system to work in. Absolute | ||
170 | events are namely for joysticks and digitizers - devices that do work in an | ||
171 | absolute coordinate systems. | ||
172 | |||
173 | Having the device report EV_REL buttons is as simple as with EV_KEY, simply | ||
174 | set the corresponding bits and call the | ||
175 | |||
176 | input_report_rel(struct input_dev *dev, int code, int value) | ||
177 | |||
178 | function. Events are generated only for nonzero value. | ||
179 | |||
180 | However EV_ABS requires a little special care. Before calling | ||
181 | input_register_device, you have to fill additional fields in the input_dev | ||
182 | struct for each absolute axis your device has. If our button device had also | ||
183 | the ABS_X axis: | ||
184 | |||
185 | button_dev.absmin[ABS_X] = 0; | ||
186 | button_dev.absmax[ABS_X] = 255; | ||
187 | button_dev.absfuzz[ABS_X] = 4; | ||
188 | button_dev.absflat[ABS_X] = 8; | ||
189 | |||
190 | This setting would be appropriate for a joystick X axis, with the minimum of | ||
191 | 0, maximum of 255 (which the joystick *must* be able to reach, no problem if | ||
192 | it sometimes reports more, but it must be able to always reach the min and | ||
193 | max values), with noise in the data up to +- 4, and with a center flat | ||
194 | position of size 8. | ||
195 | |||
196 | If you don't need absfuzz and absflat, you can set them to zero, which mean | ||
197 | that the thing is precise and always returns to exactly the center position | ||
198 | (if it has any). | ||
199 | |||
200 | 1.4 The void *private field | ||
201 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
202 | |||
203 | This field in the input structure can be used to point to any private data | ||
204 | structures in the input device driver, in case the driver handles more than | ||
205 | one device. You'll need it in the open and close callbacks. | ||
206 | |||
207 | 1.5 NBITS(), LONG(), BIT() | ||
208 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
209 | |||
210 | These three macros from input.h help some bitfield computations: | ||
211 | |||
212 | NBITS(x) - returns the length of a bitfield array in longs for x bits | ||
213 | LONG(x) - returns the index in the array in longs for bit x | ||
214 | BIT(x) - returns the index in a long for bit x | ||
215 | |||
216 | 1.6 The number, id* and name fields | ||
217 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
218 | |||
219 | The dev->number is assigned by the input system to the input device when it | ||
220 | is registered. It has no use except for identifying the device to the user | ||
221 | in system messages. | ||
222 | |||
223 | The dev->name should be set before registering the input device by the input | ||
224 | device driver. It's a string like 'Generic button device' containing a | ||
225 | user friendly name of the device. | ||
226 | |||
227 | The id* fields contain the bus ID (PCI, USB, ...), vendor ID and device ID | ||
228 | of the device. The bus IDs are defined in input.h. The vendor and device ids | ||
229 | are defined in pci_ids.h, usb_ids.h and similar include files. These fields | ||
230 | should be set by the input device driver before registering it. | ||
231 | |||
232 | The idtype field can be used for specific information for the input device | ||
233 | driver. | ||
234 | |||
235 | The id and name fields can be passed to userland via the evdev interface. | ||
236 | |||
237 | 1.7 The keycode, keycodemax, keycodesize fields | ||
238 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
239 | |||
240 | These two fields will be used for any input devices that report their data | ||
241 | as scancodes. If not all scancodes can be known by autodetection, they may | ||
242 | need to be set by userland utilities. The keycode array then is an array | ||
243 | used to map from scancodes to input system keycodes. The keycode max will | ||
244 | contain the size of the array and keycodesize the size of each entry in it | ||
245 | (in bytes). | ||
246 | |||
247 | 1.8 Key autorepeat | ||
248 | ~~~~~~~~~~~~~~~~~~ | ||
249 | |||
250 | ... is simple. It is handled by the input.c module. Hardware autorepeat is | ||
251 | not used, because it's not present in many devices and even where it is | ||
252 | present, it is broken sometimes (at keyboards: Toshiba notebooks). To enable | ||
253 | autorepeat for your device, just set EV_REP in dev->evbit. All will be | ||
254 | handled by the input system. | ||
255 | |||
256 | 1.9 Other event types, handling output events | ||
257 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
258 | |||
259 | The other event types up to now are: | ||
260 | |||
261 | EV_LED - used for the keyboard LEDs. | ||
262 | EV_SND - used for keyboard beeps. | ||
263 | |||
264 | They are very similar to for example key events, but they go in the other | ||
265 | direction - from the system to the input device driver. If your input device | ||
266 | driver can handle these events, it has to set the respective bits in evbit, | ||
267 | *and* also the callback routine: | ||
268 | |||
269 | button_dev.event = button_event; | ||
270 | |||
271 | int button_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); | ||
272 | { | ||
273 | if (type == EV_SND && code == SND_BELL) { | ||
274 | outb(value, BUTTON_BELL); | ||
275 | return 0; | ||
276 | } | ||
277 | return -1; | ||
278 | } | ||
279 | |||
280 | This callback routine can be called from an interrupt or a BH (although that | ||
281 | isn't a rule), and thus must not sleep, and must not take too long to finish. | ||
diff --git a/Documentation/input/input.txt b/Documentation/input/input.txt new file mode 100644 index 000000000000..47137e75fdb8 --- /dev/null +++ b/Documentation/input/input.txt | |||
@@ -0,0 +1,312 @@ | |||
1 | Linux Input drivers v1.0 | ||
2 | (c) 1999-2001 Vojtech Pavlik <vojtech@ucw.cz> | ||
3 | Sponsored by SuSE | ||
4 | $Id: input.txt,v 1.8 2002/05/29 03:15:01 bradleym Exp $ | ||
5 | ---------------------------------------------------------------------------- | ||
6 | |||
7 | 0. Disclaimer | ||
8 | ~~~~~~~~~~~~~ | ||
9 | This program is free software; you can redistribute it and/or modify it | ||
10 | under the terms of the GNU General Public License as published by the Free | ||
11 | Software Foundation; either version 2 of the License, or (at your option) | ||
12 | any later version. | ||
13 | |||
14 | This program is distributed in the hope that it will be useful, but | ||
15 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
16 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
17 | more details. | ||
18 | |||
19 | You should have received a copy of the GNU General Public License along | ||
20 | with this program; if not, write to the Free Software Foundation, Inc., 59 | ||
21 | Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | |||
23 | Should you need to contact me, the author, you can do so either by e-mail | ||
24 | - mail your message to <vojtech@ucw.cz>, or by paper mail: Vojtech Pavlik, | ||
25 | Simunkova 1594, Prague 8, 182 00 Czech Republic | ||
26 | |||
27 | For your convenience, the GNU General Public License version 2 is included | ||
28 | in the package: See the file COPYING. | ||
29 | |||
30 | 1. Introduction | ||
31 | ~~~~~~~~~~~~~~~ | ||
32 | This is a collection of drivers that is designed to support all input | ||
33 | devices under Linux. While it is currently used only on for USB input | ||
34 | devices, future use (say 2.5/2.6) is expected to expand to replace | ||
35 | most of the existing input system, which is why it lives in | ||
36 | drivers/input/ instead of drivers/usb/. | ||
37 | |||
38 | The centre of the input drivers is the input module, which must be | ||
39 | loaded before any other of the input modules - it serves as a way of | ||
40 | communication between two groups of modules: | ||
41 | |||
42 | 1.1 Device drivers | ||
43 | ~~~~~~~~~~~~~~~~~~ | ||
44 | These modules talk to the hardware (for example via USB), and provide | ||
45 | events (keystrokes, mouse movements) to the input module. | ||
46 | |||
47 | 1.2 Event handlers | ||
48 | ~~~~~~~~~~~~~~~~~~ | ||
49 | These modules get events from input and pass them where needed via | ||
50 | various interfaces - keystrokes to the kernel, mouse movements via a | ||
51 | simulated PS/2 interface to GPM and X and so on. | ||
52 | |||
53 | 2. Simple Usage | ||
54 | ~~~~~~~~~~~~~~~ | ||
55 | For the most usual configuration, with one USB mouse and one USB keyboard, | ||
56 | you'll have to load the following modules (or have them built in to the | ||
57 | kernel): | ||
58 | |||
59 | input | ||
60 | mousedev | ||
61 | keybdev | ||
62 | usbcore | ||
63 | uhci_hcd or ohci_hcd or ehci_hcd | ||
64 | usbhid | ||
65 | |||
66 | After this, the USB keyboard will work straight away, and the USB mouse | ||
67 | will be available as a character device on major 13, minor 63: | ||
68 | |||
69 | crw-r--r-- 1 root root 13, 63 Mar 28 22:45 mice | ||
70 | |||
71 | This device has to be created, unless you use devfs, in which case it's | ||
72 | created automatically. The commands to do create it by hand are: | ||
73 | |||
74 | cd /dev | ||
75 | mkdir input | ||
76 | mknod input/mice c 13 63 | ||
77 | |||
78 | After that you have to point GPM (the textmode mouse cut&paste tool) and | ||
79 | XFree to this device to use it - GPM should be called like: | ||
80 | |||
81 | gpm -t ps2 -m /dev/input/mice | ||
82 | |||
83 | And in X: | ||
84 | |||
85 | Section "Pointer" | ||
86 | Protocol "ImPS/2" | ||
87 | Device "/dev/input/mice" | ||
88 | ZAxisMapping 4 5 | ||
89 | EndSection | ||
90 | |||
91 | When you do all of the above, you can use your USB mouse and keyboard. | ||
92 | |||
93 | 3. Detailed Description | ||
94 | ~~~~~~~~~~~~~~~~~~~~~~~ | ||
95 | 3.1 Device drivers | ||
96 | ~~~~~~~~~~~~~~~~~~ | ||
97 | Device drivers are the modules that generate events. The events are | ||
98 | however not useful without being handled, so you also will need to use some | ||
99 | of the modules from section 3.2. | ||
100 | |||
101 | 3.1.1 usbhid | ||
102 | ~~~~~~~~~~~~ | ||
103 | usbhid is the largest and most complex driver of the whole suite. It | ||
104 | handles all HID devices, and because there is a very wide variety of them, | ||
105 | and because the USB HID specification isn't simple, it needs to be this big. | ||
106 | |||
107 | Currently, it handles USB mice, joysticks, gamepads, steering wheels | ||
108 | keyboards, trackballs and digitizers. | ||
109 | |||
110 | However, USB uses HID also for monitor controls, speaker controls, UPSs, | ||
111 | LCDs and many other purposes. | ||
112 | |||
113 | The monitor and speaker controls should be easy to add to the hid/input | ||
114 | interface, but for the UPSs and LCDs it doesn't make much sense. For this, | ||
115 | the hiddev interface was designed. See Documentation/usb/hiddev.txt | ||
116 | for more information about it. | ||
117 | |||
118 | The usage of the usbhid module is very simple, it takes no parameters, | ||
119 | detects everything automatically and when a HID device is inserted, it | ||
120 | detects it appropriately. | ||
121 | |||
122 | However, because the devices vary wildly, you might happen to have a | ||
123 | device that doesn't work well. In that case #define DEBUG at the beginning | ||
124 | of hid-core.c and send me the syslog traces. | ||
125 | |||
126 | 3.1.2 usbmouse | ||
127 | ~~~~~~~~~~~~~~ | ||
128 | For embedded systems, for mice with broken HID descriptors and just any | ||
129 | other use when the big usbhid wouldn't be a good choice, there is the | ||
130 | usbmouse driver. It handles USB mice only. It uses a simpler HIDBP | ||
131 | protocol. This also means the mice must support this simpler protocol. Not | ||
132 | all do. If you don't have any strong reason to use this module, use usbhid | ||
133 | instead. | ||
134 | |||
135 | 3.1.3 usbkbd | ||
136 | ~~~~~~~~~~~~ | ||
137 | Much like usbmouse, this module talks to keyboards with a simplified | ||
138 | HIDBP protocol. It's smaller, but doesn't support any extra special keys. | ||
139 | Use usbhid instead if there isn't any special reason to use this. | ||
140 | |||
141 | 3.1.4 wacom | ||
142 | ~~~~~~~~~~~ | ||
143 | This is a driver for Wacom Graphire and Intuos tablets. Not for Wacom | ||
144 | PenPartner, that one is handled by the HID driver. Although the Intuos and | ||
145 | Graphire tablets claim that they are HID tablets as well, they are not and | ||
146 | thus need this specific driver. | ||
147 | |||
148 | 3.1.5 iforce | ||
149 | ~~~~~~~~~~~~ | ||
150 | A driver for I-Force joysticks and wheels, both over USB and RS232. | ||
151 | It includes ForceFeedback support now, even though Immersion | ||
152 | Corp. considers the protocol a trade secret and won't disclose a word | ||
153 | about it. | ||
154 | |||
155 | 3.2 Event handlers | ||
156 | ~~~~~~~~~~~~~~~~~~ | ||
157 | Event handlers distrubite the events from the devices to userland and | ||
158 | kernel, as needed. | ||
159 | |||
160 | 3.2.1 keybdev | ||
161 | ~~~~~~~~~~~~~ | ||
162 | keybdev is currently a rather ugly hack that translates the input | ||
163 | events into architecture-specific keyboard raw mode (Xlated AT Set2 on | ||
164 | x86), and passes them into the handle_scancode function of the | ||
165 | keyboard.c module. This works well enough on all architectures that | ||
166 | keybdev can generate rawmode on, other architectures can be added to | ||
167 | it. | ||
168 | |||
169 | The right way would be to pass the events to keyboard.c directly, | ||
170 | best if keyboard.c would itself be an event handler. This is done in | ||
171 | the input patch, available on the webpage mentioned below. | ||
172 | |||
173 | 3.2.2 mousedev | ||
174 | ~~~~~~~~~~~~~~ | ||
175 | mousedev is also a hack to make programs that use mouse input | ||
176 | work. It takes events from either mice or digitizers/tablets and makes | ||
177 | a PS/2-style (a la /dev/psaux) mouse device available to the | ||
178 | userland. Ideally, the programs could use a more reasonable interface, | ||
179 | for example evdev | ||
180 | |||
181 | Mousedev devices in /dev/input (as shown above) are: | ||
182 | |||
183 | crw-r--r-- 1 root root 13, 32 Mar 28 22:45 mouse0 | ||
184 | crw-r--r-- 1 root root 13, 33 Mar 29 00:41 mouse1 | ||
185 | crw-r--r-- 1 root root 13, 34 Mar 29 00:41 mouse2 | ||
186 | crw-r--r-- 1 root root 13, 35 Apr 1 10:50 mouse3 | ||
187 | ... | ||
188 | ... | ||
189 | crw-r--r-- 1 root root 13, 62 Apr 1 10:50 mouse30 | ||
190 | crw-r--r-- 1 root root 13, 63 Apr 1 10:50 mice | ||
191 | |||
192 | Each 'mouse' device is assigned to a single mouse or digitizer, except | ||
193 | the last one - 'mice'. This single character device is shared by all | ||
194 | mice and digitizers, and even if none are connected, the device is | ||
195 | present. This is useful for hotplugging USB mice, so that programs | ||
196 | can open the device even when no mice are present. | ||
197 | |||
198 | CONFIG_INPUT_MOUSEDEV_SCREEN_[XY] in the kernel configuration are | ||
199 | the size of your screen (in pixels) in XFree86. This is needed if you | ||
200 | want to use your digitizer in X, because its movement is sent to X | ||
201 | via a virtual PS/2 mouse and thus needs to be scaled | ||
202 | accordingly. These values won't be used if you use a mouse only. | ||
203 | |||
204 | Mousedev will generate either PS/2, ImPS/2 (Microsoft IntelliMouse) or | ||
205 | ExplorerPS/2 (IntelliMouse Explorer) protocols, depending on what the | ||
206 | program reading the data wishes. You can set GPM and X to any of | ||
207 | these. You'll need ImPS/2 if you want to make use of a wheel on a USB | ||
208 | mouse and ExplorerPS/2 if you want to use extra (up to 5) buttons. | ||
209 | |||
210 | 3.2.3 joydev | ||
211 | ~~~~~~~~~~~~ | ||
212 | Joydev implements v0.x and v1.x Linux joystick api, much like | ||
213 | drivers/char/joystick/joystick.c used to in earlier versions. See | ||
214 | joystick-api.txt in the Documentation subdirectory for details. As | ||
215 | soon as any joystick is connected, it can be accessed in /dev/input | ||
216 | on: | ||
217 | |||
218 | crw-r--r-- 1 root root 13, 0 Apr 1 10:50 js0 | ||
219 | crw-r--r-- 1 root root 13, 1 Apr 1 10:50 js1 | ||
220 | crw-r--r-- 1 root root 13, 2 Apr 1 10:50 js2 | ||
221 | crw-r--r-- 1 root root 13, 3 Apr 1 10:50 js3 | ||
222 | ... | ||
223 | |||
224 | And so on up to js31. | ||
225 | |||
226 | 3.2.4 evdev | ||
227 | ~~~~~~~~~~~ | ||
228 | evdev is the generic input event interface. It passes the events | ||
229 | generated in the kernel straight to the program, with timestamps. The | ||
230 | API is still evolving, but should be useable now. It's described in | ||
231 | section 5. | ||
232 | |||
233 | This should be the way for GPM and X to get keyboard and mouse mouse | ||
234 | events. It allows for multihead in X without any specific multihead | ||
235 | kernel support. The event codes are the same on all architectures and | ||
236 | are hardware independent. | ||
237 | |||
238 | The devices are in /dev/input: | ||
239 | |||
240 | crw-r--r-- 1 root root 13, 64 Apr 1 10:49 event0 | ||
241 | crw-r--r-- 1 root root 13, 65 Apr 1 10:50 event1 | ||
242 | crw-r--r-- 1 root root 13, 66 Apr 1 10:50 event2 | ||
243 | crw-r--r-- 1 root root 13, 67 Apr 1 10:50 event3 | ||
244 | ... | ||
245 | |||
246 | And so on up to event31. | ||
247 | |||
248 | 4. Verifying if it works | ||
249 | ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
250 | Typing a couple keys on the keyboard should be enough to check that | ||
251 | a USB keyboard works and is correctly connected to the kernel keyboard | ||
252 | driver. | ||
253 | |||
254 | Doing a cat /dev/input/mouse0 (c, 13, 32) will verify that a mouse | ||
255 | is also emulated, characters should appear if you move it. | ||
256 | |||
257 | You can test the joystick emulation with the 'jstest' utility, | ||
258 | available in the joystick package (see Documentation/input/joystick.txt). | ||
259 | |||
260 | You can test the event devices with the 'evtest' utility available | ||
261 | in the LinuxConsole project CVS archive (see the URL below). | ||
262 | |||
263 | 5. Event interface | ||
264 | ~~~~~~~~~~~~~~~~~~ | ||
265 | Should you want to add event device support into any application (X, gpm, | ||
266 | svgalib ...) I <vojtech@ucw.cz> will be happy to provide you any help I | ||
267 | can. Here goes a description of the current state of things, which is going | ||
268 | to be extended, but not changed incompatibly as time goes: | ||
269 | |||
270 | You can use blocking and nonblocking reads, also select() on the | ||
271 | /dev/input/eventX devices, and you'll always get a whole number of input | ||
272 | events on a read. Their layout is: | ||
273 | |||
274 | struct input_event { | ||
275 | struct timeval time; | ||
276 | unsigned short type; | ||
277 | unsigned short code; | ||
278 | unsigned int value; | ||
279 | }; | ||
280 | |||
281 | 'time' is the timestamp, it returns the time at which the event happened. | ||
282 | Type is for example EV_REL for relative momement, REL_KEY for a keypress or | ||
283 | release. More types are defined in include/linux/input.h. | ||
284 | |||
285 | 'code' is event code, for example REL_X or KEY_BACKSPACE, again a complete | ||
286 | list is in include/linux/input.h. | ||
287 | |||
288 | 'value' is the value the event carries. Either a relative change for | ||
289 | EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for | ||
290 | release, 1 for keypress and 2 for autorepeat. | ||
291 | |||
292 | 6. Contacts | ||
293 | ~~~~~~~~~~~ | ||
294 | This effort has its home page at: | ||
295 | |||
296 | http://www.suse.cz/development/input/ | ||
297 | |||
298 | You'll find both the latest HID driver and the complete Input driver | ||
299 | there as well as information how to access the CVS repository for | ||
300 | latest revisions of the drivers. | ||
301 | |||
302 | There is also a mailing list for this: | ||
303 | |||
304 | majordomo@atrey.karlin.mff.cuni.cz | ||
305 | |||
306 | Send "subscribe linux-input" to subscribe to it. | ||
307 | |||
308 | The input changes are also being worked on as part of the LinuxConsole | ||
309 | project, see: | ||
310 | |||
311 | http://sourceforge.net/projects/linuxconsole/ | ||
312 | |||
diff --git a/Documentation/input/interactive.fig b/Documentation/input/interactive.fig new file mode 100644 index 000000000000..1e7de387723a --- /dev/null +++ b/Documentation/input/interactive.fig | |||
@@ -0,0 +1,42 @@ | |||
1 | #FIG 3.2 | ||
2 | Landscape | ||
3 | Center | ||
4 | Inches | ||
5 | Letter | ||
6 | 100.00 | ||
7 | Single | ||
8 | -2 | ||
9 | 1200 2 | ||
10 | 2 1 0 2 0 7 50 0 -1 6.000 0 0 -1 0 0 6 | ||
11 | 1200 3600 1800 3600 2400 4800 3000 4800 4200 5700 4800 5700 | ||
12 | 2 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5 | ||
13 | 1200 3150 4800 3150 4800 6300 1200 6300 1200 3150 | ||
14 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
15 | 1200 4800 4800 4800 | ||
16 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 4 | ||
17 | 2400 4800 2400 6525 1950 7125 1950 7800 | ||
18 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 4 | ||
19 | 3000 4800 3000 6525 3600 7125 3600 7800 | ||
20 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 0 1 3 | ||
21 | 0 0 1.00 60.00 120.00 | ||
22 | 3825 5400 4125 5100 5400 5100 | ||
23 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 0 1 3 | ||
24 | 0 0 1.00 60.00 120.00 | ||
25 | 2100 4200 2400 3900 5400 3900 | ||
26 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
27 | 4800 5700 5400 5700 | ||
28 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
29 | 1800 3600 5400 3600 | ||
30 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 0 1 3 | ||
31 | 0 0 1.00 60.00 120.00 | ||
32 | 2700 4800 2700 4425 5400 4425 | ||
33 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2 | ||
34 | 0 0 1.00 60.00 120.00 | ||
35 | 0 0 1.00 60.00 120.00 | ||
36 | 1950 7800 3600 7800 | ||
37 | 4 1 0 50 0 0 12 0.0000 4 135 810 2775 7725 Dead band\001 | ||
38 | 4 0 0 50 0 0 12 0.0000 4 180 1155 5400 5700 right saturation\001 | ||
39 | 4 0 0 50 0 0 12 0.0000 4 135 1065 5400 3600 left saturation\001 | ||
40 | 4 0 0 50 0 0 12 0.0000 4 180 2505 5400 3900 left coeff ( positive in that case )\001 | ||
41 | 4 0 0 50 0 0 12 0.0000 4 180 2640 5475 5100 right coeff ( negative in that case )\001 | ||
42 | 4 0 0 50 0 0 12 0.0000 4 105 480 5400 4425 center\001 | ||
diff --git a/Documentation/input/joystick-api.txt b/Documentation/input/joystick-api.txt new file mode 100644 index 000000000000..acbd32b88454 --- /dev/null +++ b/Documentation/input/joystick-api.txt | |||
@@ -0,0 +1,316 @@ | |||
1 | Joystick API Documentation -*-Text-*- | ||
2 | |||
3 | Ragnar Hojland Espinosa | ||
4 | <ragnar@macula.net> | ||
5 | |||
6 | 7 Aug 1998 | ||
7 | |||
8 | $Id: joystick-api.txt,v 1.2 2001/05/08 21:21:23 vojtech Exp $ | ||
9 | |||
10 | 1. Initialization | ||
11 | ~~~~~~~~~~~~~~~~~ | ||
12 | |||
13 | Open the joystick device following the usual semantics (that is, with open). | ||
14 | Since the driver now reports events instead of polling for changes, | ||
15 | immediately after the open it will issue a series of synthetic events | ||
16 | (JS_EVENT_INIT) that you can read to check the initial state of the | ||
17 | joystick. | ||
18 | |||
19 | By default, the device is opened in blocking mode. | ||
20 | |||
21 | int fd = open ("/dev/js0", O_RDONLY); | ||
22 | |||
23 | |||
24 | 2. Event Reading | ||
25 | ~~~~~~~~~~~~~~~~ | ||
26 | |||
27 | struct js_event e; | ||
28 | read (fd, &e, sizeof(struct js_event)); | ||
29 | |||
30 | where js_event is defined as | ||
31 | |||
32 | struct js_event { | ||
33 | __u32 time; /* event timestamp in milliseconds */ | ||
34 | __s16 value; /* value */ | ||
35 | __u8 type; /* event type */ | ||
36 | __u8 number; /* axis/button number */ | ||
37 | }; | ||
38 | |||
39 | If the read is successful, it will return sizeof(struct js_event), unless | ||
40 | you wanted to read more than one event per read as described in section 3.1. | ||
41 | |||
42 | |||
43 | 2.1 js_event.type | ||
44 | ~~~~~~~~~~~~~~~~~ | ||
45 | |||
46 | The possible values of ``type'' are | ||
47 | |||
48 | #define JS_EVENT_BUTTON 0x01 /* button pressed/released */ | ||
49 | #define JS_EVENT_AXIS 0x02 /* joystick moved */ | ||
50 | #define JS_EVENT_INIT 0x80 /* initial state of device */ | ||
51 | |||
52 | As mentioned above, the driver will issue synthetic JS_EVENT_INIT ORed | ||
53 | events on open. That is, if it's issuing a INIT BUTTON event, the | ||
54 | current type value will be | ||
55 | |||
56 | int type = JS_EVENT_BUTTON | JS_EVENT_INIT; /* 0x81 */ | ||
57 | |||
58 | If you choose not to differentiate between synthetic or real events | ||
59 | you can turn off the JS_EVENT_INIT bits | ||
60 | |||
61 | type &= ~JS_EVENT_INIT; /* 0x01 */ | ||
62 | |||
63 | |||
64 | 2.2 js_event.number | ||
65 | ~~~~~~~~~~~~~~~~~~~ | ||
66 | |||
67 | The values of ``number'' correspond to the axis or button that | ||
68 | generated the event. Note that they carry separate numeration (that | ||
69 | is, you have both an axis 0 and a button 0). Generally, | ||
70 | |||
71 | number | ||
72 | 1st Axis X 0 | ||
73 | 1st Axis Y 1 | ||
74 | 2nd Axis X 2 | ||
75 | 2nd Axis Y 3 | ||
76 | ...and so on | ||
77 | |||
78 | Hats vary from one joystick type to another. Some can be moved in 8 | ||
79 | directions, some only in 4, The driver, however, always reports a hat as two | ||
80 | independent axis, even if the hardware doesn't allow independent movement. | ||
81 | |||
82 | |||
83 | 2.3 js_event.value | ||
84 | ~~~~~~~~~~~~~~~~~~ | ||
85 | |||
86 | For an axis, ``value'' is a signed integer between -32767 and +32767 | ||
87 | representing the position of the joystick along that axis. If you | ||
88 | don't read a 0 when the joystick is `dead', or if it doesn't span the | ||
89 | full range, you should recalibrate it (with, for example, jscal). | ||
90 | |||
91 | For a button, ``value'' for a press button event is 1 and for a release | ||
92 | button event is 0. | ||
93 | |||
94 | Though this | ||
95 | |||
96 | if (js_event.type == JS_EVENT_BUTTON) { | ||
97 | buttons_state ^= (1 << js_event.number); | ||
98 | } | ||
99 | |||
100 | may work well if you handle JS_EVENT_INIT events separately, | ||
101 | |||
102 | if ((js_event.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON) { | ||
103 | if (js_event.value) | ||
104 | buttons_state |= (1 << js_event.number); | ||
105 | else | ||
106 | buttons_state &= ~(1 << js_event.number); | ||
107 | } | ||
108 | |||
109 | is much safer since it can't lose sync with the driver. As you would | ||
110 | have to write a separate handler for JS_EVENT_INIT events in the first | ||
111 | snippet, this ends up being shorter. | ||
112 | |||
113 | |||
114 | 2.4 js_event.time | ||
115 | ~~~~~~~~~~~~~~~~~ | ||
116 | |||
117 | The time an event was generated is stored in ``js_event.time''. It's a time | ||
118 | in milliseconds since ... well, since sometime in the past. This eases the | ||
119 | task of detecting double clicks, figuring out if movement of axis and button | ||
120 | presses happened at the same time, and similar. | ||
121 | |||
122 | |||
123 | 3. Reading | ||
124 | ~~~~~~~~~~ | ||
125 | |||
126 | If you open the device in blocking mode, a read will block (that is, | ||
127 | wait) forever until an event is generated and effectively read. There | ||
128 | are two alternatives if you can't afford to wait forever (which is, | ||
129 | admittedly, a long time;) | ||
130 | |||
131 | a) use select to wait until there's data to be read on fd, or | ||
132 | until it timeouts. There's a good example on the select(2) | ||
133 | man page. | ||
134 | |||
135 | b) open the device in non-blocking mode (O_NONBLOCK) | ||
136 | |||
137 | |||
138 | 3.1 O_NONBLOCK | ||
139 | ~~~~~~~~~~~~~~ | ||
140 | |||
141 | If read returns -1 when reading in O_NONBLOCK mode, this isn't | ||
142 | necessarily a "real" error (check errno(3)); it can just mean there | ||
143 | are no events pending to be read on the driver queue. You should read | ||
144 | all events on the queue (that is, until you get a -1). | ||
145 | |||
146 | For example, | ||
147 | |||
148 | while (1) { | ||
149 | while (read (fd, &e, sizeof(struct js_event)) > 0) { | ||
150 | process_event (e); | ||
151 | } | ||
152 | /* EAGAIN is returned when the queue is empty */ | ||
153 | if (errno != EAGAIN) { | ||
154 | /* error */ | ||
155 | } | ||
156 | /* do something interesting with processed events */ | ||
157 | } | ||
158 | |||
159 | One reason for emptying the queue is that if it gets full you'll start | ||
160 | missing events since the queue is finite, and older events will get | ||
161 | overwritten. | ||
162 | |||
163 | The other reason is that you want to know all what happened, and not | ||
164 | delay the processing till later. | ||
165 | |||
166 | Why can get the queue full? Because you don't empty the queue as | ||
167 | mentioned, or because too much time elapses from one read to another | ||
168 | and too many events to store in the queue get generated. Note that | ||
169 | high system load may contribute to space those reads even more. | ||
170 | |||
171 | If time between reads is enough to fill the queue and lose an event, | ||
172 | the driver will switch to startup mode and next time you read it, | ||
173 | synthetic events (JS_EVENT_INIT) will be generated to inform you of | ||
174 | the actual state of the joystick. | ||
175 | |||
176 | [As for version 1.2.8, the queue is circular and able to hold 64 | ||
177 | events. You can increment this size bumping up JS_BUFF_SIZE in | ||
178 | joystick.h and recompiling the driver.] | ||
179 | |||
180 | |||
181 | In the above code, you might as well want to read more than one event | ||
182 | at a time using the typical read(2) functionality. For that, you would | ||
183 | replace the read above with something like | ||
184 | |||
185 | struct js_event mybuffer[0xff]; | ||
186 | int i = read (fd, mybuffer, sizeof(struct mybuffer)); | ||
187 | |||
188 | In this case, read would return -1 if the queue was empty, or some | ||
189 | other value in which the number of events read would be i / | ||
190 | sizeof(js_event) Again, if the buffer was full, it's a good idea to | ||
191 | process the events and keep reading it until you empty the driver queue. | ||
192 | |||
193 | |||
194 | 4. IOCTLs | ||
195 | ~~~~~~~~~ | ||
196 | |||
197 | The joystick driver defines the following ioctl(2) operations. | ||
198 | |||
199 | /* function 3rd arg */ | ||
200 | #define JSIOCGAXES /* get number of axes char */ | ||
201 | #define JSIOCGBUTTONS /* get number of buttons char */ | ||
202 | #define JSIOCGVERSION /* get driver version int */ | ||
203 | #define JSIOCGNAME(len) /* get identifier string char */ | ||
204 | #define JSIOCSCORR /* set correction values &js_corr */ | ||
205 | #define JSIOCGCORR /* get correction values &js_corr */ | ||
206 | |||
207 | For example, to read the number of axes | ||
208 | |||
209 | char number_of_axes; | ||
210 | ioctl (fd, JSIOCGAXES, &number_of_axes); | ||
211 | |||
212 | |||
213 | 4.1 JSIOGCVERSION | ||
214 | ~~~~~~~~~~~~~~~~~ | ||
215 | |||
216 | JSIOGCVERSION is a good way to check in run-time whether the running | ||
217 | driver is 1.0+ and supports the event interface. If it is not, the | ||
218 | IOCTL will fail. For a compile-time decision, you can test the | ||
219 | JS_VERSION symbol | ||
220 | |||
221 | #ifdef JS_VERSION | ||
222 | #if JS_VERSION > 0xsomething | ||
223 | |||
224 | |||
225 | 4.2 JSIOCGNAME | ||
226 | ~~~~~~~~~~~~~~ | ||
227 | |||
228 | JSIOCGNAME(len) allows you to get the name string of the joystick - the same | ||
229 | as is being printed at boot time. The 'len' argument is the length of the | ||
230 | buffer provided by the application asking for the name. It is used to avoid | ||
231 | possible overrun should the name be too long. | ||
232 | |||
233 | char name[128]; | ||
234 | if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0) | ||
235 | strncpy(name, "Unknown", sizeof(name)); | ||
236 | printf("Name: %s\n", name); | ||
237 | |||
238 | |||
239 | 4.3 JSIOC[SG]CORR | ||
240 | ~~~~~~~~~~~~~~~~~ | ||
241 | |||
242 | For usage on JSIOC[SG]CORR I suggest you to look into jscal.c They are | ||
243 | not needed in a normal program, only in joystick calibration software | ||
244 | such as jscal or kcmjoy. These IOCTLs and data types aren't considered | ||
245 | to be in the stable part of the API, and therefore may change without | ||
246 | warning in following releases of the driver. | ||
247 | |||
248 | Both JSIOCSCORR and JSIOCGCORR expect &js_corr to be able to hold | ||
249 | information for all axis. That is, struct js_corr corr[MAX_AXIS]; | ||
250 | |||
251 | struct js_corr is defined as | ||
252 | |||
253 | struct js_corr { | ||
254 | __s32 coef[8]; | ||
255 | __u16 prec; | ||
256 | __u16 type; | ||
257 | }; | ||
258 | |||
259 | and ``type'' | ||
260 | |||
261 | #define JS_CORR_NONE 0x00 /* returns raw values */ | ||
262 | #define JS_CORR_BROKEN 0x01 /* broken line */ | ||
263 | |||
264 | |||
265 | 5. Backward compatibility | ||
266 | ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
267 | |||
268 | The 0.x joystick driver API is quite limited and its usage is deprecated. | ||
269 | The driver offers backward compatibility, though. Here's a quick summary: | ||
270 | |||
271 | struct JS_DATA_TYPE js; | ||
272 | while (1) { | ||
273 | if (read (fd, &js, JS_RETURN) != JS_RETURN) { | ||
274 | /* error */ | ||
275 | } | ||
276 | usleep (1000); | ||
277 | } | ||
278 | |||
279 | As you can figure out from the example, the read returns immediately, | ||
280 | with the actual state of the joystick. | ||
281 | |||
282 | struct JS_DATA_TYPE { | ||
283 | int buttons; /* immediate button state */ | ||
284 | int x; /* immediate x axis value */ | ||
285 | int y; /* immediate y axis value */ | ||
286 | }; | ||
287 | |||
288 | and JS_RETURN is defined as | ||
289 | |||
290 | #define JS_RETURN sizeof(struct JS_DATA_TYPE) | ||
291 | |||
292 | To test the state of the buttons, | ||
293 | |||
294 | first_button_state = js.buttons & 1; | ||
295 | second_button_state = js.buttons & 2; | ||
296 | |||
297 | The axis values do not have a defined range in the original 0.x driver, | ||
298 | except for that the values are non-negative. The 1.2.8+ drivers use a | ||
299 | fixed range for reporting the values, 1 being the minimum, 128 the | ||
300 | center, and 255 maximum value. | ||
301 | |||
302 | The v0.8.0.2 driver also had an interface for 'digital joysticks', (now | ||
303 | called Multisystem joysticks in this driver), under /dev/djsX. This driver | ||
304 | doesn't try to be compatible with that interface. | ||
305 | |||
306 | |||
307 | 6. Final Notes | ||
308 | ~~~~~~~~~~~~~~ | ||
309 | |||
310 | ____/| Comments, additions, and specially corrections are welcome. | ||
311 | \ o.O| Documentation valid for at least version 1.2.8 of the joystick | ||
312 | =(_)= driver and as usual, the ultimate source for documentation is | ||
313 | U to "Use The Source Luke" or, at your convenience, Vojtech ;) | ||
314 | |||
315 | - Ragnar | ||
316 | EOF | ||
diff --git a/Documentation/input/joystick-parport.txt b/Documentation/input/joystick-parport.txt new file mode 100644 index 000000000000..88a011c9f985 --- /dev/null +++ b/Documentation/input/joystick-parport.txt | |||
@@ -0,0 +1,542 @@ | |||
1 | Linux Joystick parport drivers v2.0 | ||
2 | (c) 1998-2000 Vojtech Pavlik <vojtech@ucw.cz> | ||
3 | (c) 1998 Andree Borrmann <a.borrmann@tu-bs.de> | ||
4 | Sponsored by SuSE | ||
5 | $Id: joystick-parport.txt,v 1.6 2001/09/25 09:31:32 vojtech Exp $ | ||
6 | ---------------------------------------------------------------------------- | ||
7 | |||
8 | 0. Disclaimer | ||
9 | ~~~~~~~~~~~~~ | ||
10 | Any information in this file is provided as-is, without any guarantee that | ||
11 | it will be true. So, use it at your own risk. The possible damages that can | ||
12 | happen include burning your parallel port, and/or the sticks and joystick | ||
13 | and maybe even more. Like when a lightning kills you it is not our problem. | ||
14 | |||
15 | 1. Intro | ||
16 | ~~~~~~~~ | ||
17 | The joystick parport drivers are used for joysticks and gamepads not | ||
18 | originally designed for PCs and other computers Linux runs on. Because of | ||
19 | that, PCs usually lack the right ports to connect these devices to. Parallel | ||
20 | port, because of its ability to change single bits at will, and providing | ||
21 | both output and input bits is the most suitable port on the PC for | ||
22 | connecting such devices. | ||
23 | |||
24 | 2. Devices supported | ||
25 | ~~~~~~~~~~~~~~~~~~~~ | ||
26 | Many console and 8-bit computer gamepads and joysticks are supported. The | ||
27 | following subsections discuss usage of each. | ||
28 | |||
29 | 2.1 NES and SNES | ||
30 | ~~~~~~~~~~~~~~~~ | ||
31 | The Nintendo Entertainment System and Super Nintendo Entertainment System | ||
32 | gamepads are widely available, and easy to get. Also, they are quite easy to | ||
33 | connect to a PC, and don't need much processing speed (108 us for NES and | ||
34 | 165 us for SNES, compared to about 1000 us for PC gamepads) to communicate | ||
35 | with them. | ||
36 | |||
37 | All NES and SNES use the same synchronous serial protocol, clocked from | ||
38 | the computer's side (and thus timing insensitive). To allow up to 5 NES | ||
39 | and/or SNES gamepads connected to the parallel port at once, the output | ||
40 | lines of the parallel port are shared, while one of 5 available input lines | ||
41 | is assigned to each gamepad. | ||
42 | |||
43 | This protocol is handled by the gamecon.c driver, so that's the one | ||
44 | you'll use for NES and SNES gamepads. | ||
45 | |||
46 | The main problem with PC parallel ports is that they don't have +5V power | ||
47 | source on any of their pins. So, if you want a reliable source of power | ||
48 | for your pads, use either keyboard or joystick port, and make a pass-through | ||
49 | cable. You can also pull the power directly from the power supply (the red | ||
50 | wire is +5V). | ||
51 | |||
52 | If you want to use the parallel port only, you can take the power is from | ||
53 | some data pin. For most gamepad and parport implementations only one pin is | ||
54 | needed, and I'd recommend pin 9 for that, the highest data bit. On the other | ||
55 | hand, if you are not planning to use anything else than NES / SNES on the | ||
56 | port, anything between and including pin 4 and pin 9 will work. | ||
57 | |||
58 | (pin 9) -----> Power | ||
59 | |||
60 | Unfortunately, there are pads that need a lot more of power, and parallel | ||
61 | ports that can't give much current through the data pins. If this is your | ||
62 | case, you'll need to use diodes (as a prevention of destroying your parallel | ||
63 | port), and combine the currents of two or more data bits together. | ||
64 | |||
65 | Diodes | ||
66 | (pin 9) ----|>|-------+------> Power | ||
67 | | | ||
68 | (pin 8) ----|>|-------+ | ||
69 | | | ||
70 | (pin 7) ----|>|-------+ | ||
71 | | | ||
72 | <and so on> : | ||
73 | | | ||
74 | (pin 4) ----|>|-------+ | ||
75 | |||
76 | Ground is quite easy. On PC's parallel port the ground is on any of the | ||
77 | pins from pin 18 to pin 25. So use any pin of these you like for the ground. | ||
78 | |||
79 | (pin 18) -----> Ground | ||
80 | |||
81 | NES and SNES pads have two input bits, Clock and Latch, which drive the | ||
82 | serial transfer. These are connected to pins 2 and 3 of the parallel port, | ||
83 | respectively. | ||
84 | |||
85 | (pin 2) -----> Clock | ||
86 | (pin 3) -----> Latch | ||
87 | |||
88 | And the last thing is the NES / SNES data wire. Only that isn't shared and | ||
89 | each pad needs its own data pin. The parallel port pins are: | ||
90 | |||
91 | (pin 10) -----> Pad 1 data | ||
92 | (pin 11) -----> Pad 2 data | ||
93 | (pin 12) -----> Pad 3 data | ||
94 | (pin 13) -----> Pad 4 data | ||
95 | (pin 15) -----> Pad 5 data | ||
96 | |||
97 | Note that pin 14 is not used, since it is not an input pin on the parallel | ||
98 | port. | ||
99 | |||
100 | This is everything you need on the PC's side of the connection, now on to | ||
101 | the gamepads side. The NES and SNES have different connectors. Also, there | ||
102 | are quite a lot of NES clones, and because Nintendo used proprietary | ||
103 | connectors for their machines, the cloners couldn't and used standard D-Cannon | ||
104 | connectors. Anyway, if you've got a gamepad, and it has buttons A, B, Turbo | ||
105 | A, Turbo B, Select and Start, and is connected through 5 wires, then it is | ||
106 | either a NES or NES clone and will work with this connection. SNES gamepads | ||
107 | also use 5 wires, but have more buttons. They will work as well, of course. | ||
108 | |||
109 | Pinout for NES gamepads Pinout for SNES gamepads | ||
110 | |||
111 | +----> Power +-----------------------\ | ||
112 | | 7 | o o o o | x x o | 1 | ||
113 | 5 +---------+ 7 +-----------------------/ | ||
114 | | x x o \ | | | | | | ||
115 | | o o o o | | | | | +-> Ground | ||
116 | 4 +------------+ 1 | | | +------------> Data | ||
117 | | | | | | | +---------------> Latch | ||
118 | | | | +-> Ground | +------------------> Clock | ||
119 | | | +----> Clock +---------------------> Power | ||
120 | | +-------> Latch | ||
121 | +----------> Data | ||
122 | |||
123 | Pinout for NES clone (db9) gamepads Pinout for NES clone (db15) gamepads | ||
124 | |||
125 | +---------> Clock +-----------------> Data | ||
126 | | +-------> Latch | +---> Ground | ||
127 | | | +-----> Data | | | ||
128 | | | | ___________________ | ||
129 | _____________ 8 \ o x x x x x x o / 1 | ||
130 | 5 \ x o o o x / 1 \ o x x o x x o / | ||
131 | \ x o x o / 15 `~~~~~~~~~~~~~' 9 | ||
132 | 9 `~~~~~~~' 6 | | | | ||
133 | | | | | +----> Clock | ||
134 | | +----> Power | +----------> Latch | ||
135 | +--------> Ground +----------------> Power | ||
136 | |||
137 | 2.2 Multisystem joysticks | ||
138 | ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
139 | In the era of 8-bit machines, there was something like de-facto standard | ||
140 | for joystick ports. They were all digital, and all used D-Cannon 9 pin | ||
141 | connectors (db9). Because of that, a single joystick could be used without | ||
142 | hassle on Atari (130, 800XE, 800XL, 2600, 7200), Amiga, Commodore C64, | ||
143 | Amstrad CPC, Sinclair ZX Spectrum and many other machines. That's why these | ||
144 | joysticks are called "Multisystem". | ||
145 | |||
146 | Now their pinout: | ||
147 | |||
148 | +---------> Right | ||
149 | | +-------> Left | ||
150 | | | +-----> Down | ||
151 | | | | +---> Up | ||
152 | | | | | | ||
153 | _____________ | ||
154 | 5 \ x o o o o / 1 | ||
155 | \ x o x o / | ||
156 | 9 `~~~~~~~' 6 | ||
157 | | | | ||
158 | | +----> Button | ||
159 | +--------> Ground | ||
160 | |||
161 | However, as time passed, extensions to this standard developed, and these | ||
162 | were not compatible with each other: | ||
163 | |||
164 | |||
165 | Atari 130, 800/XL/XE MSX | ||
166 | |||
167 | +-----------> Power | ||
168 | +---------> Right | +---------> Right | ||
169 | | +-------> Left | | +-------> Left | ||
170 | | | +-----> Down | | | +-----> Down | ||
171 | | | | +---> Up | | | | +---> Up | ||
172 | | | | | | | | | | | ||
173 | _____________ _____________ | ||
174 | 5 \ x o o o o / 1 5 \ o o o o o / 1 | ||
175 | \ x o o o / \ o o o o / | ||
176 | 9 `~~~~~~~' 6 9 `~~~~~~~' 6 | ||
177 | | | | | | | | | ||
178 | | | +----> Button | | | +----> Button 1 | ||
179 | | +------> Power | | +------> Button 2 | ||
180 | +--------> Ground | +--------> Output 3 | ||
181 | +----------> Ground | ||
182 | |||
183 | Amstrad CPC Commodore C64 | ||
184 | |||
185 | +-----------> Analog Y | ||
186 | +---------> Right | +---------> Right | ||
187 | | +-------> Left | | +-------> Left | ||
188 | | | +-----> Down | | | +-----> Down | ||
189 | | | | +---> Up | | | | +---> Up | ||
190 | | | | | | | | | | | ||
191 | _____________ _____________ | ||
192 | 5 \ x o o o o / 1 5 \ o o o o o / 1 | ||
193 | \ x o o o / \ o o o o / | ||
194 | 9 `~~~~~~~' 6 9 `~~~~~~~' 6 | ||
195 | | | | | | | | | ||
196 | | | +----> Button 1 | | | +----> Button | ||
197 | | +------> Button 2 | | +------> Power | ||
198 | +--------> Ground | +--------> Ground | ||
199 | +----------> Analog X | ||
200 | |||
201 | Sinclair Spectrum +2A/+3 Amiga 1200 | ||
202 | |||
203 | +-----------> Up +-----------> Button 3 | ||
204 | | +---------> Fire | +---------> Right | ||
205 | | | | | +-------> Left | ||
206 | | | +-----> Ground | | | +-----> Down | ||
207 | | | | | | | | +---> Up | ||
208 | | | | | | | | | | ||
209 | _____________ _____________ | ||
210 | 5 \ o o x o x / 1 5 \ o o o o o / 1 | ||
211 | \ o o o o / \ o o o o / | ||
212 | 9 `~~~~~~~' 6 9 `~~~~~~~' 6 | ||
213 | | | | | | | | | | ||
214 | | | | +----> Right | | | +----> Button 1 | ||
215 | | | +------> Left | | +------> Power | ||
216 | | +--------> Ground | +--------> Ground | ||
217 | +----------> Down +----------> Button 2 | ||
218 | |||
219 | And there were many others. | ||
220 | |||
221 | 2.2.1 Multisystem joysticks using db9.c | ||
222 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
223 | For the Multisystem joysticks, and their derivatives, the db9.c driver | ||
224 | was written. It allows only one joystick / gamepad per parallel port, but | ||
225 | the interface is easy to build and works with almost anything. | ||
226 | |||
227 | For the basic 1-button Multisystem joystick you connect its wires to the | ||
228 | parallel port like this: | ||
229 | |||
230 | (pin 1) -----> Power | ||
231 | (pin 18) -----> Ground | ||
232 | |||
233 | (pin 2) -----> Up | ||
234 | (pin 3) -----> Down | ||
235 | (pin 4) -----> Left | ||
236 | (pin 5) -----> Right | ||
237 | (pin 6) -----> Button 1 | ||
238 | |||
239 | However, if the joystick is switch based (eg. clicks when you move it), | ||
240 | you might or might not, depending on your parallel port, need 10 kOhm pullup | ||
241 | resistors on each of the direction and button signals, like this: | ||
242 | |||
243 | (pin 2) ------------+------> Up | ||
244 | Resistor | | ||
245 | (pin 1) --[10kOhm]--+ | ||
246 | |||
247 | Try without, and if it doesn't work, add them. For TTL based joysticks / | ||
248 | gamepads the pullups are not needed. | ||
249 | |||
250 | For joysticks with two buttons you connect the second button to pin 7 on | ||
251 | the parallel port. | ||
252 | |||
253 | (pin 7) -----> Button 2 | ||
254 | |||
255 | And that's it. | ||
256 | |||
257 | On a side note, if you have already built a different adapter for use with | ||
258 | the digital joystick driver 0.8.0.2, this is also supported by the db9.c | ||
259 | driver, as device type 8. (See section 3.2) | ||
260 | |||
261 | 2.2.2 Multisystem joysticks using gamecon.c | ||
262 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
263 | For some people just one joystick per parallel port is not enough, and/or | ||
264 | want to use them on one parallel port together with NES/SNES/PSX pads. This is | ||
265 | possible using the gamecon.c. It supports up to 5 devices of the above types, | ||
266 | including 1 and 2 buttons Multisystem joysticks. | ||
267 | |||
268 | However, there is nothing for free. To allow more sticks to be used at | ||
269 | once, you need the sticks to be purely switch based (that is non-TTL), and | ||
270 | not to need power. Just a plain simple six switches inside. If your | ||
271 | joystick can do more (eg. turbofire) you'll need to disable it totally first | ||
272 | if you want to use gamecon.c. | ||
273 | |||
274 | Also, the connection is a bit more complex. You'll need a bunch of diodes, | ||
275 | and one pullup resistor. First, you connect the Directions and the button | ||
276 | the same as for db9, however with the diodes inbetween. | ||
277 | |||
278 | Diodes | ||
279 | (pin 2) -----|<|----> Up | ||
280 | (pin 3) -----|<|----> Down | ||
281 | (pin 4) -----|<|----> Left | ||
282 | (pin 5) -----|<|----> Right | ||
283 | (pin 6) -----|<|----> Button 1 | ||
284 | |||
285 | For two button sticks you also connect the other button. | ||
286 | |||
287 | (pin 7) -----|<|----> Button 2 | ||
288 | |||
289 | And finally, you connect the Ground wire of the joystick, like done in | ||
290 | this little schematic to Power and Data on the parallel port, as described | ||
291 | for the NES / SNES pads in section 2.1 of this file - that is, one data pin | ||
292 | for each joystick. The power source is shared. | ||
293 | |||
294 | Data ------------+-----> Ground | ||
295 | Resistor | | ||
296 | Power --[10kOhm]--+ | ||
297 | |||
298 | And that's all, here we go! | ||
299 | |||
300 | 2.2.3 Multisystem joysticks using turbografx.c | ||
301 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
302 | The TurboGraFX interface, designed by | ||
303 | |||
304 | Steffen Schwenke <schwenke@burg-halle.de> | ||
305 | |||
306 | allows up to 7 Multisystem joysticks connected to the parallel port. In | ||
307 | Steffen's version, there is support for up to 5 buttons per joystick. However, | ||
308 | since this doesn't work reliably on all parallel ports, the turbografx.c driver | ||
309 | supports only one button per joystick. For more information on how to build the | ||
310 | interface, see | ||
311 | |||
312 | http://www2.burg-halle.de/~schwenke/parport.html | ||
313 | |||
314 | 2.3 Sony Playstation | ||
315 | ~~~~~~~~~~~~~~~~~~~~ | ||
316 | |||
317 | The PSX controller is supported by the gamecon.c. Pinout of the PSX | ||
318 | controller (compatible with DirectPadPro): | ||
319 | |||
320 | +---------+---------+---------+ | ||
321 | 9 | o o o | o o o | o o o | 1 parallel | ||
322 | \________|_________|________/ port pins | ||
323 | | | | | | | | ||
324 | | | | | | +--------> Clock --- (4) | ||
325 | | | | | +------------> Select --- (3) | ||
326 | | | | +---------------> Power --- (5-9) | ||
327 | | | +------------------> Ground --- (18-25) | ||
328 | | +-------------------------> Command --- (2) | ||
329 | +----------------------------> Data --- (one of 10,11,12,13,15) | ||
330 | |||
331 | The driver supports these controllers: | ||
332 | |||
333 | * Standard PSX Pad | ||
334 | * NegCon PSX Pad | ||
335 | * Analog PSX Pad (red mode) | ||
336 | * Analog PSX Pad (green mode) | ||
337 | * PSX Rumble Pad | ||
338 | * PSX DDR Pad | ||
339 | |||
340 | 2.4 Sega | ||
341 | ~~~~~~~~ | ||
342 | All the Sega controllers are more or less based on the standard 2-button | ||
343 | Multisystem joystick. However, since they don't use switches and use TTL | ||
344 | logic, the only driver usable with them is the db9.c driver. | ||
345 | |||
346 | 2.4.1 Sega Master System | ||
347 | ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
348 | The SMS gamepads are almost exactly the same as normal 2-button | ||
349 | Multisystem joysticks. Set the driver to Multi2 mode, use the corresponding | ||
350 | parallel port pins, and the following schematic: | ||
351 | |||
352 | +-----------> Power | ||
353 | | +---------> Right | ||
354 | | | +-------> Left | ||
355 | | | | +-----> Down | ||
356 | | | | | +---> Up | ||
357 | | | | | | | ||
358 | _____________ | ||
359 | 5 \ o o o o o / 1 | ||
360 | \ o o x o / | ||
361 | 9 `~~~~~~~' 6 | ||
362 | | | | | ||
363 | | | +----> Button 1 | ||
364 | | +--------> Ground | ||
365 | +----------> Button 2 | ||
366 | |||
367 | 2.4.2 Sega Genesis aka MegaDrive | ||
368 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
369 | The Sega Genesis (in Europe sold as Sega MegaDrive) pads are an extension | ||
370 | to the Sega Master System pads. They use more buttons (3+1, 5+1, 6+1). Use | ||
371 | the following schematic: | ||
372 | |||
373 | +-----------> Power | ||
374 | | +---------> Right | ||
375 | | | +-------> Left | ||
376 | | | | +-----> Down | ||
377 | | | | | +---> Up | ||
378 | | | | | | | ||
379 | _____________ | ||
380 | 5 \ o o o o o / 1 | ||
381 | \ o o o o / | ||
382 | 9 `~~~~~~~' 6 | ||
383 | | | | | | ||
384 | | | | +----> Button 1 | ||
385 | | | +------> Select | ||
386 | | +--------> Ground | ||
387 | +----------> Button 2 | ||
388 | |||
389 | The Select pin goes to pin 14 on the parallel port. | ||
390 | |||
391 | (pin 14) -----> Select | ||
392 | |||
393 | The rest is the same as for Multi2 joysticks using db9.c | ||
394 | |||
395 | 2.4.3 Sega Saturn | ||
396 | ~~~~~~~~~~~~~~~~~ | ||
397 | Sega Saturn has eight buttons, and to transfer that, without hacks like | ||
398 | Genesis 6 pads use, it needs one more select pin. Anyway, it is still | ||
399 | handled by the db9.c driver. Its pinout is very different from anything | ||
400 | else. Use this schematic: | ||
401 | |||
402 | +-----------> Select 1 | ||
403 | | +---------> Power | ||
404 | | | +-------> Up | ||
405 | | | | +-----> Down | ||
406 | | | | | +---> Ground | ||
407 | | | | | | | ||
408 | _____________ | ||
409 | 5 \ o o o o o / 1 | ||
410 | \ o o o o / | ||
411 | 9 `~~~~~~~' 6 | ||
412 | | | | | | ||
413 | | | | +----> Select 2 | ||
414 | | | +------> Right | ||
415 | | +--------> Left | ||
416 | +----------> Power | ||
417 | |||
418 | Select 1 is pin 14 on the parallel port, Select 2 is pin 16 on the | ||
419 | parallel port. | ||
420 | |||
421 | (pin 14) -----> Select 1 | ||
422 | (pin 16) -----> Select 2 | ||
423 | |||
424 | The other pins (Up, Down, Right, Left, Power, Ground) are the same as for | ||
425 | Multi joysticks using db9.c | ||
426 | |||
427 | 3. The drivers | ||
428 | ~~~~~~~~~~~~~~ | ||
429 | There are three drivers for the parallel port interfaces. Each, as | ||
430 | described above, allows to connect a different group of joysticks and pads. | ||
431 | Here are described their command lines: | ||
432 | |||
433 | 3.1 gamecon.c | ||
434 | ~~~~~~~~~~~~~ | ||
435 | Using gamecon.c you can connect up to five devices to one parallel port. It | ||
436 | uses the following kernel/module command line: | ||
437 | |||
438 | gamecon.map=port,pad1,pad2,pad3,pad4,pad5 | ||
439 | |||
440 | Where 'port' the number of the parport interface (eg. 0 for parport0). | ||
441 | |||
442 | And 'pad1' to 'pad5' are pad types connected to different data input pins | ||
443 | (10,11,12,13,15), as described in section 2.1 of this file. | ||
444 | |||
445 | The types are: | ||
446 | |||
447 | Type | Joystick/Pad | ||
448 | -------------------- | ||
449 | 0 | None | ||
450 | 1 | SNES pad | ||
451 | 2 | NES pad | ||
452 | 4 | Multisystem 1-button joystick | ||
453 | 5 | Multisystem 2-button joystick | ||
454 | 6 | N64 pad | ||
455 | 7 | Sony PSX controller | ||
456 | 8 | Sony PSX DDR controller | ||
457 | |||
458 | The exact type of the PSX controller type is autoprobed when used so | ||
459 | hot swapping should work (but is not recomended). | ||
460 | |||
461 | Should you want to use more than one of parallel ports at once, you can use | ||
462 | gamecon.map2 and gamecon.map3 as additional command line parameters for two | ||
463 | more parallel ports. | ||
464 | |||
465 | There are two options specific to PSX driver portion. gamecon.psx_delay sets | ||
466 | the command delay when talking to the controllers. The default of 25 should | ||
467 | work but you can try lowering it for better performace. If your pads don't | ||
468 | respond try raising it untill they work. Setting the type to 8 allows the | ||
469 | driver to be used with Dance Dance Revolution or similar games. Arrow keys are | ||
470 | registered as key presses instead of X and Y axes. | ||
471 | |||
472 | 3.2 db9.c | ||
473 | ~~~~~~~~~ | ||
474 | Apart from making an interface, there is nothing difficult on using the | ||
475 | db9.c driver. It uses the following kernel/module command line: | ||
476 | |||
477 | db9.dev=port,type | ||
478 | |||
479 | Where 'port' is the number of the parport interface (eg. 0 for parport0). | ||
480 | |||
481 | Caveat here: This driver only works on bidirectional parallel ports. If | ||
482 | your parallel port is recent enough, you should have no trouble with this. | ||
483 | Old parallel ports may not have this feature. | ||
484 | |||
485 | 'Type' is the type of joystick or pad attached: | ||
486 | |||
487 | Type | Joystick/Pad | ||
488 | -------------------- | ||
489 | 0 | None | ||
490 | 1 | Multisystem 1-button joystick | ||
491 | 2 | Multisystem 2-button joystick | ||
492 | 3 | Genesis pad (3+1 buttons) | ||
493 | 5 | Genesis pad (5+1 buttons) | ||
494 | 6 | Genesis pad (6+2 buttons) | ||
495 | 7 | Saturn pad (8 buttons) | ||
496 | 8 | Multisystem 1-button joystick (v0.8.0.2 pin-out) | ||
497 | 9 | Two Multisystem 1-button joysticks (v0.8.0.2 pin-out) | ||
498 | 10 | Amiga CD32 pad | ||
499 | |||
500 | Should you want to use more than one of these joysticks/pads at once, you | ||
501 | can use db9.dev2 and db9.dev3 as additional command line parameters for two | ||
502 | more joysticks/pads. | ||
503 | |||
504 | 3.3 turbografx.c | ||
505 | ~~~~~~~~~~~~~~~~ | ||
506 | The turbografx.c driver uses a very simple kernel/module command line: | ||
507 | |||
508 | turbografx.map=port,js1,js2,js3,js4,js5,js6,js7 | ||
509 | |||
510 | Where 'port' is the number of the parport interface (eg. 0 for parport0). | ||
511 | |||
512 | 'jsX' is the number of buttons the Multisystem joysticks connected to the | ||
513 | interface ports 1-7 have. For a standard multisystem joystick, this is 1. | ||
514 | |||
515 | Should you want to use more than one of these interfaces at once, you can | ||
516 | use turbografx.map2 and turbografx.map3 as additional command line parameters | ||
517 | for two more interfaces. | ||
518 | |||
519 | 3.4 PC parallel port pinout | ||
520 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
521 | .----------------------------------------. | ||
522 | At the PC: \ 13 12 11 10 9 8 7 6 5 4 3 2 1 / | ||
523 | \ 25 24 23 22 21 20 19 18 17 16 15 14 / | ||
524 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
525 | |||
526 | Pin | Name | Description | ||
527 | ~~~~~~|~~~~~~~~~|~~~~~~~~~~ | ||
528 | 1 | /STROBE | Strobe | ||
529 | 2-9 | D0-D7 | Data Bit 0-7 | ||
530 | 10 | /ACK | Acknowledge | ||
531 | 11 | BUSY | Busy | ||
532 | 12 | PE | Paper End | ||
533 | 13 | SELIN | Select In | ||
534 | 14 | /AUTOFD | Autofeed | ||
535 | 15 | /ERROR | Error | ||
536 | 16 | /INIT | Initialize | ||
537 | 17 | /SEL | Select | ||
538 | 18-25 | GND | Signal Ground | ||
539 | |||
540 | 3.5 End | ||
541 | ~~~~~~~ | ||
542 | That's all, folks! Have fun! | ||
diff --git a/Documentation/input/joystick.txt b/Documentation/input/joystick.txt new file mode 100644 index 000000000000..d53b857a3710 --- /dev/null +++ b/Documentation/input/joystick.txt | |||
@@ -0,0 +1,588 @@ | |||
1 | Linux Joystick driver v2.0.0 | ||
2 | (c) 1996-2000 Vojtech Pavlik <vojtech@ucw.cz> | ||
3 | Sponsored by SuSE | ||
4 | $Id: joystick.txt,v 1.12 2002/03/03 12:13:07 jdeneux Exp $ | ||
5 | ---------------------------------------------------------------------------- | ||
6 | |||
7 | 0. Disclaimer | ||
8 | ~~~~~~~~~~~~~ | ||
9 | This program is free software; you can redistribute it and/or modify it | ||
10 | under the terms of the GNU General Public License as published by the Free | ||
11 | Software Foundation; either version 2 of the License, or (at your option) | ||
12 | any later version. | ||
13 | |||
14 | This program is distributed in the hope that it will be useful, but | ||
15 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
16 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
17 | more details. | ||
18 | |||
19 | You should have received a copy of the GNU General Public License along | ||
20 | with this program; if not, write to the Free Software Foundation, Inc., 59 | ||
21 | Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | |||
23 | Should you need to contact me, the author, you can do so either by e-mail | ||
24 | - mail your message to <vojtech@ucw.cz>, or by paper mail: Vojtech Pavlik, | ||
25 | Simunkova 1594, Prague 8, 182 00 Czech Republic | ||
26 | |||
27 | For your convenience, the GNU General Public License version 2 is included | ||
28 | in the package: See the file COPYING. | ||
29 | |||
30 | 1. Intro | ||
31 | ~~~~~~~~ | ||
32 | The joystick driver for Linux provides support for a variety of joysticks | ||
33 | and similar devices. It is based on a larger project aiming to support all | ||
34 | input devices in Linux. | ||
35 | |||
36 | Should you encounter any problems while using the driver, or joysticks | ||
37 | this driver can't make complete use of, I'm very interested in hearing about | ||
38 | them. Bug reports and success stories are also welcome. | ||
39 | |||
40 | The input project website is at: | ||
41 | |||
42 | http://www.suse.cz/development/input/ | ||
43 | http://atrey.karlin.mff.cuni.cz/~vojtech/input/ | ||
44 | |||
45 | There is also a mailing list for the driver at: | ||
46 | |||
47 | listproc@atrey.karlin.mff.cuni.cz | ||
48 | |||
49 | send "subscribe linux-joystick Your Name" to subscribe to it. | ||
50 | |||
51 | 2. Usage | ||
52 | ~~~~~~~~ | ||
53 | For basic usage you just choose the right options in kernel config and | ||
54 | you should be set. | ||
55 | |||
56 | 2.1 inpututils | ||
57 | ~~~~~~~~~~~~~~ | ||
58 | For testing and other purposes (for example serial devices), a set of | ||
59 | utilities is available at the abovementioned website. I suggest you download | ||
60 | and install it before going on. | ||
61 | |||
62 | 2.2 Device nodes | ||
63 | ~~~~~~~~~~~~~~~~ | ||
64 | For applications to be able to use the joysticks, in you don't use devfs, | ||
65 | you'll have to manually create these nodes in /dev: | ||
66 | |||
67 | cd /dev | ||
68 | rm js* | ||
69 | mkdir input | ||
70 | mknod input/js0 c 13 0 | ||
71 | mknod input/js1 c 13 1 | ||
72 | mknod input/js2 c 13 2 | ||
73 | mknod input/js3 c 13 3 | ||
74 | ln -s input/js0 js0 | ||
75 | ln -s input/js1 js1 | ||
76 | ln -s input/js2 js2 | ||
77 | ln -s input/js3 js3 | ||
78 | |||
79 | For testing with inpututils it's also convenient to create these: | ||
80 | |||
81 | mknod input/event0 c 13 64 | ||
82 | mknod input/event1 c 13 65 | ||
83 | mknod input/event2 c 13 66 | ||
84 | mknod input/event3 c 13 67 | ||
85 | |||
86 | 2.4 Modules needed | ||
87 | ~~~~~~~~~~~~~~~~~~ | ||
88 | For all joystick drivers to function, you'll need the userland interface | ||
89 | module in kernel, either loaded or compiled in: | ||
90 | |||
91 | modprobe joydev | ||
92 | |||
93 | For gameport joysticks, you'll have to load the gameport driver as well; | ||
94 | |||
95 | modprobe ns558 | ||
96 | |||
97 | And for serial port joysticks, you'll need the serial input line | ||
98 | discipline module loaded and the inputattach utility started: | ||
99 | |||
100 | modprobe serport | ||
101 | inputattach -xxx /dev/tts/X & | ||
102 | |||
103 | In addition to that, you'll need the joystick driver module itself, most | ||
104 | usually you'll have an analog joystick: | ||
105 | |||
106 | modprobe analog | ||
107 | |||
108 | For automatic module loading, something like this might work - tailor to | ||
109 | your needs: | ||
110 | |||
111 | alias tty-ldisc-2 serport | ||
112 | alias char-major-13 input | ||
113 | above input joydev ns558 analog | ||
114 | options analog map=gamepad,none,2btn | ||
115 | |||
116 | 2.5 Verifying that it works | ||
117 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
118 | For testing the joystick driver functionality, there is the jstest | ||
119 | program in the utilities package. You run it by typing: | ||
120 | |||
121 | jstest /dev/js0 | ||
122 | |||
123 | And it should show a line with the joystick values, which update as you | ||
124 | move the stick, and press its buttons. The axes should all be zero when the | ||
125 | joystick is in the center position. They should not jitter by themselves to | ||
126 | other close values, and they also should be steady in any other position of | ||
127 | the stick. They should have the full range from -32767 to 32767. If all this | ||
128 | is met, then it's all fine, and you can play the games. :) | ||
129 | |||
130 | If it's not, then there might be a problem. Try to calibrate the joystick, | ||
131 | and if it still doesn't work, read the drivers section of this file, the | ||
132 | troubleshooting section, and the FAQ. | ||
133 | |||
134 | 2.6. Calibration | ||
135 | ~~~~~~~~~~~~~~~~ | ||
136 | For most joysticks you won't need any manual calibration, since the | ||
137 | joystick should be autocalibrated by the driver automagically. However, with | ||
138 | some analog joysticks, that either do not use linear resistors, or if you | ||
139 | want better precision, you can use the jscal program | ||
140 | |||
141 | jscal -c /dev/js0 | ||
142 | |||
143 | included in the joystick package to set better correction coefficients than | ||
144 | what the driver would choose itself. | ||
145 | |||
146 | After calibrating the joystick you can verify if you like the new | ||
147 | calibration using the jstest command, and if you do, you then can save the | ||
148 | correction coefficients into a file | ||
149 | |||
150 | jscal -p /dev/js0 > /etc/joystick.cal | ||
151 | |||
152 | And add a line to your rc script executing that file | ||
153 | |||
154 | source /etc/joystick.cal | ||
155 | |||
156 | This way, after the next reboot your joystick will remain calibrated. You | ||
157 | can also add the jscal -p line to your shutdown script. | ||
158 | |||
159 | |||
160 | 3. HW specific driver information | ||
161 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
162 | In this section each of the separate hardware specific drivers is described. | ||
163 | |||
164 | 3.1 Analog joysticks | ||
165 | ~~~~~~~~~~~~~~~~~~~~ | ||
166 | The analog.c uses the standard analog inputs of the gameport, and thus | ||
167 | supports all standard joysticks and gamepads. It uses a very advanced | ||
168 | routine for this, allowing for data precision that can't be found on any | ||
169 | other system. | ||
170 | |||
171 | It also supports extensions like additional hats and buttons compatible | ||
172 | with CH Flightstick Pro, ThrustMaster FCS or 6 and 8 button gamepads. Saitek | ||
173 | Cyborg 'digital' joysticks are also supported by this driver, because | ||
174 | they're basically souped up CHF sticks. | ||
175 | |||
176 | However the only types that can be autodetected are: | ||
177 | |||
178 | * 2-axis, 4-button joystick | ||
179 | * 3-axis, 4-button joystick | ||
180 | * 4-axis, 4-button joystick | ||
181 | * Saitek Cyborg 'digital' joysticks | ||
182 | |||
183 | For other joystick types (more/less axes, hats, and buttons) support | ||
184 | you'll need to specify the types either on the kernel command line or on the | ||
185 | module command line, when inserting analog into the kernel. The | ||
186 | parameters are: | ||
187 | |||
188 | analog.map=<type1>,<type2>,<type3>,.... | ||
189 | |||
190 | 'type' is type of the joystick from the table below, defining joysticks | ||
191 | present on gameports in the system, starting with gameport0, second 'type' | ||
192 | entry defining joystick on gameport1 and so on. | ||
193 | |||
194 | Type | Meaning | ||
195 | ----------------------------------- | ||
196 | none | No analog joystick on that port | ||
197 | auto | Autodetect joystick | ||
198 | 2btn | 2-button n-axis joystick | ||
199 | y-joy | Two 2-button 2-axis joysticks on an Y-cable | ||
200 | y-pad | Two 2-button 2-axis gamepads on an Y-cable | ||
201 | fcs | Thrustmaster FCS compatible joystick | ||
202 | chf | Joystick with a CH Flightstick compatible hat | ||
203 | fullchf | CH Flightstick compatible with two hats and 6 buttons | ||
204 | gamepad | 4/6-button n-axis gamepad | ||
205 | gamepad8 | 8-button 2-axis gamepad | ||
206 | |||
207 | In case your joystick doesn't fit in any of the above categories, you can | ||
208 | specify the type as a number by combining the bits in the table below. This | ||
209 | is not recommended unless you really know what are you doing. It's not | ||
210 | dangerous, but not simple either. | ||
211 | |||
212 | Bit | Meaning | ||
213 | -------------------------- | ||
214 | 0 | Axis X1 | ||
215 | 1 | Axis Y1 | ||
216 | 2 | Axis X2 | ||
217 | 3 | Axis Y2 | ||
218 | 4 | Button A | ||
219 | 5 | Button B | ||
220 | 6 | Button C | ||
221 | 7 | Button D | ||
222 | 8 | CHF Buttons X and Y | ||
223 | 9 | CHF Hat 1 | ||
224 | 10 | CHF Hat 2 | ||
225 | 11 | FCS Hat | ||
226 | 12 | Pad Button X | ||
227 | 13 | Pad Button Y | ||
228 | 14 | Pad Button U | ||
229 | 15 | Pad Button V | ||
230 | 16 | Saitek F1-F4 Buttons | ||
231 | 17 | Saitek Digital Mode | ||
232 | 19 | GamePad | ||
233 | 20 | Joy2 Axis X1 | ||
234 | 21 | Joy2 Axis Y1 | ||
235 | 22 | Joy2 Axis X2 | ||
236 | 23 | Joy2 Axis Y2 | ||
237 | 24 | Joy2 Button A | ||
238 | 25 | Joy2 Button B | ||
239 | 26 | Joy2 Button C | ||
240 | 27 | Joy2 Button D | ||
241 | 31 | Joy2 GamePad | ||
242 | |||
243 | 3.2 Microsoft SideWinder joysticks | ||
244 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
245 | Microsoft 'Digital Overdrive' protocol is supported by the sidewinder.c | ||
246 | module. All currently supported joysticks: | ||
247 | |||
248 | * Microsoft SideWinder 3D Pro | ||
249 | * Microsoft SideWinder Force Feedback Pro | ||
250 | * Microsoft SideWinder Force Feedback Wheel | ||
251 | * Microsoft SideWinder FreeStyle Pro | ||
252 | * Microsoft SideWinder GamePad (up to four, chained) | ||
253 | * Microsoft SideWinder Precision Pro | ||
254 | * Microsoft SideWinder Precision Pro USB | ||
255 | |||
256 | are autodetected, and thus no module parameters are needed. | ||
257 | |||
258 | There is one caveat with the 3D Pro. There are 9 buttons reported, | ||
259 | although the joystick has only 8. The 9th button is the mode switch on the | ||
260 | rear side of the joystick. However, moving it, you'll reset the joystick, | ||
261 | and make it unresponsive for about a one third of a second. Furthermore, the | ||
262 | joystick will also re-center itself, taking the position it was in during | ||
263 | this time as a new center position. Use it if you want, but think first. | ||
264 | |||
265 | The SideWinder Standard is not a digital joystick, and thus is supported | ||
266 | by the analog driver described above. | ||
267 | |||
268 | 3.3 Logitech ADI devices | ||
269 | ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
270 | Logitech ADI protocol is supported by the adi.c module. It should support | ||
271 | any Logitech device using this protocol. This includes, but is not limited | ||
272 | to: | ||
273 | |||
274 | * Logitech CyberMan 2 | ||
275 | * Logitech ThunderPad Digital | ||
276 | * Logitech WingMan Extreme Digital | ||
277 | * Logitech WingMan Formula | ||
278 | * Logitech WingMan Interceptor | ||
279 | * Logitech WingMan GamePad | ||
280 | * Logitech WingMan GamePad USB | ||
281 | * Logitech WingMan GamePad Extreme | ||
282 | * Logitech WingMan Extreme Digital 3D | ||
283 | |||
284 | ADI devices are autodetected, and the driver supports up to two (any | ||
285 | combination of) devices on a single gameport, using an Y-cable or chained | ||
286 | together. | ||
287 | |||
288 | Logitech WingMan Joystick, Logitech WingMan Attack, Logitech WingMan | ||
289 | Extreme and Logitech WingMan ThunderPad are not digital joysticks and are | ||
290 | handled by the analog driver described above. Logitech WingMan Warrior and | ||
291 | Logitech Magellan are supported by serial drivers described below. Logitech | ||
292 | WingMan Force and Logitech WingMan Formula Force are supported by the | ||
293 | I-Force driver described below. Logitech CyberMan is not supported yet. | ||
294 | |||
295 | 3.4 Gravis GrIP | ||
296 | ~~~~~~~~~~~~~~~ | ||
297 | Gravis GrIP protocol is supported by the grip.c module. It currently | ||
298 | supports: | ||
299 | |||
300 | * Gravis GamePad Pro | ||
301 | * Gravis BlackHawk Digital | ||
302 | * Gravis Xterminator | ||
303 | * Gravis Xterminator DualControl | ||
304 | |||
305 | All these devices are autodetected, and you can even use any combination | ||
306 | of up to two of these pads either chained together or using an Y-cable on a | ||
307 | single gameport. | ||
308 | |||
309 | GrIP MultiPort isn't supported yet. Gravis Stinger is a serial device and is | ||
310 | supported by the stinger driver. Other Gravis joysticks are supported by the | ||
311 | analog driver. | ||
312 | |||
313 | 3.5 FPGaming A3D and MadCatz A3D | ||
314 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
315 | The Assassin 3D protocol created by FPGaming, is used both by FPGaming | ||
316 | themselves and is licensed to MadCatz. A3D devices are supported by the | ||
317 | a3d.c module. It currently supports: | ||
318 | |||
319 | * FPGaming Assassin 3D | ||
320 | * MadCatz Panther | ||
321 | * MadCatz Panther XL | ||
322 | |||
323 | All these devices are autodetected. Because the Assassin 3D and the Panther | ||
324 | allow connecting analog joysticks to them, you'll need to load the analog | ||
325 | driver as well to handle the attached joysticks. | ||
326 | |||
327 | The trackball should work with USB mousedev module as a normal mouse. See | ||
328 | the USB documentation for how to setup an USB mouse. | ||
329 | |||
330 | 3.6 ThrustMaster DirectConnect (BSP) | ||
331 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
332 | The TM DirectConnect (BSP) protocol is supported by the tmdc.c | ||
333 | module. This includes, but is not limited to: | ||
334 | |||
335 | * ThrustMaster Millenium 3D Inceptor | ||
336 | * ThrustMaster 3D Rage Pad | ||
337 | * ThrustMaster Fusion Digital Game Pad | ||
338 | |||
339 | Devices not directly supported, but hopefully working are: | ||
340 | |||
341 | * ThrustMaster FragMaster | ||
342 | * ThrustMaster Attack Throttle | ||
343 | |||
344 | If you have one of these, contact me. | ||
345 | |||
346 | TMDC devices are autodetected, and thus no parameters to the module | ||
347 | are needed. Up to two TMDC devices can be connected to one gameport, using | ||
348 | an Y-cable. | ||
349 | |||
350 | 3.7 Creative Labs Blaster | ||
351 | ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
352 | The Blaster protocol is supported by the cobra.c module. It supports only | ||
353 | the: | ||
354 | |||
355 | * Creative Blaster GamePad Cobra | ||
356 | |||
357 | Up to two of these can be used on a single gameport, using an Y-cable. | ||
358 | |||
359 | 3.8 Genius Digital joysticks | ||
360 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
361 | The Genius digitally communicating joysticks are supported by the gf2k.c | ||
362 | module. This includes: | ||
363 | |||
364 | * Genius Flight2000 F-23 joystick | ||
365 | * Genius Flight2000 F-31 joystick | ||
366 | * Genius G-09D gamepad | ||
367 | |||
368 | Other Genius digital joysticks are not supported yet, but support can be | ||
369 | added fairly easily. | ||
370 | |||
371 | 3.9 InterAct Digital joysticks | ||
372 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
373 | The InterAct digitally communicating joysticks are supported by the | ||
374 | interact.c module. This includes: | ||
375 | |||
376 | * InterAct HammerHead/FX gamepad | ||
377 | * InterAct ProPad8 gamepad | ||
378 | |||
379 | Other InterAct digital joysticks are not supported yet, but support can be | ||
380 | added fairly easily. | ||
381 | |||
382 | 3.10 PDPI Lightning 4 gamecards | ||
383 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
384 | PDPI Lightning 4 gamecards are supported by the lightning.c module. | ||
385 | Once the module is loaded, the analog driver can be used to handle the | ||
386 | joysticks. Digitally communicating joystick will work only on port 0, while | ||
387 | using Y-cables, you can connect up to 8 analog joysticks to a single L4 | ||
388 | card, 16 in case you have two in your system. | ||
389 | |||
390 | 3.11 Trident 4DWave / Aureal Vortex | ||
391 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
392 | Soundcards with a Trident 4DWave DX/NX or Aureal Vortex/Vortex2 chipsets | ||
393 | provide an "Enhanced Game Port" mode where the soundcard handles polling the | ||
394 | joystick. This mode is supported by the pcigame.c module. Once loaded the | ||
395 | analog driver can use the enhanced features of these gameports.. | ||
396 | |||
397 | 3.13 Crystal SoundFusion | ||
398 | ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
399 | Soundcards with Crystal SoundFusion chipsets provide an "Enhanced Game | ||
400 | Port", much like the 4DWave or Vortex above. This, and also the normal mode | ||
401 | for the port of the SoundFusion is supported by the cs461x.c module. | ||
402 | |||
403 | 3.14 SoundBlaster Live! | ||
404 | ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
405 | The Live! has a special PCI gameport, which, although it doesn't provide | ||
406 | any "Enhanced" stuff like 4DWave and friends, is quite a bit faster than | ||
407 | it's ISA counterparts. It also requires special support, hence the | ||
408 | emu10k1-gp.c module for it instead of the normal ns558.c one. | ||
409 | |||
410 | 3.15 SoundBlaster 64 and 128 - ES1370 and ES1371, ESS Solo1 and S3 SonicVibes | ||
411 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
412 | These PCI soundcards have specific gameports. They are handled by the | ||
413 | sound drivers themselves. Make sure you select gameport support in the | ||
414 | joystick menu and sound card support in the sound menu for your appropriate | ||
415 | card. | ||
416 | |||
417 | 3.16 Amiga | ||
418 | ~~~~~~~~~~ | ||
419 | Amiga joysticks, connected to an Amiga, are supported by the amijoy.c | ||
420 | driver. Since they can't be autodetected, the driver has a command line. | ||
421 | |||
422 | amijoy.map=<a>,<b> | ||
423 | |||
424 | a and b define the joysticks connected to the JOY0DAT and JOY1DAT ports of | ||
425 | the Amiga. | ||
426 | |||
427 | Value | Joystick type | ||
428 | --------------------- | ||
429 | 0 | None | ||
430 | 1 | 1-button digital joystick | ||
431 | |||
432 | No more joystick types are supported now, but that should change in the | ||
433 | future if I get an Amiga in the reach of my fingers. | ||
434 | |||
435 | 3.17 Game console and 8-bit pads and joysticks | ||
436 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
437 | See joystick-parport.txt for more info. | ||
438 | |||
439 | 3.18 SpaceTec/LabTec devices | ||
440 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
441 | SpaceTec serial devices communicate using the SpaceWare protocol. It is | ||
442 | supported by the spaceorb.c and spaceball.c drivers. The devices currently | ||
443 | supported by spaceorb.c are: | ||
444 | |||
445 | * SpaceTec SpaceBall Avenger | ||
446 | * SpaceTec SpaceOrb 360 | ||
447 | |||
448 | Devices currently supported by spaceball.c are: | ||
449 | |||
450 | * SpaceTec SpaceBall 4000 FLX | ||
451 | |||
452 | In addition to having the spaceorb/spaceball and serport modules in the | ||
453 | kernel, you also need to attach a serial port to it. to do that, run the | ||
454 | inputattach program: | ||
455 | |||
456 | inputattach --spaceorb /dev/tts/x & | ||
457 | or | ||
458 | inputattach --spaceball /dev/tts/x & | ||
459 | |||
460 | where /dev/tts/x is the serial port which the device is connected to. After | ||
461 | doing this, the device will be reported and will start working. | ||
462 | |||
463 | There is one caveat with the SpaceOrb. The button #6, the on the bottom | ||
464 | side of the orb, although reported as an ordinary button, causes internal | ||
465 | recentering of the spaceorb, moving the zero point to the position in which | ||
466 | the ball is at the moment of pressing the button. So, think first before | ||
467 | you bind it to some other function. | ||
468 | |||
469 | SpaceTec SpaceBall 2003 FLX and 3003 FLX are not supported yet. | ||
470 | |||
471 | 3.19 Logitech SWIFT devices | ||
472 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
473 | The SWIFT serial protocol is supported by the warrior.c module. It | ||
474 | currently supports only the: | ||
475 | |||
476 | * Logitech WingMan Warrior | ||
477 | |||
478 | but in the future, Logitech CyberMan (the original one, not CM2) could be | ||
479 | supported as well. To use the module, you need to run inputattach after you | ||
480 | insert/compile the module into your kernel: | ||
481 | |||
482 | inputattach --warrior /dev/tts/x & | ||
483 | |||
484 | /dev/tts/x is the serial port your Warrior is attached to. | ||
485 | |||
486 | 3.20 Magellan / Space Mouse | ||
487 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
488 | The Magellan (or Space Mouse), manufactured by LogiCad3d (formerly Space | ||
489 | Systems), for many other companies (Logitech, HP, ...) is supported by the | ||
490 | joy-magellan module. It currently supports only the: | ||
491 | |||
492 | * Magellan 3D | ||
493 | * Space Mouse | ||
494 | |||
495 | models, the additional buttons on the 'Plus' versions are not supported yet. | ||
496 | |||
497 | To use it, you need to attach the serial port to the driver using the | ||
498 | |||
499 | inputattach --magellan /dev/tts/x & | ||
500 | |||
501 | command. After that the Magellan will be detected, initialized, will beep, | ||
502 | and the /dev/input/jsX device should become usable. | ||
503 | |||
504 | 3.21 I-Force devices | ||
505 | ~~~~~~~~~~~~~~~~~~~~ | ||
506 | All I-Force devices are supported by the iforce module. This includes: | ||
507 | |||
508 | * AVB Mag Turbo Force | ||
509 | * AVB Top Shot Pegasus | ||
510 | * AVB Top Shot Force Feedback Racing Wheel | ||
511 | * Logitech WingMan Force | ||
512 | * Logitech WingMan Force Wheel | ||
513 | * Guillemot Race Leader Force Feedback | ||
514 | * Guillemot Force Feedback Racing Wheel | ||
515 | * Thrustmaster Motor Sport GT | ||
516 | |||
517 | To use it, you need to attach the serial port to the driver using the | ||
518 | |||
519 | inputattach --iforce /dev/tts/x & | ||
520 | |||
521 | command. After that the I-Force device will be detected, and the | ||
522 | /dev/input/jsX device should become usable. | ||
523 | |||
524 | In case you're using the device via the USB port, the inputattach command | ||
525 | isn't needed. | ||
526 | |||
527 | The I-Force driver now supports force feedback via the event interface. | ||
528 | |||
529 | Please note that Logitech WingMan *3D devices are _not_ supported by this | ||
530 | module, rather by hid. Force feedback is not supported for those devices. | ||
531 | Logitech gamepads are also hid devices. | ||
532 | |||
533 | 3.22 Gravis Stinger gamepad | ||
534 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
535 | The Gravis Stinger serial port gamepad, designed for use with laptop | ||
536 | computers, is supported by the stinger.c module. To use it, attach the | ||
537 | serial port to the driver using: | ||
538 | |||
539 | inputattach --stinger /dev/tty/x & | ||
540 | |||
541 | where x is the number of the serial port. | ||
542 | |||
543 | 4. Troubleshooting | ||
544 | ~~~~~~~~~~~~~~~~~~ | ||
545 | There is quite a high probability that you run into some problems. For | ||
546 | testing whether the driver works, if in doubt, use the jstest utility in | ||
547 | some of its modes. The most useful modes are "normal" - for the 1.x | ||
548 | interface, and "old" for the "0.x" interface. You run it by typing: | ||
549 | |||
550 | jstest --normal /dev/input/js0 | ||
551 | jstest --old /dev/input/js0 | ||
552 | |||
553 | Additionally you can do a test with the evtest utility: | ||
554 | |||
555 | evtest /dev/input/event0 | ||
556 | |||
557 | Oh, and read the FAQ! :) | ||
558 | |||
559 | 5. FAQ | ||
560 | ~~~~~~ | ||
561 | Q: Running 'jstest /dev/js0' results in "File not found" error. What's the | ||
562 | cause? | ||
563 | A: The device files don't exist. Create them (see section 2.2). | ||
564 | |||
565 | Q: Is it possible to connect my old Atari/Commodore/Amiga/console joystick | ||
566 | or pad that uses a 9-pin D-type cannon connector to the serial port of my | ||
567 | PC? | ||
568 | A: Yes, it is possible, but it'll burn your serial port or the pad. It | ||
569 | won't work, of course. | ||
570 | |||
571 | Q: My joystick doesn't work with Quake / Quake 2. What's the cause? | ||
572 | A: Quake / Quake 2 don't support joystick. Use joy2key to simulate keypresses | ||
573 | for them. | ||
574 | |||
575 | 6. Programming Interface | ||
576 | ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
577 | The 1.0 driver uses a new, event based approach to the joystick driver. | ||
578 | Instead of the user program polling for the joystick values, the joystick | ||
579 | driver now reports only any changes of its state. See joystick-api.txt, | ||
580 | joystick.h and jstest.c included in the joystick package for more | ||
581 | information. The joystick device can be used in either blocking or | ||
582 | nonblocking mode and supports select() calls. | ||
583 | |||
584 | For backward compatibility the old (v0.x) interface is still included. | ||
585 | Any call to the joystick driver using the old interface will return values | ||
586 | that are compatible to the old interface. This interface is still limited | ||
587 | to 2 axes, and applications using it usually decode only 2 buttons, although | ||
588 | the driver provides up to 32. | ||
diff --git a/Documentation/input/shape.fig b/Documentation/input/shape.fig new file mode 100644 index 000000000000..c22bff83d06f --- /dev/null +++ b/Documentation/input/shape.fig | |||
@@ -0,0 +1,65 @@ | |||
1 | #FIG 3.2 | ||
2 | Landscape | ||
3 | Center | ||
4 | Inches | ||
5 | Letter | ||
6 | 100.00 | ||
7 | Single | ||
8 | -2 | ||
9 | 1200 2 | ||
10 | 2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 6 | ||
11 | 4200 3600 4200 3075 4950 2325 7425 2325 8250 3150 8250 3600 | ||
12 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
13 | 4200 3675 4200 5400 | ||
14 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
15 | 8250 3675 8250 5400 | ||
16 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
17 | 3675 3600 8700 3600 | ||
18 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
19 | 8775 3600 10200 3600 | ||
20 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
21 | 8325 3150 9075 3150 | ||
22 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
23 | 7500 2325 10200 2325 | ||
24 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
25 | 3600 3600 3000 3600 | ||
26 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
27 | 4125 3075 3000 3075 | ||
28 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2 | ||
29 | 0 0 1.00 60.00 120.00 | ||
30 | 0 0 1.00 60.00 120.00 | ||
31 | 4200 5400 8175 5400 | ||
32 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2 | ||
33 | 0 0 1.00 60.00 120.00 | ||
34 | 0 0 1.00 60.00 120.00 | ||
35 | 10125 2325 10125 3600 | ||
36 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2 | ||
37 | 0 0 1.00 60.00 120.00 | ||
38 | 0 0 1.00 60.00 120.00 | ||
39 | 3000 3150 3000 3600 | ||
40 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2 | ||
41 | 0 0 1.00 60.00 120.00 | ||
42 | 0 0 1.00 60.00 120.00 | ||
43 | 9075 3150 9075 3600 | ||
44 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
45 | 4950 2325 4950 1200 | ||
46 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 | ||
47 | 7425 2325 7425 1200 | ||
48 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 4 | ||
49 | 4200 3075 4200 2400 3600 1800 3600 1200 | ||
50 | 2 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 4 | ||
51 | 8250 3150 8250 2475 8775 1950 8775 1200 | ||
52 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2 | ||
53 | 0 0 1.00 60.00 120.00 | ||
54 | 0 0 1.00 60.00 120.00 | ||
55 | 3600 1275 4950 1275 | ||
56 | 2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2 | ||
57 | 0 0 1.00 60.00 120.00 | ||
58 | 0 0 1.00 60.00 120.00 | ||
59 | 7425 1275 8700 1275 | ||
60 | 4 1 0 50 0 0 12 0.0000 4 135 1140 6075 5325 Effect duration\001 | ||
61 | 4 0 0 50 0 0 12 0.0000 4 180 1305 10200 3000 Effect magnitude\001 | ||
62 | 4 0 0 50 0 0 12 0.0000 4 135 780 9150 3450 Fade level\001 | ||
63 | 4 1 0 50 0 0 12 0.0000 4 180 1035 4275 1200 Attack length\001 | ||
64 | 4 1 0 50 0 0 12 0.0000 4 180 885 8175 1200 Fade length\001 | ||
65 | 4 2 0 50 0 0 12 0.0000 4 135 930 2925 3375 Attack level\001 | ||
diff --git a/Documentation/input/xpad.txt b/Documentation/input/xpad.txt new file mode 100644 index 000000000000..b9111a703ce0 --- /dev/null +++ b/Documentation/input/xpad.txt | |||
@@ -0,0 +1,116 @@ | |||
1 | xpad - Linux USB driver for X-Box gamepads | ||
2 | |||
3 | This is the very first release of a driver for X-Box gamepads. | ||
4 | Basically, this was hacked away in just a few hours, so don't expect | ||
5 | miracles. | ||
6 | In particular, there is currently NO support for the rumble pack. | ||
7 | You won't find many ff-aware linux applications anyway. | ||
8 | |||
9 | |||
10 | 0. Status | ||
11 | --------- | ||
12 | |||
13 | For now, this driver has only been tested on just one Linux-Box. | ||
14 | This one is running a 2.4.18 kernel with usb-uhci on an amd athlon 600. | ||
15 | |||
16 | The jstest-program from joystick-1.2.15 (jstest-version 2.1.0) reports | ||
17 | 8 axes and 10 buttons. | ||
18 | |||
19 | Alls 8 axes work, though they all have the same range (-32768..32767) | ||
20 | and the zero-setting is not correct for the triggers (I don't know if that | ||
21 | is some limitation of jstest, since the input device setup should be fine. I | ||
22 | didn't have a look at jstest itself yet). | ||
23 | |||
24 | All of the 10 buttons work (in digital mode). The six buttons on the | ||
25 | right side (A, B, X, Y, black, white) are said to be "analog" and | ||
26 | report their values as 8 bit unsigned, not sure what this is good for. | ||
27 | |||
28 | I tested the controller with quake3, and configuration and | ||
29 | in game functionality were OK. However, I find it rather difficult to | ||
30 | play first person shooters with a pad. Your mileage may vary. | ||
31 | |||
32 | |||
33 | 1. USB adapter | ||
34 | -------------- | ||
35 | |||
36 | Before you can actually use the driver, you need to get yourself an | ||
37 | adapter cable to connect the X-Box controller to your Linux-Box. | ||
38 | |||
39 | Such a cable is pretty easy to build. The Controller itself is a USB compound | ||
40 | device (a hub with three ports for two expansion slots and the controller | ||
41 | device) with the only difference in a nonstandard connector (5 pins vs. 4 on | ||
42 | standard USB connector). | ||
43 | |||
44 | You just need to solder a USB connector onto the cable and keep the | ||
45 | yellow wire unconnected. The other pins have the same order on both | ||
46 | connectors so there is no magic to it. Detailed info on these matters | ||
47 | can be found on the net ([1], [2], [3]). | ||
48 | |||
49 | Thanks to the trip splitter found on the cable you don't even need to cut the | ||
50 | original one. You can buy an extension cable and cut that instead. That way, | ||
51 | you can still use the controller with your X-Box, if you have one ;) | ||
52 | |||
53 | |||
54 | 2. driver installation | ||
55 | ---------------------- | ||
56 | |||
57 | Once you have the adapter cable and the controller is connected, you need | ||
58 | to load your USB subsystem and should cat /proc/bus/usb/devices. | ||
59 | There should be an entry like the one at the end [4]. | ||
60 | |||
61 | Currently (as of version 0.0.4), the following three devices are included: | ||
62 | original Microsoft XBOX controller (US), vendor=0x045e, product=0x0202 | ||
63 | original Microsoft XBOX controller (Japan), vendor=0x045e, product=0x0285 | ||
64 | InterAct PowerPad Pro (Germany), vendor=0x05fd, product=0x107a | ||
65 | |||
66 | If you have another controller that is not listed above and is not recognized | ||
67 | by the driver, please drop me a line with the appropriate info (that is, include | ||
68 | the name, vendor and product ID, as well as the country where you bought it; | ||
69 | sending the whole dump out of /proc/bus/usb/devices along would be even better). | ||
70 | |||
71 | In theory, the driver should work with other controllers than mine | ||
72 | (InterAct PowerPad pro, bought in Germany) just fine, but I cannot test this | ||
73 | for I only have this one controller. | ||
74 | |||
75 | If you compiled and installed the driver, test the functionality: | ||
76 | > modprobe xpad | ||
77 | > modprobe joydev | ||
78 | > jstest /dev/js0 | ||
79 | |||
80 | There should be a single line showing 18 inputs (8 axes, 10 buttons), and | ||
81 | it's values should change if you move the sticks and push the buttons. | ||
82 | |||
83 | It works? Voila, your done ;) | ||
84 | |||
85 | |||
86 | 3. Thanks | ||
87 | --------- | ||
88 | |||
89 | I have to thank ITO Takayuki for the detailed info on his site | ||
90 | http://euc.jp/periphs/xbox-controller.ja.html. | ||
91 | |||
92 | His useful info and both the usb-skeleton as well as the iforce input driver | ||
93 | (Greg Kroah-Hartmann; Vojtech Pavlik) helped a lot in rapid prototyping | ||
94 | the basic functionality. | ||
95 | |||
96 | |||
97 | 4. References | ||
98 | ------------- | ||
99 | |||
100 | 1. http://euc.jp/periphs/xbox-controller.ja.html (ITO Takayuki) | ||
101 | 2. http://xpad.xbox-scene.com/ | ||
102 | 3. http://www.xboxhackz.com/Hackz-Reference.htm | ||
103 | |||
104 | 4. /proc/bus/usb/devices - dump from InterAct PowerPad Pro (Germany): | ||
105 | |||
106 | T: Bus=01 Lev=03 Prnt=04 Port=00 Cnt=01 Dev#= 5 Spd=12 MxCh= 0 | ||
107 | D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=32 #Cfgs= 1 | ||
108 | P: Vendor=05fd ProdID=107a Rev= 1.00 | ||
109 | C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA | ||
110 | I: If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=(none) | ||
111 | E: Ad=81(I) Atr=03(Int.) MxPS= 32 Ivl= 10ms | ||
112 | E: Ad=02(O) Atr=03(Int.) MxPS= 32 Ivl= 10ms | ||
113 | |||
114 | -- | ||
115 | Marko Friedemann <mfr@bmx-chemnitz.de> | ||
116 | 2002-07-16 | ||