From: tph@rmi.net (Tom Harrington)
To: linuxppc-user@lists.linuxppc.org
Cc: linuxppc-dev@lists.linuxppc.org
Subject: TurboMouse fix
Date: Mon, 21 Dec 1998 21:16:43 -0700 (MST) [thread overview]
Message-ID: <m0zsJFT-001C3VC@shell.rmi.net> (raw)
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 ]]
next reply other threads:[~1998-12-22 4:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-12-22 4:16 Tom Harrington [this message]
1998-12-22 6:03 ` TurboMouse fix 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m0zsJFT-001C3VC@shell.rmi.net \
--to=tph@rmi.net \
--cc=linuxppc-dev@lists.linuxppc.org \
--cc=linuxppc-user@lists.linuxppc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).