diff options
author | sos <sos@FreeBSD.org> | 1996-09-08 21:31:56 +0000 |
---|---|---|
committer | sos <sos@FreeBSD.org> | 1996-09-08 21:31:56 +0000 |
commit | 95d76c18b04a3719a46ba653506e4eaebf394b0d (patch) | |
tree | 7252de3f1b6d40d6f72f44c48f1d53043dc61dd4 | |
parent | 312a2a006e0eb1cdd6c1f8da012033a97a5c2d71 (diff) | |
download | FreeBSD-src-95d76c18b04a3719a46ba653506e4eaebf394b0d.zip FreeBSD-src-95d76c18b04a3719a46ba653506e4eaebf394b0d.tar.gz |
Make syscons replicate a mousesystems mouse on minor 128..
This enables other consumers of the mouse, to get it info via
moused/syscons.
In order to use it run moused (from sysconfig), and then tell
your Xserver that it should use /dev/sysmouse (mknod sysmouse c 12 128)
and it a mousesystems mouse. Everybody will be happy then :)
Remember that moused still needs to know what kind of mouse you
have..
Comments welcome, as is test results...
-rw-r--r-- | sys/dev/syscons/syscons.c | 54 | ||||
-rw-r--r-- | sys/i386/isa/syscons.c | 54 | ||||
-rw-r--r-- | sys/isa/syscons.c | 54 |
3 files changed, 108 insertions, 54 deletions
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 363e6c1..eb2321b 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.166 1996/09/06 23:35:54 pst Exp $ + * $Id: syscons.c,v 1.167 1996/09/07 21:47:53 bde Exp $ */ #include "sc.h" @@ -140,13 +140,17 @@ void (*current_saver) __P((int blank)) = none_saver; #ifdef not_yet_done #define VIRTUAL_TTY(x) (sccons[x] = ttymalloc(sccons[x])) struct CONSOLE_TTY (sccons[MAXCONS] = ttymalloc(sccons[MAXCONS])) -static const int nsccons = MAXCONS+1; -struct tty *sccons[MAXCONS+1]; +struct MOUSE_TTY (sccons[MAXCONS+1] = ttymalloc(sccons[MAXCONS+1])) +static const int nsccons = MAXCONS+2; +struct tty *sccons[MAXCONS+2]; #else #define VIRTUAL_TTY(x) &sccons[x] #define CONSOLE_TTY &sccons[MAXCONS] -static struct tty sccons[MAXCONS+1]; +#define MOUSE_TTY &sccons[MAXCONS+1] +static struct tty sccons[MAXCONS+2]; #endif +#define SC_MOUSE 128 +#define SC_CONSOLE 255 #define MONO_BUF pa_to_va(0xB0000) #define CGA_BUF pa_to_va(0xB8000) u_short *Crtat; @@ -476,10 +480,12 @@ struct tty if (init_done == COLD) return(NULL); - if (unit > MAXCONS || unit < 0) - return(NULL); - if (unit == MAXCONS) + if (unit == SC_CONSOLE) return CONSOLE_TTY; + if (unit == SC_MOUSE) + return MOUSE_TTY; + if (unit >= MAXCONS || unit < 0) + return(NULL); return VIRTUAL_TTY(unit); } @@ -488,10 +494,10 @@ static scr_stat { int unit = minor(dev); - if (unit > MAXCONS || unit < 0) - return(NULL); - if (unit == MAXCONS) + if (unit == SC_CONSOLE) return console[0]; + if (unit >= MAXCONS || unit < 0) + return(NULL); return console[unit]; } @@ -513,7 +519,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) if (!tp) return(ENXIO); - tp->t_oproc = scstart; + tp->t_oproc = (minor(dev) == SC_MOUSE) ? NULL : scstart; tp->t_param = scparam; tp->t_dev = dev; if (!(tp->t_state & TS_ISOPEN)) { @@ -530,7 +536,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) return(EBUSY); - if (!console[minor(dev)]) + if (minor(dev) < MAXCONS && !console[minor(dev)]) console[minor(dev)] = alloc_scp(); return((*linesw[tp->t_line].l_open)(dev, tp)); } @@ -747,7 +753,7 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) scp->mouse_proc = NULL; scp->mouse_pid = 0; } - return 0; + break; case MOUSE_SHOW: if (!(scp->status & MOUSE_ENABLED)) { @@ -784,10 +790,23 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) mouse->u.data.x = scp->mouse_xpos; mouse->u.data.y = scp->mouse_ypos; mouse->u.data.buttons = scp->mouse_buttons; - return 0; + break; case MOUSE_ACTION: - /* this should maybe only be settable from /dev/console SOS */ + /* this should maybe only be settable from /dev/mouse SOS */ + /* send out mouse event on /dev/mouse */ + if ((MOUSE_TTY)->t_state & TS_ISOPEN) { + u_char buf[5]; + int i; + + buf[0] = 0x80 | ((~mouse->u.data.buttons) & 0x07); + buf[1] = (mouse->u.data.x & 0x1fe >> 1); + buf[3] = (mouse->u.data.x & 0x1ff) - buf[1]; + buf[2] = -(mouse->u.data.y & 0x1fe >> 1); + buf[4] = -(mouse->u.data.y & 0x1ff) - buf[2]; + for (i=0; i<5; i++) + (*linesw[(MOUSE_TTY)->t_line].l_rint)(buf[i],MOUSE_TTY); + } cur_console->mouse_xpos += mouse->u.data.x; cur_console->mouse_ypos += mouse->u.data.y; if (cur_console->mouse_signal) { @@ -1301,9 +1320,8 @@ scstart(struct tty *tp) u_char buf[PCBURST]; scr_stat *scp = get_scr_stat(tp->t_dev); - /* XXX who repeats the call when the above flags are cleared? */ if (scp->status & SLKED || blink_in_progress) - return; + return; /* XXX who repeats the call when the above flags are cleared? */ s = spltty(); if (!(tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))) { tp->t_state |= TS_BUSY; @@ -1335,7 +1353,7 @@ sccnprobe(struct consdev *cp) } /* initialize required fields */ - cp->cn_dev = makedev(CDEV_MAJOR, MAXCONS); + cp->cn_dev = makedev(CDEV_MAJOR, SC_CONSOLE); cp->cn_pri = CN_INTERNAL; } diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c index 363e6c1..eb2321b 100644 --- a/sys/i386/isa/syscons.c +++ b/sys/i386/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.166 1996/09/06 23:35:54 pst Exp $ + * $Id: syscons.c,v 1.167 1996/09/07 21:47:53 bde Exp $ */ #include "sc.h" @@ -140,13 +140,17 @@ void (*current_saver) __P((int blank)) = none_saver; #ifdef not_yet_done #define VIRTUAL_TTY(x) (sccons[x] = ttymalloc(sccons[x])) struct CONSOLE_TTY (sccons[MAXCONS] = ttymalloc(sccons[MAXCONS])) -static const int nsccons = MAXCONS+1; -struct tty *sccons[MAXCONS+1]; +struct MOUSE_TTY (sccons[MAXCONS+1] = ttymalloc(sccons[MAXCONS+1])) +static const int nsccons = MAXCONS+2; +struct tty *sccons[MAXCONS+2]; #else #define VIRTUAL_TTY(x) &sccons[x] #define CONSOLE_TTY &sccons[MAXCONS] -static struct tty sccons[MAXCONS+1]; +#define MOUSE_TTY &sccons[MAXCONS+1] +static struct tty sccons[MAXCONS+2]; #endif +#define SC_MOUSE 128 +#define SC_CONSOLE 255 #define MONO_BUF pa_to_va(0xB0000) #define CGA_BUF pa_to_va(0xB8000) u_short *Crtat; @@ -476,10 +480,12 @@ struct tty if (init_done == COLD) return(NULL); - if (unit > MAXCONS || unit < 0) - return(NULL); - if (unit == MAXCONS) + if (unit == SC_CONSOLE) return CONSOLE_TTY; + if (unit == SC_MOUSE) + return MOUSE_TTY; + if (unit >= MAXCONS || unit < 0) + return(NULL); return VIRTUAL_TTY(unit); } @@ -488,10 +494,10 @@ static scr_stat { int unit = minor(dev); - if (unit > MAXCONS || unit < 0) - return(NULL); - if (unit == MAXCONS) + if (unit == SC_CONSOLE) return console[0]; + if (unit >= MAXCONS || unit < 0) + return(NULL); return console[unit]; } @@ -513,7 +519,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) if (!tp) return(ENXIO); - tp->t_oproc = scstart; + tp->t_oproc = (minor(dev) == SC_MOUSE) ? NULL : scstart; tp->t_param = scparam; tp->t_dev = dev; if (!(tp->t_state & TS_ISOPEN)) { @@ -530,7 +536,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) return(EBUSY); - if (!console[minor(dev)]) + if (minor(dev) < MAXCONS && !console[minor(dev)]) console[minor(dev)] = alloc_scp(); return((*linesw[tp->t_line].l_open)(dev, tp)); } @@ -747,7 +753,7 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) scp->mouse_proc = NULL; scp->mouse_pid = 0; } - return 0; + break; case MOUSE_SHOW: if (!(scp->status & MOUSE_ENABLED)) { @@ -784,10 +790,23 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) mouse->u.data.x = scp->mouse_xpos; mouse->u.data.y = scp->mouse_ypos; mouse->u.data.buttons = scp->mouse_buttons; - return 0; + break; case MOUSE_ACTION: - /* this should maybe only be settable from /dev/console SOS */ + /* this should maybe only be settable from /dev/mouse SOS */ + /* send out mouse event on /dev/mouse */ + if ((MOUSE_TTY)->t_state & TS_ISOPEN) { + u_char buf[5]; + int i; + + buf[0] = 0x80 | ((~mouse->u.data.buttons) & 0x07); + buf[1] = (mouse->u.data.x & 0x1fe >> 1); + buf[3] = (mouse->u.data.x & 0x1ff) - buf[1]; + buf[2] = -(mouse->u.data.y & 0x1fe >> 1); + buf[4] = -(mouse->u.data.y & 0x1ff) - buf[2]; + for (i=0; i<5; i++) + (*linesw[(MOUSE_TTY)->t_line].l_rint)(buf[i],MOUSE_TTY); + } cur_console->mouse_xpos += mouse->u.data.x; cur_console->mouse_ypos += mouse->u.data.y; if (cur_console->mouse_signal) { @@ -1301,9 +1320,8 @@ scstart(struct tty *tp) u_char buf[PCBURST]; scr_stat *scp = get_scr_stat(tp->t_dev); - /* XXX who repeats the call when the above flags are cleared? */ if (scp->status & SLKED || blink_in_progress) - return; + return; /* XXX who repeats the call when the above flags are cleared? */ s = spltty(); if (!(tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))) { tp->t_state |= TS_BUSY; @@ -1335,7 +1353,7 @@ sccnprobe(struct consdev *cp) } /* initialize required fields */ - cp->cn_dev = makedev(CDEV_MAJOR, MAXCONS); + cp->cn_dev = makedev(CDEV_MAJOR, SC_CONSOLE); cp->cn_pri = CN_INTERNAL; } diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c index 363e6c1..eb2321b 100644 --- a/sys/isa/syscons.c +++ b/sys/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.166 1996/09/06 23:35:54 pst Exp $ + * $Id: syscons.c,v 1.167 1996/09/07 21:47:53 bde Exp $ */ #include "sc.h" @@ -140,13 +140,17 @@ void (*current_saver) __P((int blank)) = none_saver; #ifdef not_yet_done #define VIRTUAL_TTY(x) (sccons[x] = ttymalloc(sccons[x])) struct CONSOLE_TTY (sccons[MAXCONS] = ttymalloc(sccons[MAXCONS])) -static const int nsccons = MAXCONS+1; -struct tty *sccons[MAXCONS+1]; +struct MOUSE_TTY (sccons[MAXCONS+1] = ttymalloc(sccons[MAXCONS+1])) +static const int nsccons = MAXCONS+2; +struct tty *sccons[MAXCONS+2]; #else #define VIRTUAL_TTY(x) &sccons[x] #define CONSOLE_TTY &sccons[MAXCONS] -static struct tty sccons[MAXCONS+1]; +#define MOUSE_TTY &sccons[MAXCONS+1] +static struct tty sccons[MAXCONS+2]; #endif +#define SC_MOUSE 128 +#define SC_CONSOLE 255 #define MONO_BUF pa_to_va(0xB0000) #define CGA_BUF pa_to_va(0xB8000) u_short *Crtat; @@ -476,10 +480,12 @@ struct tty if (init_done == COLD) return(NULL); - if (unit > MAXCONS || unit < 0) - return(NULL); - if (unit == MAXCONS) + if (unit == SC_CONSOLE) return CONSOLE_TTY; + if (unit == SC_MOUSE) + return MOUSE_TTY; + if (unit >= MAXCONS || unit < 0) + return(NULL); return VIRTUAL_TTY(unit); } @@ -488,10 +494,10 @@ static scr_stat { int unit = minor(dev); - if (unit > MAXCONS || unit < 0) - return(NULL); - if (unit == MAXCONS) + if (unit == SC_CONSOLE) return console[0]; + if (unit >= MAXCONS || unit < 0) + return(NULL); return console[unit]; } @@ -513,7 +519,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) if (!tp) return(ENXIO); - tp->t_oproc = scstart; + tp->t_oproc = (minor(dev) == SC_MOUSE) ? NULL : scstart; tp->t_param = scparam; tp->t_dev = dev; if (!(tp->t_state & TS_ISOPEN)) { @@ -530,7 +536,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) return(EBUSY); - if (!console[minor(dev)]) + if (minor(dev) < MAXCONS && !console[minor(dev)]) console[minor(dev)] = alloc_scp(); return((*linesw[tp->t_line].l_open)(dev, tp)); } @@ -747,7 +753,7 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) scp->mouse_proc = NULL; scp->mouse_pid = 0; } - return 0; + break; case MOUSE_SHOW: if (!(scp->status & MOUSE_ENABLED)) { @@ -784,10 +790,23 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) mouse->u.data.x = scp->mouse_xpos; mouse->u.data.y = scp->mouse_ypos; mouse->u.data.buttons = scp->mouse_buttons; - return 0; + break; case MOUSE_ACTION: - /* this should maybe only be settable from /dev/console SOS */ + /* this should maybe only be settable from /dev/mouse SOS */ + /* send out mouse event on /dev/mouse */ + if ((MOUSE_TTY)->t_state & TS_ISOPEN) { + u_char buf[5]; + int i; + + buf[0] = 0x80 | ((~mouse->u.data.buttons) & 0x07); + buf[1] = (mouse->u.data.x & 0x1fe >> 1); + buf[3] = (mouse->u.data.x & 0x1ff) - buf[1]; + buf[2] = -(mouse->u.data.y & 0x1fe >> 1); + buf[4] = -(mouse->u.data.y & 0x1ff) - buf[2]; + for (i=0; i<5; i++) + (*linesw[(MOUSE_TTY)->t_line].l_rint)(buf[i],MOUSE_TTY); + } cur_console->mouse_xpos += mouse->u.data.x; cur_console->mouse_ypos += mouse->u.data.y; if (cur_console->mouse_signal) { @@ -1301,9 +1320,8 @@ scstart(struct tty *tp) u_char buf[PCBURST]; scr_stat *scp = get_scr_stat(tp->t_dev); - /* XXX who repeats the call when the above flags are cleared? */ if (scp->status & SLKED || blink_in_progress) - return; + return; /* XXX who repeats the call when the above flags are cleared? */ s = spltty(); if (!(tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))) { tp->t_state |= TS_BUSY; @@ -1335,7 +1353,7 @@ sccnprobe(struct consdev *cp) } /* initialize required fields */ - cp->cn_dev = makedev(CDEV_MAJOR, MAXCONS); + cp->cn_dev = makedev(CDEV_MAJOR, SC_CONSOLE); cp->cn_pri = CN_INTERNAL; } |