In addition to the normal keyboard and mouse input devices,
PyGTK also contains support for 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 XInput extension. Because handling
extended input devices may involve considerable overhead, they need to be
turned on for each
(Or, more typically, for
method). 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
gtk.gdk.EXTENSION_EVENTS_CURSOR value to the
method. Otherwise, the application must retrieve the device information
function, check the has_cursor field, and, if it is
False, draw a cursor itself when it receives motion
Each pointing device is assigned a unique integer ID; events from
a particular device can be identified by the
attribute in the event structure. The events generated by pointer devices
have also been extended to contain
which contain the extended information reported as additional valuators from
the device. The
pressure attribute ranges from 0.0 to
1.0, while the tilt attributes range 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 attribute in each event
source attribute, which contains an
enumeration value describing the type of device; this currently can be one
gtk.gdk.SOURCE_CURSOR. This attribute 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
PyGTK. 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 the
function. Each device must be activated using the
method, 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 the
method. And the source type for each device can be set with the
Devices may also have associated keys or macro buttons. Such keys
can be globally set to map into normal X keyboard events. The mapping is set
method. The interfaces in this section will most likely be considerably
modified in the future to accommodate devices that may have different sets of
additional valuators than the pressure xtilt and ytilt.
|the source type of the
set_source() method sets the source
type for the input device to the value specified by
source. The value of
must be one of:
|the device is a mouse. (This will be reported for the
core pointer, even if it is something else, such as a trackball.)
|the device is a stylus of a graphics tablet or similar
|the device is an eraser. Typically, this would be the
other end of a stylus on a graphics tablet.
|the device is a graphics tablet "puck" or similar
|the input mode
True if the mode was
set_mode() method sets the input
device mode to the value specified by
mode. The value
mode must be one of:
|the device is disabled and will not report any
|the device is enabled. The device's coordinate space
maps to the entire screen.
|the device is enabled. The device's coordinate space is
mapped to a single window. The manner in which this window is chosen is
undefined, but it will typically be the same way in which the focus window
for key events is determined.
|the index of the macro button to
|the key value to generate.
|the modifiers to set.
set_key() method sets the key event
to generate when a macro button of a device is pressed. The macro button is
index. The key value and modifiers
generated are specified by
|the index of the axis.
|how the axis is used.
set_axis_use() method sets the axis
index) of the input device to be used
in the fashion specified by
use. The value of
use must be one of:
|the axis is ignored.
|the axis is used as the x axis.
|the axis is used as the y axis.
|the axis is used for pressure information.
|the axis is used for x tilt information.
|the axis is used for y tilt information.
|the axis is used for wheel information.
|a constant equal to the numerically highest axis
|a tuple containing: a tuple containing the axes
data; and, the modifiers in effect.
get_state() method returns a tuple
- a tuple containing the axes data
- the bitmask containing the set of key modifiers in
The state information is relative to the
|the earliest event time
|the latest event time
|a tuple containing event tuples each with axes
data and a timestamp
get_history() method returns a
tuple containing the motion history for the device with respect to the
specified by window between the time limits specified by
stop. The motion
history is a tuple containing event motion tuples that each contain a
timestamp for the event and a tuple with the axes data for the event.
|a sequence of axes values
|the axis use to match
|the axis value from
that matches the use type or
None if there is no
get_axis() method returns the value
axes whose axis matches the specified