determine evdev device type using g_udev_device_has_property

http://bugzilla.clutter-project.org/show_bug.cgi?id=2631
This commit is contained in:
James Athey 2011-04-12 11:33:58 -04:00 committed by Emmanuele Bassi
parent aa4ff0b90f
commit 3d3ae619c6

View File

@ -532,7 +532,6 @@ evdev_add_device (ClutterDeviceManagerEvdev *manager_evdev,
ClutterInputDevice *device; ClutterInputDevice *device;
ClutterActor *stage; ClutterActor *stage;
const gchar *device_file, *sysfs_path, *device_name; const gchar *device_file, *sysfs_path, *device_name;
const gchar * const *keys;
guint i; guint i;
device_file = g_udev_device_get_device_file (udev_device); device_file = g_udev_device_get_device_file (udev_device);
@ -551,24 +550,20 @@ evdev_add_device (ClutterDeviceManagerEvdev *manager_evdev,
if (!is_evdev (sysfs_path)) if (!is_evdev (sysfs_path))
return; return;
keys = g_udev_device_get_property_keys (udev_device); /* Clutter assumes that device types are exclusive in the
for (i = 0; keys[i]; i++) * ClutterInputDevice API */
{ if (g_udev_device_has_property (udev_device, "ID_INPUT_KEYBOARD"))
/* Clutter assumes that device types are exclusive in the type = CLUTTER_KEYBOARD_DEVICE;
* ClutterInputDevice API */ else if (g_udev_device_has_property (udev_device, "ID_INPUT_MOUSE"))
if (strcmp (keys[i], "ID_INPUT_KEY") == 0) type = CLUTTER_POINTER_DEVICE;
type = CLUTTER_KEYBOARD_DEVICE; else if (g_udev_device_has_property (udev_device, "ID_INPUT_JOYSTICK"))
else if (strcmp (keys[i], "ID_INPUT_MOUSE") == 0) type = CLUTTER_JOYSTICK_DEVICE;
type = CLUTTER_POINTER_DEVICE; else if (g_udev_device_has_property (udev_device, "ID_INPUT_TABLET"))
else if (strcmp (keys[i], "ID_INPUT_JOYSTICK") == 0) type = CLUTTER_TABLET_DEVICE;
type = CLUTTER_JOYSTICK_DEVICE; else if (g_udev_device_has_property (udev_device, "ID_INPUT_TOUCHPAD"))
else if (strcmp (keys[i], "ID_INPUT_TABLET") == 0) type = CLUTTER_TOUCHPAD_DEVICE;
type = CLUTTER_TABLET_DEVICE; else if (g_udev_device_has_property (udev_device, "ID_INPUT_TOUCHSCREEN"))
else if (strcmp (keys[i], "ID_INPUT_TOUCHPAD") == 0) type = CLUTTER_TOUCHSCREEN_DEVICE;
type = CLUTTER_TOUCHPAD_DEVICE;
else if (strcmp (keys[i], "ID_INPUT_TOUCHSCREEN") == 0)
type = CLUTTER_TOUCHSCREEN_DEVICE;
}
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_EVDEV, device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_EVDEV,
"id", 0, "id", 0,