4 * An OpenGL based 'interactive canvas' library.
6 * Copyright (C) 2010 Intel Corp.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 * Author: Damien Lespiau <damien.lespiau@intel.com>
28 #include "clutter/clutter-device-manager-private.h"
29 #include "clutter-private.h"
31 #include "clutter-input-device-evdev.h"
33 typedef struct _ClutterInputDeviceClass ClutterInputDeviceEvdevClass;
34 typedef struct _ClutterInputDeviceEvdevPrivate ClutterInputDeviceEvdevPrivate;
36 #define INPUT_DEVICE_EVDEV_PRIVATE(o) \
37 (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
38 CLUTTER_TYPE_INPUT_DEVICE_EVDEV, \
39 ClutterInputDeviceEvdevPrivate))
51 struct _ClutterInputDeviceEvdevPrivate
57 struct _ClutterInputDeviceEvdev
59 ClutterInputDevice parent;
61 ClutterInputDeviceEvdevPrivate *priv;
64 G_DEFINE_TYPE (ClutterInputDeviceEvdev,
65 clutter_input_device_evdev,
66 CLUTTER_TYPE_INPUT_DEVICE)
68 static GParamSpec *obj_props[PROP_LAST];
71 clutter_input_device_evdev_get_property (GObject *object,
76 ClutterInputDeviceEvdev *input = CLUTTER_INPUT_DEVICE_EVDEV (object);
77 ClutterInputDeviceEvdevPrivate *priv = input->priv;
82 g_value_set_string (value, priv->sysfs_path);
84 case PROP_DEVICE_PATH:
85 g_value_set_string (value, priv->device_path);
88 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
93 clutter_input_device_evdev_set_property (GObject *object,
98 ClutterInputDeviceEvdev *input = CLUTTER_INPUT_DEVICE_EVDEV (object);
99 ClutterInputDeviceEvdevPrivate *priv = input->priv;
103 case PROP_SYSFS_PATH:
104 priv->sysfs_path = g_value_dup_string (value);
106 case PROP_DEVICE_PATH:
107 priv->device_path = g_value_dup_string (value);
110 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
115 clutter_input_device_evdev_finalize (GObject *object)
117 ClutterInputDeviceEvdev *input = CLUTTER_INPUT_DEVICE_EVDEV (object);
118 ClutterInputDeviceEvdevPrivate *priv = input->priv;
120 g_free (priv->sysfs_path);
121 g_free (priv->device_path);
123 G_OBJECT_CLASS (clutter_input_device_evdev_parent_class)->finalize (object);
127 clutter_input_device_evdev_keycode_to_evdev (ClutterInputDevice *device,
128 guint hardware_keycode,
129 guint *evdev_keycode)
131 /* The hardware keycodes from the evdev backend are already evdev
133 *evdev_keycode = hardware_keycode;
138 clutter_input_device_evdev_class_init (ClutterInputDeviceEvdevClass *klass)
140 GObjectClass *object_class = G_OBJECT_CLASS (klass);
143 g_type_class_add_private (klass, sizeof (ClutterInputDeviceEvdevPrivate));
145 object_class->get_property = clutter_input_device_evdev_get_property;
146 object_class->set_property = clutter_input_device_evdev_set_property;
147 object_class->finalize = clutter_input_device_evdev_finalize;
148 klass->keycode_to_evdev = clutter_input_device_evdev_keycode_to_evdev;
151 * ClutterInputDeviceEvdev:udev-device:
153 * The Sysfs path of the device
158 g_param_spec_string ("sysfs-path",
160 P_("Path of the device in sysfs"),
162 G_PARAM_CONSTRUCT_ONLY | CLUTTER_PARAM_READWRITE);
163 obj_props[PROP_SYSFS_PATH] = pspec;
164 g_object_class_install_property (object_class, PROP_SYSFS_PATH, pspec);
167 * ClutterInputDeviceEvdev:device-path
169 * The path of the device file.
174 g_param_spec_string ("device-path",
176 P_("Path of the device node"),
178 G_PARAM_CONSTRUCT_ONLY | CLUTTER_PARAM_READWRITE);
179 obj_props[PROP_DEVICE_PATH] = pspec;
180 g_object_class_install_property (object_class, PROP_DEVICE_PATH, pspec);
184 clutter_input_device_evdev_init (ClutterInputDeviceEvdev *self)
186 self->priv = INPUT_DEVICE_EVDEV_PRIVATE (self);
189 ClutterInputDeviceEvdev *
190 _clutter_input_device_evdev_new (void)
192 return g_object_new (CLUTTER_TYPE_INPUT_DEVICE_EVDEV, NULL);
196 _clutter_input_device_evdev_get_sysfs_path (ClutterInputDeviceEvdev *device)
198 g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE_EVDEV (device), NULL);
200 return device->priv->sysfs_path;
204 _clutter_input_device_evdev_get_device_path (ClutterInputDeviceEvdev *device)
206 g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE_EVDEV (device), NULL);
208 return device->priv->device_path;