]> Pileus Git - ~andy/gtk/blob - gdk/gdkinput.h
d5fe003d7ec536835b38cb047b34730f4d8ff6fb
[~andy/gtk] / gdk / gdkinput.h
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 #include <gdk/gdktypes.h>
31
32 G_BEGIN_DECLS
33
34 #define GDK_TYPE_DEVICE              (gdk_device_get_type ())
35 #define GDK_DEVICE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DEVICE, GdkDevice))
36 #define GDK_DEVICE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DEVICE, GdkDeviceClass))
37 #define GDK_IS_DEVICE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DEVICE))
38 #define GDK_IS_DEVICE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DEVICE))
39 #define GDK_DEVICE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DEVICE, GdkDeviceClass))
40
41 typedef struct _GdkDeviceKey        GdkDeviceKey;
42 typedef struct _GdkDeviceAxis       GdkDeviceAxis;
43 typedef struct _GdkDevice           GdkDevice;
44 typedef struct _GdkDeviceClass      GdkDeviceClass;
45 typedef struct _GdkTimeCoord        GdkTimeCoord;
46
47 typedef enum
48 {
49   GDK_EXTENSION_EVENTS_NONE,
50   GDK_EXTENSION_EVENTS_ALL,
51   GDK_EXTENSION_EVENTS_CURSOR
52 } GdkExtensionMode;
53
54 typedef enum
55 {
56   GDK_SOURCE_MOUSE,
57   GDK_SOURCE_PEN,
58   GDK_SOURCE_ERASER,
59   GDK_SOURCE_CURSOR
60 } GdkInputSource;
61
62 typedef enum
63 {
64   GDK_MODE_DISABLED,
65   GDK_MODE_SCREEN,
66   GDK_MODE_WINDOW
67 } GdkInputMode;
68
69 typedef enum
70 {
71   GDK_AXIS_IGNORE,
72   GDK_AXIS_X,
73   GDK_AXIS_Y,
74   GDK_AXIS_PRESSURE,
75   GDK_AXIS_XTILT,
76   GDK_AXIS_YTILT,
77   GDK_AXIS_WHEEL,
78   GDK_AXIS_LAST
79 } GdkAxisUse;
80
81 struct _GdkDeviceKey
82 {
83   guint keyval;
84   GdkModifierType modifiers;
85 };
86
87 struct _GdkDeviceAxis
88 {
89   GdkAxisUse use;
90   gdouble    min;
91   gdouble    max;
92 };
93
94 struct _GdkDevice
95 {
96   GObject parent_instance;
97   /* All fields are read-only */
98           
99   gchar *name;
100   GdkInputSource source;
101   GdkInputMode mode;
102   gboolean has_cursor;       /* TRUE if the X pointer follows device motion */
103           
104   gint num_axes;
105   GdkDeviceAxis *axes;
106           
107   gint num_keys;
108   GdkDeviceKey *keys;
109 };
110
111 /* We don't allocate each coordinate this big, but we use it to
112  * be ANSI compliant and avoid accessing past the defined limits.
113  */
114 #define GDK_MAX_TIMECOORD_AXES 128
115
116 struct _GdkTimeCoord
117 {
118   guint32 time;
119   gdouble axes[GDK_MAX_TIMECOORD_AXES];
120 };
121
122 GType          gdk_device_get_type      (void) G_GNUC_CONST;
123
124 #ifndef GDK_MULTIHEAD_SAFE
125 /* Returns a list of GdkDevice * */       
126 GList *        gdk_devices_list              (void);
127 #endif /* GDK_MULTIHEAD_SAFE */
128
129 /* Functions to configure a device */
130 void           gdk_device_set_source    (GdkDevice      *device,
131                                          GdkInputSource  source);
132           
133 gboolean       gdk_device_set_mode      (GdkDevice      *device,
134                                          GdkInputMode    mode);
135
136 void           gdk_device_set_key       (GdkDevice      *device,
137                                          guint           index_,
138                                          guint           keyval,
139                                          GdkModifierType modifiers);
140
141 void     gdk_device_set_axis_use (GdkDevice         *device,
142                                   guint              index_,
143                                   GdkAxisUse         use);
144 void     gdk_device_get_state    (GdkDevice         *device,
145                                   GdkWindow         *window,
146                                   gdouble           *axes,
147                                   GdkModifierType   *mask);
148 gboolean gdk_device_get_history  (GdkDevice         *device,
149                                   GdkWindow         *window,
150                                   guint32            start,
151                                   guint32            stop,
152                                   GdkTimeCoord    ***events,
153                                   gint              *n_events);
154 void     gdk_device_free_history (GdkTimeCoord     **events,
155                                   gint               n_events);
156 gboolean gdk_device_get_axis     (GdkDevice         *device,
157                                   gdouble           *axes,
158                                   GdkAxisUse         use,
159                                   gdouble           *value);
160
161 void gdk_input_set_extension_events (GdkWindow        *window,
162                                      gint              mask,
163                                      GdkExtensionMode  mode);
164
165 #ifndef GDK_MULTIHEAD_SAFE
166 GdkDevice *gdk_device_get_core_pointer (void);
167 #endif
168  
169 G_END_DECLS
170
171 #endif /* __GDK_INPUT_H__ */