#include "dmxinputinit.h"
#include "lnx-keyboard.h"
#include "inputstr.h"
#include <X11/Xos.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <signal.h>
#include <sys/vt.h>
#include <sys/kd.h>
#include <termios.h>
#include "atKeynames.h"
#include <linux/keyboard.h>
#include <xkbsrv.h>
Data Structures | |
struct | _myPrivate |
Defines | |
#define | GETPRIV |
#define | LOG0(f) dmxLog(dmxDebug,f) |
#define | LOG1(f, a) dmxLog(dmxDebug,f,a) |
#define | LOG2(f, a, b) dmxLog(dmxDebug,f,a,b) |
#define | LOG3(f, a, b, c) dmxLog(dmxDebug,f,a,b,c) |
#define | FATAL0(f) dmxLog(dmxFatal,f) |
#define | FATAL1(f, a) dmxLog(dmxFatal,f,a) |
#define | FATAL2(f, a, b) dmxLog(dmxFatal,f,a,b) |
#define | MOTIONPROC dmxMotionProcPtr |
#define | ENQUEUEPROC dmxEnqueueProcPtr |
#define | CHECKPROC dmxCheckSpecialProcPtr |
#define | SWITCHRETPROC dmxVTSwitchReturnProcPtr |
#define | BLOCK DMXBlockType |
#define | MESSAGE "\033c\n\n\nDMX taking input from this console..." |
#define | FINALMESSAGE "\033cDMX terminated." |
#define | NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0])) |
#define | NUM_STATE_ENTRIES (256/32) |
#define | SYSCALL(call) while(((call) == -1) && (errno == EINTR)) |
Typedefs | |
typedef struct _myPrivate | myPrivate |
Functions | |
static int | kbdLinuxKeyDown (myPrivate *priv, int keyCode) |
static void | kbdLinuxKeyState (myPrivate *priv, int type, int keyCode) |
pointer | kbdLinuxCreatePrivate (DeviceIntPtr pKeyboard) |
void | kbdLinuxDestroyPrivate (pointer priv) |
void | kbdLinuxBell (DevicePtr pDev, int percent, int volume, int pitch, int duration) |
void | kbdLinuxCtrl (DevicePtr pDev, KeybdCtrl *ctrl) |
static int | kbdLinuxGetFreeVTNumber (void) |
static int | kbdLinuxOpenVT (int vtno) |
static int | kbdLinuxGetCurrentVTNumber (int fd) |
static int | kbdLinuxActivate (int fd, int vtno, int setSig) |
void | kbdLinuxVTPreSwitch (pointer p) |
void | kbdLinuxVTPostSwitch (pointer p) |
int | kbdLinuxVTSwitch (pointer p, int vt, void(*switch_return)(pointer), pointer switch_return_data) |
static void | kbdLinuxVTSignalHandler (int sig) |
static void | kbdLinuxOpenConsole (DevicePtr pDev) |
static void | kbdLinuxCloseConsole (DevicePtr pDev) |
void | kbdLinuxInit (DevicePtr pDev) |
static int | kbdLinuxPrefix0Mapping (unsigned char *scanCode) |
static int | kbdLinuxPrefixMapping (myPrivate *priv, unsigned char *scanCode) |
static void | kbdLinuxConvert (DevicePtr pDev, unsigned char scanCode, ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block) |
void | kbdLinuxRead (DevicePtr pDev, MOTIONPROC motion, ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block) |
int | kbdLinuxOn (DevicePtr pDev) |
void | kbdLinuxOff (DevicePtr pDev) |
static void | kbdLinuxReadKernelMapping (int fd, KeySymsPtr pKeySyms) |
static void | kbdLinuxGetMap (DevicePtr pDev, KeySymsPtr pKeySyms, CARD8 *pModMap) |
void | kbdLinuxGetInfo (DevicePtr pDev, DMXLocalInitInfoPtr info) |
Variables | |
static myPrivate * | PRIV = NULL |
static KeySym | linux_to_x [256] |
static unsigned char | at2lnx [NUM_KEYCODES] |
This code implements a low-level device driver for the Linux keyboard. The code is derived from code by Thomas Roell, Orest Zborowski, and David Dawes (see the source code for complete references).
#define BLOCK DMXBlockType |
#define CHECKPROC dmxCheckSpecialProcPtr |
#define ENQUEUEPROC dmxEnqueueProcPtr |
#define FATAL0 | ( | f | ) | dmxLog(dmxFatal,f) |
Referenced by kbdLinuxActivate(), kbdLinuxGetFreeVTNumber(), and kbdLinuxVTSwitch().
#define FATAL1 | ( | f, | |
a | |||
) | dmxLog(dmxFatal,f,a) |
Referenced by kbdLinuxGetFreeVTNumber(), kbdLinuxInit(), and kbdLinuxOn().
#define FATAL2 | ( | f, | |
a, | |||
b | |||
) | dmxLog(dmxFatal,f,a,b) |
Referenced by kbdLinuxOpenVT().
#define FINALMESSAGE "\033cDMX terminated." |
Referenced by kbdLinuxCloseConsole().
#define GETPRIV |
myPrivate *priv \ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
Referenced by kbdLinuxBell(), kbdLinuxCloseConsole(), kbdLinuxConvert(), kbdLinuxCtrl(), kbdLinuxGetMap(), kbdLinuxInit(), kbdLinuxOff(), kbdLinuxOn(), kbdLinuxOpenConsole(), and kbdLinuxRead().
#define LOG0 | ( | f | ) | dmxLog(dmxDebug,f) |
#define LOG1 | ( | f, | |
a | |||
) | dmxLog(dmxDebug,f,a) |
Referenced by kbdLinuxCloseConsole().
#define LOG2 | ( | f, | |
a, | |||
b | |||
) | dmxLog(dmxDebug,f,a,b) |
Referenced by kbdLinuxOpenConsole(), and kbdLinuxVTSignalHandler().
#define LOG3 | ( | f, | |
a, | |||
b, | |||
c | |||
) | dmxLog(dmxDebug,f,a,b,c) |
#define MESSAGE "\033c\n\n\nDMX taking input from this console..." |
Referenced by kbdLinuxOpenConsole().
#define MOTIONPROC dmxMotionProcPtr |
Referenced by kbdLinuxReadKernelMapping().
#define NUM_STATE_ENTRIES (256/32) |
Referenced by kbdLinuxKeyDown(), kbdLinuxKeyState(), kbdUSBKeyDown(), and kbdUSBKeyState().
#define SWITCHRETPROC dmxVTSwitchReturnProcPtr |
#define SYSCALL | ( | call | ) | while(((call) == -1) && (errno == EINTR)) |
Referenced by kbdLinuxActivate().
typedef struct _myPrivate myPrivate |
static int kbdLinuxActivate | ( | int | fd, |
int | vtno, | ||
int | setSig | ||
) | [static] |
References FATAL0, kbdLinuxVTSignalHandler(), and SYSCALL.
Referenced by kbdLinuxCloseConsole(), kbdLinuxOpenConsole(), and kbdLinuxVTSwitch().
void kbdLinuxBell | ( | DevicePtr | pDev, |
int | percent, | ||
int | volume, | ||
int | pitch, | ||
int | duration | ||
) |
Ring the bell.
Note: we completely ignore the volume, since Linux's ioctl() interface does not provide a way to control it. If it did, the XBell manpage tells how the actual volume is a function of the percent and the (base) volume.
Note that most of the other PC-based bell drivers compute the duration for KDMKTONE as a function of the volume and the duration. For some drivers, the duration is only measured in mS if the volume is 50, and is scaled by the volume for other values. This seems confusing and possibly incorrect (the xset man page says that the bell will be "as closely as it can to the user's specifications" -- if we ignore the volume and set the duration correctly, then we'll get one parameter "wrong" -- but if we use the volume to scale the duration, then we'll get both parameters "wrong").
References GETPRIV.
static void kbdLinuxCloseConsole | ( | DevicePtr | pDev | ) | [static] |
References FINALMESSAGE, GETPRIV, kbdLinuxActivate(), and LOG1.
Referenced by kbdLinuxOff().
static void kbdLinuxConvert | ( | DevicePtr | pDev, |
unsigned char | scanCode, | ||
ENQUEUEPROC | enqueue, | ||
CHECKPROC | checkspecial, | ||
BLOCK | block | ||
) | [static] |
References GETPRIV, kbdLinuxKeyDown(), kbdLinuxKeyState(), kbdLinuxPrefixMapping(), and MIN_KEYCODE.
Referenced by kbdLinuxRead().
pointer kbdLinuxCreatePrivate | ( | DeviceIntPtr | pKeyboard | ) |
Create a private structure for use within this file.
References _myPrivate::fd, and _myPrivate::pKeyboard.
void kbdLinuxCtrl | ( | DevicePtr | pDev, |
KeybdCtrl * | ctrl | ||
) |
Set the LEDs.
References GETPRIV.
void kbdLinuxDestroyPrivate | ( | pointer | priv | ) |
Destroy a private structure.
static int kbdLinuxGetCurrentVTNumber | ( | int | fd | ) | [static] |
Referenced by kbdLinuxOpenConsole().
static int kbdLinuxGetFreeVTNumber | ( | void | ) | [static] |
References FATAL0, and FATAL1.
Referenced by kbdLinuxOpenConsole().
void kbdLinuxGetInfo | ( | DevicePtr | pDev, |
DMXLocalInitInfoPtr | info | ||
) |
Fill the info structure with information needed to initialize pDev.
References _DMXLocalInitInfo::focusClass, _DMXLocalInitInfo::kbdFeedbackClass, kbdLinuxGetMap(), _DMXLocalInitInfo::keyboard, _DMXLocalInitInfo::keyClass, _DMXLocalInitInfo::keySyms, and _DMXLocalInitInfo::modMap.
static void kbdLinuxGetMap | ( | DevicePtr | pDev, |
KeySymsPtr | pKeySyms, | ||
CARD8 * | pModMap | ||
) | [static] |
References GETPRIV, GLYPHS_PER_KEY, kbdLinuxReadKernelMapping(), map, MAX_KEYCODE, MIN_KEYCODE, and NUM_KEYCODES.
Referenced by kbdLinuxGetInfo().
void kbdLinuxInit | ( | DevicePtr | pDev | ) |
Initialize the pDev as a Linux keyboard.
References FATAL1, GETPRIV, and kbdLinuxOpenConsole().
static int kbdLinuxKeyDown | ( | myPrivate * | priv, |
int | keyCode | ||
) | [static] |
References _myPrivate::kbdState, and NUM_STATE_ENTRIES.
Referenced by kbdLinuxConvert(), and kbdUSBConvert().
static void kbdLinuxKeyState | ( | myPrivate * | priv, |
int | type, | ||
int | keyCode | ||
) | [static] |
References _myPrivate::kbdState, and NUM_STATE_ENTRIES.
Referenced by kbdLinuxConvert().
void kbdLinuxOff | ( | DevicePtr | pDev | ) |
Turn pDev off (i.e., stop taking input from pDev).
References GETPRIV, and kbdLinuxCloseConsole().
int kbdLinuxOn | ( | DevicePtr | pDev | ) |
static void kbdLinuxOpenConsole | ( | DevicePtr | pDev | ) | [static] |
References GETPRIV, kbdLinuxActivate(), kbdLinuxGetCurrentVTNumber(), kbdLinuxGetFreeVTNumber(), kbdLinuxOpenVT(), LOG2, and MESSAGE.
Referenced by kbdLinuxInit().
static int kbdLinuxOpenVT | ( | int | vtno | ) | [static] |
References FATAL2, and O_NONBLOCK.
Referenced by kbdLinuxOpenConsole().
static int kbdLinuxPrefix0Mapping | ( | unsigned char * | scanCode | ) | [static] |
Referenced by kbdLinuxPrefixMapping().
static int kbdLinuxPrefixMapping | ( | myPrivate * | priv, |
unsigned char * | scanCode | ||
) | [static] |
References kbdLinuxPrefix0Mapping(), and _myPrivate::prefix.
Referenced by kbdLinuxConvert().
void kbdLinuxRead | ( | DevicePtr | pDev, |
MOTIONPROC | motion, | ||
ENQUEUEPROC | enqueue, | ||
CHECKPROC | checkspecial, | ||
BLOCK | block | ||
) |
Read an event from the pDev device. If the event is a motion event, enqueue it with the motion function. Otherwise, check for special keys with the checkspecial function and enqueue the event with the enqueue function. The block type is passed to the functions so that they may block SIGIO handling as appropriate to the caller of this function.
References GETPRIV, and kbdLinuxConvert().
static void kbdLinuxReadKernelMapping | ( | int | fd, |
KeySymsPtr | pKeySyms | ||
) | [static] |
References at2lnx, GLYPHS_PER_KEY, linux_to_x, map, and NUM_AT2LNX.
Referenced by kbdLinuxGetMap().
void kbdLinuxVTPostSwitch | ( | pointer | p | ) |
Currently unused hook called after returning from a VT switch.
void kbdLinuxVTPreSwitch | ( | pointer | p | ) |
Currently unused hook called prior to an VT switch.
static void kbdLinuxVTSignalHandler | ( | int | sig | ) | [static] |
References _myPrivate::fd, LOG2, PRIV, _myPrivate::switch_return, _myPrivate::switch_return_data, and _myPrivate::switched.
Referenced by kbdLinuxActivate().
int kbdLinuxVTSwitch | ( | pointer | p, |
int | vt, | ||
void(*)(pointer) | switch_return, | ||
pointer | switch_return_data | ||
) |
Tell the operating system to switch to vt. The switch_return function is called with the switch_return_data when the VT is switched back to the pre-switch VT (i.e., the user returns to the DMX session).
References FATAL0, _myPrivate::fd, kbdLinuxActivate(), _myPrivate::switch_return, _myPrivate::switch_return_data, _myPrivate::switched, and _myPrivate::vtno.
unsigned char at2lnx[NUM_KEYCODES] [static] |
Referenced by kbdLinuxReadKernelMapping().
KeySym linux_to_x[256] [static] |
Referenced by kbdLinuxReadKernelMapping().
Referenced by kbdLinuxVTSignalHandler().