📄 gdk-input-devices.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Input Devices</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="GDK Reference Manual"><link rel="up" href="reference.html" title="API Reference"><link rel="prev" href="gdk-Input.html" title="Input"><link rel="next" href="gdk-Pango-Interaction.html" title="Pango Interaction"><meta name="generator" content="GTK-Doc V1.9 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="reference" href="reference.html" title="API Reference"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"><link rel="index" href="ix06.html" title="Index of new symbols in 2.8"><link rel="index" href="ix07.html" title="Index of new symbols in 2.10"><link rel="index" href="ix08.html" title="Index of new symbols in 2.12"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="gdk-Input.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GDK Reference Manual</th><td><a accesskey="n" href="gdk-Pango-Interaction.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr><tr><td colspan="5" class="shortcuts"><nobr><a href="#id3286964" class="shortcut">Top</a>  |  <a href="#id3287451" class="shortcut">Description</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="gdk-Input-Devices"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id3286964"></a><span class="refentrytitle">Input Devices</span></h2><p>Input Devices — Functions for handling extended input devices</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include <gdk/gdk.h> <a class="link" href="gdk-Input-Devices.html#GdkDevice">GdkDevice</a>;enum <a class="link" href="gdk-Input-Devices.html#GdkInputSource">GdkInputSource</a>;enum <a class="link" href="gdk-Input-Devices.html#GdkInputMode">GdkInputMode</a>; <a class="link" href="gdk-Input-Devices.html#GdkDeviceKey">GdkDeviceKey</a>; <a class="link" href="gdk-Input-Devices.html#GdkDeviceAxis">GdkDeviceAxis</a>;enum <a class="link" href="gdk-Input-Devices.html#GdkAxisUse">GdkAxisUse</a>;<ahref="/usr/share/gtk-doc/html/glib/glib-Doubly-Linked-Lists.html#GList">GList</a>* <a class="link" href="gdk-Input-Devices.html#gdk-devices-list">gdk_devices_list</a> (void);void <a class="link" href="gdk-Input-Devices.html#gdk-device-set-source">gdk_device_set_source</a> (<a class="link" href="gdk-Input-Devices.html#GdkDevice">GdkDevice</a> *device, <a class="link" href="gdk-Input-Devices.html#GdkInputSource">GdkInputSource</a> source);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="gdk-Input-Devices.html#gdk-device-set-mode">gdk_device_set_mode</a> (<a class="link" href="gdk-Input-Devices.html#GdkDevice">GdkDevice</a> *device, <a class="link" href="gdk-Input-Devices.html#GdkInputMode">GdkInputMode</a> mode);void <a class="link" href="gdk-Input-Devices.html#gdk-device-set-key">gdk_device_set_key</a> (<a class="link" href="gdk-Input-Devices.html#GdkDevice">GdkDevice</a> *device, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> index_, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> keyval, <a class="link" href="gdk-Windows.html#GdkModifierType">GdkModifierType</a> modifiers);void <a class="link" href="gdk-Input-Devices.html#gdk-device-set-axis-use">gdk_device_set_axis_use</a> (<a class="link" href="gdk-Input-Devices.html#GdkDevice">GdkDevice</a> *device, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> index_, <a class="link" href="gdk-Input-Devices.html#GdkAxisUse">GdkAxisUse</a> use);<a class="link" href="gdk-Input-Devices.html#GdkDevice">GdkDevice</a>* <a class="link" href="gdk-Input-Devices.html#gdk-device-get-core-pointer">gdk_device_get_core_pointer</a> (void);void <a class="link" href="gdk-Input-Devices.html#gdk-device-get-state">gdk_device_get_state</a> (<a class="link" href="gdk-Input-Devices.html#GdkDevice">GdkDevice</a> *device, <a class="link" href="gdk-Windows.html#GdkWindow">GdkWindow</a> *window, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gdouble">gdouble</a> *axes, <a class="link" href="gdk-Windows.html#GdkModifierType">GdkModifierType</a> *mask);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="gdk-Input-Devices.html#gdk-device-get-history">gdk_device_get_history</a> (<a class="link" href="gdk-Input-Devices.html#GdkDevice">GdkDevice</a> *device, <a class="link" href="gdk-Windows.html#GdkWindow">GdkWindow</a> *window, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint32">guint32</a> start, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint32">guint32</a> stop, <a class="link" href="gdk-Input-Devices.html#GdkTimeCoord">GdkTimeCoord</a> ***events, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> *n_events);void <a class="link" href="gdk-Input-Devices.html#gdk-device-free-history">gdk_device_free_history</a> (<a class="link" href="gdk-Input-Devices.html#GdkTimeCoord">GdkTimeCoord</a> **events, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> n_events); <a class="link" href="gdk-Input-Devices.html#GdkTimeCoord">GdkTimeCoord</a>;<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="gdk-Input-Devices.html#gdk-device-get-axis">gdk_device_get_axis</a> (<a class="link" href="gdk-Input-Devices.html#GdkDevice">GdkDevice</a> *device, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gdouble">gdouble</a> *axes, <a class="link" href="gdk-Input-Devices.html#GdkAxisUse">GdkAxisUse</a> use, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gdouble">gdouble</a> *value);void <a class="link" href="gdk-Input-Devices.html#gdk-input-set-extension-events">gdk_input_set_extension_events</a> (<a class="link" href="gdk-Windows.html#GdkWindow">GdkWindow</a> *window, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> mask, <a class="link" href="gdk-Input-Devices.html#GdkExtensionMode">GdkExtensionMode</a> mode);enum <a class="link" href="gdk-Input-Devices.html#GdkExtensionMode">GdkExtensionMode</a>;</pre></div><div class="refsect1" lang="en"><a name="id3287451"></a><h2>Description</h2><p>In addition to the normal keyboard and mouse input devices, GTK+ alsocontains support for <em class="firstterm">extended input devices</em>. Inparticular, this support is targeted at graphics tablets. Graphicstablets typically return sub-pixel positioning information and possiblyinformation about the pressure and tilt of the stylus. UnderX, the support for extended devices is done through the <em class="firstterm">XInput</em> extension.</p><p>Because handling extended input devices may involve considerableoverhead, they need to be turned on for each <a class="link" href="gdk-Windows.html#GdkWindow"><span class="type">GdkWindow</span></a>individually using <a class="link" href="gdk-Input-Devices.html#gdk-input-set-extension-events"><code class="function">gdk_input_set_extension_events()</code></a>.(Or, more typically, for GtkWidgets, using <ahref="/usr/share/gtk-doc/html/gtk/GtkWidget.html#gtk-widget-set-extension-events"><code class="function">gtk_widget_set_extension_events()</code></a>).As an additional complication, depending on the support fromthe windowing system, its possible that a normal mousecursor will not be displayed for a particular extensiondevice. If an application does not want to deal with displayinga cursor itself, it can ask only to get extension eventsfrom devices that will display a cursor, by passing the<a class="link" href="gdk-Input-Devices.html#GDK-EXTENSION-EVENTS-CURSOR:CAPS"><code class="literal">GDK_EXTENSION_EVENTS_CURSOR</code></a> value to<a class="link" href="gdk-Input-Devices.html#gdk-input-set-extension-events"><code class="function">gdk_input_set_extension_events()</code></a>. Otherwise, the applicationmust retrieve the device information using <a class="link" href="gdk-Input-Devices.html#gdk-devices-list"><code class="function">gdk_devices_list()</code></a>,check the <em class="structfield"><code>has_cursor</code></em> field, and, if it is <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>, draw a cursor itself when it receives motion events.</p><p>Each pointing device is assigned a unique integer ID; events from aparticular device can be identified by the<em class="structfield"><code>deviceid</code></em> field in the event structure. Theevents generated by pointer devices have also been extended to contain<em class="structfield"><code>pressure</code></em>, <em class="structfield"><code>xtilt</code></em>and <em class="structfield"><code>ytilt</code></em> fields which contain the extendedinformation reported as additional <em class="firstterm">valuators</em>from the device. The <em class="structfield"><code>pressure</code></em> field is a a double value ranging from 0.0 to 1.0, while the tilt fields aredouble values ranging from -1.0 to 1.0. (With -1.0 representing themaximum tilt to the left or up, and 1.0 representing the maximumtilt to the right or down.)</p><p>One additional field in each event is the<em class="structfield"><code>source</code></em> field, which contains anenumeration value describing the type of device; this currentlycan be one of <a class="link" href="gdk-Input-Devices.html#GDK-SOURCE-MOUSE:CAPS"><code class="literal">GDK_SOURCE_MOUSE</code></a>, <a class="link" href="gdk-Input-Devices.html#GDK-SOURCE-PEN:CAPS"><code class="literal">GDK_SOURCE_PEN</code></a>, <a class="link" href="gdk-Input-Devices.html#GDK-SOURCE-ERASER:CAPS"><code class="literal">GDK_SOURCE_ERASER</code></a>,or <a class="link" href="gdk-Input-Devices.html#GDK-SOURCE-CURSOR:CAPS"><code class="literal">GDK_SOURCE_CURSOR</code></a>. This field is present to allow simpleapplications to (for instance) delete when they detect eraserdevices without having to keep track of complicated per-devicesettings.</p><p>Various aspects of each device may be configured. The easiest way ofcreating a GUI to allow the user to configure such a deviceis to use the <ahref="/usr/share/gtk-doc/html/gtk/GtkInputDialog.html"><span class="type">GtkInputDialog</span></a> widget in GTK+. However, even when using this widget, application writerswill need to directly query and set the configuration parametersin order to save the state between invocations of the application.The configuration of devices is queried using <a class="link" href="gdk-Input-Devices.html#gdk-devices-list"><code class="function">gdk_devices_list()</code></a>.Each device must be activated using <a class="link" href="gdk-Input-Devices.html#gdk-device-set-mode"><code class="function">gdk_device_set_mode()</code></a>, whichalso controls whether the device's range is mapped to theentire screen or to a single window. The mapping of the valuators ofthe device onto the predefined valuator types is set using<a class="link" href="gdk-Input-Devices.html#gdk-device-set-axis-use"><code class="function">gdk_device_set_axis_use()</code></a>. And the source type for each devicecan be set with <a class="link" href="gdk-Input-Devices.html#gdk-device-set-source"><code class="function">gdk_device_set_source()</code></a>.</p><p>Devices may also have associated <em class="firstterm">keys</em>or macro buttons. Such keys can be globally set to mapinto normal X keyboard events. The mapping is set using<a class="link" href="gdk-Input-Devices.html#gdk-device-set-key"><code class="function">gdk_device_set_key()</code></a>.</p><p>The interfaces in this section will most likely be considerablymodified in the future to accomodate devices that may have differentsets of additional valuators than the pressure <em class="structfield"><code>xtilt</code></em>and <em class="structfield"><code>ytilt</code></em>.</p></div><div class="refsect1" lang="en"><a name="id3287771"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3287781"></a><h3><a name="GdkDevice"></a>GdkDevice</h3><a class="indexterm" name="id3287793"></a><pre class="programlisting">typedef struct { 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;} GdkDevice;</pre><p>A <span class="structname">GdkDevice</span> structure containsa detailed description of an extended input device. Allfields are read-only; but you can use <a class="link" href="gdk-Input-Devices.html#gdk-device-set-source"><code class="function">gdk_device_set_source()</code></a>,<a class="link" href="gdk-Input-Devices.html#gdk-device-set-mode"><code class="function">gdk_device_set_mode()</code></a>, <a class="link" href="gdk-Input-Devices.html#gdk-device-set-key"><code class="function">gdk_device_set_key()</code></a> and <a class="link" href="gdk-Input-Devices.html#gdk-device-set-axis-use"><code class="function">gdk_device_set_axis_use()</code></a>to configure various aspects of the device.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a> <em class="structfield"><code>parent_instance</code></em>;</span></p></td><td>the parent instance</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *<em class="structfield"><code>name</code></em>;</span></p></td><td>the name of this device.</td></tr><tr><td><p><span class="term"><a class="link" href="gdk-Input-Devices.html#GdkInputSource">GdkInputSource</a> <em class="structfield"><code>source</code></em>;</span></p></td><td>the type of this device.</td></tr><tr><td><p><span class="term"><a class="link" href="gdk-Input-Devices.html#GdkInputMode">GdkInputMode</a> <em class="structfield"><code>mode</code></em>;</span></p></td><td>the mode of this device</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> <em class="structfield"><code>has_cursor</code></em>;</span></p></td><td><ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the pointer follows device motion.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <em class="structfield"><code>num_axes</code></em>;</span></p></td><td>the length of the <em class="parameter"><code>axes</code></em> array.</td></tr><tr><td><p><span class="term"><a class="link" href="gdk-Input-Devices.html#GdkDeviceAxis">GdkDeviceAxis</a> *<em class="structfield"><code>axes</code></em>;</span></p></td><td>an array of <a class="link" href="gdk-Input-Devices.html#GdkDeviceAxis"><span class="type">GdkDeviceAxis</span></a>, describing the axes of this device.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <em class="structfield"><code>num_keys</code></em>;</span></p></td><td>the length of the <em class="parameter"><code>keys</code></em> array.</td></tr><tr><td><p><span class="term"><a class="link" href="gdk-Input-Devices.html#GdkDeviceKey">GdkDeviceKey</a> *<em class="structfield"><code>keys</code></em>;</span></p></td><td>an array of <a class="link" href="gdk-Input-Devices.html#GdkDeviceKey"><span class="type">GdkDeviceKey</span></a>, describing the mapped macro buttons of this device.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3288092"></a><h3><a name="GdkInputSource"></a>enum GdkInputSource</h3><a class="indexterm" name="id3288105"></a><pre class="programlisting">typedef enum{ GDK_SOURCE_MOUSE, GDK_SOURCE_PEN, GDK_SOURCE_ERASER, GDK_SOURCE_CURSOR} GdkInputSource;</pre><p>An enumeration describing the type of an input devicein general terms.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a name="GDK-SOURCE-MOUSE:CAPS"></a><code class="literal">GDK_SOURCE_MOUSE</code></span></p></td><td>the device is a mouse. (This will be reported for the core pointer, even if it is something else, such as a trackball.)</td></tr><tr><td><p><span class="term"><a name="GDK-SOURCE-PEN:CAPS"></a><code class="literal">GDK_SOURCE_PEN</code></span></p></td><td>the device is a stylus of a graphics tablet or similar device.</td></tr><tr><td><p><span class="term"><a name="GDK-SOURCE-ERASER:CAPS"></a><code class="literal">GDK_SOURCE_ERASER</code></span></p></td><td>the device is an eraser. Typically, this would be the other end of a stylus on a graphics tablet.</td></tr><tr><td><p><span class="term"><a name="GDK-SOURCE-CURSOR:CAPS"></a><code class="literal">GDK_SOURCE_CURSOR</code></span></p></td><td>the device is a graphics tablet "puck" or similar device.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -