usb-common.c File Reference
#include "usb-private.h"
#include "usb-mouse.h"

Defines

#define USB_COMMON_DEBUG   1
#define GETPRIV
#define GETNAME
#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 LOG1INPUT(p, f, a)   dmxLogInput(p->dmxInput,f,a)
#define LOG3INPUT(p, f, a, b, c)   dmxLogInput(p->dmxInput,f,a,b,c)
#define LOG5INPUT(p, f, a, b, c, d, e)   dmxLogInput(p->dmxInput,f,a,b,c,d,e)
#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 BLOCK   DMXBlockType
#define PRESS(b)
#define RELEASE(b)
#define test_bit(bit)   (priv->mask[(bit)/8] & (1 << ((bit)%8)))
#define test_bits(bit)   (bits[(bit)/8] & (1 << ((bit)%8)))

Functions

void usbRead (DevicePtr pDev, MOTIONPROC motion, ENQUEUEPROC enqueue, int minButton, BLOCK block)
static void usbPrint (myPrivate *priv, const char *filename, const char *devname, int fd)
void usbInit (DevicePtr pDev, usbType type)
void usbOff (DevicePtr pDev)
pointer usbCreatePrivate (DeviceIntPtr pDevice)
void usbDestroyPrivate (pointer priv)

Detailed Description

Routines that are common between usb-keyboard.c, usb-mouse.c, and usb-other.c


Define Documentation

#define BLOCK   DMXBlockType
#define CHECKPROC   dmxCheckSpecialProcPtr
#define ENQUEUEPROC   dmxEnqueueProcPtr
#define FATAL0 (   f)    dmxLog(dmxFatal,f)
#define FATAL1 (   f,
 
)    dmxLog(dmxFatal,f,a)

Referenced by usbInit().

#define FATAL2 (   f,
  a,
 
)    dmxLog(dmxFatal,f,a,b)
#define GETNAME
Value:
((DMXLocalInputInfoPtr)(pDevice->public.devicePrivate)) \
                      ->name

Referenced by usbPrint().

#define GETPRIV
Value:
myPrivate *priv                                         \
                      = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private

Referenced by usbInit(), usbOff(), and usbRead().

#define LOG0 (   f)    dmxLog(dmxDebug,f)
#define LOG1 (   f,
 
)    dmxLog(dmxDebug,f,a)
#define LOG1INPUT (   p,
  f,
 
)    dmxLogInput(p->dmxInput,f,a)

Referenced by usbPrint().

#define LOG2 (   f,
  a,
 
)    dmxLog(dmxDebug,f,a,b)
#define LOG3 (   f,
  a,
  b,
 
)    dmxLog(dmxDebug,f,a,b,c)

Referenced by usbRead().

#define LOG3INPUT (   p,
  f,
  a,
  b,
 
)    dmxLogInput(p->dmxInput,f,a,b,c)

Referenced by usbPrint().

#define LOG5INPUT (   p,
  f,
  a,
  b,
  c,
  d,
 
)    dmxLogInput(p->dmxInput,f,a,b,c,d,e)

Referenced by usbPrint().

#define MOTIONPROC   dmxMotionProcPtr
#define PRESS (   b)
Value:
do {                                                 \
        enqueue(pDev, ButtonPress, 0, 0, NULL, block);   \
    } while (0)
#define RELEASE (   b)
Value:
do {                                                 \
        enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \
    } while (0)
#define test_bit (   bit)    (priv->mask[(bit)/8] & (1 << ((bit)%8)))

Referenced by othUSBGetInfo(), usbInit(), and usbPrint().

#define test_bits (   bit)    (bits[(bit)/8] & (1 << ((bit)%8)))

Referenced by usbInit(), and usbPrint().

#define USB_COMMON_DEBUG   1

Function Documentation

pointer usbCreatePrivate ( DeviceIntPtr  pDevice)

Create a private structure for use within this file.

References _myPrivate::fd, and _myPrivate::pDevice.

void usbDestroyPrivate ( pointer  priv)

Destroy a private structure.

void usbInit ( DevicePtr  pDev,
usbType  type 
)

Initialized pDev as a usbMouse, usbKeyboard, or usbOther device.

References FATAL1, GETPRIV, O_NONBLOCK, test_bit, test_bits, usbKeyboard, usbMouse, usbOther, and usbPrint().

Referenced by kbdUSBInit(), mouUSBInit(), and othUSBInit().

void usbOff ( DevicePtr  pDev)

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

References GETPRIV.

static void usbPrint ( myPrivate priv,
const char *  filename,
const char *  devname,
int  fd 
) [static]
void usbRead ( DevicePtr  pDev,
MOTIONPROC  motion,
ENQUEUEPROC  enqueue,
int  minButton,
BLOCK  block 
)

Read an event from the pDev device. If the event is a motion event, enqueue it with the motion function. Otherwise, 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.

Since USB devices return EV_KEY events for buttons and keys, minButton is used to decide if a Button or Key event should be queued.

References DMX_ABSOLUTE, DMX_MAX_AXES, DMX_RELATIVE, GETPRIV, LOG3, PRESS, and RELEASE.

Referenced by mouUSBRead(), and othUSBRead().