1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * Copyright (C) 1999 Tor Lillqvist
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.
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.
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.
22 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
23 * file for a list of people on the GTK+ Team.
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>
37 #include "gdkdirectfb.h"
38 #include "gdkprivate-directfb.h"
39 #include "gdkinput-directfb.h"
42 #include "gdkkeysyms.h"
46 static GdkDeviceAxis gdk_input_core_axes[] =
53 GdkDevice * _gdk_core_pointer = NULL;
54 GList * _gdk_input_devices = NULL;
55 gboolean _gdk_input_ignore_core = FALSE;
57 int _gdk_directfb_mouse_x = 0;
58 int _gdk_directfb_mouse_y = 0;
62 _gdk_init_input_core (void)
64 GdkDisplay *display = GDK_DISPLAY_OBJECT(_gdk_display);
65 _gdk_core_pointer = g_object_new (GDK_TYPE_DEVICE, NULL);
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;
79 gdk_device_finalize (GObject *object)
81 g_error ("A GdkDevice object was finalized. This should not happen");
85 gdk_device_class_init (GObjectClass *class)
87 class->finalize = gdk_device_finalize;
91 gdk_device_get_type (void)
93 static GType object_type = 0;
97 const GTypeInfo object_info =
99 sizeof (GdkDeviceClass),
100 (GBaseInitFunc) NULL,
101 (GBaseFinalizeFunc) NULL,
102 (GClassInitFunc) gdk_device_class_init,
103 NULL, /* class_finalize */
104 NULL, /* class_data */
107 (GInstanceInitFunc) NULL,
110 object_type = g_type_register_static (G_TYPE_OBJECT,
120 _gdk_input_init (void)
122 _gdk_init_input_core ();
123 _gdk_input_devices = g_list_append (NULL, _gdk_core_pointer);
124 _gdk_input_ignore_core = FALSE;
128 _gdk_input_exit (void)
133 for (tmp_list = _gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
135 gdkdev = (GdkDevice *)(tmp_list->data);
136 if (!GDK_IS_CORE (gdkdev))
138 gdk_device_set_mode ((GdkDevice *)gdkdev, GDK_MODE_DISABLED);
140 g_free (gdkdev->name);
141 g_free (gdkdev->axes);
142 g_free (gdkdev->keys);
147 g_list_free (_gdk_input_devices);
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.
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.
160 * Return value: %TRUE if the given axis use was found, otherwise %FALSE
163 gdk_device_get_axis (GdkDevice *device,
169 g_return_val_if_fail (device != NULL, FALSE);
174 for (i = 0; i < device->num_axes; i++)
175 if (device->axes[i].use == use)
186 gdk_device_set_key (GdkDevice *device,
189 GdkModifierType modifiers)
191 g_return_if_fail (device != NULL);
192 g_return_if_fail (index < device->num_keys);
194 device->keys[index].keyval = keyval;
195 device->keys[index].modifiers = modifiers;
199 gdk_device_set_axis_use (GdkDevice *device,
203 g_return_if_fail (device != NULL);
204 g_return_if_fail (index < device->num_axes);
206 device->axes[index].use = use;
212 device->axes[index].min = 0.0;
213 device->axes[index].max = 0.0;
217 device->axes[index].min = -1.0;
218 device->axes[index].max = 1.0;
221 device->axes[index].min = 0.0;
222 device->axes[index].max = 1.0;
228 gdk_device_set_mode (GdkDevice *device,
231 g_message ("unimplemented %s", G_STRFUNC);
237 gdk_device_get_history (GdkDevice *device,
241 GdkTimeCoord ***events,
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);
251 if (GDK_WINDOW_DESTROYED (window))
254 if (GDK_IS_CORE (device))
258 //TODODO_gdk_device_get_history (device, window, start, stop, events, n_events);
262 gdk_device_free_history (GdkTimeCoord **events,
267 for (i = 0; i < n_events; i++)
274 gdk_device_get_state (GdkDevice *device,
277 GdkModifierType *mask)
279 g_return_if_fail (device != NULL);
280 g_return_if_fail (GDK_IS_WINDOW (window));
283 *mask = _gdk_directfb_modifiers;
287 gdk_directfb_mouse_get_info (gint *x,
289 GdkModifierType *mask)
292 *x = _gdk_directfb_mouse_x;
295 *y = _gdk_directfb_mouse_y;
298 *mask = _gdk_directfb_modifiers;
302 gdk_input_set_extension_events (GdkWindow *window,
304 GdkExtensionMode mode)
306 g_message ("unimplemented %s", G_STRFUNC);
310 gdk_devices_list (void)
312 return _gdk_input_devices;
317 gdk_display_list_devices (GdkDisplay *dpy)
319 return _gdk_input_devices;
323 gdk_device_set_source (GdkDevice *device,
324 GdkInputSource source)
326 g_return_if_fail (device != NULL);
327 device->source = source;
330 #define __GDK_INPUT_NONE_C__
331 #define __GDK_INPUT_C__
332 #include "gdkaliasdef.c"