summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pcvt/mcon
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pcvt/mcon')
-rw-r--r--usr.sbin/pcvt/mcon/Makefile19
-rw-r--r--usr.sbin/pcvt/mcon/mcon.1166
-rw-r--r--usr.sbin/pcvt/mcon/mcon.c192
3 files changed, 377 insertions, 0 deletions
diff --git a/usr.sbin/pcvt/mcon/Makefile b/usr.sbin/pcvt/mcon/Makefile
new file mode 100644
index 0000000..156e431
--- /dev/null
+++ b/usr.sbin/pcvt/mcon/Makefile
@@ -0,0 +1,19 @@
+
+.if !exists(${.CURDIR}/../Makefile.inc)
+error:
+ @echo
+ @echo " You MUST link/copy"
+ @echo
+ @echo " ../Makefile.inc.NetBSD or ../Makefile.inc.FreeBSD"
+ @echo
+ @echo " to ../Makefile.inc before you can proceed !"
+ @echo
+.else
+
+PROG= mcon
+
+.include <bsd.prog.mk>
+
+$(PROG): $(INCDIR)/pcvt_ioctl.h
+
+.endif
diff --git a/usr.sbin/pcvt/mcon/mcon.1 b/usr.sbin/pcvt/mcon/mcon.1
new file mode 100644
index 0000000..e59e64d
--- /dev/null
+++ b/usr.sbin/pcvt/mcon/mcon.1
@@ -0,0 +1,166 @@
+.\" Copyright (c) 1994 Joerg Wunsch
+.\"
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Joerg Wunsch
+.\" 4. The name authors may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" @(#)mcon.1, 3.00, Last Edit-Date: [Mon Jan 10 21:28:22 1994]
+.\"
+.Dd January 3, 1994
+.Dt MCON 1
+.Sh NAME
+.Nm mcon
+.Nd controls pcvt mouse emulator
+.Sh SYNOPSIS
+.Nm mcon
+.Op Fl l Ar left-button-key
+.Op Fl m Ar mid-button-key
+.Op Fl r Ar right-button-key
+.Op Fl a Ar accel-time
+.Op Fl s Ar 0 | false | \&no
+.Op Fl s Ar 1 | true | yes
+.Ar device
+.Sh DESCRIPTION
+The
+.Nm mcon
+utility controls the configurable parameters for the mouse emulator of
+.Xr pcvt 4 .
+.br
+.Em NB :
+The mouse emulator is not configured in by default; the system's config
+file needs to specify an option line
+
+.Em options Dq PCVT_EMU_MOUSE
+
+in order to get its functionality.
+.Pp
+Either way, the
+.Nm
+program must be called with an argument
+.Ar device
+that specifies the device node used for the mouse emulation. This is
+usually the first device node of the
+.Xr pcvt 4
+driver not being used as a virtual terminal device. E.\ g., if you
+have configured eight virtual terminals
+.Pq the default value ,
+named
+.Pa /dev/ttyv0
+through
+.Pa /dev/ttyv7 ,
+the mouse emulator would allocate
+.Pa /dev/ttyv8 .
+
+If
+.Nm
+is called without any option, it will print the actual values of the
+configurable parameters.
+
+If called with an option, the program attempts to set up the new value.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl l Ar left-button-key
+.It Fl m Ar mid-button-key
+.It Fl r Ar right-button-key
+Maps the named
+.Ar button key
+to emulate either the left, middle, or right mouse button.
+.Ar Button key
+is the usual name for that key. Normal ASCII keys are denoted by the
+character they're labeled with, function keys are named
+.Em f1
+through
+.Em f10 .
+Note that the AT function keys
+.Em f11
+and
+.Em f12
+are
+.Em extended
+keys that cannot be mapped to be used with the mouse emulator since
+it only allows basic PC-scancode keys to be used.
+
+.It Fl a Ar accel-time
+Set the time limit for the internal accelerator to
+.Ar accel-time
+milliseconds. Key events occurring after a longer time than this limit
+will move the mouse cursor in single steps. Key events arriving more
+frequently will move the cursor accelerated by a factor of 6. Note that
+despite of
+.Em milliseconds
+being the unit of choice here, the time resolution is restricted by the
+timer tick distance of the underlying operating system, usually to a
+granularity of 10 milliseconds.
+
+.It Fl s Ar 0 | false | \&no
+.It Fl s Ar 1 | true | yes
+The first form disables, the second form enables the
+.Em sticky
+behaviour of the mouse buttons. Sticky mouse keys behave much like
+toggle-buttons: on first press, they become active, on second press,
+they're deactivated. Pressing another button will deactivate any
+other sticky button anyway.
+
+Sticky buttons might be more convenient since you don't need 20 fingers
+at all; on the other hand, they make it virtually impossible to initiate
+double or triple mouse clicks.
+.El
+.Sh EXAMPLES
+The following example would install the default behaviour of the
+mouse emulator:
+
+.Nm mcon
+.Fl l Ar f1
+.Fl m Ar f2
+.Fl r Ar f3
+.Fl a Ar 250
+.Fl s Ar \&no
+.Pa /dev/ttyv8
+.Sh BUGS
+The key names used to map the button-emulating keys to scan codes
+.Pq and vica verse
+are based on the American keyboard layout. This would usually not
+cause any trouble since the
+.Dq button-of-choice
+is certainly some function key that should be equal for any national
+keyboard layout.
+.Pp
+The mouse emulator is a rude hack at all; its only purpose is to provide
+a device to move the pointer within an X-windowing environment.
+.Sh SEE ALSO
+.Xr pcvt 4 ,
+.Xr X 1x .
+.Sh HISTORY
+The
+.Nm
+utility appeared in
+.Xr pcvt 4 ,
+release 3.00.
+.Sh AUTHOR
+The mouse emulator has been contributed by
+.if n Joerg Wunsch.
+.if t J\(:org Wunsch.
diff --git a/usr.sbin/pcvt/mcon/mcon.c b/usr.sbin/pcvt/mcon/mcon.c
new file mode 100644
index 0000000..89989d9
--- /dev/null
+++ b/usr.sbin/pcvt/mcon/mcon.c
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 1994 Joerg Wunsch
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Joerg Wunsch
+ * 4. The name authors may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * @(#)mcon.c, 3.20, Last Edit-Date: [Tue Dec 20 14:53:15 1994]
+ */
+
+/*---------------------------------------------------------------------------*
+ *
+ * history:
+ *
+ * -jw initial version; includes a basic mapping between PeeCee
+ * scan codes and key names
+ * -hm changed sys/pcvt_ioctl.h -> machine/pcvt_ioctl.h
+ *
+ *---------------------------------------------------------------------------*/
+
+/*
+ * Utility program to wire the mouse emulator control ioctl to the
+ * user level. Allows setting of any configurable parameter, or
+ * display the current configuration.
+ */
+
+#include <machine/pcvt_ioctl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/fcntl.h>
+
+static const char *keynames[] = {
+ "", "esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
+ "-", "+", "bksp", "tab", "q", "w", "e", "r", "t", "y", "u",
+ "i", "o", "p", "[", "]", "enter", "ctrl", "a", "s", "d", "f",
+ "g", "h", "j", "k", "l", ";", "\"", "`", "lshift", "\\",
+ "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "rshift",
+ "prtscr", "alt", "space", "caps", "f1", "f2", "f3", "f4",
+ "f5", "f6", "f7", "f8", "f9", "f10", "numlock", "scrolllock",
+ "kp7", "kp8", "kp9", "kp-", "kp4", "kp5", "kp6", "kp+",
+ "kp1", "kp2", "kp3", "kp0", "kp."
+};
+
+
+const char *scantoname(int scan) {
+ if(scan >= sizeof keynames / sizeof(const char *))
+ return "???";
+ else
+ return keynames[scan];
+}
+
+int nametoscan(const char *name) {
+ int i;
+ for(i = 0; i < sizeof keynames / sizeof(const char *); i++)
+ if(strcmp(keynames[i], name) == 0)
+ return i;
+ return -1;
+}
+
+
+int main(int argc, char **argv) {
+ int c, errs = 0, fd, do_set = 0;
+ int left = 0, mid = 0, right = 0, accel = 0, sticky = -1;
+ struct mousedefs mdef;
+
+ while((c = getopt(argc, argv, "l:m:r:a:s:")) != EOF)
+ switch(c) {
+ case 'l':
+ left = nametoscan(optarg);
+ do_set = 1;
+ if(left == -1) goto keynameerr;
+ break;
+
+ case 'm':
+ mid = nametoscan(optarg);
+ do_set = 1;
+ if(mid == -1) goto keynameerr;
+ break;
+
+ case 'r':
+ right = nametoscan(optarg);
+ do_set = 1;
+ if(right == -1) goto keynameerr;
+ break;
+
+ keynameerr:
+ {
+ fprintf(stderr, "unknown key name: %s\n",
+ optarg);
+ errs++;
+ }
+ break;
+
+ case 'a':
+ accel = 1000 * strtol(optarg, 0, 10);
+ do_set = 1;
+ break;
+
+ case 's':
+ if(strcmp(optarg, "0") == 0
+ || strcmp(optarg, "false") == 0
+ || strcmp(optarg, "no") == 0)
+ sticky = 0;
+ else if(strcmp(optarg, "1") == 0
+ || strcmp(optarg, "true") == 0
+ || strcmp(optarg, "yes") == 0)
+ sticky = 1;
+ else {
+ fprintf(stderr, "invalid argument to -s: %s\n",
+ optarg);
+ errs++;
+ }
+ do_set = 1;
+ break;
+
+ default:
+ errs++;
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ if(errs || argc != 1) {
+ fprintf(stderr, "usage: "
+ "mouse [-l key][-m key][-r key][-a acctime][-s 0|1] "
+ "mousedev\n");
+ return 2;
+ }
+
+ if((fd = open(argv[0], O_RDONLY)) < 0) {
+ perror("open(mousedev)");
+ return 2;
+ }
+ if(ioctl(fd, KBDMOUSEGET, &mdef) < 0) {
+ perror("ioctl(KBDMOUSEGET)");
+ return 1;
+ }
+
+ if(!do_set) {
+ printf("Current mouse emulator definitions:\n"
+ "left button: %s\n"
+ "middle button: %s\n"
+ "right button: %s\n"
+ "acceleration limit: %d msec\n"
+ "sticky buttons: %s\n",
+ scantoname(mdef.leftbutton),
+ scantoname(mdef.middlebutton),
+ scantoname(mdef.rightbutton),
+ mdef.acceltime / 1000,
+ mdef.stickybuttons? "yes": "no");
+ return 0;
+ }
+
+ if(left) mdef.leftbutton = left & 0x7f;
+ if(mid) mdef.middlebutton = mid & 0x7f;
+ if(right) mdef.rightbutton = right & 0x7f;
+
+ if(accel) mdef.acceltime = accel;
+ if(sticky != -1) mdef.stickybuttons = sticky;
+
+ if(ioctl(fd, KBDMOUSESET, &mdef) < 0) {
+ perror("ioctl(KBDMOUSESET)");
+ return 1;
+ }
+
+ return 0;
+}
OpenPOWER on IntegriCloud