hal/hald/linux2/probing Makefile.am, NONE, 1.1 probe-input.c, NONE, 1.1

David Zeuthen david at freedesktop.org
Tue Jan 18 11:48:15 PST 2005


Update of /cvs/hal/hal/hald/linux2/probing
In directory gabe:/tmp/cvs-serv19239/hald/linux2/probing

Added Files:
	Makefile.am probe-input.c 
Log Message:
2005-01-18  David Zeuthen  <david at fubar.dk>

	* tools/linux/Makefile.am: Remove hal.dev build rules

	* tools/linux/hal_dev.c: Remove

	* configure.in: Set linux2 as the default backend

	* hald/linux: Remove all files here as they will get reimplemented
	in hald/linux2

	* hald/linux2: Add a bunch of new files

	* hald/linux2/probing: Add some new files

2005-01-18  David Zeuthen  <davidz at redhat.com>

	Merge some more changes from the stable branch (except those
	in hald/linux and doc/spec)

	2005-01-12  David Zeuthen  <davidz at redhat.com>

	* hald/callout.c (callout_timeout_handler): Be tough and kill
	the misbehaving child the hard way - suggestion from Joe Shaw.

	2005-01-12  David Zeuthen  <davidz at redhat.com>

	* hald/linux/osspec.c (HOTPLUG_TIMEOUT): Increase to 25 seconds
	to better cope with callouts timeout of 10 seconds

	* hald/callout.c (iochn_data): Cope with callouts terminating
	and free timeout handler
	(callout_timeout_handler): New function; kill callouts if they
	time out
	(process_next_callout): Setup timeout for callouts - set to
	ten seconds

	2005-01-11  David Zeuthen  <davidz at redhat.com>

	* hald/callout.c: Simplify a lot more by demanding that callouts
	are run sequentially - which they are anyway since everything is
	serialized. Make a mental note to review and stress test this in
	the morning.

	2005-01-11  David Zeuthen  <davidz at redhat.com>

	* hald/callout.c: Fix some craziness adding an idle handler for
	detecting when callouts complete - fixes bug on my new AMD64
	system with device add/remove prior to completion of callouts -
	one visible effect was that fstab-sync was crashing since it
	couldn't retrieve the block.device device as the device was
	removed prior to the completion of the callout

	2005-01-07  David Zeuthen  <davidz at redhat.com>

	* fdi/20freedesktop/ide-drives.fdi: Also check IDE floppies for whether
	they are Zip drives

	2005-01-07  Joe Shaw  <joeshaw at novell.com>

	* configure.in: Check for popt when building fstab-sync and error
	out if it's not found.

	* tools/Makefile.am: Build fstab-sync conditionally based on
	whether --enable-fstab-sync is passed in.

	2005-01-06  David Zeuthen  <davidz at redhat.com>

	* libhal/libhal.c (hal_device_query_capability): Patch from Tim
	Müller <t.i.m at zen.co.uk>. The attached patch fixes a small memory
	leak in libhal's hal_device_query_capability().

	2005-01-03  David Zeuthen  <davidz at redhat.com>

	* configure.in: Added it to ALL_LINGUAS

	* po/it.po: Italien translation from Pier Luigi Fiorini
	<pierluigi.fiorini at mockup.org>

	2004-12-15  David Zeuthen  <davidz at redhat.com>

	* fdi/20freedesktop/usb-zip-drives.fdi: Only match on actual
	harddisks to avoid wrong detection of e.g. "Iomega ZipCD 650 USB CDRW"
	drives (Red Hat bug #143834)

	* fdi/20freedesktop/ide-drives.fdi: ditto



--- NEW FILE: Makefile.am ---

INCLUDES = \
	-DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \
	-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
	-DPACKAGE_BIN_DIR=\""$(bindir)"\" \
	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
	-I$(top_srcdir) \
	@PACKAGE_CFLAGS@

libexec_PROGRAMS = hald-probe-input

hald_probe_input_SOURCES = probe-input.c
hald_probe_input_LDADD = $(top_builddir)/libhal/libhal.la






--- NEW FILE: probe-input.c ---
/***************************************************************************
 * CVSID: $Id: probe-input.c,v 1.1 2005/01/18 19:48:13 david Exp $
 *
 * probe-input.c : Probe input devices
 *
 * Copyright (C) 2004 David Zeuthen, <david at fubar.dk>
 *
 * Licensed under the Academic Free License version 2.0
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 **************************************************************************/

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#include <linux/input.h>

#include <libhal/libhal.h>

#define test_bit(bit, array) (array[(bit) / 8] & (1 << ((bit) % 8)))

static void 
check_abs (int fd, LibHalContext *ctx, const char *udi)
{
	char bitmask[(ABS_MAX + 7) / 8];

	if (ioctl (fd, EVIOCGBIT(EV_ABS, sizeof (bitmask)), bitmask) < 0) {
		fprintf(stderr, "ioctl EVIOCGBIT failed\n");
		goto out;
	}

	if (!test_bit(ABS_X, bitmask) || !test_bit(ABS_Y, bitmask)) {
		fprintf (stderr, "missing x or y absolute axes\n");
		goto out;
	}

	hal_device_add_capability (ctx, udi, "input.tablet");

out:
	;
}

static void 
check_key (int fd, LibHalContext *ctx, const char *udi)
{
	unsigned int i;
	char bitmask[(KEY_MAX + 7) / 8];
	int is_keyboard;

	if (ioctl (fd, EVIOCGBIT(EV_KEY, sizeof (bitmask)), bitmask) < 0) {
		fprintf(stderr, "ioctl EVIOCGBIT failed\n");
		goto out;
	}

	is_keyboard = FALSE;

	/* 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)) {
			is_keyboard = TRUE;
			break;
		}
	}

	if (is_keyboard) {
		hal_device_add_capability (ctx, udi, "input.keyboard");
	}

out:
	;
}

static void 
check_rel (int fd, LibHalContext *ctx, const char *udi)
{
	char bitmask[(REL_MAX + 7) / 8];

	if (ioctl (fd, EVIOCGBIT(EV_REL, sizeof (bitmask)), bitmask) < 0) {
		fprintf(stderr, "ioctl EVIOCGBIT failed: %m\n");
		goto out;
	}

	if (!test_bit (REL_X, bitmask) || !test_bit (REL_Y, bitmask)) {
		fprintf (stderr, "missing x or y relative axes\n");
		goto out;
	}

	hal_device_add_capability (ctx, udi, "input.mouse");

out:
	;
}

int 
main (int argc, char *argv[])
{
	int fd;
	int ret;
	char *udi;
	char *device_file;
	char *physical_device;
	LibHalContext *ctx = NULL;
	char name[128];
	struct input_id id;

	fd = -1;

	/* assume failure */
	ret = 1;

	udi = getenv ("UDI");
	if (udi == NULL)
		goto out;

	ctx = hal_initialize (NULL, FALSE);
	if (ctx == NULL)
		goto out;

	device_file = getenv ("HAL_PROP_INPUT_DEVICE");
	if (device_file == NULL)
		goto out;

	fprintf(stderr, "*** handling %s\n", device_file);


	fd = open (device_file, O_RDONLY);
	if (fd < 0)
		goto out;

	/* if we don't have a physical device then only accept input buses
	 * that we now aren't hotpluggable
	 */
	if (ioctl (fd, EVIOCGID, &id) < 0) {
		fprintf(stderr, "ioctl EVIOCGID failed\n");
		goto out;
	}
	physical_device = getenv ("HAL_PROP_INPUT_PHYSICAL_DEVICE");
	if (physical_device == NULL) {
		switch (id.bustype) {
		case 17: /* TODO: x86 legacy port; use symbol instead of hardcoded constant */
			break;

			/* TODO: ADB on Apple computers */
		default:
			goto out;
		}
	}

	/* only consider devices with the event interface */
	if (ioctl (fd, EVIOCGNAME(sizeof (name)), name) < 0) {
		fprintf(stderr, "ioctl EVIOCGNAME failed\n");
		goto out;
	}
	hal_device_set_property_string (ctx, udi, "info.product", name);
	hal_device_set_property_string (ctx, udi, "input.product", name);

	check_abs (fd, ctx, udi);
	check_rel (fd, ctx, udi);
	check_key (fd, ctx, udi);

	/* success */
	ret = 0;

out:
	if (fd >= 0)
		close (fd);

	if (ctx != NULL)
		hal_shutdown (ctx);

	return ret;
}




More information about the hal-commit mailing list