1
/* $Xorg: kbd_mode.c,v 1.3 2000/08/17 19:48:29 cpqbld Exp $ */
2
/* $XdotOrg: xserver/xorg/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c,v 1.3 2005/09/28 01:57:47 alanc Exp $ */
3
/************************************************************
4
Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
8
Permission to use, copy, modify, and distribute this
9
software and its documentation for any purpose and without
10
fee is hereby granted, provided that the above copyright no-
11
tice appear in all copies and that both that copyright no-
12
tice and this permission notice appear in supporting docu-
13
mentation, and that the names of Sun or The Open Group
14
not be used in advertising or publicity pertaining to
15
distribution of the software without specific prior
16
written permission. Sun and The Open Group make no
17
representations about the suitability of this software for
18
any purpose. It is provided "as is" without any express or
21
SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
22
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
23
NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
24
ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
25
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
26
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
28
THE USE OR PERFORMANCE OF THIS SOFTWARE.
30
********************************************************/
31
/* $XFree86: kbd_mode.c,v 3.11 2002/10/23 16:23:36 tsi Exp $ */
34
static char sccsid[] = "@(#)kbd_mode.c 7.1 87/04/13";
38
* Copyright 1986 by Sun Microsystems, Inc.
40
* kbd_mode: set keyboard encoding mode
43
#include <sys/types.h>
45
#include <sys/ioctl.h>
46
#if defined(SVR4) || defined(__SVR4) || defined(__bsdi__)
53
#include </sys/sparc/dev/kbio.h>
54
#include </sys/sparc/dev/kbd.h>
58
#include <sundev/kbio.h>
59
#include <sundev/kbd.h>
61
#include <machine/kbio.h>
62
#include <machine/kbd.h>
69
static void die(char*);
70
static void usage(void);
78
int code = 0, translate, direct = -1;
82
if ((kbd_fd = open("/dev/kbd", O_RDONLY, 0)) < 0) {
83
die("Couldn't open /dev/kbd");
86
if (argc-- && **argv == '-') {
107
translate = TR_UNTRANS_EVENT;
114
if (ioctl(kbd_fd, KIOCSLED, &led))
115
die("Couldn't set LEDs");
118
click = KBD_CMD_NOCLICK;
119
if (ioctl(kbd_fd, KIOCCMD, &click))
120
die("Couldn't set click");
122
if (ioctl(kbd_fd, KIOCTRANS, (caddr_t) &translate))
123
die("Couldn't set translation");
124
if (direct != -1 && ioctl(kbd_fd, KIOCSDIRECT, (caddr_t) &direct))
125
die("Couldn't set redirect");
132
fprintf(stderr, "%s\n", msg);
141
if (ioctl(kbd_fd, KIOCGTRANS, (caddr_t) &translate)) {
142
die("Couldn't inquire current translation");
144
fprintf(stderr, "kbd_mode {-a | -e | -n | -u }\n");
145
fprintf(stderr, "\tfor ascii, encoded (normal) SunView events,\n");
146
fprintf(stderr, " \tnon-encoded, or unencoded SunView events, resp.\n");
147
fprintf(stderr, "Current mode is %s.\n",
148
( translate == 0 ? "n (non-translated bytes)" :
149
( translate == 1 ? "a (ascii bytes)" :
150
( translate == 2 ? "e (encoded events)" :
151
/* translate == 3 */ "u (unencoded events)"))));