1/* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20/*
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25 */
26
27#ifndef __GDK_INPUT_H__
28#define __GDK_INPUT_H__
29
30#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
31#error "Only <gdk/gdk.h> can be included directly."
32#endif
33
34#include <gdk/gdktypes.h>
35
36G_BEGIN_DECLS
37
38#define GDK_TYPE_DEVICE (gdk_device_get_type ())
39#define GDK_DEVICE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DEVICE, GdkDevice))
40#define GDK_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DEVICE, GdkDeviceClass))
41#define GDK_IS_DEVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DEVICE))
42#define GDK_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DEVICE))
43#define GDK_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DEVICE, GdkDeviceClass))
44
45typedef struct _GdkDeviceKey GdkDeviceKey;
46typedef struct _GdkDeviceAxis GdkDeviceAxis;
47typedef struct _GdkDevice GdkDevice;
48typedef struct _GdkDeviceClass GdkDeviceClass;
49typedef struct _GdkTimeCoord GdkTimeCoord;
50
51typedef enum
52{
53 GDK_EXTENSION_EVENTS_NONE,
54 GDK_EXTENSION_EVENTS_ALL,
55 GDK_EXTENSION_EVENTS_CURSOR
56} GdkExtensionMode;
57
58typedef enum
59{
60 GDK_SOURCE_MOUSE,
61 GDK_SOURCE_PEN,
62 GDK_SOURCE_ERASER,
63 GDK_SOURCE_CURSOR
64} GdkInputSource;
65
66typedef enum
67{
68 GDK_MODE_DISABLED,
69 GDK_MODE_SCREEN,
70 GDK_MODE_WINDOW
71} GdkInputMode;
72
73typedef enum
74{
75 GDK_AXIS_IGNORE,
76 GDK_AXIS_X,
77 GDK_AXIS_Y,
78 GDK_AXIS_PRESSURE,
79 GDK_AXIS_XTILT,
80 GDK_AXIS_YTILT,
81 GDK_AXIS_WHEEL,
82 GDK_AXIS_LAST
83} GdkAxisUse;
84
85struct _GdkDeviceKey
86{
87 guint keyval;
88 GdkModifierType modifiers;
89};
90
91struct _GdkDeviceAxis
92{
93 GdkAxisUse use;
94 gdouble min;
95 gdouble max;
96};
97
98struct _GdkDevice
99{
100 GObject parent_instance;
101 /* All fields are read-only */
102
103 gchar *GSEAL (name);
104 GdkInputSource GSEAL (source);
105 GdkInputMode GSEAL (mode);
106 gboolean GSEAL (has_cursor); /* TRUE if the X pointer follows device motion */
107
108 gint GSEAL (num_axes);
109 GdkDeviceAxis *GSEAL (axes);
110
111 gint GSEAL (num_keys);
112 GdkDeviceKey *GSEAL (keys);
113};
114
115/* We don't allocate each coordinate this big, but we use it to
116 * be ANSI compliant and avoid accessing past the defined limits.
117 */
118#define GDK_MAX_TIMECOORD_AXES 128
119
120struct _GdkTimeCoord
121{
122 guint32 time;
123 gdouble axes[GDK_MAX_TIMECOORD_AXES];
124};
125
126GType gdk_device_get_type (void) G_GNUC_CONST;
127
128#ifndef GDK_MULTIHEAD_SAFE
129/* Returns a list of GdkDevice * */
130GList * gdk_devices_list (void);
131#endif /* GDK_MULTIHEAD_SAFE */
132
133const gchar * gdk_device_get_name (GdkDevice *device);
134GdkInputSource gdk_device_get_source (GdkDevice *device);
135GdkInputMode gdk_device_get_mode (GdkDevice *device);
136gboolean gdk_device_get_has_cursor (GdkDevice *device);
137
138void gdk_device_get_key (GdkDevice *device,
139 guint index,
140 guint *keyval,
141 GdkModifierType *modifiers);
142GdkAxisUse gdk_device_get_axis_use (GdkDevice *device,
143 guint index);
144gint gdk_device_get_n_keys (GdkDevice *device);
145gint gdk_device_get_n_axes (GdkDevice *device);
146
147/* Functions to configure a device */
148void gdk_device_set_source (GdkDevice *device,
149 GdkInputSource source);
150
151gboolean gdk_device_set_mode (GdkDevice *device,
152 GdkInputMode mode);
153
154void gdk_device_set_key (GdkDevice *device,
155 guint index_,
156 guint keyval,
157 GdkModifierType modifiers);
158
159void gdk_device_set_axis_use (GdkDevice *device,
160 guint index_,
161 GdkAxisUse use);
162
163void gdk_device_get_state (GdkDevice *device,
164 GdkWindow *window,
165 gdouble *axes,
166 GdkModifierType *mask);
167
168gboolean gdk_device_get_history (GdkDevice *device,
169 GdkWindow *window,
170 guint32 start,
171 guint32 stop,
172 GdkTimeCoord ***events,
173 gint *n_events);
174
175void gdk_device_free_history (GdkTimeCoord **events,
176 gint n_events);
177gboolean gdk_device_get_axis (GdkDevice *device,
178 gdouble *axes,
179 GdkAxisUse use,
180 gdouble *value);
181
182void gdk_input_set_extension_events (GdkWindow *window,
183 gint mask,
184 GdkExtensionMode mode);
185
186#ifndef GDK_MULTIHEAD_SAFE
187GdkDevice *gdk_device_get_core_pointer (void);
188#endif
189
190G_END_DECLS
191
192#endif /* __GDK_INPUT_H__ */
193