[patch] Problem with mousedev.c

Zephaniah E. Hull
2002-10-27T00:59:28Z

[-- Attachment #1.1: Type: text/plain, Size: 1016 bytes --]

To make a long story short, mousedev.c does not properly implement the
EXPS/2 protocol, specificly dealing with the wheel.

The lower 8 bits of the 4th byte are supposed to be 0x1 or 0xf to
indicate movement of the first wheel, and 0x2 or 0xe for the second
wheel.

Attached is a patch to correct this.

This does not get my two wheel mouse working perfectly yet, sadly that
will take a bit of a hack, and I'm not sure where the best place to put
it is yet, but this gets it back to generating correct data.

Zephaniah E. Hull.
(Debian GPM maintainer.)

--
1024D/E65A7801 Zephaniah E. Hull <warp@babylon.d2dc.net>
92ED 94E4 B1E6 3624 226D 5727 4453 008B E65A 7801
CCs of replies from mailing lists are requested.

Yes, Java is so bulletproofed that to a C programmer it feels like
being in a straightjacket, but it's a really comfy and warm
straightjacket, and the world would be a safer place if everyone was
straightjacketed most of the time. -- Overheard in the SDM.

[-- Attachment #1.2: hid.diff --]
[-- Type: text/plain, Size: 1799 bytes --]

diff -ur linux/drivers/input/mousedev.c linux.mine/drivers/input/mousedev.c
--- linux/drivers/input/mousedev.c 2001-09-30 15:26:05.000000000 -0400
+++ linux.mine/drivers/input/mousedev.c 2002-10-26 18:20:19.000000000 -0400
@@ -62,7 +62,7 @@
struct fasync_struct *fasync;
struct mousedev *mousedev;
struct mousedev_list *next;
- int dx, dy, dz, oldx, oldy;
+ int dw, dx, dy, dz, oldx, oldy;
signed char ps2[6];
unsigned long buttons;
unsigned char ready, buffer, bufsiz;
@@ -117,6 +117,7 @@
case REL_X: list->dx += value; break;
case REL_Y: list->dy -= value; break;
case REL_WHEEL: if (list->mode) list->dz -= value; break;
+ case REL_HWHEEL: if (list->mode == 2) list->dw -= value; break;
}
break;

@@ -260,9 +261,22 @@
list->bufsiz = off + 3;

if (list->mode == 2) {
- list->ps2[off + 3] = (list->dz > 7 ? 7 : (list->dz < -7 ? -7 : list->dz));
- list->dz -= list->ps2[off + 3];
- list->ps2[off + 3] = (list->ps2[off + 3] & 0x0f) | ((list->buttons & 0x18) << 1);
+ if (!list->dz && !list->dw) {
+ list->ps2[off + 3] = 0;
+ } else if (list->dw > 0) {
+ list->ps2[off + 3] = 0x2;
+ list->dw--;
+ } else if (list->dw < 0) {
+ list->ps2[off + 3] = 0xe;
+ list->dw++;
+ } else if (list->dz > 0) {
+ list->ps2[off + 3] = 0x1;
+ list->dz--;
+ } else if (list->dz < 0) {
+ list->ps2[off + 3] = 0xf;
+ list->dz++;
+ }
+ list->ps2[off + 3] |= (list->buttons & 0x18) << 1;
list->bufsiz++;
}

@@ -272,7 +286,7 @@
list->bufsiz++;
}

- if (!list->dx && !list->dy && (!list->mode || !list->dz)) list->ready = 0;
+ if (!list->dx && !list->dy && (!list->mode || !list->dz) && ((list->mode != 2) || !list->dw)) list->ready = 0;
list->buffer = list->bufsiz;
}