]> Pileus Git - ~andy/gtk/blob - gdk/directfb/gdkinput-directfb.c
Include "config.h" instead of <config.h> Command used: find -name
[~andy/gtk] / gdk / directfb / gdkinput-directfb.c
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  * Copyright (C) 1999 Tor Lillqvist
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 /*
22  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
23  * file for a list of people on the GTK+ Team.
24  */
25
26 /*
27  * GTK+ DirectFB backend
28  * Copyright (C) 2001-2002  convergence integrated media GmbH
29  * Copyright (C) 2002-2004  convergence GmbH
30  * Written by Denis Oliver Kropp <dok@convergence.de> and
31  *            Sven Neumann <sven@convergence.de>
32  */
33
34 #include "config.h"
35 #include "gdk.h"
36
37 #include "gdkdirectfb.h"
38 #include "gdkprivate-directfb.h"
39 #include "gdkinput-directfb.h"
40
41 #include "gdkinput.h"
42 #include "gdkkeysyms.h"
43 #include "gdkalias.h"
44
45
46 static GdkDeviceAxis gdk_input_core_axes[] =
47 {
48   { GDK_AXIS_X, 0, 0 },
49   { GDK_AXIS_Y, 0, 0 }
50 };
51
52
53 GdkDevice     * _gdk_core_pointer       = NULL;
54 GList         * _gdk_input_devices      = NULL;
55 gboolean        _gdk_input_ignore_core  = FALSE;
56
57 int             _gdk_directfb_mouse_x   = 0;
58 int             _gdk_directfb_mouse_y   = 0;
59
60
61 void
62 _gdk_init_input_core (void)
63 {
64  GdkDisplay *display = GDK_DISPLAY_OBJECT(_gdk_display);
65   _gdk_core_pointer = g_object_new (GDK_TYPE_DEVICE, NULL);
66
67   _gdk_core_pointer->name       = "Core Pointer";
68   _gdk_core_pointer->source     = GDK_SOURCE_MOUSE;
69   _gdk_core_pointer->mode       = GDK_MODE_SCREEN;
70   _gdk_core_pointer->has_cursor = TRUE;
71   _gdk_core_pointer->num_axes   = 2;
72   _gdk_core_pointer->axes       = gdk_input_core_axes;
73   _gdk_core_pointer->num_keys   = 0;
74   _gdk_core_pointer->keys       = NULL;
75   display->core_pointer         = _gdk_core_pointer;
76 }
77
78 static void
79 gdk_device_finalize (GObject *object)
80 {
81   g_error ("A GdkDevice object was finalized. This should not happen");
82 }
83
84 static void
85 gdk_device_class_init (GObjectClass *class)
86 {
87   class->finalize = gdk_device_finalize;
88 }
89
90 GType
91 gdk_device_get_type (void)
92 {
93   static GType object_type = 0;
94
95   if (!object_type)
96     {
97       static const GTypeInfo object_info =
98       {
99         sizeof (GdkDeviceClass),
100         (GBaseInitFunc) NULL,
101         (GBaseFinalizeFunc) NULL,
102         (GClassInitFunc) gdk_device_class_init,
103         NULL,           /* class_finalize */
104         NULL,           /* class_data */
105         sizeof (GdkDevice),
106         0,              /* n_preallocs */
107         (GInstanceInitFunc) NULL,
108       };
109
110       object_type = g_type_register_static (G_TYPE_OBJECT,
111                                             "GdkDevice",
112                                             &object_info, 0);
113     }
114
115   return object_type;
116 }
117
118
119 void
120 _gdk_input_init (void)
121 {
122   _gdk_init_input_core ();
123   _gdk_input_devices = g_list_append (NULL, _gdk_core_pointer);
124   _gdk_input_ignore_core = FALSE;
125 }
126
127 void
128 _gdk_input_exit (void)
129 {
130   GList     *tmp_list;
131   GdkDevice *gdkdev;
132
133   for (tmp_list = _gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
134     {
135       gdkdev = (GdkDevice *)(tmp_list->data);
136       if (!GDK_IS_CORE (gdkdev))
137         {
138           gdk_device_set_mode ((GdkDevice *)gdkdev, GDK_MODE_DISABLED);
139
140           g_free (gdkdev->name);
141           g_free (gdkdev->axes);
142           g_free (gdkdev->keys);
143           g_free (gdkdev);
144         }
145     }
146
147   g_list_free (_gdk_input_devices);
148 }
149
150 /**
151  * gdk_device_get_axis:
152  * @device: a #GdkDevice
153  * @axes: pointer to an array of axes
154  * @use: the use to look for
155  * @value: location to store the found value.
156  *
157  * Interprets an array of double as axis values for a given device,
158  * and locates the value in the array for a given axis use.
159  *
160  * Return value: %TRUE if the given axis use was found, otherwise %FALSE
161  **/
162 gboolean
163 gdk_device_get_axis (GdkDevice  *device,
164                      gdouble    *axes,
165                      GdkAxisUse  use,
166                      gdouble    *value)
167 {
168   gint i;
169   g_return_val_if_fail (device != NULL, FALSE);
170
171   if (axes == NULL)
172     return FALSE;
173
174   for (i = 0; i < device->num_axes; i++)
175     if (device->axes[i].use == use)
176       {
177         if (value)
178           *value = axes[i];
179         return TRUE;
180       }
181
182   return FALSE;
183 }
184
185 void
186 gdk_device_set_key (GdkDevice       *device,
187                     guint            index,
188                     guint            keyval,
189                     GdkModifierType  modifiers)
190 {
191   g_return_if_fail (device != NULL);
192   g_return_if_fail (index < device->num_keys);
193
194   device->keys[index].keyval    = keyval;
195   device->keys[index].modifiers = modifiers;
196 }
197
198 void
199 gdk_device_set_axis_use (GdkDevice   *device,
200                          guint        index,
201                          GdkAxisUse   use)
202 {
203   g_return_if_fail (device != NULL);
204   g_return_if_fail (index < device->num_axes);
205
206   device->axes[index].use = use;
207
208   switch (use)
209     {
210     case GDK_AXIS_X:
211     case GDK_AXIS_Y:
212       device->axes[index].min =  0.0;
213       device->axes[index].max =  0.0;
214       break;
215     case GDK_AXIS_XTILT:
216     case GDK_AXIS_YTILT:
217       device->axes[index].min = -1.0;
218       device->axes[index].max =  1.0;
219       break;
220     default:
221       device->axes[index].min =  0.0;
222       device->axes[index].max =  1.0;
223       break;
224     }
225 }
226
227 gboolean
228 gdk_device_set_mode (GdkDevice    *device,
229                      GdkInputMode  mode)
230 {
231   g_message ("unimplemented %s", __FUNCTION__);
232
233   return FALSE;
234 }
235
236 gboolean
237 gdk_device_get_history  (GdkDevice      *device,
238                          GdkWindow      *window,
239                          guint32         start,
240                          guint32         stop,
241                          GdkTimeCoord ***events,
242                          gint           *n_events)
243 {
244   g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
245   g_return_val_if_fail (events != NULL, FALSE);
246   g_return_val_if_fail (n_events != NULL, FALSE);
247
248   *n_events = 0;
249   *events = NULL;
250
251   if (GDK_WINDOW_DESTROYED (window))
252     return FALSE;
253
254   if (GDK_IS_CORE (device))
255     return FALSE;
256   else
257     return FALSE;
258   //TODODO_gdk_device_get_history (device, window, start, stop, events, n_events);
259 }
260
261 void
262 gdk_device_free_history (GdkTimeCoord **events,
263                          gint           n_events)
264 {
265   gint i;
266
267   for (i = 0; i < n_events; i++)
268     g_free (events[i]);
269
270   g_free (events);
271 }
272
273 void
274 gdk_device_get_state (GdkDevice       *device,
275                       GdkWindow       *window,
276                       gdouble         *axes,
277                       GdkModifierType *mask)
278 {
279   g_return_if_fail (device != NULL);
280   g_return_if_fail (GDK_IS_WINDOW (window));
281
282   if (mask)
283     *mask = _gdk_directfb_modifiers;
284 }
285
286 void
287 gdk_directfb_mouse_get_info (gint            *x,
288                              gint            *y,
289                              GdkModifierType *mask)
290 {
291   if (x)
292     *x = _gdk_directfb_mouse_x;
293
294   if (y)
295     *y = _gdk_directfb_mouse_y;
296
297   if (mask)
298     *mask = _gdk_directfb_modifiers;
299 }
300
301 void
302 gdk_input_set_extension_events (GdkWindow        *window,
303                                 gint              mask,
304                                 GdkExtensionMode  mode)
305 {
306   g_message ("unimplemented %s", __FUNCTION__);
307 }
308
309 GList *
310 gdk_devices_list (void)
311 {
312   return _gdk_input_devices;
313 }
314
315
316 GList *
317 gdk_display_list_devices (GdkDisplay *dpy)
318 {
319   return _gdk_input_devices;
320 }
321
322 void
323 gdk_device_set_source (GdkDevice      *device,
324                        GdkInputSource  source)
325 {
326   g_return_if_fail (device != NULL);
327   device->source = source;
328 }
329
330 #define __GDK_INPUT_NONE_C__
331 #define __GDK_INPUT_C__
332 #include "gdkaliasdef.c"