|
Lines 2-13
Link Here
|
| 2 |
from __future__ import with_statement |
2 |
from __future__ import with_statement |
| 3 |
from __future__ import print_function |
3 |
from __future__ import print_function |
| 4 |
import re |
4 |
import re |
|
|
5 |
import os.path |
| 5 |
|
6 |
|
| 6 |
from distutils.command.build_py import build_py as _build_py |
7 |
from distutils.command.build_py import build_py as _build_py |
| 7 |
from distutils.core import setup, Extension |
8 |
from distutils.core import setup, Extension |
| 8 |
|
9 |
|
| 9 |
def append_ev(ev_type, ev_name): |
10 |
def append_ev(ev_type, ev_name): |
| 10 |
with open("/usr/include/linux/input.h") as f: |
11 |
# Newer kernels define events in different file |
|
|
12 |
if os.path.exists("/usr/include/linux/input-event-codes.h"): |
| 13 |
fpath = "/usr/include/linux/input-event-codes.h" |
| 14 |
else: |
| 15 |
fpath = "/usr/include/linux/input.h" |
| 16 |
with open(fpath) as f: |
| 11 |
with open("src/ev.py", "a") as f2: |
17 |
with open("src/ev.py", "a") as f2: |
| 12 |
for line in f: |
18 |
for line in f: |
| 13 |
match = re.match(r"^#define (" + ev_name + "_.*)\t+((?:0x[0-9a-f]+)|(?:\d+))", line) |
19 |
match = re.match(r"^#define (" + ev_name + "_.*)\t+((?:0x[0-9a-f]+)|(?:\d+))", line) |