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 @ File Index
Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

lnx-keyboard.c File Reference

#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)

Detailed Description

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).

Function Documentation

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").

pointer kbdLinuxCreatePrivate DeviceIntPtr  pKeyboard  ) 
 

Create a private structure for use within this file.

void kbdLinuxCtrl DevicePtr  pDev,
KeybdCtrl *  ctrl
 

Set the LEDs.

void kbdLinuxDestroyPrivate pointer  priv  ) 
 

Destroy a private structure.

void kbdLinuxGetInfo DevicePtr  pDev,
DMXLocalInitInfoPtr  info
 

Fill the info structure with information needed to initialize pDev.

void kbdLinuxInit DevicePtr  pDev  ) 
 

Initialize the pDev as a Linux keyboard.

void kbdLinuxOff DevicePtr  pDev  ) 
 

Turn pDev off (i.e., stop taking input from pDev).

int kbdLinuxOn DevicePtr  pDev  ) 
 

Turn pDev on (i.e., take input from pDev).

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.

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.

int kbdLinuxVTSwitch pointer  p,
int  vt,
void(*  switch_return)(pointer),
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).


Generated June 29, 2004 for Distributed Multihead X by doxygen 1.3.4. @ 1.1 log @Initial revision @ text @@ 1.1.1.1 log @initial import of xorg-server-1.4.2 @ text @@ 1.1.1.2 log @import xorg-server 1.9.2. important changes since 1.6.5 include: - built-in symbol visibility, default not export - fixes for various crashes - many fixes for XI2, EXA, dix, render, glx, xkb, EDID, randr, Xv, resource handling, Xext, vfb, xfree86 / vga and composite support. - fixes several memory leaks - many many documentation updates - record extension enabled - no longer looks for XF86Config files @ text @d9 24 a32 114

lnx-keyboard.c File Reference

#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 myPrivatePRIV = NULL
static KeySym linux_to_x [256]
static unsigned char at2lnx [NUM_KEYCODES]

Detailed Description

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 Documentation

#define BLOCK   DMXBlockType
d34 1 a34 12
#define CHECKPROC   dmxCheckSpecialProcPtr
d36 1 a36 12
#define ENQUEUEPROC   dmxEnqueueProcPtr
d38 1 a38 17
#define FATAL0 (   f  )     dmxLog(dmxFatal,f)
d40 1 a40 1

Referenced by kbdLinuxActivate(), kbdLinuxGetFreeVTNumber(), and kbdLinuxVTSwitch().

d42 1 a42 26
#define FATAL1 (   f,
  a 
)    dmxLog(dmxFatal,f,a)
d44 1 a44 1

Referenced by kbdLinuxGetFreeVTNumber(), kbdLinuxInit(), and kbdLinuxOn().

d46 1 a46 32
#define FATAL2 (   f,
  a,
  b 
)    dmxLog(dmxFatal,f,a,b)
d48 1 a48 1

Referenced by kbdLinuxOpenVT().

d50 1 a50 12
#define FINALMESSAGE   "\033cDMX terminated."
d52 1 a52 32
#define GETPRIV
Value:
myPrivate *priv                            \
                      = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
#define LOG0 (   f  )     dmxLog(dmxDebug,f)
d54 8 a61 6
d63 4 a66 4 a68 1 a69 4 d71 2 a72 20
#define LOG1 (   f,   a 
)    dmxLog(dmxDebug,f,a)

Referenced by kbdLinuxCloseConsole().

a74 1 a75 5 d77 2 a78 2 a81 23
#define LOG2 (   f,   a,
  b )    dmxLog(dmxDebug,f,a,b)
d83 2 a84 2 a86 1 a87 5 d89 2 a90 2 d94 2 a95 2 a96 3
#define LOG3 (   f,
  a,   b,
  c )    dmxLog(dmxDebug,f,a,b,c)
a97 9
d99 28 a126 11
#define MESSAGE   "\033c\n\n\nDMX taking input from this console..."
a127 3
#define MOTIONPROC   dmxMotionProcPtr
a128 9
d130 19 a148 58
#define NUM_AT2LNX   (sizeof(at2lnx) / sizeof(at2lnx[0]))
#define NUM_STATE_ENTRIES   (256/32)
#define SWITCHRETPROC   dmxVTSwitchReturnProcPtr
#define SYSCALL (   call  )     while(((call) == -1) && (errno == EINTR))

Referenced by kbdLinuxActivate().


Typedef Documentation

d150 4 a153 1 a154 11
typedef struct _myPrivate myPrivate

Function Documentation

a155 7 a156 5 d158 2 a159 2 d163 2 a164 2 a165 3
static int kbdLinuxActivate ( int  fd,
int  vtno,
int  setSig ) [static]
d168 26 a193 19

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").

void kbdLinuxBell ( DevicePtr  pDev,
int  percent,
int  volume,
int  pitch,
int  duration 
)
d195 1 d197 19 a215 13

References kbdLinuxActivate(), and LOG1.

Referenced by kbdLinuxOff().

static void kbdLinuxCloseConsole ( DevicePtr  pDev  )  [static]
d217 4 a220 4 a222 1 a223 5 d225 2 a226 2 a228 1 d230 2 a231 13 d233 1 d235 26 a260 20
static void kbdLinuxConvert ( DevicePtr  pDev, unsigned char  scanCode,
ENQUEUEPROC  enqueue, CHECKPROC  checkspecial,
BLOCK  block 
) [static]
a261 4
pointer kbdLinuxCreatePrivate ( DeviceIntPtr  pKeyboard  ) 

Create a private structure for use within this file.

a262 25

References _myPrivate::fd, and _myPrivate::pKeyboard.

d264 26 a289 17

Set the LEDs.

void kbdLinuxCtrl ( DevicePtr  pDev,
KeybdCtrl *  ctrl 
)
d291 1 d293 26 a318 17

Destroy a private structure.

void kbdLinuxDestroyPrivate ( pointer  priv  ) 
a319 3
static int kbdLinuxGetCurrentVTNumber ( int  fd  )  [static]
a320 16

Referenced by kbdLinuxOpenConsole().

d322 19 a340 13

References FATAL0, and FATAL1.

Referenced by kbdLinuxOpenConsole().

static int kbdLinuxGetFreeVTNumber ( void   )  [static]
d342 4 a345 4 a347 1 a348 4 d350 2 a351 21
void kbdLinuxGetInfo ( DevicePtr  pDev, DMXLocalInitInfoPtr  info 
)
a353 1 a354 5 d356 2 a357 2 a360 23
static void kbdLinuxGetMap ( DevicePtr  pDev, KeySymsPtr  pKeySyms,
CARD8 *  pModMap ) [static]
d362 2 a364 13
void kbdLinuxInit ( DevicePtr  pDev  ) 

Initialize the pDev as a Linux keyboard.

References FATAL1, and kbdLinuxOpenConsole().

a365 38
static int kbdLinuxKeyDown ( myPrivate priv,
int  keyCode 
) [static]
a366 5 d368 2 a369 2 d373 2 a374 2 a375 5
static void kbdLinuxKeyState ( myPrivate priv,
int  type,
int  keyCode ) [static]

References _myPrivate::kbdState, and NUM_STATE_ENTRIES.

a376 16

Referenced by kbdLinuxConvert().

d378 26 a403 40

Turn pDev off (i.e., stop taking input from pDev).

References kbdLinuxCloseConsole().

void kbdLinuxOff ( DevicePtr  pDev  ) 
int kbdLinuxOn ( DevicePtr  pDev  ) 

Turn pDev on (i.e., take input from pDev).

References FATAL1.

a404 3
static void kbdLinuxOpenConsole ( DevicePtr  pDev  )  [static]
d407 26 a432 20

References FATAL2, and O_NONBLOCK.

Referenced by kbdLinuxOpenConsole().

static int kbdLinuxOpenVT ( int  vtno  )  [static]
a433 5
static int kbdLinuxPrefix0Mapping ( unsigned char *  scanCode  )  [static]

Referenced by kbdLinuxPrefixMapping().

a434 23
d436 19 a454 13
static int kbdLinuxPrefixMapping ( myPrivate priv,
unsigned char *  scanCode 
) [static]
d456 4 a459 4 a461 1 a462 5 d464 2 a465 2 a467 1 a468 5 d470 2 a471 2 a474 24
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 kbdLinuxConvert().

d476 2 a477 2 d481 2 a482 2 a483 3
static void kbdLinuxReadKernelMapping ( int  fd,
KeySymsPtr  pKeySyms ) [static]
a484 18

References at2lnx, linux_to_x, and map.

Referenced by kbdLinuxGetMap().

d486 14 a499 134

Currently unused hook called after returning from a VT switch.

void kbdLinuxVTPostSwitch ( pointer  p  ) 
void kbdLinuxVTPreSwitch ( pointer  p  ) 

Currently unused hook called prior to an VT switch.

static void kbdLinuxVTSignalHandler ( int  sig  )  [static]
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.


Variable Documentation

unsigned char at2lnx[NUM_KEYCODES] [static]
KeySym linux_to_x[256] [static]
myPrivate* PRIV = NULL [static]
@ 1.1.1.3 log @initial import of xorg-server 1.10.3. highlights include: - fixes xorg bugs 29969, 30367, 30527, 30267, 30260, 29046, 30260, 31548, 28672, 24887, 32115, 21457, 32436, 21827, 28414, 24703, 32803, 16318, 33449, 33324, 33929, 35082, 35209, 36146, 36119 - many additional NULL checks - adjustments related to input ABI 12 - *lots* of dead code removal - vga arbitrator fixes - GL fixes - EDID fixes - conversion to using asprintf() in many places - many fixes from valgrind, compiler warnings see these for more details: http://lists.freedesktop.org/archives/xorg-announce/2011-February/001612.html http://lists.freedesktop.org/archives/xorg-announce/2011-April/001646.html http://lists.freedesktop.org/archives/xorg-announce/2011-May/001675.html http://lists.freedesktop.org/archives/xorg-announce/2011-July/001710.html @ text @d9 3 a11 2