Description
In addition to the normal keyboard and mouse input devices, GTK+ 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 GdkWindow
individually using gdk_input_set_extension_events().
(Or, more typically, for GtkWidgets, using 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
GDK_EXTENSION_EVENTS_CURSOR value to
gdk_input_set_extension_events(). Otherwise, the application
must retrieve the device information using gdk_input_list_devices(),
check the has_cursor field, and,
if it is FALSE, 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
deviceid field in the event structure. The
events generated by pointer devices have also been extended to contain
pressure, xtilt
and ytilt fields which contain the extended
information reported as additional valuators
from the device. The pressure 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 title 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
source field, which contains an
enumeration value describing the type of device; this currently
can be one of
GDK_SOURCE_MOUSE,
GDK_SOURCE_PEN,
GDK_SOURCE_ERASER,
or 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 conifigure such a device
is to use to use the GtkInputDialog 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 gdk_input_list_devices.
Each device must is activated using gdk_input_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
gdk_input_set_axes. And the source type for each device
can be set with gdk_input_set_source().
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 using
gdk_input_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 xtilt and ytilt.
Details
struct GdkDevice
struct GdkDevice
{
GObject parent_instance;
/* All fields are read-only */
gchar *name;
GdkInputSource source;
GdkInputMode mode;
gboolean has_cursor; /* TRUE if the X pointer follows device motion */
gint num_axes;
GdkDeviceAxis *axes;
gint num_keys;
GdkDeviceKey *keys;
}; |
enum GdkInputSource
typedef enum
{
GDK_SOURCE_MOUSE,
GDK_SOURCE_PEN,
GDK_SOURCE_ERASER,
GDK_SOURCE_CURSOR
} GdkInputSource; |
An enumeration describing the type of an input device
in general terms.
enum GdkInputMode
typedef enum
{
GDK_MODE_DISABLED,
GDK_MODE_SCREEN,
GDK_MODE_WINDOW
} GdkInputMode; |
An enumeration that describes the mode of an input device.
struct GdkDeviceKey
struct GdkDeviceKey
{
guint keyval;
GdkModifierType modifiers;
}; |
The GdkDeviceKey structure contains information
about the mapping of one device macro button onto
a normal X key event. It has the following fields:
struct GdkDeviceAxis
struct GdkDeviceAxis
{
GdkAxisUse use;
gdouble min;
gdouble max;
}; |
enum GdkAxisUse
typedef enum
{
GDK_AXIS_IGNORE,
GDK_AXIS_X,
GDK_AXIS_Y,
GDK_AXIS_PRESSURE,
GDK_AXIS_XTILT,
GDK_AXIS_YTILT,
GDK_AXIS_WHEEL,
GDK_AXIS_LAST
} GdkAxisUse; |
An enumeration describing the way in which a device
axis (valuator) maps onto the predefined valuator
types that GTK+ understands.
gdk_devices_list ()
GList* gdk_devices_list (void); |
gdk_device_set_axis_use ()
gdk_device_get_history ()
gdk_device_free_history ()
struct GdkTimeCoord
struct GdkTimeCoord
{
guint32 time;
gdouble axes[GDK_MAX_TIMECOORD_AXES];
}; |
The GdkTimeCoord structure stores a single event in a
motion history. It contains the following fields:
gdk_device_get_axis ()
Interprets an array of double as axis values for a given device,
and locates the value in the array for a given axis use.
gdk_input_set_extension_events ()
Turns extension events on or off for a particular window,
and specifies the event mask for extension events.
enum GdkExtensionMode
typedef enum
{
GDK_EXTENSION_EVENTS_NONE,
GDK_EXTENSION_EVENTS_ALL,
GDK_EXTENSION_EVENTS_CURSOR
} GdkExtensionMode; |
An enumeration used to specify which extension events
are desired for a particular widget.