hal: Branch 'master'

Martin Pitt martin at kemper.freedesktop.org
Thu Sep 17 06:50:54 PDT 2009


 hald/freebsd/hf-devtree.c           |    6 +++---
 hald/freebsd/hf-usb.c               |    4 ++--
 hald/freebsd/hf-util.c              |   25 ++++++++++++++++---------
 hald/freebsd/hf-util.h              |    3 ++-
 hald/freebsd/probing/probe-hiddev.c |   12 ++----------
 5 files changed, 25 insertions(+), 25 deletions(-)

New commits:
commit 2e5eed0af0761ab6f7a15659ec1efa1f66ef1ea8
Author: Aurelien Jarno <aurelien at aurel32.net>
Date:   Thu Sep 17 15:50:28 2009 +0200

    generalize keyboard detection code for FreeBSD
    
    This is needed to get Xorg working nicely with hal.
    - Only set "input" for the info.category field
    - Set input.keys on devices which have keys.

diff --git a/hald/freebsd/hf-devtree.c b/hald/freebsd/hf-devtree.c
index 410f3c6..7a54feb 100644
--- a/hald/freebsd/hf-devtree.c
+++ b/hald/freebsd/hf-devtree.c
@@ -194,7 +194,7 @@ hf_devtree_fd_set_properties (HalDevice *device)
 static void
 hf_devtree_atkbd_set_properties (HalDevice *device)
 {
-  hf_device_set_input(device, "keyboard", NULL);
+  hf_device_set_input(device, "keyboard", "keys", NULL);
 }
 
 static void
@@ -203,7 +203,7 @@ hf_devtree_psm_set_properties (HalDevice *device)
   char *devname;
 
   devname = hf_devtree_device_get_name(device);
-  hf_device_set_input(device, "mouse", devname);
+  hf_device_set_input(device, "mouse", NULL, devname);
   g_free(devname);
 }
 
@@ -213,7 +213,7 @@ hf_devtree_joy_set_properties (HalDevice *device)
   char *devname;
 
   devname = hf_devtree_device_get_name(device);
-  hf_device_set_input(device, "joystick", devname);
+  hf_device_set_input(device, "joystick", NULL, devname);
   g_free(devname);
 
   if (! hal_device_has_property(device, "info.product"))
diff --git a/hald/freebsd/hf-usb.c b/hald/freebsd/hf-usb.c
index 9bb6f3c..280e0db 100644
--- a/hald/freebsd/hf-usb.c
+++ b/hald/freebsd/hf-usb.c
@@ -392,9 +392,9 @@ hf_usb_device_new (HalDevice *parent,
     hf_devtree_device_set_name(device, di->udi_devnames[0]);
 
   if ((devname = hf_usb_get_devname(di, "ukbd")))	/* USB keyboard */
-    hf_device_set_input(device, "keyboard", NULL);
+    hf_device_set_input(device, "keyboard", "keys", devname);
   else if ((devname = hf_usb_get_devname(di, "ums")))	/* USB mouse */
-    hf_device_set_input(device, "mouse", devname);
+    hf_device_set_input(device, "mouse", NULL, devname);
   else if ((devname = hf_usb_get_devname(di, "uhid")))	/* UHID device */
     {
       hal_device_property_set_string(device, "info.category", "hiddev");
diff --git a/hald/freebsd/hf-util.c b/hald/freebsd/hf-util.c
index 9606360..aa54f57 100644
--- a/hald/freebsd/hf-util.c
+++ b/hald/freebsd/hf-util.c
@@ -326,24 +326,31 @@ hf_device_property_set_string_printf (HalDevice *device,
 
 void
 hf_device_set_input (HalDevice *device,
-		     const char *class,
+		     const char *capability1,
+		     const char *capability2,
 		     const char *devname)
 {
   g_return_if_fail(HAL_IS_DEVICE(device));
 
   hal_device_add_capability(device, "input");
+  if (capability1)
+    {
+      char *capability;
 
-  if (class)
+      capability = g_strdup_printf("input.%s", capability1);
+      hal_device_add_capability(device, capability);
+      g_free(capability);
+    }
+  if (capability2)
     {
-      char *category;
+      char *capability;
 
-      category = g_strdup_printf("input.%s", class);
-      hal_device_property_set_string(device, "info.category", category);
-      hal_device_add_capability(device, category);
-      g_free(category);
+      capability = g_strdup_printf("input.%s", capability2);
+      hal_device_add_capability(device, capability);
+      g_free(capability);
     }
-  else
-    hal_device_property_set_string(device, "info.category", "input");
+
+  hal_device_property_set_string(device, "info.category", "input");
 
   if (devname)
     hf_device_property_set_string_printf(device, "input.device", "/dev/%s", devname);
diff --git a/hald/freebsd/hf-util.h b/hald/freebsd/hf-util.h
index d4590ce..3ac34b1 100644
--- a/hald/freebsd/hf-util.h
+++ b/hald/freebsd/hf-util.h
@@ -87,7 +87,8 @@ void hf_device_property_set_string_printf (HalDevice *device,
 					   ...) G_GNUC_PRINTF(3, 4);
 
 void hf_device_set_input (HalDevice *device,
-			  const char *class,
+			  const char *capability1,
+			  const char *capability2,
 			  const char *devname);
 
 HalDevice *hf_device_store_get_parent (HalDeviceStore *store,
diff --git a/hald/freebsd/probing/probe-hiddev.c b/hald/freebsd/probing/probe-hiddev.c
index 916ae09..f0c598b 100644
--- a/hald/freebsd/probing/probe-hiddev.c
+++ b/hald/freebsd/probing/probe-hiddev.c
@@ -132,30 +132,22 @@ main (int argc, char **argv)
 
   hid_dispose_report_desc(report_desc);
 
-  if (is_keyboard || is_mouse || is_joystick)
+  if (is_keyboard || is_mouse || is_joystick || is_keypad)
     {
       libhal_device_add_capability(hfp_ctx, hfp_udi, "input", &hfp_error);
+      libhal_device_set_property_string(hfp_ctx, hfp_udi, "info.category", "input", &hfp_error);
       libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.device", device_file, &hfp_error);
     }
   if (is_keyboard)
-    {
       libhal_device_add_capability(hfp_ctx, hfp_udi, "input.keyboard", &hfp_error);
-      libhal_device_set_property_string(hfp_ctx, hfp_udi, "info.category", "input.keyboard", &hfp_error);
-    }
   if (is_keypad)
       libhal_device_add_capability(hfp_ctx, hfp_udi, "input.keypad", &hfp_error);
   if (is_keyboard || is_keypad)
       libhal_device_add_capability(hfp_ctx, hfp_udi, "input.keys", &hfp_error);
   if (is_mouse)
-    {
       libhal_device_add_capability(hfp_ctx, hfp_udi, "input.mouse", &hfp_error);
-      libhal_device_set_property_string(hfp_ctx, hfp_udi, "info.category", "input.mouse", &hfp_error);
-    }
   if (is_joystick)
-    {
       libhal_device_add_capability(hfp_ctx, hfp_udi, "input.joystick", &hfp_error);
-      libhal_device_set_property_string(hfp_ctx, hfp_udi, "info.category", "input.joystick", &hfp_error);
-    }
 
  end:
   return 0;


More information about the hal-commit mailing list