
Overview of Wacom X Extension Interface:

The Wacom tablet driver is a STREAMS module.  It will respond to STREAMS
getmsg(), but the result is not terribly useful: The output is a fragment
of a complex data type corresponding to the SGI X Input Extension API. 
The SGI X extensions use additional modules pushed after wacom.o to finish
several machine specific calculations before posting an X event.  The
preferred interface to the wacom tablet is via the X Event Queue.

The Wacom tablet can send several types of events to the X event queue.
The most immediately obvious are pointer and button events, which can be
captured by applications to determine current location and active
buttons.  Most X applications need only query the cursor position and
button state to work immediately with a mouse, Wacom tablet or other
device; any application that uses a mouse will work with the Wacom tablet
without modification.  

The whole point to the tablet, though, is that it does much more than a
mouse.  The Wacom tablet sends up to 10 valuator events to the X event queue,
depending on tablet model and user settings (only 9 of the 10 are currently
supported).  The valuators are specified in the public section of the wacom.h
file as:
	#define WAC_XCOORD_I            0
	#define WAC_YCOORD_I            1
	#define WAC_PRESSURE_I          2
	#define WAC_BUTTON_I            3
	#define WAC_TRANSDUCER_I        4
	#define WAC_XTILT_I             5
	#define WAC_YTILT_I             6
	#define WAC_ZCOORD_I            7	/* unused */
	#define WAC_HEIGHT_I            WAC_ZCOORD_I
	#define WAC_2XCOORD_I           8       /* 2nd pointer x */
	#define WAC_2YCOORD_I           9       /* 2nd pointer y */

WAC_XCOORD_I: The raw tablet X coord of the current "pushpointer" device:
some Wacom tablet models support simultaneous use of stylus and puck,
but the driver only allows one of them to push the cursor around the
screen (allowing both will cause the screen cursor to oscillate between
the two positions at roughly the screen refresh rate -- not particularly
useful).  The X coord range is tablet model and configuration dependent. 
The X coord is characteristic of the physical tablet, not the screen nor
anything pertaining to X, and is always parallel to the nominal "top" of
the physical tablet.  One side of the tablet is zero, but which side
is under user control; the user can set the X coord to increase from left
to right (default) or from right to left.  The tablet X coord may not
correspond to the display cursor x position; any valuator can drive the
horizontal axis of the cursor. 
	The current reporting range can be obtained with the idev OTHERQUERY
ioctl using the the "dimensions" request (returns <x,y> pair).  The xlist
utility will report what the X server believes the range to be; the range
may be 0-4640 for the SD510 or 0-32480 for the UD1212.  The range always
has a zero minimum.

WAC_YCOORD_I: Just like the X coord, only vertical.

WAC_PRESSURE_I: Pressure reading of pressure-sensitive pens.  This
value is also tablet and configuration specific, although the user
configurable range must be a subrange of 0-255.  To support existing
software, the user can choose to report either a smaller or greater
range than is actually supported by the tablet. Pressure ranges are
not required to have zero as a minimum. If pressure mode is
off, either for a pen or when the puck is in use, then pressure will
report 0 if no buttons are active, 255 if buttons are active.
	The current pressure curve can be obtained with idev OTHERQUERY
using the "pressurecurve" command.

WAC_BUTTON_I: The current active buttons. This is a combination of
buttons on currently active devices; normally, the X button event is
sufficient.  The valuator actually has three values: stylus, puck and
menu selection.  User button mappings are applied to stylus buttons
before encoding.  The low 5 [0-4] bits hold the bitset of stylus
buttons; multiple stylus buttons may be active simultaneously.  The
active pen button is a small ordinal in bits 8-12; the puck always
reports a single button (from 1 to number of buttons, even if several
buttons are held down together).  In multimode the driver provides the
simultaneous button state of both pen and puck for more complex
interactions.  Bits 14-19 hold any active menu item, again as a small
ordinal, since ony one menu item is active in a given packet.
	Wacom.h provides manifest constant masks that should always
be used for future compatability:
	#define WAC_BTN_PTR_MSK   0x0000001f  /* pen bits of 
		button valuator */
	#define WAC_BTN_PUCK_MSK  0x00001f00  /* puck bits
		of button valuator */
	#define WAC_BTN_PUCK_OFFSET	8   /* right shift to normalize */
	#define WAC_MENU_ITEM_MSK 0x000f8000  /* menu choice */
	#define WAC_BTN_PUCK_OFFSET	15   /* right shift to normalize */
To retrieve the buttons from the button valuator use the macros:
	#define WAC_STYLUS_BUTTONS(x)  \
		(((x)&WAC_BTN_STYLUS_MSK)>>WAC_STYLUS_OFFSET)
	#define WAC_PUCK_BUTTONS(x)    \
		(((x)&WAC_BTN_PUCK_MSK)>>WAC_PUCK_OFFSET)
	#define WAC_MENU_BUTTONS(x)    \
		(((x)&WAC_MENU_ITEM_MSK)>>WAC_MENU_OFFSET)

Device buttons are all set to "up" (0) when the device leaves proximity.

WAC_TRANSDUCER_I: Transducer id, i.e., puck, pen or eraser, or menu
item (which really doesn't belong here), in 0-2 bits.  Bit 4 set
indicates device in proximity; devices transmit some final points on
leaving proximity to clear buttons, although final X, Y position are
not updated.
    #define WAC_PUCK_ID             0x0     /* menu button; button id */
    #define WAC_STYLUS_ID           0x1     /* stylus tip */
    #define WAC_ERASER_ID           0x2     /* eraser tip */
    #define WAC_TRANSDUCER_MSK      0x7     /* transducer type mask */
    #define WAC_TRANSDUCER_PROX_MSK 0x8     /* 1 if in prox, 0 if not */
    #define WAC_MENU_ID             0x10    /* menu item */

The remaining bits are reserved for extended device identifiers
(unimplimented).

WAC_XTILT_I: Newer UD tablet stylii can report spatial orientation
(ioctl OTHERCOMMAND "tilt" "on").  This and the next valuator report
difference from perpendicular.  Positive readings are towards the tablet
physical top; range is from -60 to +60 degrees.

WAC_YTILT_I: As ytilt, but positive is to right, negative to left.

WAC_2XCOORD_I: Multimode hack.  When both the stylus and the puck are active
simultaneously (ioctl OTHERCOMMAND "multimode" "on"), the pushpointer device
is reported in the WAC_XCOORD, WAC_YCOORD, and the other device is reported
here.  Currently, when using X motion hints, it is impossible to use 
WAC_TRANSDUCER_I to determine which device moved if both devices report
through WAC_XCOORD_I, WAC_YCOORD_I; motion hints only guarantee individual
valuator changes are chronologically ordered, but not that any two valuators 
that change simultaneously will be reported simultaneously.  
    Otherwise, this is identical to WAC_XCOORD_I.

WAC_2YCOORD_I: As previous, for WAC_YCOORD_I.

---------------------

Application reads of current tablet state:

The example program, watch.c, demonstrates one method of probing the X
event queue for Wacom valuators.  The example suffers from being an
expensive polling solution.

The code should be adequately documented.  Compile with:
    %  cc -o watch watch.c  -O2 -xansi -float -KPIC -G 0 -Wf,-XNh2000 \
	-call_shared  -lXi -lXext -lX11  -L -L/lib -L/usr/lib

---------------------


