1 /* $XConsortium: kbd_mode.c,v 4.6 94/04/17 20:29:33 kaleb Exp $ */
2 /* Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * kbd_mode: set keyboard encoding mode
28 #include <sys/types.h>
37 static void die(const char *);
38 static void usage(void);
42 main(int argc
, char** argv
)
44 int code
= 0, translate
, direct
= -1;
48 if ((kbd_fd
= open("/dev/kbd", O_RDONLY
, 0)) < 0) {
49 die("Couldn't open /dev/kbd");
52 if (argc
-- && **argv
== '-') {
73 translate
= TR_UNTRANS_EVENT
;
80 if (ioctl(kbd_fd
, KIOCSLED
, &led
))
81 die("Couldn't set LEDs");
84 click
= KBD_CMD_NOCLICK
;
85 if (ioctl(kbd_fd
, KIOCCMD
, &click
))
86 die("Couldn't set click");
88 if (ioctl(kbd_fd
, KIOCTRANS
, (caddr_t
) &translate
))
89 die("Couldn't set translation");
90 if (direct
!= -1 && ioctl(kbd_fd
, KIOCSDIRECT
, (caddr_t
) &direct
))
91 die("Couldn't set redirect");
98 fprintf(stderr
, "%s\n", msg
);
107 if (ioctl(kbd_fd
, KIOCGTRANS
, (caddr_t
) &translate
)) {
108 die("Couldn't inquire current translation");
110 fprintf(stderr
, "kbd_mode {-a | -e | -n | -u }\n");
111 fprintf(stderr
, "\tfor ascii, encoded (normal) SunView events,\n");
112 fprintf(stderr
, " \tnon-encoded, or unencoded SunView events, resp.\n");
113 fprintf(stderr
, "Current mode is %s.\n",
114 ( translate
== 0 ? "n (non-translated bytes)" :
115 ( translate
== 1 ? "a (ascii bytes)" :
116 ( translate
== 2 ? "e (encoded events)" :
117 /* translate == 3 */ "u (unencoded events)"))));