]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/input_devices.sgml
e31cd9e1c3508aa396cc629f02ee00b58868a7d2
[~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.
61 The configuration of devices is queried using gdk_devices_list().
62 Each device must be activated using gdk_device_set_mode(), which
63 also controls whether the device's range is mapped to the
64 entire screen or to a single window. The mapping of the valuators of
65 the device onto the predefined valuator types is set using
66 gdk_device_set_axis_use(). And the source type for each device
67 can be set with gdk_device_set_source().
68 </para>
69 <para>
70 Devices may also have associated <firstterm>keys</firstterm>
71 or macro buttons. Such keys can be globally set to map
72 into normal X keyboard events. The mapping is set using
73 gdk_device_set_key().
74 </para>
75 <para>
76 The interfaces in this section will most likely be considerably
77 modified in the future to accomodate devices that may have different
78 sets of additional valuators than the pressure <structfield>xtilt</structfield>
79 and <structfield>ytilt</structfield>.
80 </para>
81
82 <!-- ##### SECTION See_Also ##### -->
83 <para>
84
85 </para>
86
87 <!-- ##### SECTION Stability_Level ##### -->
88
89
90 <!-- ##### SECTION Image ##### -->
91
92
93 <!-- ##### STRUCT GdkDevice ##### -->
94 <para>
95 A <structname>GdkDevice</structname> structure contains
96 a detailed description of an extended input device. All
97 fields are read-only; but you can use gdk_device_set_source(),
98 gdk_device_set_mode(), gdk_device_set_key() and gdk_device_set_axis_use()
99 to configure various aspects of the device.
100 </para>
101
102 @parent_instance: the parent instance
103 @name: the name of this device.
104 @source: the type of this device.
105 @mode: the mode of this device
106 @has_cursor: %TRUE if the pointer follows device motion.
107 @num_axes: the length of the @axes array.
108 @axes: an array of #GdkDeviceAxis, describing the axes of this device.
109 @num_keys: the length of the @keys array.
110 @keys: an array of #GdkDeviceKey, describing the mapped macro buttons 
111   of this device.
112
113 <!-- ##### ENUM GdkInputSource ##### -->
114 <para>
115 An enumeration describing the type of an input device
116 in general terms.
117 </para>
118
119 @GDK_SOURCE_MOUSE: the device is a mouse. (This will be reported for the core
120                     pointer, even if it is something else, such as a trackball.)
121 @GDK_SOURCE_PEN: the device is a stylus of a graphics tablet or similar device.
122 @GDK_SOURCE_ERASER: the device is an eraser. Typically, this would be the other end
123                     of a stylus on a graphics tablet.
124 @GDK_SOURCE_CURSOR: the device is a graphics tablet "puck" or similar device.
125
126 <!-- ##### ENUM GdkInputMode ##### -->
127 <para>
128 An enumeration that describes the mode of an input device.
129 </para>
130
131 @GDK_MODE_DISABLED: the device is disabled and will not report any events.
132 @GDK_MODE_SCREEN: the device is enabled. The device's coordinate space
133                     maps to the entire screen.
134 @GDK_MODE_WINDOW: the device is enabled. The device's coordinate space
135                     is mapped to a single window. The manner in which this window
136                     is chosen is undefined, but it will typically be the same
137                     way in which the focus window for key events is determined.
138
139 <!-- ##### STRUCT GdkDeviceKey ##### -->
140 <para>
141 The <structname>GdkDeviceKey</structname> structure contains information
142 about the mapping of one device macro button onto a normal X key event. 
143 It has the following fields:
144 </para>
145
146 @keyval: the keyval to generate when the macro button is pressed.
147          If this is 0, no keypress will be generated.
148 @modifiers: the modifiers set for the generated key event.
149
150 <!-- ##### STRUCT GdkDeviceAxis ##### -->
151 <para>
152 The <structname>GdkDeviceAxis</structname> structure contains information
153 about the range and mapping of a device axis.
154 </para>
155
156 @use: specifies how the axis is used.
157 @min: the minimal value that will be reported by this axis.
158 @max: the maximal value that will be reported by this axis.
159
160 <!-- ##### ENUM GdkAxisUse ##### -->
161 <para>
162 An enumeration describing the way in which a device
163 axis (valuator) maps onto the predefined valuator
164 types that GTK+ understands.
165 </para>
166
167 @GDK_AXIS_IGNORE: the axis is ignored.
168 @GDK_AXIS_X: the axis is used as the x axis.
169 @GDK_AXIS_Y: the axis is used as the y axis.
170 @GDK_AXIS_PRESSURE: the axis is used for pressure information.
171 @GDK_AXIS_XTILT: the axis is used for x tilt information.
172 @GDK_AXIS_YTILT: the axis is used for x tilt information.
173 @GDK_AXIS_WHEEL: the axis is used for wheel information.
174 @GDK_AXIS_LAST: a constant equal to the numerically highest axis value.
175
176 <!-- ##### FUNCTION gdk_devices_list ##### -->
177 <para>
178 </para>
179
180 @void: 
181 @Returns: 
182
183
184 <!-- ##### FUNCTION gdk_device_set_source ##### -->
185 <para>
186 Sets the source type for an input device.
187 </para>
188
189 @device: a #GdkDevice.
190 @source: the source type.
191
192
193 <!-- ##### FUNCTION gdk_device_set_mode ##### -->
194 <para>
195 Sets a the mode of an input device. The mode controls if the 
196 device is active and whether the device's range is mapped to the
197 entire screen or to a single window.
198 </para>
199
200 @device: a #GdkDevice.
201 @mode: the input mode.
202 @Returns: %TRUE if the mode was successfully changed.
203
204
205 <!-- ##### FUNCTION gdk_device_set_key ##### -->
206 <para>
207 Specifies the X key event to generate when a macro button of a device
208 is pressed.
209 </para>
210
211 @device: a #GdkDevice.
212 @index_: the index of the macro button to set.
213 @keyval: the keyval to generate.
214 @modifiers: the modifiers to set.
215
216
217 <!-- ##### FUNCTION gdk_device_set_axis_use ##### -->
218 <para>
219 Specifies how an axis of a device is used.
220 </para>
221
222 @device: a #GdkDevice.
223 @index_: the index of the axis.
224 @use: specifies how the axis is used.
225
226
227 <!-- ##### FUNCTION gdk_device_get_core_pointer ##### -->
228 <para>
229 </para>
230
231 @void: 
232 @Returns: 
233
234
235 <!-- ##### FUNCTION gdk_device_get_state ##### -->
236
237
238 @device: 
239 @window: 
240 @axes: 
241 @mask: 
242
243
244 <!-- ##### FUNCTION gdk_device_get_history ##### -->
245 <para>
246
247 </para>
248
249 @device: 
250 @window: 
251 @start: 
252 @stop: 
253 @events: 
254 @n_events: 
255 @Returns: 
256
257
258 <!-- ##### FUNCTION gdk_device_free_history ##### -->
259 <para>
260 Frees an array of #GdkTimeCoord that was returned by gdk_device_get_history().
261 </para>
262
263 @events: an array of #GdkTimeCoord.
264 @n_events: the length of the array.
265
266
267 <!-- ##### STRUCT GdkTimeCoord ##### -->
268 <para>
269 The #GdkTimeCoord structure stores a single event in a
270 motion history. It contains the following fields:
271 </para>
272
273 @time: The timestamp for this event.
274 @axes: the values of the device's axes.
275
276 <!-- ##### FUNCTION gdk_device_get_axis ##### -->
277 <para>
278
279 </para>
280
281 @device: 
282 @axes: 
283 @use: 
284 @value: 
285 @Returns: 
286
287
288 <!-- ##### FUNCTION gdk_input_set_extension_events ##### -->
289 <para>
290 Turns extension events on or off for a particular window,
291 and specifies the event mask for extension events.
292 </para>
293
294 @window: a #GdkWindow.
295 @mask: the event mask
296 @mode: the type of extension events that are desired.
297
298
299 <!-- ##### ENUM GdkExtensionMode ##### -->
300 <para>
301 An enumeration used to specify which extension events
302 are desired for a particular widget.
303 </para>
304
305 @GDK_EXTENSION_EVENTS_NONE: no extension events are desired.
306 @GDK_EXTENSION_EVENTS_ALL: all extension events are desired.
307 @GDK_EXTENSION_EVENTS_CURSOR: extension events are desired only if a cursor
308                               will be displayed for the device.
309