From owner-freebsd-current@FreeBSD.ORG Sat Jun 13 18:35:37 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0A76106575C for ; Sat, 13 Jun 2009 18:35:37 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe15.swipnet.se [212.247.155.193]) by mx1.freebsd.org (Postfix) with ESMTP id B67CD8FC14 for ; Sat, 13 Jun 2009 18:35:36 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=Neyf8s-Iv_wA:10 a=18ZzoJCRAHoA:10 a=hlIU1J3LQChSjWV/CGRL5g==:17 a=vpWRbiDSTQcv6c2LSdsA:9 a=golD-hNrPQHyoRo9S1fHJQg0AFwA:4 a=GmVSrs4unnX98mIzkBAA:9 a=QMOlRaA_8CcNgSNAqJYA:7 a=WtUEkL85JQUtij2m_fZ-q4liFP4A:4 Received: from [193.217.167.6] (account mc467741@c2i.net HELO laptop.adsl.tele2.no) by mailfe15.swip.net (CommuniGate Pro SMTP 5.2.13) with ESMTPA id 512234418; Sat, 13 Jun 2009 20:35:34 +0200 From: Hans Petter Selasky To: freebsd-current@freebsd.org Date: Sat, 13 Jun 2009 20:39:51 +0200 User-Agent: KMail/1.11.4 (FreeBSD/8.0-CURRENT; KDE/4.2.4; i386; ; ) References: <200906081801.17477.hselasky@c2i.net> <4A2D596F.9050508@freebsd.org> In-Reply-To: <4A2D596F.9050508@freebsd.org> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_4J/MKawsp/vBgof" Message-Id: <200906132039.52831.hselasky@c2i.net> Cc: Sam Leffler , ed@freebsd.org Subject: Re: KDE4 on FreeBSD (was: KDE4 and input events) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jun 2009 18:35:37 -0000 --Boundary-00=_4J/MKawsp/vBgof Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 --Boundary-00=_4J/MKawsp/vBgof Content-Type: text/x-patch; charset="iso-8859-1"; name="sysmouse.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sysmouse.c.diff" --- 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); --Boundary-00=_4J/MKawsp/vBgof--