Package: hal
Version: 0.5.12~git20090406.46dc48-2
Severity: wishlist
Tags: patch
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The attached patch makes hal-setup-keymap output valuable data to syslog.
Ideally, hal should reset the keymap to its original values when it's
stopped. This would require us to save those values somewhere, and would
also require some thought on handling mismatches between values set by hal
and actual kernel values (e.g. when some other utility has changed a key
while hal was running). So that's left for later...
With the attached patch, you'll at least get an idea on what hal changed
and thereby a possiblity to restore it manually, fix a fdi file or whatever.
Bjørn
- -- System Information:
Debian Release: 5.0.1
APT prefers stable
APT policy: (700, 'stable'), (600, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.29-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages hal depends on:
ii acl 2.2.47-2 Access control list utilities
ii adduser 3.110 add and remove users and groups
ii consolekit 0.3.0-2 framework for defining and trackin
ii dbus 1.2.1-5 simple interprocess messaging syst
ii hal-info 20090309-1 Hardware Abstraction Layer - fdi f
ii libc6 2.7-18 GNU C Library: Shared libraries
ii libdbus-1-3 1.2.1-5 simple interprocess messaging syst
ii libdbus-glib-1-2 0.80-3 simple interprocess messaging syst
ii libexpat1 2.0.1-4 XML parsing C library - runtime li
ii libgcc1 1:4.3.2-1.1 GCC support library
ii libglib2.0-0 2.16.6-1+lenny1 The GLib library of C routines
ii libhal-storage1 0.5.11-8 Hardware Abstraction Layer - share
ii libhal1 0.5.11-8 Hardware Abstraction Layer - share
ii libpolkit2 0.9-3 library for accessing PolicyKit
ii libsmbios2 2.0.3.dfsg-1 Provide access to (SM)BIOS informa
ii libstdc++6 4.3.2-1.1 The GNU Standard C++ Library v3
ii libusb-0.1-4 2:0.1.12-13 userspace USB programming library
ii libvolume-id1 0.141-1 libvolume_id shared library
ii lsb-base 3.2-20 Linux Standard Base 3.2 init scrip
ii mount 2.13.1.1-1 Tools for mounting and manipulatin
ii pciutils 1:3.0.0-6 Linux PCI Utilities
ii pm-utils 1.1.2.4-1 utilities and scripts for power ma
ii policykit 0.9-3 framework for managing administrat
ii udev 0.125-7+lenny1 /dev/ and hotplug management daemo
ii usbutils 0.73-10 Linux USB utilities
Versions of packages hal recommends:
ii eject 2.1.5+deb1-4 ejects CDs and operates CD-Changer
pn libsmbios-bin <none> (no description available)
Versions of packages hal suggests:
pn gnome-device-manager <none> (no description available)
- -- no debconf information
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAknsg2QACgkQ10rqkowbIskQzACfYNsT8w9lqZ4u1c2fGYt9iEpp
5kYAoJHR6+RGKxMK214JlbAW9+zcQt8o
=O5yZ
-----END PGP SIGNATURE-----
--- a/tools/hal-setup-keymap.c 2007-11-26 19:06:19.000000000 +0100
+++ b/tools/hal-setup-keymap.c 2009-04-20 16:02:08.000000000 +0200
@@ -29,6 +29,7 @@
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
+#include <syslog.h>
#include <sys/ioctl.h>
#ifdef HAL_LINUX_INPUT_HEADER_H
@@ -51,7 +52,7 @@
/* requires root privs */
fd = open (dev, O_RDWR);
if (fd < 0) {
- fprintf (stderr, "hal-setup-keymap: failed to open('%s'): %s\n",
+ syslog (LOG_ERR, "failed to open('%s'): %s\n",
dev, strerror (errno));
return -1;
}
@@ -66,16 +67,15 @@
int codes[2];
codes[0] = scancode;
+ if (ioctl (fd, EVIOCGKEYCODE, codes) < 0)
+ return -1;
+ ret = codes[1];
codes[1] = keycode;
- ret = ioctl (fd, EVIOCSKEYCODE, codes);
- if (ret < 0) {
- fprintf (stderr, "hal-setup-keymap: failed to set scancode %x to keycode %d: %s\n",
- scancode, keycode, strerror(errno));
+ if (ioctl (fd, EVIOCSKEYCODE, codes) < 0)
return -1;
- }
- return 0;
+ return ret;
}
int
@@ -92,14 +92,15 @@
DBusError error;
const struct key *name;
+ openlog ("hal-setup-keymap", 0, LOG_DAEMON);
udi = getenv ("UDI");
if (udi == NULL) {
- fprintf (stderr, "hal-setup-keymap: Failed to get UDI\n");
+ syslog (LOG_ERR, "Failed to get UDI\n");
return 1;
}
dbus_error_init (&error);
if ((ctx = libhal_ctx_init_direct (&error)) == NULL) {
- fprintf (stderr, "hal-setup-keymap: Unable to initialise libhal context: %s\n", error.message);
+ syslog (LOG_ERR, "Unable to initialise libhal context: %s\n", error.message);
return 1;
}
@@ -112,14 +113,14 @@
dbus_error_init (&error);
keymap_list = libhal_device_get_property_strlist (ctx, udi, "input.keymap.data", &error);
if (dbus_error_is_set (&error) == TRUE) {
- fprintf (stderr, "hal-setup-keymap: Failed to get keymap list: '%s'\n", error.message);
+ syslog (LOG_ERR, "Failed to get keymap list: '%s'\n", error.message);
return 1;
}
/* get the device */
device = libhal_device_get_property_string (ctx, udi, "input.device", &error);
if (dbus_error_is_set (&error) == TRUE) {
- fprintf (stderr, "hal-setup-keymap: Failed to get input device list: '%s'\n", error.message);
+ syslog (LOG_ERR, "Failed to get input device list: '%s'\n", error.message);
return 1;
}
@@ -127,7 +128,7 @@
fprintf (stderr, "hal-setup-keymap: Using device %s\n", device);
fd = evdev_open (device);
if (fd < 0) {
- fprintf (stderr, "hal-setup-keymap: Could not open device\n");
+ syslog (LOG_ERR, "Could not open device\n");
return 1;
}
@@ -147,19 +148,26 @@
name = lookup_key (keyname, strlen(keyname));
if (name != NULL) {
keycode = name->id;
- fprintf (stderr, "hal-setup-keymap: parsed %s to (0x%x, %i)\n",
- keymap_list[i], scancode, keycode);
- evdev_set_keycode (fd, scancode, keycode);
+ syslog (LOG_DEBUG, "'%s' parsed %s to (0x%02x, %i)\n",
+ udi, keymap_list[i], scancode, keycode);
+
+ if ((values = evdev_set_keycode (fd, scancode, keycode)) < 0)
+ syslog (LOG_ERR, "'%s' failed to set scancode 0x%02x to keycode %d: %s\n",
+ udi, scancode, keycode, strerror(errno));
+ else
+ syslog (LOG_INFO, "'%s' changing scancode 0x%02x from %d to %d\n",
+ udi, scancode, values, keycode);
} else {
- fprintf (stderr, "hal-setup-keymap: failed to find key '%s'\n", keyname);
+ syslog (LOG_ERR, "failed to find key '%s'\n", keyname);
}
} else {
- fprintf (stderr, "hal-setup-keymap: Failed to parse %s\n", keymap_list[i]);
+ syslog (LOG_ERR, "Failed to parse %s\n", keymap_list[i]);
}
} while (keymap_list[++i] != NULL);
libhal_free_string_array (keymap_list);
close (fd);
+ closelog ();
/* we do not have to poll anything, so exit */
return 0;