Bug#273733: dvb-utils: av7110_loadkeys doesn't allow BTN_*

Darren Salt pkg-vdr-dvb-devel@lists.alioth.debian.org
Mon, 27 Sep 2004 21:47:49 +0100


This message is in MIME format which your mailer apparently does not support.
You either require a newer version of your software which supports MIME, or
a separate MIME decoding utility.  Alternatively, ask the sender of this
message to resend it in a different format.

--998569252--1729981899--1493879278
Content-Type: text/plain; charset=us-ascii

Package: dvb-utils
Version: 1.1.0-2
Tags: patch

While adding a keymappings /proc interface to budget_ci and adapting
av7110_loadkeys to work with it, I found that it wouldn't accept key names
which begin with "BTN_". I have a use for these :-)

-- 
| Darren Salt   | nr. Ashington, | linux (or ds) at
| woody, sarge, | Northumberland | youmustbejoking
| RISC OS       | Toon Army      | demon co uk
|   We've got Shearer, you haven't

Enter your personal identification number.

--998569252--1729981899--1493879278
Content-Type: text/plain; charset=iso-8859-1; name="input_keynames.patch"
Content-Disposition: attachment; filename="input_keynames.patch"
Content-Transfer-Encoding: quoted-printable

diff -urNad linuxtv-dvb-apps-1.1.0/util/av7110_loadkeys/Makefile linuxtv-=
dvb-apps-1.1.0/util/av7110_loadkeys/Makefile
--- linuxtv-dvb-apps-1.1.0/util/av7110_loadkeys/Makefile	2004-09-27 19:25=
:17.000000000 +0100
+++ linuxtv-dvb-apps-1.1.0/util/av7110_loadkeys/Makefile	2004-09-27 19:38=
:06.000000000 +0100
@@ -12,7 +12,7 @@
 evtest.o: evtest.c input_keynames.h
=20
=20
-input_keynames.h: /usr/include/linux/input.h input_fake.h
+input_keynames.h: /usr/include/linux/input.h input_fake.h Makefile
 	@echo 'generate $@...'
 	@echo '#ifndef __INPUT_KEYNAMES_H__' > $@
 	@echo '#define __INPUT_KEYNAMES_H__' >> $@
@@ -32,8 +32,17 @@
 	@echo '' >> $@
 	@echo 'static struct input_key_name key_name [] =3D {' >> $@
 	@for x in `cat /usr/include/linux/input.h input_fake.h | \
-	          grep KEY_ | grep "#define" | grep -v KEY_MAX | \
-		  cut -f 1 | cut -f 2 -d ' ' | sort | uniq` ; do \
+	          egrep '#define[ \t]+KEY_' | grep -v KEY_MAX | \
+		  cut -f 1 | cut -f 2 -d ' ' | sort -u` ; do \
+		echo "        { \"`echo $$x | cut -b 5-`\", $$x }," >> $@ \
+		; \
+	done
+	@echo '};' >> $@
+	@echo '' >> $@
+	@echo 'static struct input_key_name btn_name [] =3D {' >> $@
+	@for x in `cat /usr/include/linux/input.h input_fake.h | \
+	          egrep '#define[ \t]+BTN_' | \
+		  cut -f 1 | cut -f 2 -d ' ' | sort -u` ; do \
 		echo "        { \"`echo $$x | cut -b 5-`\", $$x }," >> $@ \
 		; \
 	done
diff -urNad linuxtv-dvb-apps-1.1.0/util/av7110_loadkeys/av7110_loadkeys.c=
 linuxtv-dvb-apps-1.1.0/util/av7110_loadkeys/av7110_loadkeys.c
--- linuxtv-dvb-apps-1.1.0/util/av7110_loadkeys/av7110_loadkeys.c	2004-09=
-27 19:25:17.000000000 +0100
+++ linuxtv-dvb-apps-1.1.0/util/av7110_loadkeys/av7110_loadkeys.c	2004-09=
-27 19:34:25.000000000 +0100
@@ -35,7 +35,8 @@
 {
 	int cmp, index;
 	int l =3D 1;
-	int r =3D sizeof (key_name) / sizeof (key_name[0]);
+	const struct input_key_name *kn;
+	int r;
=20
 	if (limit < 5)
 		return -1;
@@ -46,7 +47,18 @@
 		limit--;
 	}
=20
-	if (pos [0] !=3D 'K' || pos[1] !=3D 'E' || pos[2] !=3D 'Y' || pos[3] !=3D=
 '_')
+	if (pos[3] !=3D '_')
+		return -2;
+
+	if (pos[0] =3D=3D 'K' && pos[1] =3D=3D 'E' && pos[2] =3D=3D 'Y') {
+		kn =3D key_name;
+		r =3D sizeof (key_name) / sizeof (key_name[0]);
+	}
+	else if (pos[0] =3D=3D 'B' && pos[1] =3D=3D 'T' && pos[2] =3D=3D 'N') {=

+		kn =3D btn_name;
+		r =3D sizeof (btn_name) / sizeof (btn_name[0]);
+	}
+	else
 		return -2;
=20
 	(*nend) +=3D 4;
@@ -58,19 +70,19 @@
=20
 		index =3D (l + r) / 2;
 	=09
-		len0 =3D strlen(key_name[index-1].name);
+		len0 =3D strlen(kn[index-1].name);
=20
 		while (len1 < limit && isgraph(pos[len1]))
 			len1++;
=20
-		cmp =3D strncmp (key_name[index-1].name, pos,
-			       strlen(key_name[index-1].name));
+		cmp =3D strncmp (kn[index-1].name, pos,
+			       strlen(kn[index-1].name));
 =09
 		if (len0 < len1 && cmp =3D=3D 0)
 			cmp =3D -1;
=20
 		if (cmp =3D=3D 0) {
-			*nend =3D pos + strlen (key_name[index-1].name);
+			*nend =3D pos + strlen (kn[index-1].name);
=20
 			if (**nend !=3D '\n' &&
 			    **nend !=3D '\t' &&
@@ -78,7 +90,7 @@
 			    *nend !=3D pos)
 				return -3;
=20
-			return key_name[index-1].key;
+			return kn[index-1].key;
 		}
=20
 		if (cmp < 0)

--998569252--1729981899--1493879278--