4 if (hw.z > 30) input_report_key(dev, BTN_TOUCH, 1);
5 if (hw.z < 25) input_report_key(dev, BTN_TOUCH, 0);
8 + if (hw.z > 0 && hw.x != 1) {
9 input_report_abs(dev, ABS_X, hw.x);
10 input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - hw.y);
13 input_report_abs(dev, ABS_PRESSURE, hw.z);
15 input_report_abs(dev, ABS_TOOL_WIDTH, finger_width);
16 input_report_key(dev, BTN_TOOL_FINGER, num_fingers == 1);
17 input_report_key(dev, BTN_TOOL_DOUBLETAP, num_fingers == 2);
18 input_report_key(dev, BTN_TOOL_TRIPLETAP, num_fingers == 3);
21 input_report_key(dev, BTN_LEFT, hw.left);
22 input_report_key(dev, BTN_RIGHT, hw.right);
28 #include "synaptics.h"
29 -#include "logips2pp.h"
32 -#include "lifebook.h"
33 -#include "trackpoint.h"
34 -#include "touchkit_ps2.h"
35 -#include "elantech.h"
38 #define DRIVER_DESC "PS/2 mouse driver"
41 * Full packet accumulated, process it
45 - * Scroll wheel on IntelliMice, scroll buttons on NetMice
48 - if (psmouse->type == PSMOUSE_IMPS || psmouse->type == PSMOUSE_GENPS)
49 - input_report_rel(dev, REL_WHEEL, -(signed char) packet[3]);
52 - * Scroll wheel and buttons on IntelliMouse Explorer
55 - if (psmouse->type == PSMOUSE_IMEX) {
56 - switch (packet[3] & 0xC0) {
57 - case 0x80: /* vertical scroll on IntelliMouse Explorer 4.0 */
58 - input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 32) - (int) (packet[3] & 31));
60 - case 0x40: /* horizontal scroll on IntelliMouse Explorer 4.0 */
61 - input_report_rel(dev, REL_HWHEEL, (int) (packet[3] & 32) - (int) (packet[3] & 31));
65 - input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 8) - (int) (packet[3] & 7));
66 - input_report_key(dev, BTN_SIDE, (packet[3] >> 4) & 1);
67 - input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1);
73 - * Extra buttons on Genius NewNet 3D
76 - if (psmouse->type == PSMOUSE_GENPS) {
77 - input_report_key(dev, BTN_SIDE, (packet[0] >> 6) & 1);
78 - input_report_key(dev, BTN_EXTRA, (packet[0] >> 7) & 1);
82 - * Extra button on ThinkingMouse
84 - if (psmouse->type == PSMOUSE_THINKPS) {
85 - input_report_key(dev, BTN_EXTRA, (packet[0] >> 3) & 1);
86 - /* Without this bit of weirdness moving up gives wildly high Y changes. */
87 - packet[1] |= (packet[0] & 0x40) << 1;
91 - * Cortron PS2 Trackball reports SIDE button on the 4th bit of the first
94 - if (psmouse->type == PSMOUSE_CORTRON) {
95 - input_report_key(dev, BTN_SIDE, (packet[0] >> 3) & 1);
101 @@ -403,144 +343,6 @@
106 - * Genius NetMouse magic init.
108 -static int genius_detect(struct psmouse *psmouse, int set_properties)
110 - struct ps2dev *ps2dev = &psmouse->ps2dev;
111 - unsigned char param[4];
114 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
115 - ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11);
116 - ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11);
117 - ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11);
118 - ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO);
120 - if (param[0] != 0x00 || param[1] != 0x33 || param[2] != 0x55)
123 - if (set_properties) {
124 - set_bit(BTN_EXTRA, psmouse->dev->keybit);
125 - set_bit(BTN_SIDE, psmouse->dev->keybit);
126 - set_bit(REL_WHEEL, psmouse->dev->relbit);
128 - psmouse->vendor = "Genius";
129 - psmouse->name = "Mouse";
130 - psmouse->pktsize = 4;
137 - * IntelliMouse magic init.
139 -static int intellimouse_detect(struct psmouse *psmouse, int set_properties)
141 - struct ps2dev *ps2dev = &psmouse->ps2dev;
142 - unsigned char param[2];
145 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
147 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
149 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
150 - ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
155 - if (set_properties) {
156 - set_bit(BTN_MIDDLE, psmouse->dev->keybit);
157 - set_bit(REL_WHEEL, psmouse->dev->relbit);
159 - if (!psmouse->vendor) psmouse->vendor = "Generic";
160 - if (!psmouse->name) psmouse->name = "Wheel Mouse";
161 - psmouse->pktsize = 4;
168 - * Try IntelliMouse/Explorer magic init.
170 -static int im_explorer_detect(struct psmouse *psmouse, int set_properties)
172 - struct ps2dev *ps2dev = &psmouse->ps2dev;
173 - unsigned char param[2];
175 - intellimouse_detect(psmouse, 0);
178 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
180 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
182 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
183 - ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
188 -/* Magic to enable horizontal scrolling on IntelliMouse 4.0 */
190 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
192 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
194 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
196 - if (set_properties) {
197 - set_bit(BTN_MIDDLE, psmouse->dev->keybit);
198 - set_bit(REL_WHEEL, psmouse->dev->relbit);
199 - set_bit(REL_HWHEEL, psmouse->dev->relbit);
200 - set_bit(BTN_SIDE, psmouse->dev->keybit);
201 - set_bit(BTN_EXTRA, psmouse->dev->keybit);
203 - if (!psmouse->vendor) psmouse->vendor = "Generic";
204 - if (!psmouse->name) psmouse->name = "Explorer Mouse";
205 - psmouse->pktsize = 4;
212 - * Kensington ThinkingMouse / ExpertMouse magic init.
214 -static int thinking_detect(struct psmouse *psmouse, int set_properties)
216 - struct ps2dev *ps2dev = &psmouse->ps2dev;
217 - unsigned char param[2];
218 - static const unsigned char seq[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20 };
222 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
224 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
225 - for (i = 0; i < ARRAY_SIZE(seq); i++) {
227 - ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
229 - ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
234 - if (set_properties) {
235 - set_bit(BTN_EXTRA, psmouse->dev->keybit);
237 - psmouse->vendor = "Kensington";
238 - psmouse->name = "ThinkingMouse";
245 * Bare PS/2 protocol "detection". Always succeeds.
250 - * Cortron PS/2 protocol detection. There's no special way to detect it, so it
251 - * must be forced by sysfs protocol writing.
253 -static int cortron_detect(struct psmouse *psmouse, int set_properties)
255 - if (set_properties) {
256 - psmouse->vendor = "Cortron";
257 - psmouse->name = "PS/2 Trackball";
258 - set_bit(BTN_SIDE, psmouse->dev->keybit);
265 * psmouse_extensions() probes for any extensions to the basic PS/2 protocol
266 * the mouse may have.
269 int synaptics_hardware = 0;
272 - * We always check for lifebook because it does not disturb mouse
273 - * (it only checks DMI information).
275 - if (lifebook_detect(psmouse, set_properties) == 0) {
276 - if (max_proto > PSMOUSE_IMEX) {
277 - if (!set_properties || lifebook_init(psmouse) == 0)
278 - return PSMOUSE_LIFEBOOK;
283 - * Try Kensington ThinkingMouse (we try first, because synaptics probe
284 - * upsets the thinkingmouse).
287 - if (max_proto > PSMOUSE_IMEX && thinking_detect(psmouse, set_properties) == 0)
288 - return PSMOUSE_THINKPS;
291 * Try Synaptics TouchPad. Note that probing is done even if Synaptics protocol
292 * support is disabled in config - we need to know if it is synaptics so we
293 * can reset it properly after probing for intellimouse.
295 synaptics_reset(psmouse);
299 - * Try ALPS TouchPad
301 - if (max_proto > PSMOUSE_IMEX) {
302 - ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
303 - if (alps_detect(psmouse, set_properties) == 0) {
304 - if (!set_properties || alps_init(psmouse) == 0)
305 - return PSMOUSE_ALPS;
307 - * Init failed, try basic relative protocols
309 - max_proto = PSMOUSE_IMEX;
314 - * Try OLPC HGPK touchpad.
316 - if (max_proto > PSMOUSE_IMEX &&
317 - hgpk_detect(psmouse, set_properties) == 0) {
318 - if (!set_properties || hgpk_init(psmouse) == 0)
319 - return PSMOUSE_HGPK;
321 - * Init failed, try basic relative protocols
323 - max_proto = PSMOUSE_IMEX;
327 - * Try Elantech touchpad.
329 - if (max_proto > PSMOUSE_IMEX &&
330 - elantech_detect(psmouse, set_properties) == 0) {
331 - if (!set_properties || elantech_init(psmouse) == 0)
332 - return PSMOUSE_ELANTECH;
334 - * Init failed, try basic relative protocols
336 - max_proto = PSMOUSE_IMEX;
339 - if (max_proto > PSMOUSE_IMEX) {
340 - if (genius_detect(psmouse, set_properties) == 0)
341 - return PSMOUSE_GENPS;
343 - if (ps2pp_init(psmouse, set_properties) == 0)
344 - return PSMOUSE_PS2PP;
346 - if (trackpoint_detect(psmouse, set_properties) == 0)
347 - return PSMOUSE_TRACKPOINT;
349 - if (touchkit_ps2_detect(psmouse, set_properties) == 0)
350 - return PSMOUSE_TOUCHKIT_PS2;
354 - * Reset to defaults in case the device got confused by extended
355 - * protocol probes. Note that we follow up with full reset because
356 - * some mice put themselves to sleep when they see PSMOUSE_RESET_DIS.
358 - ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
359 - psmouse_reset(psmouse);
361 - if (max_proto >= PSMOUSE_IMEX && im_explorer_detect(psmouse, set_properties) == 0)
362 - return PSMOUSE_IMEX;
364 - if (max_proto >= PSMOUSE_IMPS && intellimouse_detect(psmouse, set_properties) == 0)
365 - return PSMOUSE_IMPS;
368 - * Okay, all failed, we have a standard mouse here. The number of the buttons
369 - * is still a question, though. We assume 3.
371 - ps2bare_detect(psmouse, set_properties);
373 if (synaptics_hardware) {
377 .detect = ps2bare_detect,
379 -#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
381 - .type = PSMOUSE_PS2PP,
383 - .alias = "logitech",
384 - .detect = ps2pp_init,
388 - .type = PSMOUSE_THINKPS,
389 - .name = "ThinkPS/2",
390 - .alias = "thinkps",
391 - .detect = thinking_detect,
394 - .type = PSMOUSE_GENPS,
397 - .detect = genius_detect,
400 - .type = PSMOUSE_IMPS,
404 - .detect = intellimouse_detect,
407 - .type = PSMOUSE_IMEX,
408 - .name = "ImExPS/2",
411 - .detect = im_explorer_detect,
413 #ifdef CONFIG_MOUSE_PS2_SYNAPTICS
415 .type = PSMOUSE_SYNAPTICS,
417 .init = synaptics_init,
420 -#ifdef CONFIG_MOUSE_PS2_ALPS
422 - .type = PSMOUSE_ALPS,
423 - .name = "AlpsPS/2",
425 - .detect = alps_detect,
429 -#ifdef CONFIG_MOUSE_PS2_LIFEBOOK
431 - .type = PSMOUSE_LIFEBOOK,
433 - .alias = "lifebook",
434 - .init = lifebook_init,
437 -#ifdef CONFIG_MOUSE_PS2_TRACKPOINT
439 - .type = PSMOUSE_TRACKPOINT,
441 - .alias = "trackpoint",
442 - .detect = trackpoint_detect,
445 -#ifdef CONFIG_MOUSE_PS2_TOUCHKIT
447 - .type = PSMOUSE_TOUCHKIT_PS2,
448 - .name = "touchkitPS/2",
449 - .alias = "touchkit",
450 - .detect = touchkit_ps2_detect,
453 -#ifdef CONFIG_MOUSE_PS2_OLPC
455 - .type = PSMOUSE_HGPK,
456 - .name = "OLPC HGPK",
458 - .detect = hgpk_detect,
461 -#ifdef CONFIG_MOUSE_PS2_ELANTECH
463 - .type = PSMOUSE_ELANTECH,
465 - .alias = "elantech",
466 - .detect = elantech_detect,
467 - .init = elantech_init,
471 - .type = PSMOUSE_CORTRON,
472 - .name = "CortronPS/2",
474 - .detect = cortron_detect,
477 .type = PSMOUSE_AUTO,