Date: Wed, 19 Jan 2000 19:50:02 -0800 (PST) From: Kelly Yancey <kbyanc@posi.net> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/15996: patch adds hw.syscons.sc_mouse_char sysctl variable Message-ID: <200001200350.TAA70737@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/15996; it has been noted by GNATS.
From: Kelly Yancey <kbyanc@posi.net>
To: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/15996: patch adds hw.syscons.sc_mouse_char sysctl variable
Date: Wed, 19 Jan 2000 22:38:12 -0500 (EST)
> In principle, any change should go into -CURRENT first, then will be
> merged to -STABLE. Although the patch for -STABLE will be much
> different from the patch for -CURRENT in our case, I believe this
> principle will still stand.
>
> We shall first commit the change to -CURRENT and test its concept
> for a while there, then apply the change to -STABLE.
>
> Kazu
>
Here is a patch against -stable as of Jan 19, 2000 which MFC's the
functionality using ioctl rather than sysctl. I also imported the changes
to vidcontrol to facilitate setting the mouse character. I have been using
this on a couple of -stable boxen without incident for several days now.
Kelly
--- sys/i386/include/console.h.orig Wed Jan 19 20:59:14 2000
+++ sys/i386/include/console.h Wed Jan 19 21:07:22 2000
@@ -161,6 +161,7 @@
#define MOUSE_ACTION 0x07
#define MOUSE_MOTION_EVENT 0x08
#define MOUSE_BUTTON_EVENT 0x09
+#define MOUSE_MOUSECHAR 0x0a
struct mouse_info {
int operation;
@@ -168,6 +169,7 @@
struct mouse_data data;
struct mouse_mode mode;
struct mouse_event event;
+ int mouse_char;
}u;
};
--- sys/alpha/include/console.h.orig Wed Jan 19 21:02:10 2000
+++ sys/alpha/include/console.h Wed Jan 19 21:08:27 2000
@@ -162,6 +162,7 @@
#define MOUSE_ACTION 0x07
#define MOUSE_MOTION_EVENT 0x08
#define MOUSE_BUTTON_EVENT 0x09
+#define MOUSE_MOUSECHAR 0x0a
struct mouse_info {
int operation;
@@ -169,6 +170,7 @@
struct mouse_data data;
struct mouse_mode mode;
struct mouse_event event;
+ int mouse_char;
}u;
};
--- usr.sbin/vidcontrol/vidcontrol.c.orig Wed Jan 19 21:46:52 2000
+++ usr.sbin/vidcontrol/vidcontrol.c Wed Jan 19 21:52:24 2000
@@ -33,6 +33,7 @@
#include <ctype.h>
#include <err.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -57,10 +58,11 @@
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);
}
@@ -390,6 +392,22 @@
}
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)
{
struct mouse_info mouse;
@@ -529,7 +547,7 @@
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);
@@ -552,6 +570,9 @@
break;
case 'L':
load_default_scrnmap();
+ break;
+ case 'M':
+ set_mouse_char(optarg);
break;
case 'm':
set_mouse(optarg);
--- sys/dev/syscons/syscons.c.orig Wed Jan 19 20:52:32 2000
+++ sys/dev/syscons/syscons.c Wed Jan 19 22:27:33 2000
@@ -41,6 +41,8 @@
#endif
#include "opt_syscons.h"
+#include <limits.h>
+
#if NSC > 0
#include <sys/param.h>
#include <sys/systm.h>
@@ -239,6 +241,7 @@
#define SC_CONSOLE 255
vm_offset_t Crtat;
static const int nsccons = MAXCONS+2;
+static int sc_mouse_char = SC_MOUSE_CHAR;
#define WRAPHIST(scp, pointer, offset)\
((scp)->history + ((((pointer) - (scp)->history) + (scp)->history_size \
@@ -1280,6 +1283,54 @@
}
break;
+ case MOUSE_MOUSECHAR:
+ if (mouse->u.mouse_char < 0) {
+ mouse->u.mouse_char = sc_mouse_char;
+ } else {
+ char *font = NULL;
+
+ if (mouse->u.mouse_char >= UCHAR_MAX - 4)
+ return EINVAL;
+
+ /*
+ * The base character for drawing the mouse pointer has changed.
+ * Clear the pointer, restore the original font definitions,
+ * and the redraw the pointer - mangling the new characters.
+ */
+ s = spltty();
+ remove_mouse_image(cur_console);
+
+ if (ISTEXTSC(cur_console) &&
+ (cur_console->font_size != FONT_NONE)) {
+ if (scp->font_size < 14) {
+ if (fonts_loaded & FONT_8)
+ font = font_8;
+ }
+ else if (scp->font_size >= 16) {
+ if (fonts_loaded & FONT_16)
+ font = font_16;
+ }
+ else {
+ if (fonts_loaded & FONT_14)
+ font = font_8;
+ }
+
+ if (font != NULL) {
+ font_loading_in_progress = TRUE;
+ (*vidsw[scp->ad]->load_font)(scp->adp, 0,
+ cur_console->font_size,
+ font + (sc_mouse_char * cur_console->font_size),
+ sc_mouse_char, 4);
+ font_loading_in_progress = FALSE;
+ (*vidsw[scp->ad]->show_font)(scp->adp, 0);
+ }
+ }
+
+ sc_mouse_char = mouse->u.mouse_char;
+ splx(s);
+ }
+ break;
+
default:
return EINVAL;
}
@@ -4217,13 +4268,13 @@
}
if (scp->status & MOUSE_VISIBLE) {
- if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR)
+ if ((scp->cursor_saveunder & 0xff) == sc_mouse_char)
bcopy(&scp->mouse_cursor[0], cursor, scp->font_size);
- else if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR + 1)
+ else if ((scp->cursor_saveunder & 0xff) == sc_mouse_char + 1)
bcopy(&scp->mouse_cursor[32], cursor, scp->font_size);
- else if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR + 2)
+ else if ((scp->cursor_saveunder & 0xff) == sc_mouse_char + 2)
bcopy(&scp->mouse_cursor[64], cursor, scp->font_size);
- else if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR + 3)
+ else if ((scp->cursor_saveunder & 0xff) == sc_mouse_char + 3)
bcopy(&scp->mouse_cursor[96], cursor, scp->font_size);
else
bcopy(font_buffer+((scp->cursor_saveunder & 0xff)*scp->font_size),
@@ -4551,16 +4602,16 @@
#endif
font_loading_in_progress = TRUE;
(*vidsw[scp->ad]->load_font)(scp->adp, 0, 32, scp->mouse_cursor,
- SC_MOUSE_CHAR, 4);
+ sc_mouse_char, 4);
font_loading_in_progress = FALSE;
- writew(crt_pos, (*(scp->mouse_pos) & 0xff00) | SC_MOUSE_CHAR);
+ writew(crt_pos, (*(scp->mouse_pos) & 0xff00) | sc_mouse_char);
writew(crt_pos+2*scp->xsize,
- (*(scp->mouse_pos + scp->xsize) & 0xff00) | (SC_MOUSE_CHAR + 2));
+ (*(scp->mouse_pos + scp->xsize) & 0xff00) | (sc_mouse_char + 2));
if (scp->mouse_xpos < (scp->xsize-1)*8) {
- writew(crt_pos + 2, (*(scp->mouse_pos + 1) & 0xff00) | (SC_MOUSE_CHAR + 1));
+ writew(crt_pos + 2, (*(scp->mouse_pos + 1) & 0xff00) | (sc_mouse_char + 1));
writew(crt_pos+2*scp->xsize + 2,
- (*(scp->mouse_pos + scp->xsize + 1) & 0xff00) | (SC_MOUSE_CHAR + 3));
+ (*(scp->mouse_pos + scp->xsize + 1) & 0xff00) | (sc_mouse_char + 3));
}
mark_for_update(scp, scp->mouse_pos - scp->scr_buf);
mark_for_update(scp, scp->mouse_pos + scp->xsize + 1 - scp->scr_buf);
--
Kelly Yancey - kbyanc@posi.net - Richmond, VA
Analyst / E-business Development, Bell Industries http://www.bellind.com/
Maintainer, BSD Driver Database http://www.posi.net/freebsd/drivers/
Coordinator, Team FreeBSD http://www.posi.net/freebsd/Team-FreeBSD/
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001200350.TAA70737>
