[PATCH] generalize keyboard detection code for FreeBSD
Aurelien Jarno
aurelien at aurel32.net
Mon Aug 17 14:34:18 PDT 2009
It comes late, but it is needed to get Xorg working nicely with hal.
This patch:
- Only set "input" for the info.category field
- Set input.keys on devices which have keys.
---
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(-)
diff --git a/hald/freebsd/hf-devtree.c b/hald/freebsd/hf-devtree.c
index 01203f0..53c7012 100644
--- a/hald/freebsd/hf-devtree.c
+++ b/hald/freebsd/hf-devtree.c
@@ -186,7 +186,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
@@ -195,7 +195,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);
}
@@ -205,7 +205,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 d04f7f2..888d17f 100644
--- a/hald/freebsd/hf-usb.c
+++ b/hald/freebsd/hf-usb.c
@@ -424,9 +424,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", devname);
+ 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 e9b5016..97d7a8c 100644
--- a/hald/freebsd/probing/probe-hiddev.c
+++ b/hald/freebsd/probing/probe-hiddev.c
@@ -118,30 +118,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;
--
1.6.1.3
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien at aurel32.net http://www.aurel32.net
More information about the hal
mailing list