[Midnightbsd-cvs] mports: lirc/files:

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Nov 10 19:13:00 EST 2007


Log Message:
-----------


Added Files:
-----------
    mports/comms/lirc/files:
        lircd.sh.in (r1.1)
        patch-daemons::Makefile.in (r1.1)
        patch-daemons::hw_hiddev.c (r1.1)
        patch-daemons::lircd.c (r1.1)

-------------- next part --------------
--- /dev/null
+++ comms/lirc/files/patch-daemons::Makefile.in
@@ -0,0 +1,11 @@
+--- daemons/Makefile.in.orig	Sat Mar 10 17:14:33 2007
++++ daemons/Makefile.in	Sat Mar 10 17:14:45 2007
+@@ -919,8 +919,6 @@
+ @SANDBOXED_FALSE@@USE_FIFOS_FALSE at uninstall-local: rmdev
+ 
+ install-data-local:
+-	test "$(lircd_conf)" = ""  || test -e $(DESTDIR)$(sysconfdir)/lircd.conf  || ($(mkinstalldirs) $(DESTDIR)$(sysconfdir) && $(INSTALL_DATA) $(top_srcdir)/remotes/$(lircd_conf) $(DESTDIR)$(sysconfdir)/lircd.conf)
+-	test "$(lircmd_conf)" = "" || test -e $(DESTDIR)$(sysconfdir)/lircmd.conf || ($(mkinstalldirs) $(DESTDIR)$(sysconfdir) && $(INSTALL_DATA) $(top_srcdir)/remotes/$(lircmd_conf) $(DESTDIR)$(sysconfdir)/lircmd.conf)
+ 
+ mkdev:
+ 	test -e $(DESTDIR)$(devdir)/lircd || ($(mkinstalldirs) $(DESTDIR)$(devdir) && @mknod@ $(DESTDIR)$(devdir)/lircd p)
--- /dev/null
+++ comms/lirc/files/lircd.sh.in
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# $MidnightBSD: mports/comms/lirc/files/lircd.sh.in,v 1.1 2007/11/11 00:12:59 laffer1 Exp $
+# $FreeBSD: ports/comms/lirc/files/lircd.sh.in,v 1.1 2007/01/19 02:27:23 bland Exp $
+#
+# PROVIDE: lircd
+# REQUIRE: DAEMON
+#
+# Add the following line to /etc/rc.conf to enable lircd:
+#
+# lircd_enable="YES"
+#
+
+. %%RC_SUBR%%
+
+name="lircd"
+rcvar=`set_rcvar`
+
+load_rc_config ${name}
+: ${lircd_enable="NO"}
+: ${lircd_device="/dev/lirc0"}
+
+
+prefix=%%PREFIX%%
+procname=${prefix}/sbin/lircd
+pidfile=/var/run/lircd.pid
+lircd_config="${prefix}/etc/lircd.conf"
+required_files=${lircd_config}
+command="${prefix}/sbin/lircd"
+command_args="-d ${lircd_device} ${lircd_config}"
+
+run_rc_command "$1"
--- /dev/null
+++ comms/lirc/files/patch-daemons::lircd.c
@@ -0,0 +1,18 @@
+--- daemons/lircd.c.orig	Sun Jul 10 18:04:12 2005
++++ daemons/lircd.c	Fri Nov 24 14:21:10 2006
+@@ -755,9 +755,12 @@
+ 	strcpy(serv_addr.sun_path,lircdfile);
+ 	if(bind(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr))==-1)
+ 	{
+-		fprintf(stderr,"%s: could not assign address to socket\n",
+-			progname);
+-		perror(progname);
++		fprintf(stderr,
++                        "%s: could not assign address to socket %s: %s (%d)\n",
++			progname,
++                        lircdfile,
++                        strerror (errno),
++                        errno );
+ 		goto start_server_failed1;
+ 	}
+ 	
--- /dev/null
+++ comms/lirc/files/patch-daemons::hw_hiddev.c
@@ -0,0 +1,160 @@
+--- daemons/hw_hiddev.c.orig	Sun Jul 10 18:04:11 2005
++++ daemons/hw_hiddev.c	Thu Nov 23 14:41:52 2006
+@@ -19,14 +19,19 @@
+ #include <stdio.h>
+ #include <sys/fcntl.h>
+ 
++#ifdef __FreeBSD__
++#include <usbhid.h>
++#else  /* assume Linux */
+ #include <linux/types.h>
+ #include <linux/hiddev.h>
++#endif
+ 
+ #include "hardware.h"
+ #include "ir_remote.h"
+ #include "lircd.h"
+ #include "receive.h"
+-
++#include <errno.h>
++#include <string.h>
+ 
+ static int hiddev_init();
+ static int hiddev_deinit(void);
+@@ -103,7 +108,11 @@
+ 	logprintf(LOG_INFO, "initializing '%s'", hw.device);
+ 	
+ 	if ((hw.fd = open(hw.device, O_RDONLY)) < 0) {
+-		logprintf(LOG_ERR, "unable to open '%s'", hw.device);
++		logprintf(LOG_ERR,
++                          "unable to open '%s': %s (%d)",
++                          hw.device,
++                          strerror (errno),
++                          errno );
+ 		return 0;
+ 	}
+ 	
+@@ -143,38 +152,117 @@
+ }
+ 
+ 
++/*
++ * Read a record from the remote control, decode it and return a
++ * string of the form
++ *
++ * 00010046000042fe 00 start DVICO_MCE
++ *
++ * The first field is the complete event.  The second appears to tbe
++ * the repeat flag, the third the name of the the key, and the fourth
++ * some kind of identification.  I have no idea how much of this is
++ * used.
++ *
++ * The code below works around the extremely fast repeat holdoff on
++ * the DVICO control.  It's difficult to press a key without it
++ * repeating.  We work around this by ignoring the first 3 repeats.
++ *
++ * For FreeBSD, we have the problem of a different HID interface.
++ * Linux returns a struct hiddev_event, while FreeBSD returns data
++ * with no specific structure.  Part of the Linux structure is the
++ * hid, which FreeBSD doesn't seem to supply.  Work around these
++ * issues by reading the FreeBSD data and packing it into a Linux
++ * struct hiddev_event.  This requires lying about the hid.
++ */
++
+ char *hiddev_rec(struct ir_remote *remotes)
+ {
++#ifdef __FreeBSD__
++#define HIDRECLEN 3                             /* get this from hid_init() */
++	char inbuf [HIDRECLEN];
++        struct hiddev_event
++        {
++		unsigned hid;
++		int16_t value;
++        };
++#endif
+ 	struct hiddev_event event;
+ 	int rd;
+ 	/* Remotec Mediamaster specific */
+ 	static int wheel_count = 0;
+ 	static int x_movement = 0;
++        static int repeat_count = 0;
+ 	int y_movement=0;
+ 	int x_direction=0;
+ 	int y_direction=0;
+ 	
+ 	LOGPRINTF(1, "hiddev_rec");
+ 	
++#ifdef __FreeBSD__
++	rd = read(hw.fd, inbuf, sizeof inbuf);
++                if (rd != sizeof inbuf) {
++		logprintf(LOG_ERR,
++                                  "Really read %d bytes from '%s', expected %d",
++                                  rd,
++                                  hw.device,
++                                  sizeof inbuf );
++		return 0;
++	}
++	event.hid = 0x10046;             /* XXX not in FreeBSD */
++	event.value = * (int16_t *) (&inbuf [1]);
++                rd = sizeof event;                          /* to make code happy */
++#else
+ 	rd = read(hw.fd, &event, sizeof event);
++#endif
+ 	if (rd != sizeof event) {
+-		logprintf(LOG_ERR, "error reading '%s'", hw.device);
++		logprintf(LOG_ERR,
++                                  "Read %d bytes from '%s', expected %d",
++                                  rd,
++                                  hw.device,
++                                  sizeof event );
+ 		return 0;
+ 	}
+ 
+ 	LOGPRINTF(1, "hid 0x%X  value 0x%X", event.hid, event.value);
+ 
+ 	pre_code = event.hid;
+-	main_code = event.value;
+-
++	main_code = event.value & 0xffff;                   /* only 16 bits */
+ 	/*
+ 	 * This stuff is probably dvico specific.
+ 	 * I don't have any other hid devices to test...
+ 	 */
+-	if (event.hid == 0x10046) {
+-		repeat_flag = (main_code & dvico_repeat_mask);
++	if (pre_code == 0x10046) {
++                if (main_code & dvico_repeat_mask) /* repeated press */
++                	repeat_count++;                /* count them */
++                else
++                	repeat_count = 0;              /* reset */
++                repeat_flag = repeat_count > 2; /* real repeat flag */
+ 		main_code = (main_code & ~dvico_repeat_mask);
+-		return decode_all(remotes);
++                        /*
++                         * Skip this if we're working around the premature
++                         * repeat.
++                         */
++                        if (repeat_flag || (repeat_count == 0))
++                        {
++				char *foo;
++
++                        	foo = decode_all(remotes);
++                                /*
++                                 * XXX Experimental code.  Chop off the first 12
++                                 * bytes of the hex code, which FreeBSD does not
++                                 * provide, and which I suspect nobody cares
++                                 * about.
++                                 *
++                                 * For some reason, we can get NULL back here,
++                                 * so we need to check for that before returning
++                                 * address 0xc.
++                                 */
++                                if (foo)
++                                  foo = &foo [12];     /* chop off the leading chars. */
++                                return foo;
++                        }
++                        else
++                        	return 0;                    /* no data */
+ 	}
+ 	/* Remotec Mediamaster specific code */
+ 	/* Y-Coordinate,


More information about the Midnightbsd-cvs mailing list