aboutsummaryrefslogtreecommitdiffstats
path: root/debian/patches/02_av7110_loadkeys-BTN.dpatch
blob: 8f49275b8770267749630198e462650e36e0eb03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#! /bin/sh /usr/share/dpatch/dpatch-run
## 02_av7110_loadkeys-BTN.dpatch by Thomas Schmidt <thomas.schmidt@in.stud.tu-ilmenau.de>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: patch to allow BTN_* as input-keynames (closes: #273733)

@DPATCH@
diff -urNad linuxtv-dvb-apps/util/av7110_loadkeys/av7110_loadkeys.c /tmp/dpep.6x7trg/linuxtv-dvb-apps/util/av7110_loadkeys/av7110_loadkeys.c
--- linuxtv-dvb-apps/util/av7110_loadkeys/av7110_loadkeys.c	2004-05-14 12:32:12.000000000 +0200
+++ /tmp/dpep.6x7trg/linuxtv-dvb-apps/util/av7110_loadkeys/av7110_loadkeys.c	2004-09-28 15:49:18.000000000 +0200
@@ -35,7 +35,8 @@
 {
 	int cmp, index;
 	int l = 1;
-	int r = sizeof (key_name) / sizeof (key_name[0]);
+	const struct input_key_name *kn;
+	int r;
 
 	if (limit < 5)
 		return -1;
@@ -46,7 +47,18 @@
 		limit--;
 	}
 
-	if (pos [0] != 'K' || pos[1] != 'E' || pos[2] != 'Y' || pos[3] != '_')
+	if (pos[3] != '_')
+		return -2;
+
+	if (pos[0] == 'K' && pos[1] == 'E' && pos[2] == 'Y') {
+		kn = key_name;
+		r = sizeof (key_name) / sizeof (key_name[0]);
+	}
+	else if (pos[0] == 'B' && pos[1] == 'T' && pos[2] == 'N') {
+		kn = btn_name;
+		r = sizeof (btn_name) / sizeof (btn_name[0]);
+	}
+	else
 		return -2;
 
 	(*nend) += 4;
@@ -58,19 +70,19 @@
 
 		index = (l + r) / 2;
 		
-		len0 = strlen(key_name[index-1].name);
+		len0 = strlen(kn[index-1].name);
 
 		while (len1 < limit && isgraph(pos[len1]))
 			len1++;
 
-		cmp = strncmp (key_name[index-1].name, pos,
-			       strlen(key_name[index-1].name));
+		cmp = strncmp (kn[index-1].name, pos,
+			       strlen(kn[index-1].name));
 	
 		if (len0 < len1 && cmp == 0)
 			cmp = -1;
 
 		if (cmp == 0) {
-			*nend = pos + strlen (key_name[index-1].name);
+			*nend = pos + strlen (kn[index-1].name);
 
 			if (**nend != '\n' &&
 			    **nend != '\t' &&
@@ -78,7 +90,7 @@
 			    *nend != pos)
 				return -3;
 
-			return key_name[index-1].key;
+			return kn[index-1].key;
 		}
 
 		if (cmp < 0)
diff -urNad linuxtv-dvb-apps/util/av7110_loadkeys/Makefile /tmp/dpep.6x7trg/linuxtv-dvb-apps/util/av7110_loadkeys/Makefile
--- linuxtv-dvb-apps/util/av7110_loadkeys/Makefile	2004-05-14 12:32:12.000000000 +0200
+++ /tmp/dpep.6x7trg/linuxtv-dvb-apps/util/av7110_loadkeys/Makefile	2004-09-28 15:49:18.000000000 +0200
@@ -12,7 +12,7 @@
 evtest.o: evtest.c input_keynames.h
 
 
-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 [] = {' >> $@
 	@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 [] = {' >> $@
+	@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