1 /************************************************************
2 Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
6 Permission to use, copy, modify, and distribute this
7 software and its documentation for any purpose and without
8 fee is hereby granted, provided that the above copyright no-
9 tice appear in all copies and that both that copyright no-
10 tice and this permission notice appear in supporting docu-
11 mentation, and that the names of Sun or The Open Group
12 not be used in advertising or publicity pertaining to
13 distribution of the software without specific prior
14 written permission. Sun and The Open Group make no
15 representations about the suitability of this software for
16 any purpose. It is provided "as is" without any express or
19 SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
20 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
21 NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
22 ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
23 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
24 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
26 THE USE OR PERFORMANCE OF THIS SOFTWARE.
28 ********************************************************/
31 static char sccsid[] = "@(#)kbd_mode.c 7.1 87/04/13";
35 * Copyright 1986 by Sun Microsystems, Inc.
37 * kbd_mode: set keyboard encoding mode
40 #include <sys/types.h>
42 #include <sys/ioctl.h>
43 #if defined(SVR4) || defined(__SVR4) || defined(__bsdi__)
50 #include </sys/sparc/dev/kbio.h>
51 #include </sys/sparc/dev/kbd.h>
55 #include <sundev/kbio.h>
56 #include <sundev/kbd.h>
58 #include <machine/kbio.h>
59 #include <machine/kbd.h>
66 static void die(char*);
67 static void usage(void);
75 int code
= 0, translate
, direct
= -1;
79 if ((kbd_fd
= open("/dev/kbd", O_RDONLY
, 0)) < 0) {
80 die("Couldn't open /dev/kbd");
83 if (argc
-- && **argv
== '-') {
104 translate
= TR_UNTRANS_EVENT
;
111 if (ioctl(kbd_fd
, KIOCSLED
, &led
))
112 die("Couldn't set LEDs");
115 click
= KBD_CMD_NOCLICK
;
116 if (ioctl(kbd_fd
, KIOCCMD
, &click
))
117 die("Couldn't set click");
119 if (ioctl(kbd_fd
, KIOCTRANS
, (caddr_t
) &translate
))
120 die("Couldn't set translation");
121 if (direct
!= -1 && ioctl(kbd_fd
, KIOCSDIRECT
, (caddr_t
) &direct
))
122 die("Couldn't set redirect");
129 fprintf(stderr
, "%s\n", msg
);
138 if (ioctl(kbd_fd
, KIOCGTRANS
, (caddr_t
) &translate
)) {
139 die("Couldn't inquire current translation");
141 fprintf(stderr
, "kbd_mode {-a | -e | -n | -u }\n");
142 fprintf(stderr
, "\tfor ascii, encoded (normal) SunView events,\n");
143 fprintf(stderr
, " \tnon-encoded, or unencoded SunView events, resp.\n");
144 fprintf(stderr
, "Current mode is %s.\n",
145 ( translate
== 0 ? "n (non-translated bytes)" :
146 ( translate
== 1 ? "a (ascii bytes)" :
147 ( translate
== 2 ? "e (encoded events)" :
148 /* translate == 3 */ "u (unencoded events)"))));