| plan 9 kernel history: overview | file list | diff list |
2000/1012/pc/mouse.c (diff list | history)
| 1997/0327/sys/src/9/pc/mouse.c:115,121 – 1997/0808/sys/src/9/pc/mouse.c:115,124 (short | long) | ||
| 1997/0327 | i8042auxcmd(0xE7); break; default: | |
| 1997/0808 | if(n == 1) mouseaccelerate("1"); else mouseaccelerate(field[1]); | |
| 1997/0327 | break; } } else if(strcmp(field[0], "linear") == 0){ | |
| 1997/0808/sys/src/9/pc/mouse.c:6,13 – 1997/1101/sys/src/9/pc/mouse.c:6,26 (short | long) | ||
| 1997/0327 | #include "../port/error.h" #include "io.h" | |
| 1997/1101 | #define Image IMAGE #include <draw.h> #include <memdraw.h> | |
| 1997/0327 | #include "screen.h" | |
| 1997/1101 | /* * mouse types */ enum { Mouseother= 0, Mouseserial= 1, MousePS2= 2, }; static int mousetype; | |
| 1997/0327 | /* * setup a serial mouse | |
| 1997/1101/sys/src/9/pc/mouse.c:101,112 – 1998/0417/sys/src/9/pc/mouse.c:101,108 (short | long) | ||
|
Change mousectl to accept list of fields.
rsc Fri Mar 4 12:44:25 2005 | ||
| 1997/0327 | } void | |
| 1998/0417 | mousectl(char* field[], int n) | |
| 1997/0327 | { | |
| 1997/1101/sys/src/9/pc/mouse.c:154,161 – 1998/0417/sys/src/9/pc/mouse.c:150,156 | ||
| 1997/0327 | i8042auxcmd(n); break; } | |
| 1998/0417 | } | |
| 1997/0327 | else error(Ebadctl); } | |
| 1998/0417/sys/src/9/pc/mouse.c:9,14 – 1999/0119/sys/src/9/pc/mouse.c:9,15 (short | long) | ||
| 1997/1101 | #define Image IMAGE #include <draw.h> #include <memdraw.h> | |
| 1999/0119 | #include <cursor.h> | |
| 1997/0327 | #include "screen.h" | |
| 1997/1101 | /* | |
| 1999/0119/sys/src/9/pc/mouse.c:151,156 – 1999/0224/sys/src/9/pc/mouse.c:151,162 (short | long) | ||
| 1997/0327 | i8042auxcmd(n); break; } | |
| 1999/0224 | } else if(strcmp(field[0], "reset") == 0){ i8042auxcmd(0xF6); i8042auxcmd(0xEA); /* streaming */ i8042auxcmd(0xE8); /* set resolution */ i8042auxcmd(3); i8042auxcmd(0xF4); /* enabled */ | |
| 1998/0417 | } | |
| 1997/0327 | else error(Ebadctl); | |
| 1999/0224/sys/src/9/pc/mouse.c:101,106 – 1999/0225/sys/src/9/pc/mouse.c:101,180 (short | long) | ||
| 1997/0327 | mousetype = MousePS2; } | |
| 1999/0225 | static int intellimouse; static int resolution; static int accelerated; static void setaccelerated(int x) { accelerated = x; switch(mousetype){ case MousePS2: i8042auxcmd(0xE7); break; default: mouseaccelerate(x); break; } } static void setlinear(void) { accelerated = 0; switch(mousetype){ case MousePS2: i8042auxcmd(0xE6); break; default: mouseaccelerate(0); break; } } static void setres(int n) { resolution = n; switch(mousetype){ case MousePS2: i8042auxcmd(0xE8); i8042auxcmd(n); break; } } static void setintellimouse(void) { intellimouse = 1; switch(mousetype){ case MousePS2: i8042auxcmd(0xF3); /* set sample */ i8042auxcmd(0xC8); i8042auxcmd(0xF3); /* set sample */ i8042auxcmd(0x64); i8042auxcmd(0xF3); /* set sample */ i8042auxcmd(0x50); break; } } static void resetmouse(void) { switch(mousetype){ case MousePS2: i8042auxcmd(0xF6); i8042auxcmd(0xEA); /* streaming */ i8042auxcmd(0xE8); /* set resolution */ i8042auxcmd(3); i8042auxcmd(0xF4); /* enabled */ break; } } | |
| 1997/0327 | void | |
| 1998/0417 | mousectl(char* field[], int n) | |
| 1997/0327 | { | |
| 1999/0224/sys/src/9/pc/mouse.c:119,162 – 1999/0225/sys/src/9/pc/mouse.c:193,219 | ||
| 1997/0327 | } } else if(strcmp(field[0], "ps2") == 0){ ps2mouse(); | |
| 1999/0225 | } else if(strcmp(field[0], "ps2intellimouse") == 0){ ps2mouse(); setintellimouse(); | |
| 1997/0327 | } else if(strcmp(field[0], "accelerated") == 0){ | |
| 1997/0808 |
| |
| 1997/0327 |
| |
| 1999/0225 | setaccelerated(n == 1 ? 1 : atoi(field[1])); | |
| 1997/0327 | } else if(strcmp(field[0], "linear") == 0){ | |
| 1999/0225 | setlinear(); | |
| 1997/0327 | } else if(strcmp(field[0], "res") == 0){ | |
| 1999/0225 | if(n >= 2) | |
| 1997/0327 | n = atoi(field[1]); | |
| 1999/0225 | setres(n); | |
| 1999/0224 | } else if(strcmp(field[0], "reset") == 0){ | |
| 1999/0225 | resetmouse(); if(accelerated) setaccelerated(accelerated); if(resolution) setres(resolution); if(intellimouse) setintellimouse(); } else if(strcmp(field[0], "intellimouse") == 0){ setintellimouse(); | |
| 1998/0417 | } | |
| 1997/0327 | else error(Ebadctl); | |
| 1999/0225/sys/src/9/pc/mouse.c:59,65 – 2000/0716/sys/src/9/pc/mouse.c:59,65 (short | long) | ||
| 1997/0327 | { static short msg[3]; static int nb; | |
| 2000/0716 | static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 3, 2, 3, 6, 7 }; | |
| 1997/0327 | int buttons, dx, dy; /* | |
| 2000/0716/sys/src/9/pc/mouse.c:52,58 – 2000/0731/sys/src/9/pc/mouse.c:52,58 (short | long) | ||
| 1997/0327 | * byte 1 - DX * byte 2 - DY * | |
| 2000/0731 | * shift & right button is the same as middle button | |
| 1997/0327 | */ static void ps2mouseputc(int c, int shift) | |
| 2000/0731/sys/src/9/pc/mouse.c:101,110 – 2000/1005/sys/src/9/pc/mouse.c:101,106 (short | long) | ||
| 1997/0327 | mousetype = MousePS2; } | |
| 1999/0225 |
| |
| 2000/1005/sys/src/9/pc/mouse.c:101,106 – 2000/1006/sys/src/9/pc/mouse.c:101,110 (short | long) | ||
| 1997/0327 | mousetype = MousePS2; } | |
| 2000/1006 | static int intellimouse; static int resolution; static int accelerated; | |
| 1999/0225 | static void setaccelerated(int x) { | |
| 2000/1006/sys/src/9/pc/mouse.c:22,27 – 2000/1012/sys/src/9/pc/mouse.c:22,31 (short | long) | ||
| 1997/1101 | MousePS2= 2, }; static int mousetype; | |
| 2000/1012 | static int intellimouse; static int packetsize; static int resolution; static int accelerated; | |
| 1997/0327 | /* * setup a serial mouse | |
| 2000/1006/sys/src/9/pc/mouse.c:43,48 – 2000/1012/sys/src/9/pc/mouse.c:47,53 | ||
| 1997/0327 | else ns16552special(port, setspeed, 0, 0, mouseputc); mousetype = Mouseserial; | |
| 2000/1012 | packetsize = 3; | |
| 1997/0327 | } /* | |
| 2000/1006/sys/src/9/pc/mouse.c:53,63 – 2000/1012/sys/src/9/pc/mouse.c:58,79 | ||
| 1997/0327 | * byte 2 - DY * | |
| 2000/0731 | * shift & right button is the same as middle button | |
| 2000/1012 | * * Intellimouse and AccuPoint with extra buttons deliver * byte 3 - 00 or 01 or FF according to extra button state. * extra buttons are mapped in this code to buttons 4 and 5. * AccuPoint generates repeated events for these buttons; * it and Intellimouse generate 'down' events only, so * user-level code is required to generate button 'up' events * if they are needed by the application. * Also on laptops with AccuPoint AND external mouse, the * controller may deliver 3 or 4 bytes according to the type * of the external mouse; code must adapt. | |
| 1997/0327 | */ static void ps2mouseputc(int c, int shift) { | |
| 2000/1012 | static short msg[4]; | |
| 1997/0327 | static int nb; | |
| 2000/0716 | static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 3, 2, 3, 6, 7 }; | |
| 1997/0327 | int buttons, dx, dy; | |
| 2000/1006/sys/src/9/pc/mouse.c:66,75 – 2000/1012/sys/src/9/pc/mouse.c:82,95 | ||
| 1997/0327 | * check byte 0 for consistency */ if(nb==0 && (c&0xc8)!=0x08) | |
| 2000/1012 | if(intellimouse && (c==0x00 || c==0x01 || c==0xFF)){ /* last byte of 4-byte packet */ packetsize = 4; return; } | |
| 1997/0327 | msg[nb] = c; | |
| 2000/1012 | if(++nb == packetsize){ | |
| 1997/0327 | nb = 0; if(msg[0] & 0x10) msg[1] |= 0xFF00; | |
| 2000/1006/sys/src/9/pc/mouse.c:77,82 – 2000/1012/sys/src/9/pc/mouse.c:97,118 | ||
| 1997/0327 | msg[2] |= 0xFF00; buttons = b[(msg[0]&7) | (shift ? 8 : 0)]; | |
| 2000/1012 | if(intellimouse && packetsize==4){ if((msg[3]&0xc8) == 0x08){ /* first byte of 3-byte packet */ packetsize = 3; msg[0] = msg[3]; nb = 1; /* fall through to emit previous packet */ }else{ /* the AccuPoint on the Toshiba 34[48]0CT encodes extra buttons as 4 and 5 */ /* they repeat and don't release, however, so user-level timing code is required */ if(msg[3] == 0xFF) buttons |= 1<<3; if(msg[3] == 0x01) buttons |= 1<<4; } } | |
| 1997/0327 | dx = msg[1]; dy = -msg[2]; mousetrack(buttons, dx, dy); | |
| 2000/1006/sys/src/9/pc/mouse.c:99,110 – 2000/1012/sys/src/9/pc/mouse.c:135,143 | ||
| 1997/0327 | i8042auxcmd(0xF4); mousetype = MousePS2; | |
| 2000/1012 | packetsize = 3; | |
| 1997/0327 | } | |
| 2000/1006 |
| |
| 1999/0225 | static void setaccelerated(int x) { | |
| 2000/1006/sys/src/9/pc/mouse.c:149,154 – 2000/1012/sys/src/9/pc/mouse.c:182,188 | ||
| 1999/0225 | setintellimouse(void) { intellimouse = 1; | |
| 2000/1012 | packetsize = 4; | |
| 1999/0225 | switch(mousetype){ case MousePS2: i8042auxcmd(0xF3); /* set sample */ | |
| 2000/1006/sys/src/9/pc/mouse.c:164,169 – 2000/1012/sys/src/9/pc/mouse.c:198,204 | ||
| 1999/0225 | static void resetmouse(void) { | |
| 2000/1012 | packetsize = 3; | |
| 1999/0225 | switch(mousetype){ case MousePS2: i8042auxcmd(0xF6); | |
| 2000/1012/sys/src/9/pc/mouse.c:69,74 – 2001/0404/sys/src/9/pc/mouse.c:69,80 (short | long) | ||
| 2000/1012 | * Also on laptops with AccuPoint AND external mouse, the * controller may deliver 3 or 4 bytes according to the type * of the external mouse; code must adapt. | |
| 2001/0404 | * * On the NEC Versa series (and perhaps others?) we seem to * lose a byte from the packet every once in a while, which * means we lose where we are in the instruction stream. * To resynchronize, if we get a byte more than two seconds * after the previous byte, we assume it's the first in a packet. | |
| 1997/0327 | */ static void ps2mouseputc(int c, int shift) | |
| 2000/1012/sys/src/9/pc/mouse.c:76,82 – 2001/0404/sys/src/9/pc/mouse.c:82,98 | ||
| 2000/1012 | static short msg[4]; | |
| 1997/0327 | static int nb; | |
| 2000/0716 | static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 3, 2, 3, 6, 7 }; | |
| 2001/0404 | static ulong lasttick; ulong m; | |
| 1997/0327 | int buttons, dx, dy; | |
| 2001/0404 | /* * Resynchronize in stream with timing; see comment above. */ m = MACHP(0)->ticks; if(TK2SEC(m - lasttick) > 2) nb = 0; lasttick = m; | |
| 1997/0327 | /* * check byte 0 for consistency | |
| 2001/0404/sys/src/9/pc/mouse.c:33,38 – 2001/0527/sys/src/9/pc/mouse.c:33,39 (short | long) | ||
| 1997/0327 | static void serialmouse(int port, char *type, int setspeed) { | |
| 2001/0527 | #ifdef notdef | |
| 1997/0327 | if(mousetype == Mouseserial) error(Emouseset); | |
| 2001/0404/sys/src/9/pc/mouse.c:43,53 – 2001/0527/sys/src/9/pc/mouse.c:44,58 | ||
| 1997/0327 | if(setspeed) setspeed = 1200; if(type && *type == 'M') | |
| 2001/0527 | uartspecial(port, setspeed, 0, 0, m3mouseputc); | |
| 1997/0327 | else | |
| 2001/0527 | uartspecial(port, setspeed, 0, 0, mouseputc); | |
| 1997/0327 | mousetype = Mouseserial; | |
| 2000/1012 | packetsize = 3; | |
| 2001/0527 | #else error("serial mouse not supported yet"); USED(port, type, setspeed); #endif /* notdef */ | |
| 1997/0327 | } /* | |
| 2001/0404/sys/src/9/pc/mouse.c:131,137 – 2001/0527/sys/src/9/pc/mouse.c:136,142 | ||
| 2000/1012 | } | |
| 1997/0327 | dx = msg[1]; dy = -msg[2]; | |
| 2001/0527 | mousetrack(dx, dy, buttons, TK2MS(MACHP(0)->ticks)); | |
| 1997/0327 | } return; } | |
| 2001/0527/sys/src/9/pc/mouse.c:27,32 – 2001/1120/sys/src/9/pc/mouse.c:27,56 (short | long) | ||
| 2000/1012 | static int resolution; static int accelerated; | |
| 1997/0327 | ||
| 2001/1120 | enum { CMaccelerated, CMintellimouse, CMlinear, CMps2, CMps2intellimouse, CMres, CMreset, CMserial, }; static Cmdtab mousectlmsg[] = { CMaccelerated, "accelerated", 0, CMintellimouse, "intellimouse", 1, CMlinear, "linear", 1, CMps2, "ps2", 1, CMps2intellimouse, "ps2intellimouse", 1, CMres, "res", 0, CMreset, "reset", 1, CMserial, "serial", 0, }; | |
| 1997/0327 | /* * setup a serial mouse */ | |
| 2001/0527/sys/src/9/pc/mouse.c:232,266 – 2001/1120/sys/src/9/pc/mouse.c:256,290 | ||
| 1999/0225 | } | |
| 1997/0327 | void | |
| 1998/0417 |
| |
| 2001/1120 | mousectl(Cmdbuf *cb) | |
| 1997/0327 | { | |
| 2001/1120 | Cmdtab *ct; ct = lookupcmd(cb, mousectlmsg, nelem(mousectlmsg)); switch(ct->index){ case CMaccelerated: setaccelerated(cb->nf == 1 ? 1 : atoi(cb->f[1])); break; case CMintellimouse: setintellimouse(); break; case CMlinear: setlinear(); break; case CMps2: | |
| 1997/0327 | ps2mouse(); | |
| 1999/0225 |
| |
| 2001/1120 | break; case CMps2intellimouse: | |
| 1999/0225 | ps2mouse(); setintellimouse(); | |
| 1997/0327 |
| |
| 1999/0225 |
| |
| 1997/0327 |
| |
| 1999/0225 |
| |
| 1997/0327 |
| |
| 1999/0225 |
| |
| 1997/0327 |
| |
| 1999/0225 |
| |
| 1999/0224 |
| |
| 2001/1120 | break; case CMres: if(cb->nf >= 2) setres(atoi(cb->f[1])); else setres(1); break; case CMreset: | |
| 1999/0225 | resetmouse(); if(accelerated) setaccelerated(accelerated); | |
| 2001/0527/sys/src/9/pc/mouse.c:268,276 – 2001/1120/sys/src/9/pc/mouse.c:292,311 | ||
| 1999/0225 | setres(resolution); if(intellimouse) setintellimouse(); | |
| 2001/1120 | break; case CMserial: switch(cb->nf){ case 1: serialmouse(atoi(cb->f[0]+6), 0, 1); break; case 2: serialmouse(atoi(cb->f[1]), 0, 0); break; case 3: default: serialmouse(atoi(cb->f[1]), cb->f[2], 0); break; } break; | |
| 1998/0417 | } | |
| 1997/0327 |
| |
| 2001/1120/sys/src/9/pc/mouse.c:26,35 – 2001/1121/sys/src/9/pc/mouse.c:26,37 (short | long) | ||
| 2000/1012 | static int packetsize; static int resolution; static int accelerated; | |
| 2001/1121 | static int mousehwaccel; | |
| 1997/0327 | ||
| 2001/1120 | enum { CMaccelerated, | |
| 2001/1121 | CMhwaccel, | |
| 2001/1120 | CMintellimouse, CMlinear, CMps2, | |
| 2001/1120/sys/src/9/pc/mouse.c:42,47 – 2001/1121/sys/src/9/pc/mouse.c:44,50 | ||
| 2001/1120 | static Cmdtab mousectlmsg[] = { CMaccelerated, "accelerated", 0, | |
| 2001/1121 | CMhwaccel, "hwaccel", 2, | |
| 2001/1120 | CMintellimouse, "intellimouse", 1, CMlinear, "linear", 1, CMps2, "ps2", 1, | |
| 2001/1120/sys/src/9/pc/mouse.c:181,200 – 2001/1121/sys/src/9/pc/mouse.c:184,215 | ||
| 1997/0327 | mousetype = MousePS2; | |
| 2000/1012 | packetsize = 3; | |
| 2001/1121 | mousehwaccel = 1; | |
| 1997/0327 | } | |
| 2001/1121 | /* * The PS/2 Trackpoint multiplexor on the IBM Thinkpad T23 ignores * acceleration commands. It is supposed to pass them on * to the attached device, but my Logitech mouse is simply * not behaving any differently. For such devices, we allow * the user to use "hwaccel off" to tell us to back off to * software acceleration even if we're using the PS/2 port. * (Serial mice are always software accelerated.) * For more information on the Thinkpad multiplexor, see * http://wwwcssrv.almaden.ibm.com/trackpoint/ */ | |
| 1999/0225 | static void setaccelerated(int x) { accelerated = x; | |
| 2001/1121 | if(mousehwaccel){ switch(mousetype){ case MousePS2: i8042auxcmd(0xE7); return; } | |
| 1999/0225 | } | |
| 2001/1121 | mouseaccelerate(x); | |
| 1999/0225 | } static void | |
| 2001/1120/sys/src/9/pc/mouse.c:201,214 – 2001/1121/sys/src/9/pc/mouse.c:216,229 | ||
| 1999/0225 | setlinear(void) { accelerated = 0; | |
| 2001/1121 | if(mousehwaccel){ switch(mousetype){ case MousePS2: i8042auxcmd(0xE6); return; } | |
| 1999/0225 | } | |
| 2001/1121 | mouseaccelerate(0); | |
| 1999/0225 | } static void | |
| 2001/1120/sys/src/9/pc/mouse.c:307,311 – 2001/1121/sys/src/9/pc/mouse.c:322,333 | ||
| 2001/1120 | break; } break; | |
| 2001/1121 | case CMhwaccel: if(strcmp(cb->f[1], "on")==0) mousehwaccel = 1; else if(strcmp(cb->f[1], "off")==0) mousehwaccel = 0; else cmderror(cb, "bad mouse control message"); | |
| 1998/0417 | } | |
| 1997/0327 | } | |
| 2001/1121/sys/src/9/pc/mouse.c:21,26 – 2002/0503/sys/src/9/pc/mouse.c:21,28 (short | long) | ||
| 1997/1101 | Mouseserial= 1, MousePS2= 2, }; | |
| 2002/0503 | static QLock mousectlqlock; | |
| 1997/1101 | static int mousetype; | |
| 2000/1012 | static int intellimouse; static int packetsize; | |
| 2001/1121/sys/src/9/pc/mouse.c:55,88 – 2002/0503/sys/src/9/pc/mouse.c:57,62 | ||
| 2001/1120 | }; | |
| 1997/0327 | /* | |
| 2001/0527 |
| |
| 1997/0327 |
| |
| 2001/0527 |
| |
| 1997/0327 |
| |
| 2001/0527 |
| |
| 1997/0327 |
| |
| 2000/1012 |
| |
| 2001/0527 |
| |
| 1997/0327 |
| |
| 2001/1121/sys/src/9/pc/mouse.c:275,280 – 2002/0503/sys/src/9/pc/mouse.c:249,260 | ||
| 1997/0327 | { | |
| 2001/1120 | Cmdtab *ct; | |
| 2002/0503 | qlock(&mousectlqlock); if(waserror()){ qunlock(&mousectlqlock); nexterror(); } | |
| 2001/1120 | ct = lookupcmd(cb, mousectlmsg, nelem(mousectlmsg)); switch(ct->index){ case CMaccelerated: | |
| 2001/1121/sys/src/9/pc/mouse.c:309,326 – 2002/0503/sys/src/9/pc/mouse.c:289,304 | ||
| 1999/0225 | setintellimouse(); | |
| 2001/1120 | break; case CMserial: | |
| 2002/0503 | if(mousetype == Mouseserial) error(Emouseset); if(cb->nf > 2 && *cb->f[2] == 'M') i8250mouse(cb->f[1], m3mouseputc, 0); else i8250mouse(cb->f[1], mouseputc, cb->nf == 1); mousetype = Mouseserial; packetsize = 3; | |
| 2001/1120 | break; | |
| 2001/1121 | case CMhwaccel: if(strcmp(cb->f[1], "on")==0) | |
| 2001/1121/sys/src/9/pc/mouse.c:330,333 – 2002/0503/sys/src/9/pc/mouse.c:308,314 | ||
| 2001/1121 | else cmderror(cb, "bad mouse control message"); | |
| 1998/0417 | } | |
| 2002/0503 | qunlock(&mousectlqlock); poperror(); | |
| 1997/0327 | } | |