95d65cf6bb
xc/config/cf/Imake.rules Correct comment to match rule name for InstallDriverSDKObjectModule xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c Log results of ioctls to probe keyboard type & layout
132 lines
3.8 KiB
C
132 lines
3.8 KiB
C
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c,v 1.1 2001/05/28 02:42:31 tsi Exp $ */
|
|
/*
|
|
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
|
|
* Copyright 1993 by David Dawes <dawes@XFree86.org>
|
|
* Copyright 1999 by David Holland <davidh@iquest.net)
|
|
*
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
* the above copyright notice appear in all copies and that both that copyright
|
|
* notice and this permission notice appear in supporting documentation, and
|
|
* that the names of Thomas Roell, David Dawes, and David Holland not be used
|
|
* in advertising or publicity pertaining to distribution of the software
|
|
* without specific, written prior permission. Thomas Roell, David Dawes, and
|
|
* David Holland make no representations about the suitability of this software
|
|
* for any purpose. It is provided "as is" without express or implied
|
|
* warranty.
|
|
*
|
|
* THOMAS ROELL, DAVID DAWES, AND DAVID HOLLAND DISCLAIM ALL WARRANTIES WITH
|
|
* REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
* AND FITNESS. IN NO EVENT SHALL THOMAS ROELL, DAVID DAWES, OR DAVID HOLLAND
|
|
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
/* $XdotOrg:$ */
|
|
|
|
#include "xf86.h"
|
|
#include "xf86Priv.h"
|
|
#include "xf86_OSlib.h"
|
|
|
|
static int sun_otranslation = -1;
|
|
static int sun_odirect = -1;
|
|
int sun_ktype;
|
|
|
|
int
|
|
xf86GetKbdLeds()
|
|
{
|
|
int leds;
|
|
|
|
ioctl(xf86Info.kbdFd, KIOCGLED, &leds);
|
|
return leds;
|
|
}
|
|
|
|
void
|
|
xf86SetKbdRepeat(char rad)
|
|
{
|
|
/* Nothing to do */
|
|
}
|
|
|
|
/*
|
|
* Save initial keyboard state. This is called at the start of each server
|
|
* generation.
|
|
*/
|
|
|
|
void
|
|
xf86KbdInit()
|
|
{
|
|
int klayout;
|
|
const char *ktype_name;
|
|
|
|
if (xf86Info.kbdFd < 0) {
|
|
xf86Info.kbdFd = open("/dev/kbd", O_RDWR|O_NONBLOCK);
|
|
if(xf86Info.kbdFd < 0)
|
|
FatalError("Unable to open keyboard: /dev/kbd\n");
|
|
}
|
|
|
|
/*
|
|
* None of the following should ever fail. If it does, something is
|
|
* broken (IMO) - DWH 8/21/99
|
|
*/
|
|
|
|
if (ioctl(xf86Info.kbdFd, KIOCTYPE, &sun_ktype) < 0)
|
|
FatalError("Unable to determine keyboard type: %d\n", errno);
|
|
|
|
if (ioctl(xf86Info.kbdFd, KIOCLAYOUT, &klayout) < 0)
|
|
FatalError("Unable to determine keyboard layout: %d\n", errno);
|
|
|
|
if (ioctl(xf86Info.kbdFd, KIOCGTRANS, &sun_otranslation) < 0)
|
|
FatalError("Unable to determine keyboard translation mode\n");
|
|
|
|
if (ioctl(xf86Info.kbdFd, KIOCGDIRECT, &sun_odirect) < 0)
|
|
FatalError("Unable to determine keyboard direct setting\n");
|
|
|
|
switch (sun_ktype) {
|
|
case KB_SUN3:
|
|
ktype_name = "Sun Type 3"; break;
|
|
case KB_SUN4:
|
|
ktype_name = "Sun Type 4/5/6"; break;
|
|
case KB_USB:
|
|
ktype_name = "USB"; break;
|
|
case KB_PC:
|
|
ktype_name = "PC"; break;
|
|
default:
|
|
ktype_name = "Unknown"; break;
|
|
}
|
|
xf86Msg(X_PROBED, "Keyboard type: %s (%d)\n", ktype_name, sun_ktype);
|
|
xf86Msg(X_PROBED, "Keyboard layout: %d\n", klayout);
|
|
}
|
|
|
|
int
|
|
xf86KbdOn(void)
|
|
{
|
|
int tmp = 1;
|
|
|
|
if (ioctl(xf86Info.kbdFd, KIOCSDIRECT, &tmp) == -1)
|
|
FatalError("Setting keyboard direct mode on\n");
|
|
|
|
/* Setup translation */
|
|
|
|
tmp = TR_UNTRANS_EVENT;
|
|
|
|
if (ioctl(xf86Info.kbdFd, KIOCTRANS, &tmp) == -1)
|
|
FatalError("Setting keyboard translation\n");
|
|
|
|
return xf86Info.kbdFd;
|
|
}
|
|
|
|
int
|
|
xf86KbdOff()
|
|
{
|
|
if ((sun_otranslation != -1) &&
|
|
(ioctl(xf86Info.kbdFd, KIOCTRANS, &sun_otranslation) < 0))
|
|
FatalError("Unable to restore keyboard translation mode\n");
|
|
|
|
if ((sun_odirect != 0) &&
|
|
(ioctl(xf86Info.kbdFd, KIOCSDIRECT, &sun_odirect) < 0 ))
|
|
FatalError("Unable to restore keyboard direct setting\n");
|
|
|
|
return xf86Info.kbdFd;
|
|
}
|