Skip to content

Commit 9e22407

Browse files
author
Kevin Ward
committed
Check for input-event-codes.h at build.
Newer kernels define event codes in a separate file from input.h. This change checks for the new file and uses that for generating ev.py if possible.
1 parent 1c37e30 commit 9e22407

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
from __future__ import with_statement
33
from __future__ import print_function
44
import re
5+
import os.path
56

67
from distutils.command.build_py import build_py as _build_py
78
from distutils.core import setup, Extension
89

910
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:
1117
with open("src/ev.py", "a") as f2:
1218
for line in f:
1319
match = re.match(r"^#define (" + ev_name + "_.*)\t+((?:0x[0-9a-f]+)|(?:\d+))", line)

0 commit comments

Comments
 (0)