Skip to content

Commit 32a5b4e

Browse files
committed
2 parents 27cbbe8 + 6ada83b commit 32a5b4e

File tree

6 files changed

+695
-0
lines changed

6 files changed

+695
-0
lines changed

recipes/evdev/patches/evcnt.patch

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff -Naur orig/evdev/input.c v0.4.7/evdev/input.c
2+
--- orig/evdev/input.c 2015-06-11 13:56:43.483891914 -0500
3+
+++ v0.4.7/evdev/input.c 2015-06-11 13:57:29.079529095 -0500
4+
@@ -24,6 +24,8 @@
5+
#include <linux/input.h>
6+
#endif
7+
8+
+#define EV_CNT (EV_MAX+1)
9+
+
10+
#define MAX_NAME_SIZE 256
11+
12+
extern char* EV_NAME[EV_CNT];
13+
@@ -190,7 +192,7 @@
14+
absinfo.maximum,
15+
absinfo.fuzz,
16+
absinfo.flat,
17+
- absinfo.resolution);
18+
+ 0);
19+
20+
evlong = PyLong_FromLong(ev_code);
21+
absitem = Py_BuildValue("(OO)", evlong, py_absinfo);
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
diff -Naur orig/evdev/util.py v0.4.7/evdev/util.py
2+
--- orig/evdev/util.py 2015-06-12 16:31:46.532994729 -0500
3+
+++ v0.4.7/evdev/util.py 2015-06-12 16:32:59.489933840 -0500
4+
@@ -3,15 +3,53 @@
5+
import os
6+
import stat
7+
import glob
8+
+import subprocess
9+
10+
from evdev import ecodes
11+
from evdev.events import event_factory
12+
13+
14+
+su = False
15+
+
16+
+
17+
+def get_su_binary():
18+
+ global su
19+
+ if su is not False:
20+
+ return su
21+
+
22+
+ su_files = ['/sbin/su', '/system/bin/su', '/system/xbin/su', '/data/local/xbin/su',
23+
+ '/data/local/bin/su', '/system/sd/xbin/su', '/system/bin/failsafe/su',
24+
+ '/data/local/su']
25+
+ su = None
26+
+
27+
+ for fn in su_files:
28+
+ if os.path.exists(fn):
29+
+ try:
30+
+ cmd = [fn, '-c', 'id']
31+
+ output = subprocess.check_output(cmd)
32+
+ except Exception:
33+
+ pass
34+
+ else:
35+
+ if 'uid=0' in output:
36+
+ su = fn
37+
+ break
38+
+
39+
+ return su
40+
+
41+
+
42+
+def fix_permissions(nodes):
43+
+ su = get_su_binary()
44+
+ if su:
45+
+ cmd = 'chmod 666 ' + ' '.join(nodes)
46+
+ print cmd
47+
+ subprocess.check_call(['su', '-c', cmd])
48+
+
49+
+
50+
def list_devices(input_device_dir='/dev/input'):
51+
'''List readable character devices in ``input_device_dir``.'''
52+
53+
fns = glob.glob('{}/event*'.format(input_device_dir))
54+
+ fix_permissions(fns)
55+
fns = list(filter(is_device, fns))
56+
57+
return fns
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff -Naur orig/setup.py v0.4.7/setup.py
2+
--- orig/setup.py 2015-06-11 14:16:31.315765908 -0500
3+
+++ v0.4.7/setup.py 2015-06-11 14:17:05.800263536 -0500
4+
@@ -64,7 +64,7 @@
5+
6+
#-----------------------------------------------------------------------------
7+
def create_ecodes():
8+
- header = '/usr/include/linux/input.h'
9+
+ header = '##INCLUDE_DIR##/usr/include/linux/input.h'
10+
11+
if not os.path.isfile(header):
12+
msg = '''\

recipes/evdev/patches/keycnt.patch

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff -Naur orig/evdev/genecodes.py v0.4.7/evdev/genecodes.py
2+
--- orig/evdev/genecodes.py 2015-06-12 11:18:39.460538902 -0500
3+
+++ v0.4.7/evdev/genecodes.py 2015-06-12 11:20:49.004337615 -0500
4+
@@ -17,6 +17,8 @@
5+
#include <linux/input.h>
6+
#endif
7+
8+
+#define KEY_CNT (KEY_MAX+1)
9+
+
10+
/* Automatically generated by evdev.genecodes */
11+
/* Generated on %s */
12+
13+
@@ -88,6 +88,7 @@
14+
macro = regex.search(line)
15+
if macro:
16+
yield ' PyModule_AddIntMacro(m, %s);' % macro.group(1)
17+
+ yield ' PyModule_AddIntMacro(m, KEY_CNT);'
18+
19+
uname = list(os.uname()); del uname[1]
20+
uname = ' '.join(uname)

0 commit comments

Comments
 (0)