5566f87
diff -Naurp lirc-0.8.4a.orig/daemons/hw_devinput.c lirc-0.8.4a.upd/daemons/hw_devinput.c
5566f87
--- lirc-0.8.4a.orig/daemons/hw_devinput.c	2008-03-02 14:16:30.000000000 -0500
5566f87
+++ lirc-0.8.4a.upd/daemons/hw_devinput.c	2008-12-08 17:10:05.072745094 -0500
5566f87
@@ -220,7 +220,7 @@ int devinput_init()
5566f87
 	if (ioctl(hw.fd, EVIOCGRAB, 1) == -1)
5566f87
 	{
5566f87
 		logprintf(LOG_WARNING, "can't get exclusive access to events "
5566f87
-			  "comming from `%s' interface",
5566f87
+			  "coming from `%s' interface",
5566f87
 			  hw.device);
5566f87
 	}
5566f87
 #endif
4661870
diff -Naurp lirc-0.8.4a.orig/daemons/input_map.c lirc-0.8.4a.upd/daemons/input_map.c
4661870
--- lirc-0.8.4a.orig/daemons/input_map.c	1969-12-31 19:00:00.000000000 -0500
4661870
+++ lirc-0.8.4a.upd/daemons/input_map.c	2008-12-08 17:51:33.087443731 -0500
4661870
@@ -0,0 +1,58 @@
4661870
+/*      $Id: input_map.c,v 5.1 2008/10/26 15:10:17 lirc Exp $      */
4661870
+
4661870
+/****************************************************************************
4661870
+ ** input_map.c *************************************************************
4661870
+ ****************************************************************************
4661870
+ *
4661870
+ * input_map.c - button namespace derived from Linux input layer
4661870
+ *
4661870
+ * Copyright (C) 2008 Christoph Bartelmus <lirc@bartelmus.de>
4661870
+ *
4661870
+ */
4661870
+
4661870
+#include <stdlib.h>
4661870
+#include <string.h>
4661870
+
4661870
+#include "input_map.h"
4661870
+
4661870
+struct
4661870
+{
4661870
+	char *name;
4661870
+	linux_input_code code;
4661870
+
4661870
+} input_map[] = {
4661870
+#include "input_map.inc"
4661870
+	{NULL, 0}
4661870
+};
4661870
+
4661870
+int get_input_code(const char *name, linux_input_code *code)
4661870
+{
4661870
+	int i;
4661870
+	
4661870
+	for(i=0; input_map[i].name != NULL; i++)
4661870
+	{
4661870
+		if(strcasecmp(name, input_map[i].name) == 0)
4661870
+		{
4661870
+			*code = input_map[i].code;
4661870
+			return i;
4661870
+		}
4661870
+	}
4661870
+	return -1;
4661870
+}
4661870
+
4661870
+void fprint_namespace(FILE *f)
4661870
+{
4661870
+	int i;
4661870
+	
4661870
+	for(i=0; input_map[i].name != NULL; i++)
4661870
+	{
4661870
+		fprintf(stdout, "%s\n", input_map[i].name);
4661870
+	}
4661870
+}
4661870
+
4661870
+int is_in_namespace(const char *name)
4661870
+{
4661870
+	linux_input_code dummy;
4661870
+	
4661870
+	return get_input_code(name, &dummy) == -1 ? 0 : 1;
4661870
+}
4661870
diff -Naurp lirc-0.8.4a.orig/daemons/input_map.h lirc-0.8.4a.upd/daemons/input_map.h
4661870
--- lirc-0.8.4a.orig/daemons/input_map.h	1969-12-31 19:00:00.000000000 -0500
4661870
+++ lirc-0.8.4a.upd/daemons/input_map.h	2008-12-08 17:51:33.106519735 -0500
4661870
@@ -0,0 +1,35 @@
4661870
+/*      $Id: input_map.h,v 5.1 2008/10/26 15:10:17 lirc Exp $      */
4661870
+
4661870
+/****************************************************************************
4661870
+ ** input_map.h *************************************************************
4661870
+ ****************************************************************************
4661870
+ *
4661870
+ * input_map.h - button namespace derived from Linux input layer
4661870
+ *
4661870
+ * Copyright (C) 2008 Christoph Bartelmus <lirc@bartelmus.de>
4661870
+ *
4661870
+ */
4661870
+
4661870
+#ifndef INPUT_MAP_H
4661870
+#define INPUT_MAP_H
4661870
+
4661870
+#include <stdio.h>
4661870
+#include <sys/types.h>
4661870
+#include <unistd.h>
4661870
+
4661870
+#if defined __linux__
4661870
+#include <linux/input.h>
4661870
+#include <linux/uinput.h>
4661870
+#endif
4661870
+
4661870
+#if defined __linux__
4661870
+typedef __u16 linux_input_code;
4661870
+#else
4661870
+typedef unsigned short linux_input_code;
4661870
+#endif
4661870
+
4661870
+int get_input_code(const char *name, linux_input_code *code);
4661870
+void fprint_namespace(FILE *f);
4661870
+int is_in_namespace(const char *name);
4661870
+
4661870
+#endif /* INPUT_MAP_H */
4661870
diff -Naurp lirc-0.8.4a.orig/daemons/input_map.sh lirc-0.8.4a.upd/daemons/input_map.sh
4661870
--- lirc-0.8.4a.orig/daemons/input_map.sh	1969-12-31 19:00:00.000000000 -0500
4661870
+++ lirc-0.8.4a.upd/daemons/input_map.sh	2008-12-08 17:51:33.106519735 -0500
4661870
@@ -0,0 +1,11 @@
4661870
+#! /bin/sh
4661870
+
4661870
+TYPES="KEY BTN"
4661870
+file=${1:-/usr/include/linux/input.h}
4661870
+
4661870
+for type in $TYPES; do
4661870
+	grep "^#define ${type}_" < $file|sort|while read; do
4661870
+		sed --expression="s/^#define \([^ 	]*\)\(.*\)/{\"\1\", \2},/"|grep -v "KEY_HANGUEL\|KEY_MIN_INTERESTING"
4661870
+	done
4661870
+done
4661870
+
5566f87
diff -Naurp lirc-0.8.4a.orig/daemons/irrecord.c lirc-0.8.4a.upd/daemons/irrecord.c
5566f87
--- lirc-0.8.4a.orig/daemons/irrecord.c	2008-12-08 16:47:25.358745194 -0500
4661870
+++ lirc-0.8.4a.upd/daemons/irrecord.c	2008-12-08 18:10:06.096432179 -0500
4661870
@@ -52,6 +52,7 @@
4661870
 #include "ir_remote.h"
4661870
 #include "config_file.h"
4661870
 #include "receive.h"
4661870
+#include "input_map.h"
4661870
 
4661870
 void flushhw(void);
4661870
 int resethw(void);
4661870
@@ -80,7 +81,7 @@ void get_scheme(struct ir_remote *remote
4661870
 struct lengths *get_max_length(struct lengths *first,unsigned int *sump);
4661870
 void unlink_length(struct lengths **first,struct lengths *remove);
4661870
 int get_trail_length(struct ir_remote *remote, int interactive);
4661870
-int get_lead_length(struct ir_remote *remote);
4661870
+int get_lead_length(struct ir_remote *remote, int interactive);
4661870
 int get_repeat_length(struct ir_remote *remote, int interactive);
4661870
 int get_header_length(struct ir_remote *remote, int interactive);
4661870
 int get_data_length(struct ir_remote *remote, int interactive);
4661870
@@ -96,7 +97,7 @@ const char *usage="Usage: %s [options] f
4661870
 struct ir_remote remote;
4661870
 struct ir_ncode ncode;
4661870
 
4661870
-#define IRRECORD_VERSION "0.5"
4661870
+#define IRRECORD_VERSION "5.84"
4661870
 #define BUTTON 80+1
4661870
 #define RETRIES 10
4661870
 
4661870
@@ -120,7 +121,7 @@ lirc_t aeps = 100;
4661870
 #define TH_REPEAT      90
4661870
 #define TH_TRAIL       90
4661870
 #define TH_LEAD        90
4661870
-#define TH_IS_BIT      15
4661870
+#define TH_IS_BIT      10
4661870
 #define TH_RC6_SIGNAL 550
4661870
 
4661870
 #define MIN_GAP  20000
4661870
@@ -314,6 +315,7 @@ int main(int argc,char **argv)
4661870
 	int repeat_flag;
4661870
 	lirc_t min_remaining_gap, max_remaining_gap;
4661870
 	int force;
4661870
+	int disable_namespace = 0;
4661870
 	int retries;
4661870
 	int no_data = 0;
4661870
 	struct ir_remote *remotes=NULL;
4661870
@@ -338,6 +340,8 @@ int main(int argc,char **argv)
4661870
 			{"device",required_argument,NULL,'d'},
4661870
 			{"driver",required_argument,NULL,'H'},
4661870
 			{"force",no_argument,NULL,'f'},
4661870
+			{"disable-namespace",no_argument,NULL,'n'},
4661870
+			{"list-namespace",no_argument,NULL,'l'},
4661870
 #ifdef DEBUG
4661870
 			{"pre",no_argument,NULL,'p'},
4661870
 			{"post",no_argument,NULL,'P'},
4661870
@@ -348,9 +352,9 @@ int main(int argc,char **argv)
4661870
 			{0, 0, 0, 0}
4661870
 		};
4661870
 #ifdef DEBUG
4661870
-		c = getopt_long(argc,argv,"hvad:H:fpPtiT",long_options,NULL);
4661870
+		c = getopt_long(argc,argv,"hvad:H:fnlpPtiT",long_options,NULL);
4661870
 #else
4661870
-		c = getopt_long(argc,argv,"hvad:H:f",long_options,NULL);
4661870
+		c = getopt_long(argc,argv,"hvad:H:fnl",long_options,NULL);
4661870
 #endif
4661870
 		if(c==-1)
4661870
 			break;
4661870
@@ -362,6 +366,8 @@ int main(int argc,char **argv)
4661870
 			printf("\t -v --version\t\tdisplay version\n");
4661870
 			printf("\t -a --analyse\t\tanalyse raw_codes config files\n");
4661870
 			printf("\t -f --force\t\tforce raw mode\n");
4661870
+			printf("\t -n --disable-namespace\t\tdisables namespace checks\n");
4661870
+			printf("\t -l --list-namespace\t\tlist valid button names\n");
4661870
 			printf("\t -H --driver=driver\tuse given driver\n");
4661870
 			printf("\t -d --device=device\tread from given device\n");
4661870
 			exit(EXIT_SUCCESS);
4661870
@@ -385,6 +391,13 @@ int main(int argc,char **argv)
4661870
 		case 'f':
4661870
 			force=1;
4661870
 			break;
4661870
+		case 'n':
4661870
+			disable_namespace = 1;
4661870
+			break;
4661870
+		case 'l':
4661870
+			fprint_namespace(stdout);
4661870
+			exit(EXIT_SUCCESS);
4661870
+			break;
4661870
 #ifdef DEBUG
4661870
 		case 'p':
4661870
 			get_pre=1;
4661870
@@ -502,7 +515,7 @@ int main(int argc,char **argv)
4661870
 			exit(EXIT_FAILURE);
4661870
 		}
4661870
 		strcpy(filename_new, filename);
4661870
-		strcat(filename_new, ".new");
4661870
+		strcat(filename_new, ".conf");
4661870
 		filename = filename_new;
4661870
 	}
4661870
 	else
4661870
@@ -717,6 +730,17 @@ int main(int argc,char **argv)
4661870
 		{
4661870
 			break;
4661870
 		}
4661870
+		if(!disable_namespace && !is_in_namespace(buffer))
4661870
+		{
4661870
+			printf("'%s' is not in name space (use "
4661870
+			       "--disable-namespace to disable checks)\n",
4661870
+			       buffer);
4661870
+			printf("Use '%s --list-namespace' to see a full list "
4661870
+			       "of valid button names\n",
4661870
+			       progname);
4661870
+			printf("Please try again.\n");
4661870
+			continue;
4661870
+		}
4661870
 		
4661870
 		if(is_raw(&remote))
4661870
 		{
4661870
@@ -1379,7 +1403,8 @@ void analyse_remote(struct ir_remote *ra
4661870
 	ir_code pre, code, post;
4661870
 	int repeat_flag;
4661870
 	lirc_t min_remaining_gap, max_remaining_gap;
4661870
-	struct ir_ncode new_codes[100];
4661870
+	struct ir_ncode *new_codes;
4661870
+	size_t new_codes_count = 100;
4661870
 	int new_index = 0;
4661870
 	int ret;
4661870
 
4661870
@@ -1395,18 +1420,27 @@ void analyse_remote(struct ir_remote *ra
5566f87
 	next_code = NULL;
5566f87
 	current_code = NULL;
5566f87
 	current_index = 0;
5566f87
+	memset(&remote, 0, sizeof(remote));
5566f87
 	get_lengths(&remote, 0, 0 /* not interactive */ );
5566f87
 
4661870
-	if(is_rc6(&remote))
4661870
+	if(is_rc6(&remote) && remote.bits >= 5)
4661870
 	{
4661870
 		/* have to assume something as it's very difficult to
4661870
 		   extract the rc6_mask from the data that we have */
4661870
-		remote.rc6_mask = (ir_code) 0x100000000ll;
4661870
+		remote.rc6_mask = ((ir_code) 0x1ll) << (remote.bits-5);
4661870
 	}
4661870
 
4661870
 	remote.name = raw_data->name;
4661870
+	remote.freq = raw_data->freq;
4661870
 	
4661870
-	memset(new_codes, 0, sizeof(new_codes));
4661870
+	new_codes = malloc(new_codes_count * sizeof(*new_codes));
4661870
+	if(new_codes == NULL)
4661870
+	{
4661870
+		fprintf(stderr, "%s: out of memory\n",
4661870
+			progname);
4661870
+		return;
4661870
+	}
4661870
+	memset(new_codes, 0 , new_codes_count * sizeof(*new_codes));
4661870
 	codes = raw_data->codes;
4661870
 	while(codes->name!=NULL)
4661870
 	{
4661870
@@ -1429,6 +1463,25 @@ void analyse_remote(struct ir_remote *ra
4661870
 		}
4661870
 		else
4661870
 		{
4661870
+			if(new_index+1 >= new_codes_count)
4661870
+			{
4661870
+				struct ir_ncode *renew_codes;
4661870
+				
4661870
+				new_codes_count *= 2;
4661870
+				renew_codes = realloc
4661870
+					(new_codes,
4661870
+					 new_codes_count * sizeof(*new_codes));
4661870
+				if(renew_codes == NULL)
4661870
+				{
4661870
+					fprintf(stderr, "%s: out of memory\n",
4661870
+						progname);
4661870
+					free(new_codes);
4661870
+					return;
4661870
+				}
4661870
+				memset(&new_codes[new_codes_count/2], 0 , new_codes_count/2 * sizeof(*new_codes));
4661870
+				new_codes = renew_codes;
4661870
+			}
4661870
+			
4661870
 			new_codes[new_index].name = codes->name;
4661870
 			new_codes[new_index].code = code;
4661870
 			new_index++;
4661870
@@ -1438,6 +1491,8 @@ void analyse_remote(struct ir_remote *ra
4661870
 	new_codes[new_index].name = NULL;
4661870
 	remote.codes = new_codes;
4661870
 	fprint_remotes(stdout, &remote);
4661870
+	remote.codes = NULL;
4661870
+	free(new_codes);
4661870
 }
4661870
 
4661870
 #ifdef DEBUG
4661870
@@ -1610,7 +1665,7 @@ inline lirc_t calc_signal(struct lengths
4661870
 int get_lengths(struct ir_remote *remote, int force, int interactive)
4661870
 {
4661870
 	int retval;
4661870
-	lirc_t data,average,sum,remaining_gap,header;
4661870
+	lirc_t data,average,maxspace,sum,remaining_gap,header;
4661870
 	enum analyse_mode mode=MODE_GAP;
4661870
 	int first_signal;
4661870
 
4661870
@@ -1628,7 +1683,7 @@ int get_lengths(struct ir_remote *remote
4661870
 		flushhw();
4661870
 	}
4661870
 	retval=1;
4661870
-	average=0;sum=0;count=0;count_spaces=0;
4661870
+	average=0;maxspace=0;sum=0;count=0;count_spaces=0;
4661870
 	count_3repeats=0;count_5repeats=0;count_signals=0;
4661870
 	first_signal=-1;header=0;
4661870
 	first_length=0;
4661870
@@ -1657,12 +1712,15 @@ int get_lengths(struct ir_remote *remote
4661870
 					continue;
4661870
 				}
4661870
 				average=data;
4661870
+				maxspace=data;
4661870
 			}
4661870
 			else if(is_space(data))
4661870
 			{
4661870
 				if(data>MIN_GAP || data>100*average ||
4661870
 				   /* this MUST be a gap */
4661870
-				   (count_spaces>10 && data>5*average))  
4661870
+				   (count_spaces>10 && data>5*average)
4661870
+				   /* || Echostar
4661870
+				      (count_spaces>20 && data>9*maxspace/10)*/)
4661870
 					/* this should be a gap */
4661870
 				{
4661870
 					struct lengths *scan;
4661870
@@ -1674,7 +1732,7 @@ int get_lengths(struct ir_remote *remote
4661870
 					merge_lengths(first_sum);
4661870
 					add_length(&first_gap,data);
4661870
 					merge_lengths(first_gap);
4661870
-					sum=0;count_spaces=0;average=0;
4661870
+					sum=0;count_spaces=0;average=0;maxspace=0;
4661870
 					
4661870
 					maxcount=0;
4661870
 					scan=first_sum;
4661870
@@ -1740,6 +1798,10 @@ int get_lengths(struct ir_remote *remote
4661870
 				average=(average*count_spaces+data)
4661870
 				/(count_spaces+1);
4661870
 				count_spaces++;
4661870
+				if(data>maxspace)
4661870
+				{
4661870
+					maxspace=data;
4661870
+				}
4661870
 			}
4661870
 			if(count>SAMPLES*MAX_SIGNALS*2)
4661870
 			{
4661870
@@ -1773,8 +1835,9 @@ int get_lengths(struct ir_remote *remote
4661870
 			}
4661870
 			sum+=data&PULSE_MASK;
4661870
 
4661870
-			if((data&PULSE_MASK)>=remaining_gap*(100-eps)/100
4661870
-			   || (data&PULSE_MASK)>=remaining_gap-aeps)
4661870
+			if(count>2 &&
4661870
+			   ((data&PULSE_MASK)>=remaining_gap*(100-eps)/100
4661870
+			    || (data&PULSE_MASK)>=remaining_gap-aeps))
4661870
 			{
4661870
 				if(is_space(data))
4661870
 				{
4661870
@@ -1882,7 +1945,7 @@ int get_lengths(struct ir_remote *remote
4661870
 					get_scheme(remote, interactive);
4661870
 					if(!get_header_length(remote, interactive) ||
4661870
 					   !get_trail_length(remote, interactive) ||
4661870
-					   !get_lead_length(remote) ||
4661870
+					   !get_lead_length(remote, interactive) ||
4661870
 					   !get_repeat_length(remote, interactive) ||
4661870
 					   !get_data_length(remote, interactive))
4661870
 					{
4661870
@@ -2173,7 +2236,7 @@ int get_trail_length(struct ir_remote *r
4661870
 	return(1);
4661870
 }
4661870
 
4661870
-int get_lead_length(struct ir_remote *remote)
4661870
+int get_lead_length(struct ir_remote *remote, int interactive)
4661870
 {
4661870
 	unsigned int sum,max_count;
4661870
 	struct lengths *first_lead,*max_length,*max2_length;
4661870
@@ -2190,7 +2253,7 @@ int get_lead_length(struct ir_remote *re
4661870
 #       endif
4661870
 	if(max_count>=sum*TH_LEAD/100)
4661870
 	{
4661870
-		printf("Found lead pulse: %lu\n",
4661870
+		iprintf(interactive, "Found lead pulse: %lu\n",
4661870
 		       (unsigned long) calc_signal(max_length));
4661870
 		remote->plead=calc_signal(max_length);
4661870
 		return(1);
4661870
@@ -2207,12 +2270,12 @@ int get_lead_length(struct ir_remote *re
4661870
 	}
4661870
 	if(abs(2*a-b)
4661870
 	{
4661870
-		printf("Found hidden lead pulse: %lu\n",
4661870
+		iprintf(interactive, "Found hidden lead pulse: %lu\n",
4661870
 		       (unsigned long) a);
4661870
 		remote->plead=a;
4661870
 		return(1);
4661870
 	}
4661870
-	printf("No lead pulse found.\n");
4661870
+	iprintf(interactive, "No lead pulse found.\n");
4661870
 	return(1);
4661870
 }
4661870
 
5566f87
diff -Naurp lirc-0.8.4a.orig/daemons/lircd.c lirc-0.8.4a.upd/daemons/lircd.c
5566f87
--- lirc-0.8.4a.orig/daemons/lircd.c	2008-10-04 17:48:43.000000000 -0400
5566f87
+++ lirc-0.8.4a.upd/daemons/lircd.c	2008-12-08 17:06:32.108557638 -0500
5566f87
@@ -1,4 +1,4 @@
5566f87
-/*      $Id: lircd.c,v 5.80 2008/10/04 21:48:43 lirc Exp $      */
5566f87
+/*       $Id: lircd.c,v 5.82 2008/12/06 20:00:03 lirc Exp $      */
5566f87
 
5566f87
 /****************************************************************************
5566f87
  ** lircd.c *****************************************************************
5566f87
@@ -57,6 +57,12 @@
5566f87
 #include <fcntl.h>
5566f87
 #include <sys/file.h>
5566f87
 
5566f87
+#if defined(__linux__)
5566f87
+#include <linux/input.h>
5566f87
+#include <linux/uinput.h>
5566f87
+#include "input_map.h"
5566f87
+#endif
5566f87
+
5566f87
 #if defined __APPLE__
5566f87
 #include <sys/ioccom.h>
5566f87
 #endif
5566f87
@@ -151,31 +157,40 @@ FILE *lf=NULL;
5566f87
 
5566f87
 /* quite arbitrary limits */
5566f87
 #define MAX_PEERS	100
5566f87
-/* substract one for lirc, sockfd, sockinet, logfile, pidfile */
5566f87
-#define MAX_CLIENTS     (FD_SETSIZE-5-MAX_PEERS)
5566f87
+/* substract one for lirc, sockfd, sockinet, logfile, pidfile, uinput */
5566f87
+#define MAX_CLIENTS     (FD_SETSIZE-6-MAX_PEERS)
5566f87
 
5566f87
 int sockfd, sockinet;
5566f87
+static int uinputfd = -1;
5566f87
 int clis[MAX_CLIENTS];
5566f87
 
5566f87
 #define CT_LOCAL  1
5566f87
 #define CT_REMOTE 2
5566f87
 
5566f87
-int cli_type[MAX_CLIENTS];
5566f87
-int clin=0;
5566f87
+static int cli_type[MAX_CLIENTS];
5566f87
+static int clin=0;
5566f87
 
5566f87
 int listen_tcpip=0;
5566f87
 unsigned short int port=LIRC_INET_PORT;
5566f87
+struct in_addr address;
5566f87
 
5566f87
 struct	peer_connection *peers[MAX_PEERS];
5566f87
 int	peern = 0;
5566f87
 
5566f87
 int debug=0;
5566f87
-int daemonized=0;
5566f87
-int allow_simulate=0;
5566f87
+static int daemonized=0;
5566f87
+static int allow_simulate=0;
5566f87
+static int userelease=0;
5566f87
+static int useuinput=0;
5566f87
 
5566f87
 static sig_atomic_t term=0,hup=0,alrm=0;
5566f87
 static int termsig;
5566f87
 
5566f87
+inline int use_hw()
5566f87
+{
5566f87
+	return (clin>0 || (useuinput && uinputfd != -1) || repeat_remote != NULL);
5566f87
+}
5566f87
+
5566f87
 /* set_transmitters only supports 32 bit int */
5566f87
 #define MAX_TX (CHAR_BIT*sizeof(unsigned long))
5566f87
 
5566f87
@@ -303,6 +318,7 @@ void dosigterm(int sig)
5566f87
 		free_config(free_remotes);
5566f87
 	}
5566f87
 	free_config(remotes);
5566f87
+	repeat_remote = NULL;
5566f87
 	logprintf(LOG_NOTICE,"caught signal");
5566f87
 	for (i=0; i
5566f87
 	{
5566f87
@@ -311,6 +327,13 @@ void dosigterm(int sig)
5566f87
 	};
5566f87
 	shutdown(sockfd,2);
5566f87
 	close(sockfd);
5566f87
+
5566f87
+	if(uinputfd != -1)
5566f87
+	{
5566f87
+		ioctl(uinputfd, UI_DEV_DESTROY);
5566f87
+		close(uinputfd);
5566f87
+		uinputfd = -1;
5566f87
+	}
5566f87
 	if(listen_tcpip)
5566f87
 	{
5566f87
 		shutdown(sockinet,2);
5566f87
@@ -318,7 +341,7 @@ void dosigterm(int sig)
5566f87
 	}
5566f87
 	fclose(pidf);
5566f87
 	(void) unlink(pidfile);
5566f87
-	if(clin>0 && hw.deinit_func) hw.deinit_func();
5566f87
+	if(use_hw() && hw.deinit_func) hw.deinit_func();
5566f87
 #ifdef USE_SYSLOG
5566f87
 	closelog();
5566f87
 #else
5566f87
@@ -387,6 +410,52 @@ void dosighup(int sig)
5566f87
       }
5566f87
 }
5566f87
 
5566f87
+int setup_uinputfd(const char *name)
5566f87
+{
5566f87
+#if defined(__linux__)
5566f87
+	int fd;
5566f87
+	int key;
5566f87
+	struct uinput_user_dev dev;
5566f87
+	
5566f87
+	fd = open("/dev/input/uinput", O_RDWR);
5566f87
+	if(fd == -1)
5566f87
+	{
5566f87
+		fprintf(stderr, "could not open %s\n", "uinput");
5566f87
+		perror(NULL);
5566f87
+		return -1;
5566f87
+	}
5566f87
+	memset(&dev, 0, sizeof(dev));
5566f87
+	strncpy(dev.name, name, sizeof(dev.name));
5566f87
+	dev.name[sizeof(dev.name)-1] = 0;
5566f87
+	if(write(fd, &dev, sizeof(dev)) != sizeof(dev) ||
5566f87
+	   ioctl(fd, UI_SET_EVBIT, EV_KEY) != 0 ||
5566f87
+	   ioctl(fd, UI_SET_EVBIT, EV_REP) != 0)
5566f87
+	{
5566f87
+		goto setup_error;
5566f87
+	}
5566f87
+
5566f87
+        for(key = KEY_RESERVED; key <= KEY_UNKNOWN; key++)
5566f87
+	{
5566f87
+                if(ioctl(fd, UI_SET_KEYBIT, key) != 0)
5566f87
+		{
5566f87
+			goto setup_error;
5566f87
+                }
5566f87
+	}
5566f87
+
5566f87
+	if(ioctl(fd, UI_DEV_CREATE) != 0)
5566f87
+	{
5566f87
+		goto setup_error;
5566f87
+	}
5566f87
+	return fd;
5566f87
+	
5566f87
+ setup_error:
5566f87
+	fprintf(stderr, "could not setup %s\n", "uinput");
5566f87
+	perror(NULL);
5566f87
+	close(fd);
5566f87
+#endif
5566f87
+	return -1;
5566f87
+}
5566f87
+
5566f87
 void config(void)
5566f87
 {
5566f87
 	FILE *fd;
5566f87
@@ -448,9 +517,7 @@ void remove_client(int fd)
5566f87
 			logprintf(LOG_INFO,"removed client");
5566f87
 			
5566f87
 			clin--;
5566f87
-			if(clin==0 &&
5566f87
-			   repeat_remote==NULL &&
5566f87
-			   hw.deinit_func)
5566f87
+			if(!use_hw() && hw.deinit_func)
5566f87
 			{
5566f87
 				hw.deinit_func();
5566f87
 			}
5566f87
@@ -508,8 +575,8 @@ void add_client(int sock)
5566f87
 	{
5566f87
 		cli_type[clin]=0; /* what? */
5566f87
 	}
5566f87
-	clis[clin++]=fd;
5566f87
-	if(clin==1 && repeat_remote==NULL)
5566f87
+	clis[clin]=fd;
5566f87
+	if(!use_hw())
5566f87
 	{
5566f87
 		if(hw.init_func)
5566f87
 		{
5566f87
@@ -525,6 +592,7 @@ void add_client(int sock)
5566f87
 			}
5566f87
 		}
5566f87
 	}
5566f87
+	clin++;
5566f87
 }
5566f87
 
5566f87
 int add_peer_connection(char *server)
5566f87
@@ -799,6 +867,10 @@ void start_server(mode_t permission,int 
5566f87
 	listen(sockfd,3);
5566f87
 	nolinger(sockfd);
5566f87
 
5566f87
+	if(useuinput)
5566f87
+	{
5566f87
+		uinputfd = setup_uinputfd(progname);
5566f87
+	}
5566f87
 	if(listen_tcpip)
5566f87
 	{
5566f87
 		int enable=1;
5566f87
@@ -815,7 +887,7 @@ void start_server(mode_t permission,int 
5566f87
 		(void) setsockopt(sockinet,SOL_SOCKET,SO_REUSEADDR,
5566f87
 				  &enable,sizeof(enable));
5566f87
 		serv_addr_in.sin_family=AF_INET;
5566f87
-		serv_addr_in.sin_addr.s_addr=htonl(INADDR_ANY);
5566f87
+		serv_addr_in.sin_addr=address;
5566f87
 		serv_addr_in.sin_port=htons(port);
5566f87
 		
5566f87
 		if(bind(sockinet,(struct sockaddr *) &serv_addr_in,
5566f87
@@ -995,7 +1067,7 @@ void dosigalrm(int sig)
5566f87
 			free(repeat_message);
5566f87
 			repeat_message=NULL;
5566f87
 		}
5566f87
-		if(clin==0 && repeat_remote==NULL && hw.deinit_func)
5566f87
+		if(!use_hw() && hw.deinit_func)
5566f87
 		{
5566f87
 			hw.deinit_func();
5566f87
 		}
5566f87
@@ -1025,7 +1097,7 @@ void dosigalrm(int sig)
5566f87
 		repeat_message=NULL;
5566f87
 		repeat_fd=-1;
5566f87
 	}
5566f87
-	if(clin==0 && repeat_remote==NULL && hw.deinit_func)
5566f87
+	if(!use_hw() && hw.deinit_func)
5566f87
 	{
5566f87
 		hw.deinit_func();
5566f87
 	}
5566f87
@@ -1645,13 +1717,21 @@ void free_old_remotes()
5566f87
 	struct ir_remote *scan_remotes,*found;
5566f87
 	struct ir_ncode *code;
5566f87
 	const char *release_event;
5566f87
+	const char *release_remote_name;
5566f87
+	const char *release_button_name;
5566f87
 	
5566f87
 	if(decoding ==free_remotes) return;
5566f87
 	
5566f87
-	release_event = release_map_remotes(free_remotes, remotes);
5566f87
+	release_event = release_map_remotes(free_remotes, remotes,
5566f87
+					    &release_remote_name,
5566f87
+					    &release_button_name);
5566f87
 	if(release_event != NULL)
5566f87
 	{
5566f87
-		broadcast_message(release_event);
5566f87
+		input_message(release_event,
5566f87
+			      release_remote_name,
5566f87
+			      release_button_name,
5566f87
+			      0,
5566f87
+			      1);
5566f87
 	}
5566f87
 	if(last_remote!=NULL)
5566f87
 	{
5566f87
@@ -1741,19 +1821,56 @@ void free_old_remotes()
5566f87
 	}
5566f87
 }
5566f87
 
5566f87
-void broadcast_message(const char *message)
5566f87
+void input_message(const char *message, const char *remote_name,
5566f87
+		   const char *button_name, int reps, int release)
5566f87
 {
5566f87
-	int len,i;
5566f87
 	const char *release_message;
5566f87
+	const char *release_remote_name;
5566f87
+	const char *release_button_name;
5566f87
 
5566f87
-	release_message = check_release_event();
5566f87
+	release_message = check_release_event(&release_remote_name,
5566f87
+					      &release_button_name);
5566f87
 	if(release_message)
5566f87
 	{
5566f87
-		broadcast_message(release_message);
5566f87
+		input_message(release_message, release_remote_name,
5566f87
+			      release_button_name, 0, 1);
5566f87
+	}
5566f87
+	
5566f87
+	if(!release || userelease)
5566f87
+	{
5566f87
+		broadcast_message(message);
5566f87
 	}
5566f87
+	
5566f87
+#ifdef __linux__
5566f87
+	if(uinputfd != -1)
5566f87
+	{
5566f87
+		linux_input_code input_code;
5566f87
+		
5566f87
+		if(reps < 2 &&
5566f87
+		   get_input_code(button_name, &input_code) != -1)
5566f87
+		{
5566f87
+			struct input_event event;
5566f87
+			
5566f87
+			memset(&event, 0, sizeof(event));
5566f87
+			event.type = EV_KEY;
5566f87
+			event.code = input_code;
5566f87
+			event.value = release ? 0 : (reps>0 ? 2:1);
5566f87
+			if(write(uinputfd, &event, sizeof(event)) != sizeof(event))
5566f87
+			{
5566f87
+				logprintf(LOG_ERR, "writing to uinput failed");
5566f87
+				logperror(LOG_ERR, NULL);
5566f87
+			}
5566f87
+		}
5566f87
+	}
5566f87
+#endif
5566f87
+}
5566f87
 
5566f87
+void broadcast_message(const char *message)
5566f87
+{
5566f87
+	int len,i;
5566f87
+	
5566f87
 	len=strlen(message);
5566f87
-			
5566f87
+	
5566f87
 	for (i=0; i
5566f87
 	{
5566f87
 		LOGPRINTF(1,"writing to client %d",i);
5566f87
@@ -1799,7 +1916,7 @@ int waitfordata(long maxusec)
5566f87
 				FD_SET(sockinet,&fds);
5566f87
 				maxfd=max(maxfd,sockinet);
5566f87
 			}
5566f87
-			if(clin>0 && hw.rec_mode!=0 && hw.fd!=-1)
5566f87
+			if(use_hw() && hw.rec_mode!=0 && hw.fd!=-1)
5566f87
 			{
5566f87
 				FD_SET(hw.fd,&fds);
5566f87
 				maxfd=max(maxfd,hw.fd);
5566f87
@@ -1915,10 +2032,19 @@ int waitfordata(long maxusec)
5566f87
 			   timercmp(&now, &release_time, >))
5566f87
 			{
5566f87
 				const char *release_message;
5566f87
-				release_message = trigger_release_event();
5566f87
+				const char *release_remote_name;
5566f87
+				const char *release_button_name;
5566f87
+				
5566f87
+				release_message = trigger_release_event
5566f87
+					(&release_remote_name,
5566f87
+					 &release_button_name);
5566f87
 				if(release_message)
5566f87
 				{
5566f87
-					broadcast_message(release_message);
5566f87
+					input_message(release_message,
5566f87
+						      release_remote_name,
5566f87
+						      release_button_name,
5566f87
+						      0,
5566f87
+						      1);
5566f87
 				}
5566f87
 			}
5566f87
 			if(free_remotes!=NULL)
5566f87
@@ -1948,7 +2074,9 @@ int waitfordata(long maxusec)
5566f87
 		}
5566f87
 		while(ret==-1 && errno==EINTR);
5566f87
 		
5566f87
-		if(hw.fd == -1 && clin > 0 && hw.init_func)
5566f87
+		if(hw.fd == -1 &&
5566f87
+		   use_hw() &&
5566f87
+		   hw.init_func)
5566f87
 		{
5566f87
 			log_enable(0);
5566f87
 			hw.init_func();
5566f87
@@ -1993,7 +2121,7 @@ int waitfordata(long maxusec)
5566f87
 			LOGPRINTF(1,"registering inet client");
5566f87
 			add_client(sockinet);
5566f87
 		}
5566f87
-                if(clin>0 && hw.rec_mode!=0 && hw.fd!=-1 &&
5566f87
+                if(use_hw() && hw.rec_mode!=0 && hw.fd!=-1 &&
5566f87
 		   FD_ISSET(hw.fd,&fds))
5566f87
                 {
5566f87
 			register_input();
5566f87
@@ -2016,13 +2144,20 @@ void loop()
5566f87
 		
5566f87
 		if(message!=NULL)
5566f87
 		{
5566f87
+			const char *remote_name;
5566f87
+			const char *button_name;
5566f87
+			int reps;
5566f87
+			
5566f87
 			if(hw.ioctl_func &&
5566f87
 			   (hw.features&LIRC_CAN_NOTIFY_DECODE))
5566f87
 			{
5566f87
 				hw.ioctl_func(LIRC_NOTIFY_DECODE, NULL);
5566f87
 			}
5566f87
 			
5566f87
-			broadcast_message(message);
5566f87
+			get_release_data(&remote_name, &button_name, &reps);
5566f87
+
5566f87
+			input_message(message, remote_name, button_name,
5566f87
+				      reps, 0);
5566f87
 		}
5566f87
 	}
5566f87
 }
5566f87
@@ -2034,6 +2169,7 @@ int main(int argc,char **argv)
5566f87
 	mode_t permission=S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
5566f87
 	char *device=NULL;
5566f87
 
5566f87
+	address.s_addr = htonl(INADDR_ANY);
5566f87
 	hw_choose_driver(NULL);
5566f87
 	while(1)
5566f87
 	{
5566f87
@@ -2058,9 +2194,15 @@ int main(int argc,char **argv)
5566f87
 #                       endif
5566f87
 			{"release",optional_argument,NULL,'r'},
5566f87
 			{"allow-simulate",no_argument,NULL,'a'},
5566f87
+#                       if defined(__linux__)
5566f87
+			{"uinput",no_argument,NULL,'u'},
5566f87
+#                       endif
5566f87
 			{0, 0, 0, 0}
5566f87
 		};
5566f87
 		c = getopt_long(argc,argv,"hvnp:H:d:o:P:l::c:r::a"
5566f87
+#                               if defined(__linux__)
5566f87
+				"u"
5566f87
+#                               endif
5566f87
 #                               ifndef USE_SYSLOG
5566f87
 				"L:"
5566f87
 #                               endif
5566f87
@@ -2080,7 +2222,7 @@ int main(int argc,char **argv)
5566f87
 			printf("\t -p --permission=mode\t\tfile permissions for " LIRCD "\n");
5566f87
 			printf("\t -H --driver=driver\t\tuse given driver\n");
5566f87
 			printf("\t -d --device=device\t\tread from given device\n");
5566f87
-			printf("\t -l --listen[=port]\t\tlisten for network connections on port\n");
5566f87
+			printf("\t -l --listen[=[addresss:]port]\t\tlisten for network connections\n");
5566f87
 			printf("\t -c --connect=host[:port]\tconnect to remote lircd server\n");
5566f87
                         printf("\t -o --output=socket\t\toutput socket filename\n");
5566f87
                         printf("\t -P --pidfile=file\t\tdaemon pid file\n");
5566f87
@@ -2092,6 +2234,9 @@ int main(int argc,char **argv)
5566f87
 #                       endif
5566f87
 			printf("\t -r --release[=suffix]\t\tauto-generate release events\n");
5566f87
 			printf("\t -a --allow-simulate\t\taccept SIMULATE command\n");
5566f87
+#                       if defined(__linux__)
5566f87
+			printf("\t -u --uinput\t\tgenerate Linux input events\n");
5566f87
+#                       endif
5566f87
 			return(EXIT_SUCCESS);
5566f87
 		case 'v':
5566f87
 			printf("%s %s\n",progname,VERSION);
5566f87
@@ -2135,16 +2280,28 @@ int main(int argc,char **argv)
5566f87
 			{
5566f87
 				long p;
5566f87
 				char *endptr;
5566f87
-				
5566f87
-				p=strtol(optarg,&endptr,10);
5566f87
+				char *sep = strchr(optarg, ':');
5566f87
+				char *port_str = sep ? sep + 1 : optarg;
5566f87
+				p=strtol(port_str,&endptr,10);
5566f87
 				if(!*optarg || *endptr || p<1 || p>USHRT_MAX)
5566f87
 				{
5566f87
 					fprintf(stderr,
5566f87
 						"%s: bad port number \"%s\"\n",
5566f87
-						progname,optarg);
5566f87
+						progname,port_str);
5566f87
 					return(EXIT_FAILURE);
5566f87
 				}
5566f87
 				port=(unsigned short int) p;
5566f87
+				if (sep)
5566f87
+				{
5566f87
+					*sep = 0;
5566f87
+					if(!inet_aton(optarg, &address))
5566f87
+					{
5566f87
+						fprintf(stderr,
5566f87
+							"%s: bad address \"%s\"\n",
5566f87
+							progname,optarg);
5566f87
+						return(EXIT_FAILURE);
5566f87
+					}
5566f87
+				}
5566f87
 			}
5566f87
 			else
5566f87
 			{
5566f87
@@ -2174,10 +2331,16 @@ int main(int argc,char **argv)
5566f87
 			{
5566f87
 				set_release_suffix(LIRC_RELEASE_SUFFIX);
5566f87
 			}
5566f87
+			userelease=1;
5566f87
 			break;
5566f87
 		case 'a':
5566f87
 			allow_simulate=1;
5566f87
 			break;
5566f87
+#               if defined(__linux__)
5566f87
+		case 'u':
5566f87
+			useuinput=1;
5566f87
+			break;
5566f87
+#               endif
5566f87
 		default:
5566f87
 			printf("Usage: %s [options] [config-file]\n",progname);
5566f87
 			return(EXIT_FAILURE);
5566f87
diff -Naurp lirc-0.8.4a.orig/daemons/lircd.h lirc-0.8.4a.upd/daemons/lircd.h
5566f87
--- lirc-0.8.4a.orig/daemons/lircd.h	2007-09-29 13:13:14.000000000 -0400
5566f87
+++ lirc-0.8.4a.upd/daemons/lircd.h	2008-12-08 16:54:04.374682209 -0500
5566f87
@@ -32,6 +32,7 @@ void sigterm(int sig);
5566f87
 void dosigterm(int sig);
5566f87
 void sighup(int sig);
5566f87
 void dosighup(int sig);
5566f87
+int setup_uinput(const char *name);
5566f87
 void config(void);
5566f87
 void nolinger(int sock);
5566f87
 void remove_client(int fd);
5566f87
@@ -76,6 +77,8 @@ int send_core(int fd,char *message,char 
5566f87
 int version(int fd,char *message,char *arguments);
5566f87
 int get_pid(int fd,char *message,char *arguments);
5566f87
 int get_command(int fd);
5566f87
+void input_message(const char *message, const char *remote_name,
5566f87
+		   const char *button_name, int reps, int release);
5566f87
 void broadcast_message(const char *message);
5566f87
 int waitfordata(long maxusec);
5566f87
 void loop(void);
5566f87
diff -Naurp lirc-0.8.4a.orig/daemons/Makefile.am lirc-0.8.4a.upd/daemons/Makefile.am
5566f87
--- lirc-0.8.4a.orig/daemons/Makefile.am	2008-09-21 14:33:19.000000000 -0400
4661870
+++ lirc-0.8.4a.upd/daemons/Makefile.am	2008-12-08 17:58:11.557500930 -0500
4661870
@@ -7,6 +7,8 @@
4661870
 
4661870
 INCLUDES = -I$(top_srcdir)
4661870
 
4661870
+BUILT_SOURCES = input_map.inc
4661870
+
4661870
 noinst_LIBRARIES = libhw_module.a
4661870
 libhw_module_a_SOURCES = \
4661870
 			hw-types.c hw-types.h hardware.h \
4661870
@@ -59,7 +61,8 @@ libhw_module_a_DEPENDENCIES = @hw_module
5566f87
 sbin_PROGRAMS = lircd lircmd
5566f87
 
5566f87
 lircd_SOURCES = lircd.c lircd.h \
5566f87
-		config_file.c config_file.h
5566f87
+		config_file.c config_file.h \
5566f87
+		input_map.c input_map.h
5566f87
 lircd_LDADD = @daemon@ libhw_module.a @hw_module_libs@
5566f87
 
5566f87
 lircmd_SOURCES = lircmd.c
4661870
@@ -69,7 +72,8 @@ bin_PROGRAMS = irrecord
4661870
 
4661870
 irrecord_SOURCES = irrecord.c \
4661870
 		config_file.c config_file.h \
4661870
-		dump_config.c dump_config.h
4661870
+		dump_config.c dump_config.h \
4661870
+		input_map.c input_map.h
4661870
 
4661870
 irrecord_LDADD = libhw_module.a @hw_module_libs@ @receive@
4661870
 irrecord_DEPENDENCIES = @receive@
4661870
@@ -79,6 +83,7 @@ EXTRA_PROGRAMS = lircd.simsend lircd.sim
5566f87
 noinst_PROGRAMS = @maintmode_daemons_extra@
5566f87
 lircd_simsend_SOURCES = lircd.c ir_remote.c config_file.c \
5566f87
 		lircd.h ir_remote.h ir_remote_types.h config_file.h \
5566f87
+		input_map.c input_map.h \
5566f87
 		hw-types.c hw-types.h hardware.h \
5566f87
 		hw_default.c hw_default.h \
5566f87
 		receive.c receive.h \
4661870
@@ -87,6 +92,7 @@ lircd_simsend_SOURCES = lircd.c ir_remot
5566f87
 lircd_simsend_CFLAGS = -DSIM_SEND
5566f87
 lircd_simrec_SOURCES = lircd.c ir_remote.c config_file.c \
5566f87
 		lircd.h ir_remote.h ir_remote_types.h config_file.h \
5566f87
+		input_map.c input_map.h \
5566f87
 		hw-types.c hw-types.h hardware.h \
5566f87
 		hw_default.c hw_default.h \
5566f87
 		receive.c receive.h \
4661870
@@ -125,4 +131,10 @@ rmfifo:
4661870
 	-$(RM) $(DESTDIR)$(devdir)/lircd
4661870
 	-$(RM) $(DESTDIR)$(devdir)/lircm
4661870
 
4661870
+input_map.inc:
4661870
+	$(srcdir)/input_map.sh >$@
4661870
+
4661870
+DISTCLEANFILES = input_map.inc
4661870
+EXTRA_DIST = input_map.inc input_map.sh
4661870
+
4661870
 CLEANFILES = *~
5566f87
diff -Naurp lirc-0.8.4a.orig/daemons/release.c lirc-0.8.4a.upd/daemons/release.c
5566f87
--- lirc-0.8.4a.orig/daemons/release.c	2008-02-06 08:43:07.000000000 -0500
5566f87
+++ lirc-0.8.4a.upd/daemons/release.c	2008-12-08 16:59:03.799472804 -0500
5566f87
@@ -1,4 +1,4 @@
5566f87
-/*      $Id: release.c,v 1.3 2008/02/06 13:43:07 lirc Exp $      */
5566f87
+/*      $Id: release.c,v 1.4 2008/12/06 20:00:03 lirc Exp $      */
5566f87
 
5566f87
 /****************************************************************************
5566f87
  ** release.c ***************************************************************
5566f87
@@ -25,24 +25,23 @@ static struct timeval release_time;
5566f87
 static struct ir_remote *release_remote;
5566f87
 static struct ir_ncode *release_ncode;
5566f87
 static ir_code release_code;
5566f87
+static int release_reps;
5566f87
 static lirc_t release_gap;
5566f87
 
5566f87
 static struct ir_remote *release_remote2;
5566f87
 static struct ir_ncode *release_ncode2;
5566f87
 static ir_code release_code2;
5566f87
-static const char *release_suffix = NULL;
5566f87
+static const char *release_suffix = LIRC_RELEASE_SUFFIX;
5566f87
 static char message[PACKET_SIZE+1];
5566f87
 
5566f87
 void register_input(void)
5566f87
 {
5566f87
 	struct timeval gap;
5566f87
 	
5566f87
-	if(release_suffix == NULL) return;
5566f87
-	
5566f87
 	if(release_remote == NULL) return;
5566f87
 	
5566f87
 	timerclear(&gap);
5566f87
-	gap.tv_usec = 2*release_gap;
5566f87
+	gap.tv_usec = 3*release_gap;
5566f87
 	
5566f87
 	gettimeofday(&release_time,NULL);
5566f87
 	timeradd(&release_time, &gap, &release_time);
5566f87
@@ -51,8 +50,6 @@ void register_input(void)
5566f87
 void register_button_press(struct ir_remote *remote, struct ir_ncode *ncode,
5566f87
 			   ir_code code, int reps)
5566f87
 {
5566f87
-	if(release_suffix == NULL) return;
5566f87
-	
5566f87
 	if(reps == 0 && release_remote != NULL)
5566f87
 	{
5566f87
 		release_remote2 = release_remote;
5566f87
@@ -63,11 +60,21 @@ void register_button_press(struct ir_rem
5566f87
 	release_remote = remote;
5566f87
 	release_ncode = ncode;
5566f87
 	release_code = code;
5566f87
+	release_reps = reps;
5566f87
 	release_gap = remote->max_remaining_gap;
5566f87
 	
5566f87
 	register_input();
5566f87
 }
5566f87
 
5566f87
+void get_release_data(const char **remote_name,
5566f87
+		      const char **button_name,
5566f87
+		      int *reps)
5566f87
+{
5566f87
+	*remote_name = release_remote->name;
5566f87
+	*button_name = release_ncode->name;
5566f87
+	*reps = release_reps;
5566f87
+}
5566f87
+
5566f87
 void set_release_suffix(const char *s)
5566f87
 {
5566f87
 	release_suffix = s;
5566f87
@@ -78,12 +85,15 @@ void get_release_time(struct timeval *tv
5566f87
 	*tv = release_time;
5566f87
 }
5566f87
 
5566f87
-const char *check_release_event(void)
5566f87
+const char *check_release_event(const char **remote_name,
5566f87
+				const char **button_name)
5566f87
 {
5566f87
 	int len = 0;
5566f87
 	
5566f87
 	if(release_remote2 != NULL)
5566f87
 	{
5566f87
+		*remote_name = release_remote2->name;
5566f87
+		*button_name = release_ncode2->name;
5566f87
 		len = write_message(message, PACKET_SIZE+1,
5566f87
 				    release_remote2->name,
5566f87
 				    release_ncode2->name, release_suffix,
5566f87
@@ -98,18 +108,21 @@ const char *check_release_event(void)
5566f87
 			return(NULL);
5566f87
 		}
5566f87
 
5566f87
-		logprintf(LOG_INFO, "check");
5566f87
+		LOGPRINTF(3, "check");
5566f87
 		return message;
5566f87
 	}
5566f87
 	return NULL;
5566f87
 }
5566f87
 
5566f87
-const char *trigger_release_event(void)
5566f87
+const char *trigger_release_event(const char **remote_name,
5566f87
+				  const char **button_name)
5566f87
 {
5566f87
 	int len = 0;
5566f87
 	
5566f87
 	if(release_remote != NULL)
5566f87
 	{
5566f87
+		*remote_name = release_remote->name;
5566f87
+		*button_name = release_ncode->name;
5566f87
 		len = write_message(message, PACKET_SIZE+1,
5566f87
 				    release_remote->name, release_ncode->name,
5566f87
 				    release_suffix, release_code, 0);
5566f87
@@ -123,13 +136,15 @@ const char *trigger_release_event(void)
5566f87
 			logprintf(LOG_ERR,"message buffer overflow");
5566f87
 			return(NULL);
5566f87
 		}
5566f87
-		logprintf(LOG_INFO, "trigger");
5566f87
+		LOGPRINTF(3, "trigger");
5566f87
 		return message;
5566f87
 	}
5566f87
 	return NULL;
5566f87
 }
5566f87
 
5566f87
-const char *release_map_remotes(struct ir_remote *old, struct ir_remote *new)
5566f87
+const char *release_map_remotes(struct ir_remote *old, struct ir_remote *new,
5566f87
+				const char **remote_name,
5566f87
+				const char **button_name)
5566f87
 {
5566f87
 	struct ir_remote *remote;
5566f87
 	struct ir_ncode *ncode;
5566f87
@@ -150,7 +165,7 @@ const char *release_map_remotes(struct i
5566f87
 		}
5566f87
 		else
5566f87
 		{
5566f87
-			return trigger_release_event();
5566f87
+			return trigger_release_event(remote_name, button_name);
5566f87
 		}
5566f87
 	}
5566f87
 	return NULL;
5566f87
diff -Naurp lirc-0.8.4a.orig/daemons/release.h lirc-0.8.4a.upd/daemons/release.h
5566f87
--- lirc-0.8.4a.orig/daemons/release.h	2007-05-06 07:54:02.000000000 -0400
4661870
+++ lirc-0.8.4a.upd/daemons/release.h	2008-12-08 17:48:55.251581644 -0500
5566f87
@@ -1,4 +1,4 @@
5566f87
-/*      $Id: release.h,v 1.1 2007/05/06 11:54:02 lirc Exp $      */
5566f87
+/*      $Id: release.h,v 1.2 2008/12/06 20:00:03 lirc Exp $      */
5566f87
 
5566f87
 /****************************************************************************
5566f87
  ** release.h ***************************************************************
5566f87
@@ -18,10 +18,17 @@
5566f87
 void register_input(void);
5566f87
 void register_button_press(struct ir_remote *remote, struct ir_ncode *ncode,
5566f87
 			   ir_code code, int reps);
5566f87
+void get_release_data(const char **remote_name,
5566f87
+		      const char **button_name,
5566f87
+		      int *reps);
5566f87
 void set_release_suffix(const char *s);
5566f87
 void get_release_time(struct timeval *tv);
5566f87
-const char *check_release_event(void);
5566f87
-const char *trigger_release_event(void);
5566f87
-const char *release_map_remotes(struct ir_remote *old, struct ir_remote *new);
5566f87
+const char *check_release_event(const char **remote_name,
5566f87
+				const char **button_name);
5566f87
+const char *trigger_release_event(const char **remote_name,
5566f87
+				  const char **button_name);
4661870
+const char *release_map_remotes(struct ir_remote *old, struct ir_remote *new,
5566f87
+				const char **remote_name,
5566f87
+				const char **button_name);
5566f87
 
5566f87
 #endif /* RELEASE_H */
5566f87
diff -Naurp lirc-0.8.4a.orig/doc/man/lircd.8 lirc-0.8.4a.upd/doc/man/lircd.8
5566f87
--- lirc-0.8.4a.orig/doc/man/lircd.8	2008-10-26 10:15:37.000000000 -0400
5566f87
+++ lirc-0.8.4a.upd/doc/man/lircd.8	2008-12-08 17:14:44.574433177 -0500
5566f87
@@ -70,8 +70,9 @@ the device name isn't fixed. \fISTRING\f
5566f87
 wildcards and '\\' to mark them as literal.
5566f87
 
5566f87
 With the --listen option you can let lircd listen for network
5566f87
-connections on the given port. The default port is 8765. No security
5566f87
-checks are currently implemented.
5566f87
+connections on the given address/port. The default address is 0.0.0.0,
5566f87
+which means that connections on all network interfaces will be accepted.
5566f87
+The default port is 8765. No security checks are currently implemented.
5566f87
 
5566f87
 The --connect option allows you to connect to other lircd servers that
5566f87
 provide a network socket at the given host and port number. The number
5566f87
@@ -99,6 +100,14 @@ users with access to the lircd socket wi
5566f87
 E.g. if you have configured your system to shut down by a button press
5566f87
 on your remote control, everybody will be able to shut down
5566f87
 your system from the command line.
5566f87
+
5566f87
+On Linux systems the --uinput option will enable automatic generation
5566f87
+of Linux input events. lircd will open /dev/input/uinput and inject
5566f87
+key events to the Linux kernel. The key code depends on the name that
5566f87
+was given a button in the lircd config file, e.g. if the button is
5566f87
+named KEY_1, the '1' key code will be generated. You will find a
5566f87
+complete list of possible button names in /usr/include/linux/input.h.
5566f87
+
5566f87
 .SH FILES
5566f87
 
5566f87
 The config file for lircd is located in /etc/lircd.conf. lircd
5566f87
diff -Naurp lirc-0.8.4a.orig/NEWS lirc-0.8.4a.upd/NEWS
5566f87
--- lirc-0.8.4a.orig/NEWS	2008-12-08 16:47:25.391622403 -0500
5566f87
+++ lirc-0.8.4a.upd/NEWS	2008-12-08 17:40:05.345432825 -0500
5566f87
@@ -1,3 +1,7 @@
5566f87
+0.8.5-CVS: future
5566f87
+  * Linux input event generation using uinput
5566f87
+  * standardised namespace following Linux input conventions
5566f87
+
5566f87
 0.8.4a: 10/26/08
5566f87
   * fixed show-stopper bug in irrecord for drivers using MODE2
5566f87
 
5566f87
diff -Naurp lirc-0.8.4a.orig/TODO lirc-0.8.4a.upd/TODO
5566f87
--- lirc-0.8.4a.orig/TODO	2008-07-31 07:17:53.000000000 -0400
5566f87
+++ lirc-0.8.4a.upd/TODO	2008-12-08 17:40:51.546432812 -0500
5566f87
@@ -2,8 +2,6 @@
5566f87
 
5566f87
 * __init, __exit
5566f87
 
5566f87
-* uinput
5566f87
-
5566f87
 * namespace
5566f87
 
5566f87
 * GUI for irrecord