Date: Sat, 13 Jun 2009 20:39:51 +0200 From: Hans Petter Selasky <hselasky@c2i.net> To: freebsd-current@freebsd.org Cc: Sam Leffler <sam@freebsd.org>, ed@freebsd.org Subject: Re: KDE4 on FreeBSD (was: KDE4 and input events) Message-ID: <200906132039.52831.hselasky@c2i.net> In-Reply-To: <4A2D596F.9050508@freebsd.org> References: <200906081801.17477.hselasky@c2i.net> <4A2D596F.9050508@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Monday 08 June 2009 20:33:19 Sam Leffler wrote:
> Hans Petter Selasky wrote:
> > Hi,
Hi,
I was trying to figure out why the right mouse button on the builtin touchpad
of my Aspire One had died, just to conclude that it was a hardware problem and
that I have to use an external USB mouse :-) During my investigation I found
some possibly unlocked code in sysmouse.c . Also I found out that the
/dev/sysmouse is not opened in raw mode, because ttydisc_can_bypass() is never
true in sysmouse.c . I've made a patch. Ed: Can you go through my patch and
see if the issues I've fixed apply or if there is a bug in the TTY code, not
detecting that raw mode should be selected.
Patch for X-org server:
/usr/ports/x11-servers/xorg-server/work/xorg-server-1.6.1/hw/xfree86/os-
support/shared/posix_tty.c
_X_EXPORT int
xf86OpenSerial (pointer options)
...
/* set up default port parameters */
SYSCALL (tcgetattr (fd, &t));
+ cfmakeraw(&t);
SYSCALL (tcsetattr (fd, TCSANOW, &t));
...
--HPS
[-- Attachment #2 --]
--- sys/dev/syscons/sysmouse.c 2009-05-30 08:19:51.000000000 +0200
+++ sys/dev/syscons/sysmouse.c 2009-06-13 15:15:04.000000000 +0200
@@ -118,12 +118,14 @@
return 0;
case MOUSE_GETSTATUS: /* get accumulated mouse events */
+ tty_lock(sysmouse_tty);
*(mousestatus_t *)data = mouse_status;
mouse_status.flags = 0;
mouse_status.obutton = mouse_status.button;
mouse_status.dx = 0;
mouse_status.dy = 0;
mouse_status.dz = 0;
+ tty_unlock(sysmouse_tty);
return 0;
#ifdef notyet
@@ -174,7 +176,7 @@
sysmouse_event(mouse_info_t *info)
{
/* MOUSE_BUTTON?DOWN -> MOUSE_MSC_BUTTON?UP */
- static int butmap[8] = {
+ static const int butmap[8] = {
MOUSE_MSC_BUTTON1UP | MOUSE_MSC_BUTTON2UP | MOUSE_MSC_BUTTON3UP,
MOUSE_MSC_BUTTON2UP | MOUSE_MSC_BUTTON3UP,
MOUSE_MSC_BUTTON1UP | MOUSE_MSC_BUTTON3UP,
@@ -184,9 +186,9 @@
MOUSE_MSC_BUTTON1UP,
0,
};
- u_char buf[8];
+ uint8_t buf[8];
int x, y, z;
- int i, flags = 0;
+ int flags = 0;
tty_lock(sysmouse_tty);
@@ -214,9 +216,10 @@
mouse_status.dy += y;
mouse_status.dz += z;
mouse_status.flags |= ((x || y || z) ? MOUSE_POSCHANGED : 0)
- | (mouse_status.obutton ^ mouse_status.button);
+ | (mouse_status.obutton ^ mouse_status.button);
flags = mouse_status.flags;
- if (flags == 0 || !tty_opened(sysmouse_tty))
+ if (flags == 0 || !tty_opened(sysmouse_tty) ||
+ !ttydisc_can_bypass(sysmouse_tty))
goto done;
/* the first five bytes are compatible with MouseSystems' */
@@ -228,17 +231,16 @@
y = -imax(imin(y, 255), -256);
buf[2] = y >> 1;
buf[4] = y - buf[2];
- for (i = 0; i < MOUSE_MSC_PACKETSIZE; ++i)
- ttydisc_rint(sysmouse_tty, buf[i], 0);
- if (mouse_level >= 1) {
+ if (mouse_level == 1) {
/* extended part */
z = imax(imin(z, 127), -128);
buf[5] = (z >> 1) & 0x7f;
buf[6] = (z - (z >> 1)) & 0x7f;
/* buttons 4-10 */
buf[7] = (~mouse_status.button >> 3) & 0x7f;
- for (i = MOUSE_MSC_PACKETSIZE; i < MOUSE_SYS_PACKETSIZE; ++i)
- ttydisc_rint(sysmouse_tty, buf[i], 0);
+ ttydisc_rint_bypass(sysmouse_tty, buf, MOUSE_SYS_PACKETSIZE);
+ } else {
+ ttydisc_rint_bypass(sysmouse_tty, buf, MOUSE_MSC_PACKETSIZE);
}
ttydisc_rint_done(sysmouse_tty);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906132039.52831.hselasky>
