From c9e64b4212b64933efbe433808ea9a09a1b38ff8 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 21 Oct 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-10-21 --- boot/boot.c | 3 +++ pc/kbd.c | 9 --------- pc/screen.h | 2 -- port/devbit.c | 19 ++++++++++++------- port/devscc.c | 11 +++++++++-- port/portdat.h | 12 ++++++++++++ 6 files changed, 36 insertions(+), 20 deletions(-) diff --git a/boot/boot.c b/boot/boot.c index cbc383857711a569572209246dcdb3afce7bcf3a..ebfdd8f7cd25b1267b461adca15a61aed8c1bf0c 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -44,6 +44,9 @@ boot(int argc, char *argv[]) print("%s ", argv[fd]); print("\n");/**/ + if(argc <= 1) + pflag = 1; + ARGBEGIN{ case 'a': aflag = 1; diff --git a/pc/kbd.c b/pc/kbd.c index 6931491d4324d467630cdf19f5b922f839259b5d..6f0525dadf4c5509b160cab2761d46b846f94ce4 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -113,10 +113,7 @@ KIOQ kbdq; static int keybuttons; static uchar ccc; -static int mousetype; -static int mouseport; static int shift; -extern int mouseshifted; enum { @@ -127,11 +124,6 @@ enum Csf= (1<<2), /* system flag */ Cmouseint= (1<<1), /* mouse interrupt enable */ Ckbdint= (1<<0), /* kbd interrupt enable */ - - /* what kind of mouse */ - Mouseother= 0, - Mouseserial= 1, - MousePS2= 2, }; static void kbdintr(Ureg*); @@ -286,7 +278,6 @@ serialmouse(int port, char *type, int setspeed) uartspecial(port, 0, &mouseq, setspeed ? 1200 : 0); if(type && *type == 'M') mouseq.putc = m3mouseputc; - mouseport = port; mousetype = Mouseserial; } diff --git a/pc/screen.h b/pc/screen.h index 311016a5a61d07c6f8bad67595b2d4482cabe2d9..a3dd699a525856e050fc5a74688ba926b93df537 100644 --- a/pc/screen.h +++ b/pc/screen.h @@ -29,5 +29,3 @@ extern Cursorinfo cursor; extern void mouseupdate(int); #define hwscreenwrite(a, b) - -int islcd; diff --git a/port/devbit.c b/port/devbit.c index adf5a96db240e74a429775b1a4538148a31daa92..c8fdfac31580b5175e3051e65044f294e2befacb 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -109,6 +109,8 @@ Mouseinfo mouse; Cursorinfo cursor; Rendez lcdmouse; int mouseshifted; +int mousetype; +int islcd; Cursor arrow = { @@ -2047,14 +2049,15 @@ mouseupdate(int dolock) * byte 2 - 0 Y5 Y4 Y3 Y2 Y1 Y0 * byte 3 - 0 M x x x x x (optional) * - * shift & left button is the same as middle button (for 2 button mice) + * shift & right button is the same as middle button (for 2 button mice) */ int m3mouseputc(IOQ *q, int c) { static uchar msg[3]; static int nb; - static uchar b[] = { 0, 4, 1, 5, 0, 4, 3, 7 }; + static int middle; + static uchar b[] = { 0, 4, 1, 5, 0, 2, 1, 5 }; short x; USED(q); @@ -2064,15 +2067,15 @@ m3mouseputc(IOQ *q, int c) if(nb==0){ if((c&0x40) == 0){ /* an extra byte gets sent for the middle button */ - mousebuttons((mouse.buttons & ~2) | ((c&0x20) ? 2 : 0)); + middle = (c&0x20) ? 2 : 0; + mousebuttons((mouse.buttons & ~2) | middle); return 0; } } msg[nb] = c; if(++nb == 3){ nb = 0; - mouse.newbuttons = (mouse.buttons & 2) - | b[(msg[0]>>4)&3 | (mouseshifted ? 4 : 0)]; + mouse.newbuttons = middle | b[(msg[0]>>4)&3 | (mouseshifted ? 4 : 0)]; x = (msg[0]&0x3)<<14; mouse.dx = (x>>8) | msg[1]; x = (msg[0]&0xc)<<12; @@ -2085,13 +2088,15 @@ m3mouseputc(IOQ *q, int c) /* * Logitech 5 byte packed binary mouse format, 8 bit bytes + * + * shift & right button is the same as middle button (for 2 button mice) */ int mouseputc(IOQ *q, int c) { static short msg[5]; static int nb; - static uchar b[] = {0, 4, 2, 6, 1, 5, 3, 7}; + static uchar b[] = {0, 4, 2, 6, 1, 5, 3, 7, 0, 2, 2, 6, 1, 5, 3, 7}; USED(q); if((c&0xF0) == 0x80) @@ -2100,7 +2105,7 @@ mouseputc(IOQ *q, int c) if(c & 0x80) msg[nb] |= ~0xFF; /* sign extend */ if(++nb == 5){ - mouse.newbuttons = b[(msg[0]&7)^7]; + mouse.newbuttons = b[((msg[0]&7)^7) | (mouseshifted ? 2 : 0)]; mouse.dx = msg[1]+msg[3]; mouse.dy = -(msg[2]+msg[4]); mouse.track = 1; diff --git a/port/devscc.c b/port/devscc.c index 2b03d3360599b63837fb04c9bc4410cb23c117de..fab9363c599740896f177b95bb58276f0c1933c3 100644 --- a/port/devscc.c +++ b/port/devscc.c @@ -96,6 +96,7 @@ struct SCC uchar *data; /* data register in Z8530 */ int printing; /* true if printing */ ulong freq; /* clock frequency */ + uchar mask; /* bits/char */ /* console interface */ int special; /* can't use the stream interface */ @@ -198,19 +199,23 @@ sccbits(SCC *sp, int n) switch(n){ case 5: + sp->mask = 0x1f; rbits = Rx5bits; tbits = Tx5bits; break; case 6: + sp->mask = 0x3f; rbits = Rx6bits; tbits = Tx6bits; break; case 7: + sp->mask = 0x7f; rbits = Rx7bits; tbits = Tx7bits; break; case 8: default: + sp->mask = 0xff; rbits = Rx8bits; tbits = Tx8bits; break; @@ -298,6 +303,7 @@ sccsetup0(SCC *sp, int brsource) sccwrreg(sp, 3, 0); sp->sticky[5] = TxEna | Tx8bits; sccwrreg(sp, 5, 0); + sp->mask = 0xff; } void @@ -369,7 +375,7 @@ sccintr0(SCC *sp, uchar x) cq = sp->iq; while(*sp->ptr&RxReady){ onepointseven(); - ch = *sp->data; + ch = *sp->data & sp->mask; if (ch == CTLS && sp->xonoff) sp->blocked = 1; else if (ch == CTLQ && sp->xonoff) { @@ -477,7 +483,8 @@ sccspecial(int port, IOQ *oq, IOQ *iq, int baud) sp->oq = oq; sp->iq = iq; sccenable(sp); - sccsetbaud(sp, baud); + if(baud) + sccsetbaud(sp, baud); if(iq){ /* diff --git a/port/portdat.h b/port/portdat.h index cd9c417fdf41e57a4f7cebcea5cf5b35e1aabd45..52e9ba2f9513fb0cdd585f82e9b963dcd9103189 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -774,3 +774,15 @@ enum AUTHLEN = 8, }; + +/* + * mouse types + */ +enum +{ + Mouseother= 0, + Mouseserial= 1, + MousePS2= 2, +}; +extern int mouseshifted; +extern int mousetype;