
/usr/lib/X11/input/config/README

Device controls are an extensible way to change or query things about
devices.  They fall into two categories:  those intercepted by the X
server and those used by the device drivers.  The server uses the x_init
controls which change the way the X server views devices.  The device
drivers use device_init controls which change device characteristics.

You can issue device controls on the fly using devctrl program (in
4Dgifts), or by calling XSGIDeviceControl from within a program, or by
storing them in configuration files which reside in the
/usr/lib/X11/input/config directory.

There are (potentially) two configuration files per device in the
directory /usr/lib/X11/input/config.  The device_init options live in a
file with the same name as the streams module which implements the device
(which is also the name of the link we create in /dev/input).  The x_init
options live in a file with the X name of the device (as supplied by the
streams modules).  Some devices use the same name for the streams module
and for the X device (tablet, mouse), but some use different names for
the two (sball(streams) == spaceball(X), calcomp(streams) == tablet(x)).

When the X server finds a new device (or when it starts up), it:
   opens the device and finds a streams module
   issues device_init controls
   asks the device to describe itself
   issues x_init controls 
   closes the device (unless autostart is on for it)

When some program opens a device that is not autostarted or open by some
other program, the X server:
   opens the device and finds the streams module
   issues device_init controls
   issues x_init controls
   starts reporting events from the device

The X server intercepts about a dozen x_init controls:

    pushpointer		on/off/exclusive
			Controls whether or not the device generates core
			pointer events as well as extension events.   "on"
			means generate both,  "off" means generate extension
			events only and "exclusive" means generate core
			events for two axes and extension events for the
			rest of them.

    pushx		<axis number>
			Specifies the device axis which generates the X
			position in core pointer events *if* pushpointer
			is "on" or "exclusive."

    pushy		<axis number>
			Specifies the device axis which generates the Y
			position in core pointer events *if* pushpointer
			is "on" or "exclusive."

    name		<new name>
			Renames the device.   This changes the name of the
			device as reported by the X input extension.   Note
			that the GL uses device name to map X events to
			GL events, so you can use this request to fake out
			the GL (e.g. change your name to "dial+buttons" to
			make the GL generate dial events for your device).

    type		<new type>
			Changes the type of the device as reported by the
			X input extension.

    keymap		<keymap name>
			Not implemented, but reserved (and intercepted).

    scale		iso/fit/none
			Tells the X server how to scale the device the next
			time it is opened.   Scale "iso" uses the full range
			of either the X or Y axis but preserves a 1 to 1
			aspect ratio. Scale "fit" uses the full range of
			both axes (aspect ratio may be skewed).   Scale
			"none" uses raw device data.   Unless you're supporting
			a tablet, you probably want scale "none."

    scalewhich		allvals/novals/ptrvals/ptr/noptr/none
			Specifies the axes and events affected by the "scale"
			control.    Scalewhich "allvals" scales all extension
			device valuators (meaningless for scale-to-fit).   
			Scalewhich "novals" doesn't scale any extension device
			valuators.   Scalewhich "ptrvals" scales only the 
			extension valuators which correspond to the core pointer
			X and Y axes.    Scalewhich "ptr" means to scale the
			core pointer X and Y values and "noptr" means no
			to.   Scalewhich "none" means don't scale anything.
			The effects of this control are cumulative, so you
			can issue several.

    autostart		on/off
			Specifies whether (on) or not (off) the device is
			opened automatically by the X server or not (IRIX4.0.5
			and later only).  Extension devices are normally 
			ignored until some client explicitly opens them, but
			you can change that using this directive.  This allows
			you to use several devices to control the cursor
			simultaneously without explicitly opening the 
			extension devices you want to be alive.

Here are some of the more common device_init controls.  Any control which
changes the observed characteristics of the device should be issued only
as a "device_init" control because the X server has already asked the
device to describe itself when it issues the "x_init" controls and it
will not notice the changes.  "Observed chararcteristics" include number
of axes, buttons or keys or the range of the devices axes; they do *not*
include controls which change the way that physical device events are
mapped onto X events.


    pressure		on/off
			For pressure sensitive tablets.   Start/stop reporting
			pressure (and tilt/height in some cases) information.
			This option adds axes (for the pen pressure value) to
			a device, so it should be a device_init option.

    btnpressure		<pressure>
			For pressure sensitive tablets.  Specifies the
			threshold above which the tip pressure generates a
			button event.  Note that this is a raw 8 bit
			integer, *not* an ascii decimal number.  To set the
			tip button pressure to '5', use '^E' (control-E),
			NOT '5'.  This option controls the mapping of
			physical pressure events on to X button events, but
			it does *not* affect the observed characteristics of
			the device.  It can safely be used as either an
			x_init or a device_init option.

    invert		<axes to invert>
			Where <axes to invert> is a (case sensitive) string 
			of characters which specifies the axes to be inverted.
			An 'x' means invert the X axis in core pointer events,
			a 'y' means invert the Y axis.  A single digit '0'-'9'
			means invert the corresponding axis in extension 
			events.   A '!' in the string reverses the 
			interpretation of all following characters in the
			string.   For example "y1" means: invert the Y axis
			in core events and axis 1 in extension events (leave
			all other axes alone).   A "y!x" means: invert the
			Y axis in core events but do not invert the X axis;
			in this case, extension events are not affected.
			Affects mapping only, so it can be either x_init or
			device_init.

    left/right/top/bottom		<offset>
			Primarily for tablet devices.  Specifies a dead margin
			(in raw device coordinates) around the edges of the
			tablet.  These requests change the apparent size
			of the tablet surface so they should be device_init
			options only.

    scale[xXyY0-9]	<scale factor>

			Control scaling on an axis by axis basis.  To use
			this, first set scalewhich "none" in the X server
			so the X server doesn't clobber your values.
			For example:
			   scalex "1/5" scales core pointer x events by one
					fifth.
			   scale4 "5"   scales extension valuator 4 events
					by 5.
			Note that changing scaling does not affect the range
			of the valuator -- extension valuators are clamped to
			the range of the device.   In other words, if you 
			scale a tablet axis by 5, you'll only be able to use 
			one-fifth of the tablets surface in the corresponding
			direction.  These affect mapping only, so they can
			be device_init or x_init.

    max[xXyY0-9]	<maximum value>
			Changes the maximum value for the corresponding 
			valuators.   Note that "maxx" and "maxy" change the
			axes that correspond to the core pointer axes, not
			the core pointer events themselves.   In other words,
			you can't use this request to get illegal core pointer 
			events (core pointer events are always restricted to
			the screen).  device_init only.

    model		<vendor specific>
			Specifies the model of the device so the driver can
			do model specific things.   Unfortunately, probing
			a device from the kernel is pretty messy, so we use
			this control in a configuration file to specify the
			type of device attached (for now).  device_init only.

EXAMPLES:

  The calcomp tablet uses a streams module named "calcomp" but reports an X
  name of "tablet" so that the GL recognizes calcomp events correctly.  The
  drawing pad II is 7" by 7" and has a resolution of 1000 points per inch.
  To scale raw tablet events to screen coordinates (1280x1024) we create
  /usr/lib/X11/input/config/tablet (name of *X* device) with the contents:

	x_init {
	    scalewhich	"none"
	    scalex	"914/5000"
	    scaley	"914/5000"
	    scale0	"914/5000"
	    scale1	"914/5000"
        }

  To make the calcomp tablet control the cursor automatically, we would add
  the lines:

	pushpointer	"on"
	autostart	"on"

  If we wanted a 1" margin around the tablet, we'd create a device_init
  file (/usr/lib/X11/input/config/calcomp) with the contents:

	device_init {
	    left	"1000"
	    right	"1000"
	    top		"1000"
	    bottom	"1000"
        }

  Of course, this reduces the tablet surface by 2000 units in each
  direction, so we'd have to recalculate scale[xy01] values for the x_init
  options to get the mapping right.

  If we wanted to do the same thing for the Hitachi tablet, (streams module
  == tablet, X name == tablet) we'd put both the x_init and device_init
  sections in the same file (/usr/lib/X11/input/config/tablet).
