Make the mouse cursor char code configurable via the CONS_MOUSECTL
ioctl. By popular demand.
This commit is contained in:
parent
cceb490e8b
commit
39ecc2b7cd
@ -46,10 +46,6 @@
|
||||
|
||||
#include <isa/isareg.h>
|
||||
|
||||
#ifndef SC_MOUSE_CHAR
|
||||
#define SC_MOUSE_CHAR (0xd0)
|
||||
#endif
|
||||
|
||||
#ifndef SC_RENDER_DEBUG
|
||||
#define SC_RENDER_DEBUG 0
|
||||
#endif
|
||||
@ -286,6 +282,7 @@ draw_txtmouse(scr_stat *scp, int x, int y)
|
||||
#ifndef SC_ALT_MOUSE_IMAGE
|
||||
u_char font_buf[128];
|
||||
u_short cursor[32];
|
||||
u_char c;
|
||||
int pos;
|
||||
int xoffset, yoffset;
|
||||
int crtc_addr;
|
||||
@ -328,17 +325,18 @@ draw_txtmouse(scr_stat *scp, int x, int y)
|
||||
crtc_addr = scp->sc->adp->va_crtc_addr;
|
||||
while (!(inb(crtc_addr + 6) & 0x08)) /* idle */ ;
|
||||
#endif
|
||||
c = scp->sc->mouse_char;
|
||||
(*vidsw[scp->sc->adapter]->load_font)(scp->sc->adp, 0, 32, font_buf,
|
||||
SC_MOUSE_CHAR, 4);
|
||||
c, 4);
|
||||
|
||||
sc_vtb_putc(&scp->scr, pos, SC_MOUSE_CHAR, sc_vtb_geta(&scp->scr, pos));
|
||||
sc_vtb_putc(&scp->scr, pos, c, sc_vtb_geta(&scp->scr, pos));
|
||||
/* FIXME: may be out of range! */
|
||||
sc_vtb_putc(&scp->scr, pos + scp->xsize, SC_MOUSE_CHAR + 2,
|
||||
sc_vtb_putc(&scp->scr, pos + scp->xsize, c + 2,
|
||||
sc_vtb_geta(&scp->scr, pos + scp->xsize));
|
||||
if (x < (scp->xsize - 1)*8) {
|
||||
sc_vtb_putc(&scp->scr, pos + 1, SC_MOUSE_CHAR + 1,
|
||||
sc_vtb_putc(&scp->scr, pos + 1, c + 1,
|
||||
sc_vtb_geta(&scp->scr, pos + 1));
|
||||
sc_vtb_putc(&scp->scr, pos + scp->xsize + 1, SC_MOUSE_CHAR + 3,
|
||||
sc_vtb_putc(&scp->scr, pos + scp->xsize + 1, c + 3,
|
||||
sc_vtb_geta(&scp->scr, pos + scp->xsize + 1));
|
||||
}
|
||||
#else /* SC_ALT_MOUSE_IMAGE */
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#if NSC > 0
|
||||
|
||||
#include <limits.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
@ -954,6 +955,23 @@ sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
|
||||
#endif /* SC_NO_CUTPASTE */
|
||||
break;
|
||||
|
||||
case MOUSE_MOUSECHAR:
|
||||
if (mouse->u.mouse_char < 0) {
|
||||
mouse->u.mouse_char = scp->sc->mouse_char;
|
||||
} else {
|
||||
if (mouse->u.mouse_char >= UCHAR_MAX - 4)
|
||||
return EINVAL;
|
||||
s = spltty();
|
||||
sc_remove_all_mouse(scp->sc);
|
||||
#ifndef SC_NO_FONT_LOADING
|
||||
if (ISTEXTSC(cur_scp) && (cur_scp->font_size != FONT_NONE))
|
||||
copy_font(cur_scp, LOAD, cur_scp->font_size, cur_scp->font);
|
||||
#endif
|
||||
scp->sc->mouse_char = mouse->u.mouse_char;
|
||||
splx(s);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
@ -46,10 +46,6 @@
|
||||
|
||||
#include <isa/isareg.h>
|
||||
|
||||
#ifndef SC_MOUSE_CHAR
|
||||
#define SC_MOUSE_CHAR (0xd0)
|
||||
#endif
|
||||
|
||||
#ifndef SC_RENDER_DEBUG
|
||||
#define SC_RENDER_DEBUG 0
|
||||
#endif
|
||||
@ -286,6 +282,7 @@ draw_txtmouse(scr_stat *scp, int x, int y)
|
||||
#ifndef SC_ALT_MOUSE_IMAGE
|
||||
u_char font_buf[128];
|
||||
u_short cursor[32];
|
||||
u_char c;
|
||||
int pos;
|
||||
int xoffset, yoffset;
|
||||
int crtc_addr;
|
||||
@ -328,17 +325,18 @@ draw_txtmouse(scr_stat *scp, int x, int y)
|
||||
crtc_addr = scp->sc->adp->va_crtc_addr;
|
||||
while (!(inb(crtc_addr + 6) & 0x08)) /* idle */ ;
|
||||
#endif
|
||||
c = scp->sc->mouse_char;
|
||||
(*vidsw[scp->sc->adapter]->load_font)(scp->sc->adp, 0, 32, font_buf,
|
||||
SC_MOUSE_CHAR, 4);
|
||||
c, 4);
|
||||
|
||||
sc_vtb_putc(&scp->scr, pos, SC_MOUSE_CHAR, sc_vtb_geta(&scp->scr, pos));
|
||||
sc_vtb_putc(&scp->scr, pos, c, sc_vtb_geta(&scp->scr, pos));
|
||||
/* FIXME: may be out of range! */
|
||||
sc_vtb_putc(&scp->scr, pos + scp->xsize, SC_MOUSE_CHAR + 2,
|
||||
sc_vtb_putc(&scp->scr, pos + scp->xsize, c + 2,
|
||||
sc_vtb_geta(&scp->scr, pos + scp->xsize));
|
||||
if (x < (scp->xsize - 1)*8) {
|
||||
sc_vtb_putc(&scp->scr, pos + 1, SC_MOUSE_CHAR + 1,
|
||||
sc_vtb_putc(&scp->scr, pos + 1, c + 1,
|
||||
sc_vtb_geta(&scp->scr, pos + 1));
|
||||
sc_vtb_putc(&scp->scr, pos + scp->xsize + 1, SC_MOUSE_CHAR + 3,
|
||||
sc_vtb_putc(&scp->scr, pos + scp->xsize + 1, c + 3,
|
||||
sc_vtb_geta(&scp->scr, pos + scp->xsize + 1));
|
||||
}
|
||||
#else /* SC_ALT_MOUSE_IMAGE */
|
||||
|
@ -56,6 +56,10 @@
|
||||
#undef SC_PIXEL_MODE
|
||||
#endif
|
||||
|
||||
#ifndef SC_MOUSE_CHAR
|
||||
#define SC_MOUSE_CHAR (0xd0)
|
||||
#endif
|
||||
|
||||
#ifndef SC_DEBUG_LEVEL
|
||||
#define SC_DEBUG_LEVEL 0
|
||||
#endif
|
||||
@ -237,6 +241,8 @@ typedef struct sc_softc {
|
||||
u_char *font_16;
|
||||
#endif
|
||||
|
||||
u_char mouse_char;
|
||||
|
||||
} sc_softc_t;
|
||||
|
||||
/* virtual screen */
|
||||
|
@ -82,7 +82,7 @@ static driver_t sc_driver = {
|
||||
sizeof(sc_softc_t),
|
||||
};
|
||||
|
||||
static sc_softc_t main_softc = { 0, 0, 0, -1, NULL, -1, NULL, };
|
||||
static sc_softc_t main_softc;
|
||||
|
||||
static int
|
||||
scprobe(device_t dev)
|
||||
@ -122,17 +122,17 @@ sc_softc_t
|
||||
return NULL;
|
||||
if (flags & SC_KERNEL_CONSOLE) {
|
||||
/* FIXME: clear if it is wired to another unit! */
|
||||
main_softc.unit = unit;
|
||||
return &main_softc;
|
||||
sc = &main_softc;
|
||||
} else {
|
||||
sc = (sc_softc_t *)device_get_softc(devclass_get_device(sc_devclass, unit));
|
||||
if (!(sc->flags & SC_INIT_DONE)) {
|
||||
sc->unit = unit;
|
||||
sc->keyboard = -1;
|
||||
sc->adapter = -1;
|
||||
}
|
||||
return sc;
|
||||
}
|
||||
sc->unit = unit;
|
||||
if (!(sc->flags & SC_INIT_DONE)) {
|
||||
sc->keyboard = -1;
|
||||
sc->adapter = -1;
|
||||
sc->mouse_char = SC_MOUSE_CHAR;
|
||||
}
|
||||
return sc;
|
||||
}
|
||||
|
||||
sc_softc_t
|
||||
|
@ -148,10 +148,12 @@ struct mouse_info {
|
||||
#define MOUSE_ACTION 0x07
|
||||
#define MOUSE_MOTION_EVENT 0x08
|
||||
#define MOUSE_BUTTON_EVENT 0x09
|
||||
#define MOUSE_MOUSECHAR 0x0a
|
||||
union {
|
||||
mouse_data_t data;
|
||||
mouse_mode_t mode;
|
||||
mouse_event_t event;
|
||||
int mouse_char;
|
||||
} u;
|
||||
};
|
||||
typedef struct mouse_info mouse_info_t;
|
||||
|
@ -33,6 +33,7 @@ static const char rcsid[] =
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -57,10 +58,11 @@ struct vid_info info;
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "%s\n%s\n%s\n",
|
||||
fprintf(stderr, "%s\n%s\n%s\n%s\n",
|
||||
"usage: vidcontrol [-r fg bg] [-b color] [-c appearance] [-d] [-l scrmap]",
|
||||
" [-i adapter | mode] [-L] [-m on|off] [-f size file]",
|
||||
" [-s number] [-t N|off] [-x] [mode] [fgcol [bgcol]] [show]");
|
||||
" [-i adapter | mode] [-L] [-M char] [-m on|off]",
|
||||
" [-f size file] [-s number] [-t N|off] [-x] [mode]",
|
||||
" [fgcol [bgcol]] [show]");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -405,6 +407,22 @@ set_border_color(char *arg)
|
||||
usage();
|
||||
}
|
||||
|
||||
void
|
||||
set_mouse_char(char *arg)
|
||||
{
|
||||
struct mouse_info mouse;
|
||||
long l;
|
||||
|
||||
l = strtol(arg, NULL, 0);
|
||||
if ((l < 0) || (l > UCHAR_MAX)) {
|
||||
warnx("argument to -M must be 0 through %d", UCHAR_MAX);
|
||||
return;
|
||||
}
|
||||
mouse.operation = MOUSE_MOUSECHAR;
|
||||
mouse.u.mouse_char = (int)l;
|
||||
ioctl(0, CONS_MOUSECTL, &mouse);
|
||||
}
|
||||
|
||||
void
|
||||
set_mouse(char *arg)
|
||||
{
|
||||
@ -555,7 +573,7 @@ main(int argc, char **argv)
|
||||
info.size = sizeof(info);
|
||||
if (ioctl(0, CONS_GETINFO, &info) < 0)
|
||||
err(1, "must be on a virtual console");
|
||||
while((opt = getopt(argc, argv, "b:c:df:i:l:Lm:r:s:t:x")) != -1)
|
||||
while((opt = getopt(argc, argv, "b:c:df:i:l:LM:m:r:s:t:x")) != -1)
|
||||
switch(opt) {
|
||||
case 'b':
|
||||
set_border_color(optarg);
|
||||
@ -579,6 +597,9 @@ main(int argc, char **argv)
|
||||
case 'L':
|
||||
load_default_scrnmap();
|
||||
break;
|
||||
case 'M':
|
||||
set_mouse_char(optarg);
|
||||
break;
|
||||
case 'm':
|
||||
set_mouse(optarg);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user