patch from christophe.dumez@intel.com for joystick support
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 29 Jun 2012 08:18:12 +0000 (08:18 +0000)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 29 Jun 2012 08:18:12 +0000 (08:18 +0000)
ticket #1100

SVN revision: 73027

legacy/eeze/AUTHORS
legacy/eeze/ChangeLog
legacy/eeze/NEWS
legacy/eeze/src/lib/Eeze.h
legacy/eeze/src/lib/eeze_udev_find.c
legacy/eeze/src/lib/eeze_udev_syspath.c
legacy/eeze/src/lib/eeze_udev_watch.c

index 5307e33..96a45af 100644 (file)
@@ -1,3 +1,4 @@
 Mike Blumenkrantz (zmike/discomfitor) <michael.blumenkrantz@gmail.com>
 Cedric Bail <cedric@efl.so>
 Mikael Sans <sans.mikael@gmail.com>
+Christophe Dumez <christophe.dumez@intel.com>
index 9a2be58..311cfa9 100644 (file)
@@ -96,3 +96,7 @@
 2012-06-29 Mike Blumenkrantz
 
         * Fix crash in eeze_net_free()
+
+2012-06-29 Christophe Dumez (christophe.dumez@intel.com)
+
+        * Added joystick detection
index 6e73890..23d7195 100644 (file)
@@ -1,4 +1,11 @@
-Eeze 1.2.0
+Eeze 1.3.0
+
+Changes since Eeze 1.1.0:
+-------------------------
+
+Additions:
+
+    * Joystick support
 
 Changes since Eeze 1.1.0:
 -------------------------
index dd9b8ba..e816655 100644 (file)
@@ -216,7 +216,11 @@ typedef enum
    /** - WebCam */
    EEZE_UDEV_TYPE_V4L,
    /** - Bluetooth */
-   EEZE_UDEV_TYPE_BLUETOOTH
+   EEZE_UDEV_TYPE_BLUETOOTH,
+   /** - Joystick
+    * @since 1.3
+    */
+   EEZE_UDEV_TYPE_JOYSTICK
 } Eeze_Udev_Type;
 /**@}*/
 
@@ -456,6 +460,15 @@ EAPI Eina_Bool        eeze_udev_syspath_is_kbd(const char *syspath);
  * @return If true, the device is a touchpad
  */
 EAPI Eina_Bool        eeze_udev_syspath_is_touchpad(const char *syspath);
+
+/**
+ * Checks whether the device is a joystick.
+ *
+ * @param syspath The /sys/ path with or without the /sys/
+ * @return If true, the device is a joystick
+ * @since 1.3
+ */
+EAPI Eina_Bool        eeze_udev_syspath_is_joystick(const char *syspath);
    /**
     * @}
     */
index bdd1037..3bd06ab 100644 (file)
@@ -188,6 +188,13 @@ eeze_udev_find_by_type(Eeze_Udev_Type etype,
 #endif
         break;
 
+      case EEZE_UDEV_TYPE_JOYSTICK:
+        udev_enumerate_add_match_subsystem(en, "input");
+#ifndef OLD_UDEV_RRRRRRRRRRRRRR
+        udev_enumerate_add_match_property(en, "ID_INPUT_JOYSTICK", "1");
+#endif
+        break;
+
       case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
         udev_enumerate_add_match_subsystem(en, "block");
         udev_enumerate_add_match_property(en, "ID_FS_USAGE", "filesystem");
index 55ba843..df858e6 100644 (file)
@@ -236,6 +236,34 @@ eeze_udev_syspath_is_touchpad(const char *syspath)
    return touchpad;
 }
 
+EAPI Eina_Bool
+eeze_udev_syspath_is_joystick(const char *syspath)
+{
+   _udev_device *device = NULL;
+   Eina_Bool joystick = EINA_FALSE;
+   const char *test;
+
+   if (!syspath)
+     return EINA_FALSE;
+
+   if (!(device = _new_device(syspath)))
+     return EINA_FALSE;
+#ifdef OLD_UDEV_RRRRRRRRRRRRRR
+   test = udev_device_get_property_value(device, "ID_CLASS");
+
+   if ((test) && (!strcmp(test, "joystick")))
+     joystick = EINA_TRUE;
+#else
+   test = udev_device_get_property_value(device, "ID_INPUT_JOYSTICK");
+
+   if (test && (test[0] == '1'))
+     joystick = EINA_TRUE;
+
+#endif
+   udev_device_unref(device);
+   return joystick;
+}
+
 EAPI const char *
 eeze_udev_devpath_get_syspath(const char *devpath)
 {
index 5c23421..b89e2d6 100644 (file)
@@ -166,6 +166,24 @@ _get_syspath_from_watch(void             *data,
 
         break;
 
+      case EEZE_UDEV_TYPE_JOYSTICK:
+#ifdef OLD_UDEV_RRRRRRRRRRRRRR
+        if ((!(test = udev_device_get_subsystem(device)))
+            || (strcmp(test, "input")))
+          goto error;
+
+        test = udev_device_get_property_value(device, "ID_CLASS");
+
+        if ((test) && (!strcmp(test, "joystick")))
+          break;
+
+        goto error;
+#endif
+        if (!udev_device_get_property_value(device, "ID_INPUT_JOYSTICK"))
+          goto error;
+
+        break;
+
       case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
 #ifdef OLD_UDEV_RRRRRRRRRRRRRR
         if ((!(test = udev_device_get_subsystem(device)))
@@ -319,14 +337,9 @@ eeze_udev_watch_add(Eeze_Udev_Type     type,
 
    switch (type)
      {
+      case EEZE_UDEV_TYPE_JOYSTICK:
       case EEZE_UDEV_TYPE_KEYBOARD:
-        udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
-        break;
-
       case EEZE_UDEV_TYPE_MOUSE:
-        udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
-        break;
-
       case EEZE_UDEV_TYPE_TOUCHPAD:
         udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
         break;