]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/input_devices.sgml
Update for multihead.
[~andy/gtk] / docs / reference / gdk / tmpl / input_devices.sgml
1 <!-- ##### SECTION Title ##### -->
2 Input Devices
3
4 <!-- ##### SECTION Short_Description ##### -->
5 Functions for handling extended input devices.
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 In addition to the normal keyboard and mouse input devices, GTK+ also
10 contains support for <firstterm>extended input devices</firstterm>. In
11 particular, this support is targeted at graphics tablets. Graphics
12 tablets typically return sub-pixel positioning information and possibly
13 information about the pressure and tilt of the stylus. Under
14 X, the support for extended devices is done through the 
15 <firstterm>XInput</firstterm> extension.
16 </para>
17 <para>
18 Because handling extended input devices may involve considerable
19 overhead, they need to be turned on for each #GdkWindow
20 individually using gdk_input_set_extension_events().
21 (Or, more typically, for GtkWidgets, using gtk_widget_set_extension_events()).
22 As an additional complication, depending on the support from
23 the windowing system, its possible that a normal mouse
24 cursor will not be displayed for a particular extension
25 device. If an application does not want to deal with displaying
26 a cursor itself, it can ask only to get extension events
27 from devices that will display a cursor, by passing the
28 %GDK_EXTENSION_EVENTS_CURSOR value to
29 gdk_input_set_extension_events(). Otherwise, the application
30 must retrieve the device information using gdk_devices_list(),
31 check the <structfield>has_cursor</structfield> field, and, 
32 if it is %FALSE, draw a cursor itself when it receives 
33 motion events.
34 </para>
35 <para>
36 Each pointing device is assigned a unique integer ID; events from a
37 particular device can be identified by the
38 <structfield>deviceid</structfield> field in the event structure. The
39 events generated by pointer devices have also been extended to contain
40 <structfield>pressure</structfield>, <structfield>xtilt</structfield>
41 and <structfield>ytilt</structfield> fields which contain the extended
42 information reported as additional <firstterm>valuators</firstterm>
43 from the device. The <structfield>pressure</structfield> field is a 
44 a double value ranging from 0.0 to 1.0, while the tilt fields are
45 double values ranging from -1.0 to 1.0. (With -1.0 representing the
46 maximum tilt to the left or up, and 1.0 representing the maximum
47 tilt to the right or down.)
48 </para>
49 <para>
50 One additional field in each event is the
51 <structfield>source</structfield> field, which contains an
52 enumeration value describing the type of device; this currently
53 can be one of %GDK_SOURCE_MOUSE, %GDK_SOURCE_PEN, %GDK_SOURCE_ERASER,
54 or %GDK_SOURCE_CURSOR. This field is present to allow simple
55 applications to (for instance) delete when they detect eraser
56 devices without having to keep track of complicated per-device
57 settings.
58 </para>
59 <para>
60 Various aspects of each device may be configured. The easiest way of
61 creating a GUI to allow the user to configure such a device
62 is to use the #GtkInputDialog widget in GTK+. 
63 However, even when using this widget, application writers
64 will need to directly query and set the configuration parameters
65 in order to save the state between invocations of the application.
66 The configuration of devices is queried using gdk_devices_list().
67 Each device must be activated using gdk_device_set_mode(), which
68 also controls whether the device's range is mapped to the
69 entire screen or to a single window. The mapping of the valuators of
70 the device onto the predefined valuator types is set using
71 gdk_device_set_axis_use(). And the source type for each device
72 can be set with gdk_device_set_source().
73 </para>
74 <para>
75 Devices may also have associated <firstterm>keys</firstterm>
76 or macro buttons. Such keys can be globally set to map
77 into normal X keyboard events. The mapping is set using
78 gdk_device_set_key().
79 </para>
80 <para>
81 The interfaces in this section will most likely be considerably
82 modified in the future to accomodate devices that may have different
83 sets of additional valuators than the pressure <structfield>xtilt</structfield>
84 and <structfield>ytilt</structfield>.
85 </para>
86
87 <!-- ##### SECTION See_Also ##### -->
88 <para>
89
90 </para>
91
92 <!-- ##### STRUCT GdkDevice ##### -->
93 <para>
94 A <structname>GdkDevice</structname> structure contains
95 a detailed description of an extended input device. All
96 fields are read-only; but you can use gdk_device_set_source(),
97 gdk_device_set_mode(), gdk_device_set_key() and gdk_device_set_axis_use()
98 to configure various aspects of the device.
99 </para>
100
101 @parent_instance: 
102 @name: the name of this device.
103 @source: the type of this device.
104 @mode: the mode of this device
105 @has_cursor: %TRUE if the pointer follows device motion.
106 @num_axes: the length of the @axes array.
107 @axes: an array of #GdkDeviceAxis, describing the axes of this device.
108 @num_keys: the length of the @keys array.
109 @keys: an array of #GdkDeviceKey, describing the mapped macro buttons 
110   of this device.
111
112 <!-- ##### ENUM GdkInputSource ##### -->
113 <para>
114 An enumeration describing the type of an input device
115 in general terms.
116 </para>
117
118 @GDK_SOURCE_MOUSE: the device is a mouse. (This will be reported for the core
119                     pointer, even if it is something else, such as a trackball.)
120 @GDK_SOURCE_PEN: the device is a stylus of a graphics tablet or similar device.
121 @GDK_SOURCE_ERASER: the device is an eraser. Typically, this would be the other end
122                     of a stylus on a graphics tablet.
123 @GDK_SOURCE_CURSOR: the device is a graphics tablet "puck" or similar device.
124
125 <!-- ##### ENUM GdkInputMode ##### -->
126 <para>
127 An enumeration that describes the mode of an input device.
128 </para>
129
130 @GDK_MODE_DISABLED: the device is disabled and will not report any events.
131 @GDK_MODE_SCREEN: the device is enabled. The device's coordinate space
132                     maps to the entire screen.
133 @GDK_MODE_WINDOW: the device is enabled. The device's coordinate space
134                     is mapped to a single window. The manner in which this window
135                     is chosen is undefined, but it will typically be the same
136                     way in which the focus window for key events is determined.
137
138 <!-- ##### STRUCT GdkDeviceKey ##### -->
139 <para>
140 The <structname>GdkDeviceKey</structname> structure contains information
141 about the mapping of one device macro button onto a normal X key event. 
142 It has the following fields:
143 </para>
144
145 @keyval: the keyval to generate when the macro button is pressed.
146          If this is 0, no keypress will be generated.
147 @modifiers: the modifiers set for the generated key event.
148
149 <!-- ##### STRUCT GdkDeviceAxis ##### -->
150 <para>
151 The <structname>GdkDeviceAxis</structname> structure contains information
152 about the range and mapping of a device axis.
153 </para>
154
155 @use: specifies how the axis is used.
156 @min: the minimal value that will be reported by this axis.
157 @max: the maximal value that will be reported by this axis.
158
159 <!-- ##### ENUM GdkAxisUse ##### -->
160 <para>
161 An enumeration describing the way in which a device
162 axis (valuator) maps onto the predefined valuator
163 types that GTK+ understands.
164 </para>
165
166 @GDK_AXIS_IGNORE: the axis is ignored.
167 @GDK_AXIS_X: the axis is used as the x axis.
168 @GDK_AXIS_Y: the axis is used as the y axis.
169 @GDK_AXIS_PRESSURE: the axis is used for pressure information.
170 @GDK_AXIS_XTILT: the axis is used for x tilt information.
171 @GDK_AXIS_YTILT: the axis is used for x tilt information.
172 @GDK_AXIS_WHEEL: the axis is used for wheel information.
173 @GDK_AXIS_LAST: a constant equal to the numerically highest axis value.
174
175 <!-- ##### FUNCTION gdk_devices_list ##### -->
176 <para>
177 </para>
178
179 @Returns: 
180
181
182 <!-- ##### FUNCTION gdk_device_set_source ##### -->
183 <para>
184 Sets the source type for an input device.
185 </para>
186
187 @device: a #GdkDevice.
188 @source: the source type.
189
190
191 <!-- ##### FUNCTION gdk_device_set_mode ##### -->
192 <para>
193 Sets a the mode of an input device. The mode controls if the 
194 device is active and whether the device's range is mapped to the
195 entire screen or to a single window.
196 </para>
197
198 @device: a #GdkDevice.
199 @mode: the input mode.
200 @Returns: %TRUE if the mode was successfully changed.
201
202
203 <!-- ##### FUNCTION gdk_device_set_key ##### -->
204 <para>
205 Specifies the X key event to generate when a macro button of a device
206 is pressed.
207 </para>
208
209 @device: a #GdkDevice.
210 @index: the index of the macro button to set.
211 @keyval: the keyval to generate.
212 @modifiers: the modifiers to set.
213
214
215 <!-- ##### FUNCTION gdk_device_set_axis_use ##### -->
216 <para>
217 Specifies how an axis of a device is used.
218 </para>
219
220 @device: a #GdkDevice.
221 @index: the index of the axis.
222 @use: specifies how the axis is used.
223
224
225 <!-- ##### FUNCTION gdk_device_get_core_pointer ##### -->
226 <para>
227 Returns the device for the core pointer. The device is statically
228 allocated and should not be freed.
229 </para>
230
231 @Returns: a #GdkDevice.
232
233
234 <!-- ##### FUNCTION gdk_device_get_state ##### -->
235 <para>
236 Gets the current state of a device.
237 </para>
238
239 @device: a #GdkDevice.
240 @window: a #GdkWindow.
241 @axes: an array of doubles to store the values of the axes of @device in, 
242   or %NULL.
243 @mask: location to store the modifiers, or %NULL.
244
245
246 <!-- ##### FUNCTION gdk_device_get_history ##### -->
247 <para>
248 Obtains the motion history for a device.
249 </para>
250
251 @device: a #GdkDevice.
252 @window: the window wrt. which the event coordinates will be translated.
253 @start: only return events newer than this timestamp.
254 @stop: only return events older than this timestamp.
255 @events: location to return a newly-allocated array of #GdkTimeCoord.
256 @n_events: location to return the length of @events.
257 @Returns: %TRUE if the @events were successfully filled.
258
259
260 <!-- ##### FUNCTION gdk_device_free_history ##### -->
261 <para>
262 Frees an array of #GdkTimeCoord that was returned by gdk_device_get_history().
263 </para>
264
265 @events: an array of #GdkTimeCoord.
266 @n_events: the length of the array.
267
268
269 <!-- ##### STRUCT GdkTimeCoord ##### -->
270 <para>
271 The #GdkTimeCoord structure stores a single event in a
272 motion history. It contains the following fields:
273 </para>
274
275 @time: The timestamp for this event.
276 @axes: the values of the device's axes.
277
278 <!-- ##### FUNCTION gdk_device_get_axis ##### -->
279 <para>
280
281 </para>
282
283 @device: 
284 @axes: 
285 @use: 
286 @value: 
287 @Returns: 
288
289
290 <!-- ##### FUNCTION gdk_input_set_extension_events ##### -->
291 <para>
292 Turns extension events on or off for a particular window,
293 and specifies the event mask for extension events.
294 </para>
295
296 @window: a #GdkWindow.
297 @mask: the event mask
298 @mode: the type of extension events that are desired.
299
300
301 <!-- ##### ENUM GdkExtensionMode ##### -->
302 <para>
303 An enumeration used to specify which extension events
304 are desired for a particular widget.
305 </para>
306
307 @GDK_EXTENSION_EVENTS_NONE: no extension events are desired.
308 @GDK_EXTENSION_EVENTS_ALL: all extension events are desired.
309 @GDK_EXTENSION_EVENTS_CURSOR: extension events are desired only if a cursor
310                               will be displayed for the device.
311