/* $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 * Copyright 1999 by David Holland #endif #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; }