
@c %start of fragment

@node Input Devices
@chapter Input Devices
Functions for handling extended input devices

@section Overview
In addition to the normal keyboard and mouse input devices, GTK+ also contains
support for @dfn{extended input devices}. In particular, this support is
targeted at graphics tablets. Graphics tablets typically return sub-pixel
positioning information and possibly information about the pressure and tilt of
the stylus. Under X, the support for extended devices is done through the
@dfn{XInput} extension.

Because handling extended input devices may involve considerable overhead, they
need to be turned on for each @code{<gdk-window>} individually using
@code{gdk-input-set-extension-events}. (Or, more typically, for GtkWidgets,
using @code{gtk-widget-set-extension-events}). As an additional complication,
depending on the support from the windowing system, its possible that a normal
mouse cursor will not be displayed for a particular extension device. If an
application does not want to deal with displaying a cursor itself, it can ask
only to get extension events from devices that will display a cursor, by passing
the @samp{GDK_EXTENSION_EVENTS_CURSOR} value to
@code{gdk-input-set-extension-events}. Otherwise, the application must retrieve
the device information using @code{gdk-devices-list}, check the field, and, if
it is @samp{@code{#f}}, draw a cursor itself when it receives motion events.

Each pointing device is assigned a unique integer ID; events from a particular
device can be identified by the field in the event structure. The events
generated by pointer devices have also been extended to contain , and fields
which contain the extended information reported as additional @dfn{valuators}
from the device. The field is a a double value ranging from 0.0 to 1.0, while
the tilt fields are double values ranging from -1.0 to 1.0. (With -1.0
representing the maximum tilt to the left or up, and 1.0 representing the
maximum tilt to the right or down.)

One additional field in each event is the field, which contains an enumeration
value describing the type of device; this currently can be one of
@samp{GDK_SOURCE_MOUSE}, @samp{GDK_SOURCE_PEN}, @samp{GDK_SOURCE_ERASER}, or
@samp{GDK_SOURCE_CURSOR}. This field is present to allow simple applications to
(for instance) delete when they detect eraser devices without having to keep
track of complicated per-device settings.

Various aspects of each device may be configured. The easiest way of creating a
GUI to allow the user to configure such a device is to use the
@code{<gtk-input-dialog>} widget in GTK+. However, even when using this widget,
application writers will need to directly query and set the configuration
parameters in order to save the state between invocations of the application.
The configuration of devices is queried using @code{gdk-devices-list}. Each
device must be activated using @code{gdk-device-set-mode}, which also controls
whether the device's range is mapped to the entire screen or to a single window.
The mapping of the valuators of the device onto the predefined valuator types is
set using @code{gdk-device-set-axis-use}. And the source type for each device
can be set with @code{gdk-device-set-source}.

Devices may also have associated @dfn{keys} or macro buttons. Such keys can be
globally set to map into normal X keyboard events. The mapping is set using
@code{gdk-device-set-key}.

The interfaces in this section will most likely be considerably modified in the
future to accomodate devices that may have different sets of additional
valuators than the pressure and .

@section Usage
@include defuns-input_devices.xml.texi

@c %end of fragment
