hal: Branch 'master' - 2 commits

David Zeuthen david at kemper.freedesktop.org
Mon Apr 2 23:18:10 PDT 2007


 doc/spec/hal-spec-properties.xml          |   63 ++++++++++++++++++++++++++++++
 fdi/policy/10osvendor/10-input-policy.fdi |    2 
 hald/freebsd/probing/probe-hiddev.c       |   10 ++++
 hald/linux/device.c                       |   58 +++++++++++++++++++++++----
 4 files changed, 122 insertions(+), 11 deletions(-)

New commits:
diff-tree 0391cb5e4e9a26d1c9494727999d38714cb3af18 (from 10066e8aecdc92e6c6460b2d5c4817ad13e4e83e)
Author: David Zeuthen <davidz at redhat.com>
Date:   Tue Apr 3 02:18:04 2007 -0400

    update spec to mention input.* capabilities

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 0965971..36e4283 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -4204,6 +4204,69 @@ org.freedesktop.Hal.Device.Volume.method
         </tgroup>
       </informaltable>
     </sect2>
+    <sect2 id="device-properties-input-keys">
+      <title>
+        input.keys namespace
+      </title>
+      <para>
+        The input device have keys that can be pressed. No namespace
+        specific properties.
+      </para>
+    </sect2>
+    <sect2 id="device-properties-input-keypad">
+      <title>
+        input.keypad namespace
+      </title>
+      <para>
+        The input device have keypad keys. No namespace
+        specific properties.
+      </para>
+    </sect2>
+    <sect2 id="device-properties-input-keyboard">
+      <title>
+        input.keyboard namespace
+      </title>
+      <para>
+        The input device is a normal keyboard. No namespace specific
+        properties.
+      </para>
+    </sect2>
+    <sect2 id="device-properties-input-mouse">
+      <title>
+        input.mouse namespace
+      </title>
+      <para>
+        The input device is a mouse. No namespace specific
+        properties.
+      </para>
+    </sect2>
+    <sect2 id="device-properties-input-switch">
+      <title>
+        input.switch namespace
+      </title>
+      <para>
+        The input device is a switch, e.g. it has buttons with
+        state. No namespace specific properties.
+      </para>
+    </sect2>
+    <sect2 id="device-properties-input-joystick">
+      <title>
+        input.joystick namespace
+      </title>
+      <para>
+        The input device is a joystick. No namespace specific
+        properties.
+      </para>
+    </sect2>
+    <sect2 id="device-properties-input-tablet">
+      <title>
+        input.tablet namespace
+      </title>
+      <para>
+        The input device is a tablet. No namespace specific
+        properties.
+      </para>
+    </sect2>
     <sect2 id="device-properties-pcmcia_socket">
       <title>
         pcmcia_socket namespace
diff-tree 10066e8aecdc92e6c6460b2d5c4817ad13e4e83e (from 435bb36fe2425f16ab73a1f52d866172163ded5c)
Author: Guillem Jover <guillem.jover at nokia.com>
Date:   Tue Apr 3 02:10:36 2007 -0400

    generalize keyboard detection code
    
    Some devices do not have a proper keyboard, still they have keys, those
    should be handled by the input addon, but should not be considered a
    keyboard. This patch thus adds two new input capabilities, input.keys
    and input.keypad. A device with more than two keys will have the
    input.keys set and it might have input.keyboard, input.keypad or
    neither depending on the supported keys.

diff --git a/fdi/policy/10osvendor/10-input-policy.fdi b/fdi/policy/10osvendor/10-input-policy.fdi
index 79a8a3e..6e24632 100644
--- a/fdi/policy/10osvendor/10-input-policy.fdi
+++ b/fdi/policy/10osvendor/10-input-policy.fdi
@@ -7,7 +7,7 @@
       <match key="info.capabilities" contains="button">
 	<append key="info.addons" type="strlist">hald-addon-input</append>
       </match>
-      <match key="info.capabilities" contains="input.keyboard">
+      <match key="info.capabilities" contains="input.keys">
 	<append key="info.addons" type="strlist">hald-addon-input</append>
         <match key="info.capabilities" contains_not="button">
 	  <append key="info.capabilities" type="strlist">button</append>
diff --git a/hald/freebsd/probing/probe-hiddev.c b/hald/freebsd/probing/probe-hiddev.c
index 049a17d..e9b5016 100644
--- a/hald/freebsd/probing/probe-hiddev.c
+++ b/hald/freebsd/probing/probe-hiddev.c
@@ -47,6 +47,7 @@ main (int argc, char **argv)
   struct hid_data *data;
   hid_item_t item;
   boolean is_keyboard = FALSE;
+  boolean is_keypad = FALSE;
   boolean is_mouse = FALSE;
   boolean is_joystick = FALSE;
 
@@ -105,9 +106,12 @@ main (int argc, char **argv)
 	    break;
 
 	  case HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_KEYBOARD):
-	  case HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_KEYPAD):
 	    is_keyboard = TRUE;
 	    break;
+
+	  case HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_KEYPAD):
+	    is_keypad = TRUE;
+	    break;
 	  }
       }
   hid_end_parse(data);
@@ -124,6 +128,10 @@ main (int argc, char **argv)
       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);
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 1211535..da1785a 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -118,10 +118,49 @@ out:
 	;
 }
 
+static gboolean
+input_test_keyboard (long *bitmask)
+{
+	int i;
+
+	for (i = KEY_Q; i <= KEY_P; i++) {
+		if (!test_bit (i, bitmask))
+			return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean
+input_test_keypad (long *bitmask)
+{
+	int i;
+
+	for (i = KEY_KP7; i <= KEY_KPDOT; i++) {
+		if (!test_bit (i, bitmask))
+			return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean
+input_test_keys (long *bitmask)
+{
+	int i;
+
+	/* All keys that are not buttons are less than BTN_MISC */
+	for (i = KEY_RESERVED + 1; i < BTN_MISC; i++) {
+		if (test_bit (i, bitmask))
+			return TRUE;
+	}
+
+	return FALSE;
+}
+
 static void
 input_test_key (HalDevice *d, const char *sysfs_path)
 {
-	int i;
 	char *s;
 	long bitmask[NBITS(KEY_MAX)];
 	int num_bits;
@@ -149,15 +188,16 @@ input_test_key (HalDevice *d, const char
 			hal_device_property_set_string (d, "button.type", "hibernate");
 		}
 	} else {
-		/* TODO: we probably should require lots of bits set to classify as keyboard. Oh well */
+		gboolean is_keyboard = input_test_keyboard (bitmask);
+		gboolean is_keypad = input_test_keypad (bitmask);
 
-		/* All keys that are not buttons are less than BTN_MISC */
-		for (i = KEY_RESERVED + 1; i < BTN_MISC; i++) {
-			if (test_bit (i, bitmask)) {
-				hal_device_add_capability (d, "input.keyboard");
-				break;
-			}
-		}
+		if (is_keyboard)
+			hal_device_add_capability (d, "input.keyboard");
+		if (is_keypad)
+			hal_device_add_capability (d, "input.keypad");
+
+		if (is_keyboard || is_keypad || input_test_keys (bitmask))
+			hal_device_add_capability (d, "input.keys");
 	}
 out:
 	;


More information about the hal-commit mailing list