* TurboMouse fix
@ 1998-12-22 4:16 Tom Harrington
1998-12-22 6:03 ` john s jacobs anderson
1998-12-22 6:11 ` FD_SET/FD_ZERO, vi clone compiling john s jacobs anderson
0 siblings, 2 replies; 9+ messages in thread
From: Tom Harrington @ 1998-12-22 4:16 UTC (permalink / raw)
To: linuxppc-user; +Cc: linuxppc-dev
I've updated Mark Abene's "mousehack" fix for the Kensington Turbo Mouse
to work with newer kernels. The source code is below.
It should compile straight away-- "cc mousehack.c". Then run the program,
abd your TurboMouse should work as a 3-button mouse. If it works for you,
put it somewhere convenient (like /sbin) and call it from /etc/rc.d/rc.local.
This has only been tested on a G3 desktop, running 2.1.125, with a
version 5.0 TurboMouse. I'd appreciate feedback on how it works
(or fails to work) with other setups.
See notes in the comments about tracking speed and button arrangement.
Tom Harrington
--- cut here ---
/* mousehack.c
*
* A program for linux-pmac by jonh Tue Feb 18 00:46:10 EST 1997
* hacked mercilessly by warner@lothar.com: don't blame jonh for my bugs!
*
* Now does magic for the Kensington turbo mouse trackball (phiber@phiber.com)
* 8/30/98
*
* Minor update to make it work with 2.1.125 (tph@rmi.net) 12/21/1998
* - If tracking is too fast, use "xset" to fix it.
* - If button arrangement seems weird, use "xmodmap". The default is:
* lower left = 1, lower right = 2, upper left = 3, upper left = off.
* xmodmap -e "pointer = 1 3 2" works for me.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <asm/adb_mouse.h>
#include <asm/cuda.h>
int fd;
void
send(unsigned char *y, int len)
{
int n;
#ifdef DEBUG
printf("send: ");
for (n=0; n < len; n++)
printf("0x%02x ",y[n]);
printf("\n");
#endif
n = write(fd, y, (size_t) len);
if (n < len) {
perror("writing /dev/adb");
close(fd);
exit (EXIT_FAILURE);
}
}
void
listen(unsigned char *y)
{
int n;
n = read(fd, y, 80);
#ifdef DEBUG
printf("%d: ",n);
if (n > 0) {
int i;
for (i=0; i < n; i++)
printf("0x%02x ",y[i]);
}
printf("\n");
#endif
if (n < 0) {
perror("reading /dev/adb");
close(fd);
exit(EXIT_FAILURE);
}
}
void
sethandler(int addr, int handler)
{
unsigned char y[15];
y[0] = ADB_PACKET;
/* mouse (0x30) listen (0x08) reg 3 (0x03) */
y[1] = ADB_WRITEREG(addr, 3);
/* service request enable (0x20), device addr 3 (0x03) */
y[2] = 0x20 + addr;
y[3]= handler;
send(y, 4);
listen(y);
}
void
moveadb(int src, int dst)
{
unsigned char y[15];
y[0] = ADB_PACKET;
y[1] = ADB_WRITEREG(src, 3);
y[2] = 0x20 + dst;
y[3] = 0xfe;
send(y, 4);
listen(y);
}
void
initreg2()
{
unsigned char x[15];
unsigned char y[] = { ADB_PACKET, ADB_WRITEREG(3, 2), 0xe7, 0x8c, 0, 0, 0, 0xff, 0xff, 0x94 };
send(y, 10);
listen(x);
x[0] = ADB_PACKET;
x[1] = 0x31; /* flush device 3 */
send(x, 2);
listen(x);
}
void
setreg2()
{
unsigned char y[] = { ADB_PACKET, ADB_WRITEREG(3, 2), 0xa5, 0x14, 0, 0, 0x69, 0xff, 0xff, 0x27 };
send(y, 10);
listen(y);
}
int
main(int argc, char **argv)
{
fd = open("/dev/adb", O_RDWR);
if (fd <= 0) {
perror("opening /dev/adb");
exit(EXIT_FAILURE);
}
sethandler(15, -1); /* tph */
sethandler(3, 4);
moveadb(3, 15);
initreg2();
setreg2();
close(fd);
return 0;
}
--- cut here ---
[[ This message was sent via the linuxppc-dev mailing list. Replies are ]]
[[ not forced back to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. To unsubscribe from linuxppc-dev, send ]]
[[ the message 'unsubscribe' to linuxppc-dev-request@lists.linuxppc.org ]]
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: TurboMouse fix
1998-12-22 4:16 TurboMouse fix Tom Harrington
@ 1998-12-22 6:03 ` john s jacobs anderson
1998-12-22 16:51 ` Tom Harrington
1998-12-22 18:29 ` Mark Abene
1998-12-22 6:11 ` FD_SET/FD_ZERO, vi clone compiling john s jacobs anderson
1 sibling, 2 replies; 9+ messages in thread
From: john s jacobs anderson @ 1998-12-22 6:03 UTC (permalink / raw)
To: Tom Harrington; +Cc: linuxppc-user, linuxppc-dev
> I've updated Mark Abene's "mousehack" fix for the Kensington Turbo Mouse
> to work with newer kernels. The source code is below.
<snip>
> This has only been tested on a G3 desktop, running 2.1.125, with a
> version 5.0 TurboMouse. I'd appreciate feedback on how it works
> (or fails to work) with other setups.
system: 7500 chasis with 166 MHz 604 card, 2.1.127 kernel. Kensington
TurboMouse 4.0 (the 2 button kind), window maker 0.20.3
(do you need to know anything else? sorry, I'm still a wet behind the
ears...)
exported mail to ~, trimmed file in pico, then `cc mousehack.c`.
gives :
/tmp/cca082751.o: In function `sethandler':
/tmp/cca082751.o(.text+0x148): undefined reference to `ADB-WRITEREG'
(same error repeated at (.text+0x1dc) in function `moveadb'
(.text+0x26c) in function `initreg2'
(.text+0x364) in function `setreg2'
collect2: ld returned 1 exit status
ack! what now? I'm drooling at the thought of a functional 2 button mouse,
and if it only ends up working with v5.0 TurboMice, Santa might have to
make a late delivery...
john.
jacobs@treefort.org
www.treefort.org/~jacobs/ <--- LinuxPPC notes'n'stuff...
[[ This message was sent via the linuxppc-dev mailing list. Replies are ]]
[[ not forced back to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. To unsubscribe from linuxppc-dev, send ]]
[[ the message 'unsubscribe' to linuxppc-dev-request@lists.linuxppc.org ]]
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: TurboMouse fix
1998-12-22 6:03 ` john s jacobs anderson
@ 1998-12-22 16:51 ` Tom Harrington
1998-12-22 21:59 ` john s jacobs anderson
1998-12-22 18:29 ` Mark Abene
1 sibling, 1 reply; 9+ messages in thread
From: Tom Harrington @ 1998-12-22 16:51 UTC (permalink / raw)
To: john s jacobs anderson; +Cc: linuxppc-user, linuxppc-dev
> system: 7500 chasis with 166 MHz 604 card, 2.1.127 kernel. Kensington
> TurboMouse 4.0 (the 2 button kind), window maker 0.20.3
>
> (do you need to know anything else? sorry, I'm still a wet behind the
> ears...)
>
> exported mail to ~, trimmed file in pico, then `cc mousehack.c`.
>
> gives :
> /tmp/cca082751.o: In function `sethandler':
> /tmp/cca082751.o(.text+0x148): undefined reference to `ADB-WRITEREG'
> (same error repeated at (.text+0x1dc) in function `moveadb'
> (.text+0x26c) in function `initreg2'
> (.text+0x364) in function `setreg2'
> collect2: ld returned 1 exit status
>
> ack! what now? I'm drooling at the thought of a functional 2 button mouse,
> and if it only ends up working with v5.0 TurboMice, Santa might have to
> make a late delivery...
Hmm, maybe something in your header files? ADB_WRITEREG is defined (on
my system) in /usr/include/asm/adb_mouse.h. Look for this file and see
what's there.
I'm surprised it complains about "ADB-WRITEREG" when the code uses
"ADB_WRITEREG". You didn't happen to "fix" this while trimming the
file in pico, did you?
I really don't know if mousehack is useful (or even necessary) with a v4.0
TurboMouse. I assume you've tried the "mousemode" command?
Tom
[[ This message was sent via the linuxppc-dev mailing list. Replies are ]]
[[ not forced back to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. To unsubscribe from linuxppc-dev, send ]]
[[ the message 'unsubscribe' to linuxppc-dev-request@lists.linuxppc.org ]]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: TurboMouse fix
1998-12-22 16:51 ` Tom Harrington
@ 1998-12-22 21:59 ` john s jacobs anderson
1998-12-23 4:58 ` Tom Harrington
0 siblings, 1 reply; 9+ messages in thread
From: john s jacobs anderson @ 1998-12-22 21:59 UTC (permalink / raw)
To: Tom Harrington; +Cc: linuxppc-user, linuxppc-dev
> Hmm, maybe something in your header files? ADB_WRITEREG is defined (on
> my system) in /usr/include/asm/adb_mouse.h. Look for this file and see
> what's there.
OMM, the /usr/include/asm dir is a symlink to asm-ppc in the kernel
source, which is 2.1.131. That file contains a struct def for
mouse_status, and that's all. The ADB_WRITEREG, etc. #defines are in
adb.h.
> I'm surprised it complains about "ADB-WRITEREG" when the code uses
> "ADB_WRITEREG". You didn't happen to "fix" this while trimming the
> file in pico, did you?
No, I screwed up while re-typing the error messages into my email.
Nothing in between the --cut here-- and --cut here-- (or whatever you
had delimiting the code) was changed.
(Is it just me, or is everybody assuming I'm way more stupid than is
necessary? I followed instructions, and when that didn't work, I provided
the requested feedback, and so far I've got two condescending emails to
show for it.)
> I really don't know if mousehack is useful (or even necessary) with a v4.0
> TurboMouse. I assume you've tried the "mousemode" command?
Well, Mark Abene(sp?) has said in this thread that mousehack doesn't work
with the 4.0 balls. I've tried mousemode; the mouse just switches back.
Maybe it's time to start shopping for one of the 5.0 turbo mice -- too
bad, the design and construction seems a lot more solid on the 4.0 models.
john.
jacobs@treefort.org
www.treefort.org/~jacobs
[[ This message was sent via the linuxppc-dev mailing list. Replies are ]]
[[ not forced back to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. To unsubscribe from linuxppc-dev, send ]]
[[ the message 'unsubscribe' to linuxppc-dev-request@lists.linuxppc.org ]]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: TurboMouse fix
1998-12-22 21:59 ` john s jacobs anderson
@ 1998-12-23 4:58 ` Tom Harrington
1998-12-23 5:24 ` john s jacobs anderson
0 siblings, 1 reply; 9+ messages in thread
From: Tom Harrington @ 1998-12-23 4:58 UTC (permalink / raw)
To: john s jacobs anderson; +Cc: linuxppc-user, linuxppc-dev
> > Hmm, maybe something in your header files? ADB_WRITEREG is defined (on
> > my system) in /usr/include/asm/adb_mouse.h. Look for this file and see
> > what's there.
>
> OMM, the /usr/include/asm dir is a symlink to asm-ppc in the kernel
> source, which is 2.1.131. That file contains a struct def for
> mouse_status, and that's all. The ADB_WRITEREG, etc. #defines are in
> adb.h.
Err... hmm. I can't quite account for that. I did make a mistake in
that the macro is defined in cuda.h, not adb_mouse.h, on my system.
But I'm running a pretty basic R4 install, upgraded to 2.1.125.
Maybe you chose different install options than I did? IIRC I told
it to give me every programming-related option available.
If you see the definition in adb.h on your box, then adding
"#include asm/adb.h", and deleting either adb_mouse.h or cuda.h,
(whichever gcc doesn't like) should get it compiling.
Can anyone else account for the header file discrepancy?
> > I'm surprised it complains about "ADB-WRITEREG" when the code uses
> > "ADB_WRITEREG". You didn't happen to "fix" this while trimming the
> > file in pico, did you?
>
> No, I screwed up while re-typing the error messages into my email.
> Nothing in between the --cut here-- and --cut here-- (or whatever you
> had delimiting the code) was changed.
>
> (Is it just me, or is everybody assuming I'm way more stupid than is
> necessary? I followed instructions, and when that didn't work, I provided
> the requested feedback, and so far I've got two condescending emails to
> show for it.)
Two of the most painful lessons of programming are:
1. Everyone makes the stupidest mistakes, all the time.
2. If you don't understand #1, you will still make stupid mistakes, but
it will take you FOREVER to find them.
Yes, I suggested that you might have made a stupid mistake. That
doesn't mean I was suggesting that _you_ are stupid. If you do
understand #1, you learn to look for stupid mistakes right from the
start (I _still_ use "=" for "==" sometimes, but now I know to expect
it).
> > I really don't know if mousehack is useful (or even necessary) with a v4.0
> > TurboMouse. I assume you've tried the "mousemode" command?
>
> Well, Mark Abene(sp?) has said in this thread that mousehack doesn't work
> with the 4.0 balls. I've tried mousemode; the mouse just switches back.
Yeah, it sounds like the 4.0 TurboMouse is pretty weird in this regard.
They could have just used the extended mouse protocol, after all.
Tom
[[ This message was sent via the linuxppc-dev mailing list. Replies are ]]
[[ not forced back to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. To unsubscribe from linuxppc-dev, send ]]
[[ the message 'unsubscribe' to linuxppc-dev-request@lists.linuxppc.org ]]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: TurboMouse fix
1998-12-23 4:58 ` Tom Harrington
@ 1998-12-23 5:24 ` john s jacobs anderson
0 siblings, 0 replies; 9+ messages in thread
From: john s jacobs anderson @ 1998-12-23 5:24 UTC (permalink / raw)
To: Tom Harrington; +Cc: linuxppc-user, linuxppc-dev
On Tue, 22 Dec 1998, Tom Harrington wrote:
> > > Hmm, maybe something in your header files? ADB_WRITEREG is defined (on
> > > my system) in /usr/include/asm/adb_mouse.h. Look for this file and see
> > > what's there.
> >
> > OMM, the /usr/include/asm dir is a symlink to asm-ppc in the kernel
> > source, which is 2.1.131. That file contains a struct def for
> > mouse_status, and that's all. The ADB_WRITEREG, etc. #defines are in
> > adb.h.
>
> Err... hmm. I can't quite account for that. I did make a mistake in
> that the macro is defined in cuda.h, not adb_mouse.h, on my system.
> But I'm running a pretty basic R4 install, upgraded to 2.1.125.
> Maybe you chose different install options than I did? IIRC I told
> it to give me every programming-related option available.
That's also what I did, IIRC. Keep in mind that while I'm booting off the
2.1.127 kernal, using BootX, all my kernel sources are 2.1.131. Am I wrong
to think that things might have moved around?
>
> If you see the definition in adb.h on your box, then adding
> "#include asm/adb.h", and deleting either adb_mouse.h or cuda.h,
> (whichever gcc doesn't like) should get it compiling.
Actually, it's not necessary to remove anything; just adding
#include <asm/adb.h>
below the last #include results in happy source, which complies into
a.out. Woo hoo! Running the code _does_ have an effect -- two to be exact.
Before running the code, left button was mouse1 and right button either
did nothing or produced seriously wacky results in a non-intuitive way.
After running the code, right button maps to mouse2! A step in the right
direction. However, left button is now mapped to some funky click-lock
like mode, where one click causes it to act like a depress-and-hold. You
have to double-click to get a single click effect, 4Xclick to 2Xclick.
Any ideas why that's happening?
> Two of the most painful lessons of programming are:
> 1. Everyone makes the stupidest mistakes, all the time.
> 2. If you don't understand #1, you will still make stupid mistakes, but
> it will take you FOREVER to find them.
For me, 1. expresess itself via using numeric comparison operators in Perl
when I should use string comparison operators (I can't get it thru my head
that (==) != (eq) )
> Yes, I suggested that you might have made a stupid mistake. That
> doesn't mean I was suggesting that _you_ are stupid. If you do
> understand #1, you learn to look for stupid mistakes right from the
> start (I _still_ use "=" for "==" sometimes, but now I know to expect
> it).
Sorry -- I may over over-read your original reply. I'm touchy this time of
year -- all that Xmas cheer stuff.
> They could have just used the extended mouse protocol, after all.
Prrotocols? We don't need no steekin' protocols!
john.
jacobs@treefort.org
www.treefort.org/~jacobs
[[ This message was sent via the linuxppc-dev mailing list. Replies are ]]
[[ not forced back to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. To unsubscribe from linuxppc-dev, send ]]
[[ the message 'unsubscribe' to linuxppc-dev-request@lists.linuxppc.org ]]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: TurboMouse fix
1998-12-22 6:03 ` john s jacobs anderson
1998-12-22 16:51 ` Tom Harrington
@ 1998-12-22 18:29 ` Mark Abene
1998-12-22 21:49 ` john s jacobs anderson
1 sibling, 1 reply; 9+ messages in thread
From: Mark Abene @ 1998-12-22 18:29 UTC (permalink / raw)
To: linuxppc-user, linuxppc-dev
Three things:
1) mousehack is **ONLY** for TurboMouse 5.0 trackballs! Not two button 4.0's.
I had written a hack last year for my 4.0, but abandoned it when I got a 5.0.
The 4.0 would actually require kernel mods to the ADB code since the two buttons
send left and right arrow-key keycodes, and the kernel would have to recognize
that they were coming from a different ADB address in order to properly treat
them as mouse-button events. Otherwise, the kernel just thinks you have two
keyboards. At least in kernel 2.1.24, the adb code treats anything with
dev-handler 2 as a keyboard, which in this case is faulty logic.
2) You should NEVER edit source code with pico, since it breaks wrapped lines
which turns source code into useless mulch.
3) Did you type in your error messages by hand? The macro used in my program
is ADB_WRITEREG, with an underscore, not a hyphen. It's no shock that the
hyphenated version is undefined, as it don't exist.
-Mark
On Mon, Dec 21, 1998 at 11:03:14PM -0700, john s jacobs anderson wrote:
>
> <snip>
>
> system: 7500 chasis with 166 MHz 604 card, 2.1.127 kernel. Kensington
> TurboMouse 4.0 (the 2 button kind), window maker 0.20.3
>
> (do you need to know anything else? sorry, I'm still a wet behind the
> ears...)
>
> exported mail to ~, trimmed file in pico, then `cc mousehack.c`.
>
> gives :
> /tmp/cca082751.o: In function `sethandler':
> /tmp/cca082751.o(.text+0x148): undefined reference to `ADB-WRITEREG'
> (same error repeated at (.text+0x1dc) in function `moveadb'
> (.text+0x26c) in function `initreg2'
> (.text+0x364) in function `setreg2'
> collect2: ld returned 1 exit status
>
> ack! what now? I'm drooling at the thought of a functional 2 button mouse,
> and if it only ends up working with v5.0 TurboMice, Santa might have to
> make a late delivery...
>
> john.
> jacobs@treefort.org
> www.treefort.org/~jacobs/ <--- LinuxPPC notes'n'stuff...
>
...
[[ This message was sent via the linuxppc-dev mailing list. Replies are ]]
[[ not forced back to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. To unsubscribe from linuxppc-dev, send ]]
[[ the message 'unsubscribe' to linuxppc-dev-request@lists.linuxppc.org ]]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: TurboMouse fix
1998-12-22 18:29 ` Mark Abene
@ 1998-12-22 21:49 ` john s jacobs anderson
0 siblings, 0 replies; 9+ messages in thread
From: john s jacobs anderson @ 1998-12-22 21:49 UTC (permalink / raw)
To: Mark Abene; +Cc: linuxppc-user, linuxppc-dev
Bad morning, Mark?
> 1) mousehack is **ONLY** for TurboMouse 5.0 trackballs! Not two button 4.0's.
> I had written a hack last year for my 4.0, but abandoned it when I got a 5.0.
> The 4.0 would actually require kernel mods to the ADB code since the two buttons
> send left and right arrow-key keycodes, and the kernel would have to recognize
> that they were coming from a different ADB address in order to properly treat
> them as mouse-button events. Otherwise, the kernel just thinks you have two
> keyboards. At least in kernel 2.1.24, the adb code treats anything with
> dev-handler 2 as a keyboard, which in this case is faulty logic.
ok.
> 2) You should NEVER edit source code with pico, since it breaks wrapped lines
> which turns source code into useless mulch.
did you look at the source? none of the lines were that long; I didn't
have emacs open, and vi(m) still gives me headaches. But thanks for the
heads up.
> 3) Did you type in your error messages by hand? The macro used in my program
> is ADB_WRITEREG, with an underscore, not a hyphen. It's no shock that the
> hyphenated version is undefined, as it don't exist.
yes, I did, and yes, my finger apparently slipped off the shift key for
the duration of the - keystroke. Mea maxima culpa, eh?
john.
[[ This message was sent via the linuxppc-dev mailing list. Replies are ]]
[[ not forced back to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. To unsubscribe from linuxppc-dev, send ]]
[[ the message 'unsubscribe' to linuxppc-dev-request@lists.linuxppc.org ]]
^ permalink raw reply [flat|nested] 9+ messages in thread
* FD_SET/FD_ZERO, vi clone compiling
1998-12-22 4:16 TurboMouse fix Tom Harrington
1998-12-22 6:03 ` john s jacobs anderson
@ 1998-12-22 6:11 ` john s jacobs anderson
1 sibling, 0 replies; 9+ messages in thread
From: john s jacobs anderson @ 1998-12-22 6:11 UTC (permalink / raw)
To: linuxppc-user; +Cc: linuxppc-dev
Forgive the FAQ, but it's not in the FAQ-O-Matic, and I know I've seen it
answered on this list before (that email is saved on the Mac side, and I'm
running a monster Perl script, so I can't reboot right at the moment).
I keep getting errors that refer to undefined references to __FD_SET and
__FD_ZERO when I'm compiling stuff. How do I fix this?
On a different note, has anyone successfully compiled the late-ish
versions of any of the vi clones (vim, elvis, vile) under LinuxPPC? That's
where I'm getting those errors...
Thanks,
john.
jacobs@treefort.org
www.treefort.org/~jacobs <-- LinuxPPC stuff...
[[ This message was sent via the linuxppc-dev mailing list. Replies are ]]
[[ not forced back to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. To unsubscribe from linuxppc-dev, send ]]
[[ the message 'unsubscribe' to linuxppc-dev-request@lists.linuxppc.org ]]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~1998-12-23 5:24 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-12-22 4:16 TurboMouse fix Tom Harrington
1998-12-22 6:03 ` john s jacobs anderson
1998-12-22 16:51 ` Tom Harrington
1998-12-22 21:59 ` john s jacobs anderson
1998-12-23 4:58 ` Tom Harrington
1998-12-23 5:24 ` john s jacobs anderson
1998-12-22 18:29 ` Mark Abene
1998-12-22 21:49 ` john s jacobs anderson
1998-12-22 6:11 ` FD_SET/FD_ZERO, vi clone compiling john s jacobs anderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).