head 1.2; access; symbols netbsd-7-2-RELEASE:1.1.1.3 netbsd-7-1-2-RELEASE:1.1.1.3 netbsd-7-1-1-RELEASE:1.1.1.3 netbsd-7-1:1.1.1.3.0.14 netbsd-7-1-RELEASE:1.1.1.3 netbsd-7-1-RC2:1.1.1.3 netbsd-7-1-RC1:1.1.1.3 netbsd-7-0-2-RELEASE:1.1.1.3 netbsd-7-0-1-RELEASE:1.1.1.3 netbsd-7-0:1.1.1.3.0.12 netbsd-7-0-RELEASE:1.1.1.3 netbsd-7-0-RC3:1.1.1.3 netbsd-7-0-RC2:1.1.1.3 netbsd-7-0-RC1:1.1.1.3 netbsd-5-2-3-RELEASE:1.1.1.1 netbsd-5-1-5-RELEASE:1.1.1.1 netbsd-6-0-6-RELEASE:1.1.1.3 netbsd-6-1-5-RELEASE:1.1.1.3 netbsd-7:1.1.1.3.0.10 netbsd-7-base:1.1.1.3 netbsd-6-1-4-RELEASE:1.1.1.3 netbsd-6-0-5-RELEASE:1.1.1.3 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.3 riastradh-drm2:1.1.1.3.0.8 riastradh-drm2-base:1.1.1.3 netbsd-6-1-3-RELEASE:1.1.1.3 netbsd-6-0-4-RELEASE:1.1.1.3 netbsd-5-2-2-RELEASE:1.1.1.1 netbsd-5-1-4-RELEASE:1.1.1.1 netbsd-6-1-2-RELEASE:1.1.1.3 netbsd-6-0-3-RELEASE:1.1.1.3 netbsd-5-2-1-RELEASE:1.1.1.1 netbsd-5-1-3-RELEASE:1.1.1.1 netbsd-6-1-1-RELEASE:1.1.1.3 xorg-server-1-10-6:1.1.1.3 netbsd-6-1:1.1.1.3.0.6 netbsd-6-0-2-RELEASE:1.1.1.3 netbsd-6-1-RELEASE:1.1.1.3 netbsd-6-1-RC4:1.1.1.3 netbsd-6-1-RC3:1.1.1.3 netbsd-6-1-RC2:1.1.1.3 netbsd-6-1-RC1:1.1.1.3 netbsd-5-2:1.1.1.1.0.8 netbsd-6-0-1-RELEASE:1.1.1.3 netbsd-5-2-RELEASE:1.1.1.1 netbsd-5-2-RC1:1.1.1.1 netbsd-6-0:1.1.1.3.0.4 netbsd-6-0-RELEASE:1.1.1.3 netbsd-6-0-RC2:1.1.1.3 netbsd-6-0-RC1:1.1.1.3 netbsd-6:1.1.1.3.0.2 netbsd-6-base:1.1.1.3 netbsd-5-1-2-RELEASE:1.1.1.1 netbsd-5-1-1-RELEASE:1.1.1.1 xorg-server-1-10-3:1.1.1.3 mrg-xorg-server-1-9-5-pre-1-10-3:1.1.1.2 xorg-server-1-9-5:1.1.1.2 xorg-server-1-9-2:1.1.1.2 netbsd-5-1:1.1.1.1.0.6 netbsd-5-1-RELEASE:1.1.1.1 netbsd-5-1-RC4:1.1.1.1 netbsd-5-1-RC3:1.1.1.1 netbsd-5-1-RC2:1.1.1.1 netbsd-5-1-RC1:1.1.1.1 netbsd-5-0-2-RELEASE:1.1.1.1 xorg-server-1-6-5:1.1.1.1 xorg-server-1-6-3:1.1.1.1 netbsd-5-0-1-RELEASE:1.1.1.1 xorg-server-1-6-2:1.1.1.1 xorg-server-1-6-1-901:1.1.1.1 netbsd-5-0:1.1.1.1.0.4 netbsd-5-0-RELEASE:1.1.1.1 netbsd-5-0-RC4:1.1.1.1 netbsd-5-0-RC3:1.1.1.1 netbsd-5-0-RC2:1.1.1.1 netbsd-5-0-RC1:1.1.1.1 netbsd-5:1.1.1.1.0.2 netbsd-5-base:1.1.1.1 xorg-server-1-4-2:1.1.1.1 xorg:1.1.1; locks; strict; comment @# @; 1.2 date 2016.08.11.00.04.29; author mrg; state dead; branches; next 1.1; commitid FQxwnZNPy5ZgOOhz; 1.1 date 2008.07.31.19.50.31; author mrg; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2008.07.31.19.50.31; author mrg; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 2010.11.23.05.21.22; author mrg; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 2011.08.02.06.56.52; author mrg; state Exp; branches; next ; desc @@ 1.2 log @first merge of netbsd changes. not tested yet. @ text @
#include "dmxinputinit.h"#include "lnx-keyboard.h"#include "inputstr.h"#include "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 "xf86Keymap.h"#include <linux/keyboard.h>Data Structures | |
| struct | _myPrivate |
Functions | |
| 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) |
| void | kbdLinuxVTPreSwitch (pointer p) |
| void | kbdLinuxVTPostSwitch (pointer p) |
| int | kbdLinuxVTSwitch (pointer p, int vt, void(*switch_return)(pointer), pointer switch_return_data) |
| void | kbdLinuxInit (DevicePtr pDev) |
| void | kbdLinuxRead (DevicePtr pDev, MOTIONPROC motion, ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block) |
| int | kbdLinuxOn (DevicePtr pDev) |
| void | kbdLinuxOff (DevicePtr pDev) |
| void | kbdLinuxGetInfo (DevicePtr pDev, DMXLocalInitInfoPtr info) |
|
||||||||||||||||||||||||
|
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"). |
|
|
Create a private structure for use within this file. |
|
||||||||||||
|
Set the LEDs. |
|
|
Destroy a private structure. |
|
||||||||||||
|
Fill the info structure with information needed to initialize pDev. |
|
|
Initialize the pDev as a Linux keyboard. |
|
|
Turn pDev off (i.e., stop taking input from pDev). |
|
|
Turn pDev on (i.e., take input from pDev). |
|
||||||||||||||||||||||||
|
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. |
|
|
Currently unused hook called after returning from a VT switch. |
|
|
Currently unused hook called prior to an VT switch. |
|
||||||||||||||||||||
|
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). |
#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().
d42 1 a42 26| #define FATAL1 | ( | f, | ||
| a | ||||
| ) | dmxLog(dmxFatal,f,a) |
Referenced by kbdLinuxGetFreeVTNumber(), kbdLinuxInit(), and kbdLinuxOn().
d46 1 a46 32| #define FATAL2 | ( | f, | ||
| a, | ||||
| b | ||||
| ) | dmxLog(dmxFatal,f,a,b) |
Referenced by kbdLinuxOpenVT().
d50 1 a50 12| #define FINALMESSAGE "\033cDMX terminated." |
| #define GETPRIV |
myPrivate *priv \ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
| #define LOG0 | ( | f | ) | dmxLog(dmxDebug,f) |
| #define LOG1 | ( | f, | a68 1a69 4 | a |
| ) | dmxLog(dmxDebug,f,a) |
Referenced by kbdLinuxCloseConsole().
| #define LOG2 | ( | f, | a74 1a75 5 | a, | |||
| d77 2 a78 2 | b | a81 23 | ) | dmxLog(dmxDebug,f,a,b) |
Referenced by kbdLinuxOpenConsole(), and kbdLinuxVTSignalHandler().
| #define LOG3 | ( | f, | |||||
| d83 2 a84 2 | a, | a86 1a87 5 | b, | ||||
| d89 2 a90 2 | c | d94 2 a95 2 | ) | dmxLog(dmxDebug,f,a,b,c) | a96 3
| #define MESSAGE "\033c\n\n\nDMX taking input from this console..." |
| #define MOTIONPROC dmxMotionProcPtr | a127 3
| #define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0])) |
| #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 | a154 11
| static int kbdLinuxActivate | ( | int | fd, | ||||
| a156 5 | int | vtno, | |||||
| d158 2 a159 2 | int | setSig | d163 2 a164 2 | ) | [static] |
a165 3
References FATAL0, kbdLinuxVTSignalHandler(), and SYSCALL.
Referenced by kbdLinuxCloseConsole(), kbdLinuxOpenConsole(), and kbdLinuxVTSwitch().
| void kbdLinuxBell | ( | DevicePtr | pDev, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int | percent, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int | volume, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int | pitch, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int | duration | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) |
| static void kbdLinuxCloseConsole | ( | DevicePtr | pDev | ) | [static] |
d195 1
d197 19
a215 13
| static void kbdLinuxConvert | ( | DevicePtr | pDev, | a222 1a223 5 | unsigned char | scanCode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| d225 2 a226 2 | ENQUEUEPROC | enqueue, | a228 1d230 2 a231 13 | CHECKPROC | checkspecial, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BLOCK | block | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | [static] |
d233 1
d235 26
a260 20
| pointer kbdLinuxCreatePrivate | ( | DeviceIntPtr | pKeyboard | ) | a261 4 |
Create a private structure for use within this file.
a262 25References _myPrivate::fd, and _myPrivate::pKeyboard.
| void kbdLinuxCtrl | ( | DevicePtr | pDev, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| KeybdCtrl * | ctrl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) |
| void kbdLinuxDestroyPrivate | ( | pointer | priv | ) | d291 1 d293 26 a318 17 |
| static int kbdLinuxGetCurrentVTNumber | ( | int | fd | ) | [static] |
a319 3
Referenced by kbdLinuxOpenConsole().
| static int kbdLinuxGetFreeVTNumber | ( | void | ) | [static] |
| void kbdLinuxGetInfo | ( | DevicePtr | pDev, | a347 1a348 4 | 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, | a353 1a354 5 | KeySymsPtr | pKeySyms, | |
| d356 2 a357 2 | CARD8 * | pModMap | a360 23 | ) | [static] |
References kbdLinuxReadKernelMapping(), map, MIN_KEYCODE, and NUM_KEYCODES.
Referenced by kbdLinuxGetInfo().
| void kbdLinuxInit | ( | DevicePtr | pDev | ) | d362 2 a364 13
Initialize the pDev as a Linux keyboard.
References FATAL1, 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, | ||||
| a366 5 | int | type, | |||||
| d368 2 a369 2 | int | keyCode | d373 2 a374 2 | ) | [static] |
a375 5
References _myPrivate::kbdState, and NUM_STATE_ENTRIES.
a376 16Referenced by kbdLinuxConvert().
| void kbdLinuxOff | ( | DevicePtr | pDev | ) |
| int kbdLinuxOn | ( | DevicePtr | pDev | ) |
Turn pDev on (i.e., take input from pDev).
References FATAL1.
| static void kbdLinuxOpenConsole | ( | DevicePtr | pDev | ) | [static] |
a404 3
References kbdLinuxActivate(), kbdLinuxGetCurrentVTNumber(), kbdLinuxGetFreeVTNumber(), kbdLinuxOpenVT(), and LOG2.
Referenced by kbdLinuxInit().
| static int kbdLinuxOpenVT | ( | int | vtno | ) | [static] |
| static int kbdLinuxPrefix0Mapping | ( | unsigned char * | scanCode | ) | [static] |
a433 5
Referenced by kbdLinuxPrefixMapping().
a434 23| static int kbdLinuxPrefixMapping | ( | myPrivate * | priv, | ||||
| unsigned char * | scanCode | ||||||
| ) | [static] |
| void kbdLinuxRead | ( | DevicePtr | pDev, | a461 1a462 5 | MOTIONPROC | motion, | |
| d464 2 a465 2 | ENQUEUEPROC | enqueue, | a467 1a468 5 | CHECKPROC | checkspecial, | ||
| d470 2 a471 2 | BLOCK | block | a474 24 | ) |
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 kbdLinuxConvert().
| static void kbdLinuxReadKernelMapping | ( | int | fd, | ||||
| d476 2 a477 2 | KeySymsPtr | pKeySyms | d481 2 a482 2 | ) | [static] |
a483 3
References at2lnx, linux_to_x, and map.
Referenced by kbdLinuxGetMap().
| void kbdLinuxVTPostSwitch | ( | pointer | p | ) |
| void kbdLinuxVTPreSwitch | ( | pointer | p | ) |
Currently unused hook called prior to an VT switch.
| static void kbdLinuxVTSignalHandler | ( | int | sig | ) | [static] |
References _myPrivate::fd, LOG2, _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().