Subject: bin/18143: moused gets very hosed when using an X10 MouseRemote
To: None <gnats-bugs@gnats.netbsd.org>
From: Paul Shupak <paul@fsrv.plectere.com>
List: netbsd-bugs
Date: 09/01/2002 18:59:41
>Number: 18143
>Category: bin
>Synopsis: moused gets very hosed when using an X10 MouseRemote
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Sep 01 19:00:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Paul Shupak
>Release: NetBSD 1.6G as of "Sun Sep 1 18:50:56 PDT 2002"
>Organization:
>Environment:
System: NetBSD fsrv 1.6G NetBSD 1.6G (FSRV) #199: Sat Aug 31 20:55:33 PDT 2002 root@fsrv:/usr/src/sys/arch/i386/compile/FSRV i386
Architecture: i386
Machine: i386
>Description:
The code misinterprets "key" press events as either a motion event,
a button up/down event or both.
>How-To-Repeat:
press any "key" on a MouseRemote ( or compatible );
- watch the mouse and or cursor do strange things and/or lock-up
>Fix:
Diff of code to simply discard key presses ( w/ residual debugging
code to print them if desired -- may be GC'd ).
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/moused/moused.c,v
retrieving revision 1.7
diff -c -r1.7 moused.c
*** moused.c 2002/08/09 02:17:28 1.7
--- moused.c 2002/09/02 01:49:00
***************
*** 1438,1443 ****
--- 1438,1484 ----
}
}
+ #define DEBUG_X10_KEYS
+ #if defined DEBUG_X10_KEYS && DEBUG_X10_KEYS
+ /* NOTE: Already bit-reversed to match the JR10A MouseRemote's reports */
+ static const char * const x10_rem_keys[256] = { /* JR/URxx remote controls */
+ /* 0x00-0x03 */ "??", "??", "Channel +", "Channel -",
+ /* 0x04-0x07 */ "??", "M/All Off", "Volume +", "Volume -",
+ /* 0x08-0x0F */ "??", "??", "??", "??", "??", "PLAY", "STOP", "POWER",
+ /* 0x10-0x17 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0x18-0x1F */ "??", "??", "??", "B", "REW", "FF", "??", "??",
+ /* 0x20-0x27 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0x28-0x2F */ "??", "??", "??", "D", "??", "??", "??", "??",
+ /* 0x30-0x37 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0x38-0x3F */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0x40-0x47 */ "0", "1/MP3", "2/DVD", "3/CD", "4", "5", "6", "7",
+ /* 0x48-0x4B */ "8", "9", "ENT:OK", "Left Arrow",
+ /* 0x4C-0x4F */ "??", "??", "PAUSE", "LAST",
+ /* 0x50-0x57 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0x58-0x5F */ "??", "??", "??", "PC", "A", "A/B", "??", "??",
+ /* 0x60-0x67 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0x68-0x6F */ "??", "??", "??", "C", "??", "MENU", "??", "??",
+ /* 0x70-0x77 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0x78-0x7F */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0x80-0x87 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0x88-0x8F */ "??", "??", "??", "Right Arrow", "??", "??", "??", "??",
+ /* 0x90-0x97 */ "??", "??", "??", "EXIT", "??", "??", "??", "??",
+ /* 0x98-0x9F */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0xA0-0xA7 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0xA8-0xAF */ "??", "??", "??", "Up Arrow", "??", "??", "??", "??",
+ /* 0xB0-0xB7 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0xB8-0xBF */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0xC0-0xC7 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0xC8-0xCF */ "??", "??", "??", "Down Arrow", "??", "??", "??", "??",
+ /* 0xD0-0xD7 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0xD8-0xDF */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0xE0-0xE7 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0xE8-0xEF */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0xF0-0xF7 */ "??", "??", "??", "??", "??", "??", "??", "??",
+ /* 0xF8-0xFF */ "??", "??", "??", "??", "??", "??", "??", "REC"
+ } ;
+ #endif /* #if defined DEBUG_X10_KEYS && DEBUG_X10_KEYS */
+
static int
r_protocol(u_char rBuf, mousestatus_t *act)
{
***************
*** 1678,1686 ****
act->obutton = act->button;
switch (rodent.rtype)
{
case MOUSE_PROTO_MS: /* Microsoft */
case MOUSE_PROTO_LOGIMOUSEMAN: /* MouseMan/TrackMan */
- case MOUSE_PROTO_X10MOUSEREM: /* X10 MouseRemote */
act->button = act->obutton & MOUSE_BUTTON4DOWN;
if (rodent.flags & ChordMiddle)
act->button |= ((pBuf[0] & MOUSE_MSS_BUTTONS) == MOUSE_MSS_BUTTONS)
--- 1719,1751 ----
act->obutton = act->button;
switch (rodent.rtype)
{
+ case MOUSE_PROTO_X10MOUSEREM: /* X10 MouseRemote */
+ /*
+ * Check if it is an X10-style "entertainment" key event;
+ * We must AT LEAST discard this "event" to stay in "sync"!
+ * Otherwise it will be "misinterpreted" as movement and/or
+ * button events; Besides, many X10 devices will generate
+ * these "key" events, NOT just a MouseRemote ( i.e. JR20A
+ * Remote control ), so a "noisy" or "busy" enviroment may
+ * have very many of them floating about!
+ */
+ if (((pBuf[0] & 0xFC) == 0x44) && (pBuf[2] == 0x3F)) {
+
+ #if defined DEBUG_X10_KEYS && DEBUG_X10_KEYS */
+ unsigned char key = ((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F);
+
+ /* We could always do SOMETHING with it... - ala "Boom 2000" */
+ (void) fprintf( stderr, "X10 key: 0x%02X - %u - \"%s\"\n",
+ key, key, x10_rem_keys[ key ] ) ;
+ #endif /* #if defined DEBUG_X10_KEYS && DEBUG_X10_KEYS */
+
+ return 0;
+ }
+ /* It is a "normal" mouse event! */
+ /*FALLTHROUGH*/
+
case MOUSE_PROTO_MS: /* Microsoft */
case MOUSE_PROTO_LOGIMOUSEMAN: /* MouseMan/TrackMan */
act->button = act->obutton & MOUSE_BUTTON4DOWN;
if (rodent.flags & ChordMiddle)
act->button |= ((pBuf[0] & MOUSE_MSS_BUTTONS) == MOUSE_MSS_BUTTONS)
***************
*** 1690,1708 ****
act->button |= (act->obutton & MOUSE_BUTTON2DOWN)
| butmapmss[(pBuf[0] & MOUSE_MSS_BUTTONS) >> 4];
- #if 0
- /* Send X10 btn events to remote client (ensure -128-+127 range) */
- if ((rodent.rtype == MOUSE_PROTO_X10MOUSEREM) &&
- ((pBuf[0] & 0xFC) == 0x44) && (pBuf[2] == 0x3F)) {
- if (rodent.mremcfd >= 0) {
- unsigned char key = (signed char)(((pBuf[0] & 0x03) << 6) |
- (pBuf[1] & 0x3F));
- write( rodent.mremcfd, &key, 1 );
- }
- return 0;
- }
- #endif
-
act->dx = (char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F));
act->dy = (char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F));
break;
--- 1755,1760 ----
>Release-Note:
>Audit-Trail:
>Unformatted: