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